Post: Surge "Rise" Menu Base - NO OVERFLOW [UPDATED 11/11/14]
10-10-2014, 03:25 AM #1
TheFallen
Former Dark Night
(adsbygoogle = window.adsbygoogle || []).push({});
Surge "Rise" Menu Base




Surge is finally out of beta and with that comes better features and better updates! So keep your eyes out for those!
All updates will be posted here.

Update 1.3.1
(Only supported by GSC Studio)




  • Bug fixes


Features


  • Overflow fix - no more string overflows! NEW (see "Setting Text and Preventing Overflow")
  • Works with other menu base's menu formats
  • Cursor Remembrance
  • Menu Paging
  • Ultimate Control System
  • Verification
  • Live Player Menu
  • Built-in API
  • Stable
  • Multi-input functions


Controls


  • Open - Dpad Down
  • Exit - R3
  • Select - X
  • Close - O
  • Scroll Up/Down - L1/R1


API Information (Advanced)

API
accessability.gsc


Function Parameters Return CallOn Description
checkAccess none none client Checks if the player has access and welcome them
changePlayerAccess client player
int accessLevel
none client Changes the access level of a player with a message
setAccessLevel int accessLevel none client Sets the access level of a player
getAccessLevel none int client Gets the access level of a player
getAccessLevelStatus [string acLevel] string client Gets the access level status of a player


hud_utilities.gsc


Function Parameters Return CallOn Description
setColor string type
string elem
string color
none level Sets an elements color in settings (does not actually change the visible color)
color string name rgb level Gets the rgb values for the specificed color (color must be defined using setColor())
addTheme string name
string label
(r,g,b) primaryColor
(r,g,b) secondaryColor
none client Adds a theme for the menu
setSafeText client player
string str
none text element Sets an element



menu.gsc


Function Parameters Return CallOn Description
addMenu string parent
string name
string title
none client Adds a menu
addOption string parent
string label
function function
var input
string type
entity entity
none client Adds an option to a menu
exitMenu none none client Exits the menu



toggle.gsc


Function Parameters Return CallOn Description
toggle var var
boolean state
none entity Toggles functions on and off with message



utilities.gsc


Function Parameters Return CallOn Description
getName none string client Gets the player's name without a clantag
isEmpty var var boolean entity Tells if the var is defined or is empty
enableDebugMode boolean toggle none level Toggles debug mode for Surge
addSetting string name
val value
none level Adds a setting for Surge
getSetting string name val level Gets the value of a setting for Surge
addVar string name
val value
none client Adds a var for a player (used in toggles)
getVar string name val client Gets the value of a var for a player (used in toggles)




Setting Text and Preventing Overflow


See "Creating Text", "Setting Text", and "Destroying Text" You must login or register to view this content.


Adding to the Menu
Adding Menus
Surge allows you to have multiple menus/submenus to help you organize your mods. You can do this by going to menu.gsc, updateMenu(), and calling addMenu(parent, name, title). Parent is the menu to add the menu to, name is the ID of the menu (must be unique), and title is the text to display for the title (if dynamic titles are enabled).

Ex:
    
updateMenu()
{
self addMenu("main", "accountSettings", "Account");
}


Adding Options
Surge allows you to have multiple menus/submenus to help you organize your mods. You can do this by going to menu.gsc, updateMenu(), and calling addOption(parent, label, function, [input], [type], [entity]). Parent is the menu to add the option to, label is the text to display, function is the function to be called when selected, input (optional) is the arguments to pass to the function when called, type (optional) is the type of function it is (see below), and entity (optional) is the entity to call the function on.

Simple

Adding a simple option is easy. All you need is the menu name, the option text, the function, and the input of you need one. Everything else is taken care of.

Ex:
    
updateMenu()
{
self addOption("main", "God Mode", ::enableGod);
self addOption("main", "God Mode", ::toggle, "god"); // Optional input
}



Advanced
Do not attempt the following unless you understand programming and what everything below means.


Surge allows you to have complete control over your mods. You can customize every aspect of the call to have it do what ever you need it to.

Input is optional but you can pass up to 5 arguments at once if you choose to. To do this simply create an array and add your desired inputs to the array and pass that in.

Type is optional and defaults to "thread" which runs the function async (along side) the rest. The other value for this is "immediate" which will pause execution, branch off, run the function, and then return to the parent thread.

Entity is optional and defaults to self. This allows you to call functions on any entity accessible in the scope.

Ex:
    
updateMenu()
{
player = level.players[0];

inputArray = [];
inputArray[0] = "arg1";
inputArray[1] = 2;
...
inputArray[4] = myObj; // last;
self addOption("main", "Multi Arg Func", ::multiFunc, input, "immediate", player); // This is equivalent to player multiFunc("arg1", 2, ..., myObj);
self addOption("main", "Multi Arg Func 2", ::multiFunc, input, "thread", player); // This is equivalent to player thread multiFunc("arg1", 2, ..., myObj);
}



Adding Options to the Player Menu
To add an option to the player menu add an option like you normally would except this time the type and entity arguments are required. Type should be "thread" for more info on this) and entitiy must be the client you want to call the function on (read Adding Options - Advanced for more information on these).

Ex:
    
updatePlayerMenu()
{
player = level.players[0];
self addOption(player + "Options", "Give God Mode", ::toggle, "god", "thread" player); // This will toggle god mode for this player.
}



Converting Menu Bases

Shark's Menu Base
To use Shark's menu base's option and menu format with Surge, simply copy and paste your old menu options and functions into updateMenu() or updatePlayerMenu() respectively. They will work right along with Surge's regular format with no problems.

Ex:
    
updateMenu()
{
self addMenu("", "main", "Surge");
self add_menu("test", "main", "Test Menu");
// Options in Shark's menu base format
self add_option("test", "Item", ::test);
self add_option("test", "Item 1", ::testOne, "arg1");
self add_option("test", "Item 2", ::testTwo, "arg1", "arg2");
self add_menu_alt("subMenu", "test");
self add_option("subMenu", "Sub Item", ::test);
self add_option("subMenu", "Sub Item 1", ::testOne, "arg1");
self add_option("subMenu", "Sub Item 2", ::testTwo, "arg1", "arg2");
//
self addMenu("main", "self", "Me");
self addOption("self", "God Mode", ::toggle, "god");
self addOption("self", "Unlimited Ammo", ::toggle, "ammo");
self addOption("self", "No Clip", ::toggle, "noclip");
}

updatePlayersMenu()
{
self.surge["menu"]["players"]["options"] = [];

foreach(player in level.players)
{
name = player getName();
menu = "player_" + name;
accessLevelsMenu = name + "_access_levels";

self addMenu("players", menu, "[" + player getAccessLevelStatus() + "] " + name);
if(player isHost() == false)
{
self addMenu(menu, accessLevelsMenu, "Change Access Level");
input = [];
input[0] = player; // This never changes because our first input is always the player
input[1] = 0; // This changed because it represents different access levels
self addOption(accessLevelsMenu, "Level 0 (" + level.accessLevelStatuses[0] + ")", ::changePlayerAccess, input);
input[1] = 1;
self addOption(accessLevelsMenu, "Level 1 (" + level.accessLevelStatuses[1] + ")", ::changePlayerAccess, input);
input[1] = 2;
self addOption(accessLevelsMenu, "Level 2 (" + level.accessLevelStatuses[2] + ")", ::changePlayerAccess, input);
// Shark's Menu Option Format
self add_option(accessLevelsMenu, "Option", ::function, input1, input2);
self add_option(accessLevelsMenu, "Option 1", ::function, input1, input2);
self add_option(accessLevelsMenu, "Option 2", ::function, input1, input2);
//
}
}

if(isEmpty(self.surge["menu"]["players"]["options"][self.surge["menu"]["players"]["position"]]))
self.surge["menu"]["players"]["position"] = 0;
}


Themes and Styling
Adding Colors
Go to main.gsc and find the function init(). Here is where you will define your colors.

Ex:
    
init()
{
//addColor(colorName, rgb)
addColor("red", (1, 0, 0));
}


Setting Colors
Go to main.gsc and find the function initSurge(). Here is where you will set your colors. You set them with setColor(type, elem, color). The type must exist in the first level of self.surge and the elem must exist in any level of self.surge[type]["hud"]. Color can be any (r, g, b) object. You can use predefined colors (view above) by calling color("color name").

Ex:
    
initSurge()
{
setColor("menu", "background", color("red"));
// or
setColor("menu", "background", (1, 0, 0));
}


Adding Themes
Go to main.gsc and find the function initSurge(). Here is where you will add your themes. You add them by calling addTheme(name, label, primaryColor, secondaryColor) with the name being the ID of the theme (must be unique), label being the text to display in the theme menu, and primaryColor and secondaryColor being any (r, g, b) object.

Ex:
    
initSurge()
{
addTheme("cherry", "Cherry", level.red, (1, 1, 1));
}


Turning On/Off Dynamic Menu Titles
Surge allows you to have dynamic menu titles. By default this is disabled to maximize stability but it can be turned on by going to main.gsc, initSurge(), and setting self.surge["settings"]["updateTitle"] = true;

Ex:
    
initSurge()
{
self.surge["settings"]["updateTitle"] = true; // On
self.surge["settings"]["updateTitle"] = false; // Off
}



Using the Toggle System
Surge comes with a easy-to-use toggle system that helps you create toggles. To start in main.gsc under initSurge() add an index to the vars array with the ID of your toggle. From there simply add an if statement with the ID of your toggle and inside of that is where the actual toggling goes on. To call it simply call toggle(var, [state]); You can either specify on/off or have it default to the opposite of what it currently is. Take a look at the example to see how to do this.

Ex:
    
initSurge()
{
self.surge["vars"]["god"] = false; // Defaults to false because we don't have god mode on when we spawn.
}

toggle(var, state)
{
if(isEmpty(state))
self.surge["vars"][var] = !self.surge["vars"][var];
else
self.surge["vars"][var] = state;

if(self.surge["vars"][var] == true)
status = "^2Enabled";
else
status = "^1Disabled";

// God mode
if(var == "god")
{
self iprintln("God Mode: " + status);

if(self.surge["vars"][var] == true)
self EnableInvulnerability();
else
{
// Only disable if not in menu; else will be disabled upon menu exit
if(self.surge["menu"]["active"] == false)
self DisableInvulnerability();
}
}
// generic example
else if(var == "varName")
{
self iprintln("Var Name: " + status); // prints out our status

if(self.surge["vars"][var] == true) // toggled on
self thread turnOnVar();
else // toggled off
self thread turnOffVar();
}
}

    
updateMenu()
{
self addOption("main", "God Mode", ::toggle, "god");
}


You must login or register to view this content.


Change Log

You must login or register to view this content.


  • Bug fixes



Past Updates

You must login or register to view this content.


  • Bug fixes
  • GUI change



You must login or register to view this content.


  • Shark Menu Base Converter



You must login or register to view this content.


  • Fixed Verifiaction Bug
  • Improved API
  • Added Overflow Fix (No string overflows)
  • GUI Changes



You must login or register to view this content.


Credits


  • ItsLollo1000 for his thread and anyone whose codes I used
  • Exelo for line_horizontal material
  • Taylor for reminding me how weird GSC when I tried doing something from a C language and for helping me test
  • iMCSx for his GSC Studio
  • Aiden729 for ideas and the release video
  • SyGnUs for testing
  • Adidas for testing
  • dtx12 for usage of clearAllTextAfterHudElem()
  • Shark for his menu base's option format
  • Natsu for menu base converter idea and references
Last edited by TheFallen ; 11-12-2014 at 03:52 AM. Reason: updated to 1.3.1

The following 41 users say thank you to TheFallen for this useful post:

/SneakerStreet/, A Friend, AlexNGU, anxify, BoatyMcBoatFace, BossamBemass, Bucko, canadiancaper, Chris, CustomSilent-, EncepT, ErasedDev, EternalHabit, Geo, iifire, iknownothing, Im Not Boobdidas, Im_YouViolateMe, ImPiffHD, ItsLollo1000, Jaredm09, John Leepe, M0T1VAT10N, MilkShakeModz, Obris, OrbitModding, Script Kiddie, seb5594, Shark, Source Code, StonedYoda, Taylor, SyGnUs, Synergy, Terrorize 420, The_Urban_Ninja, Vanz, zshred
10-10-2014, 03:36 AM #2
PureGoldMod
Do a barrel roll!
So raw good shit :y:
10-10-2014, 04:21 AM #3
OrbitModding
Little One
Nice :p !
Last edited by OrbitModding ; 10-17-2014 at 01:16 PM.
10-10-2014, 04:33 AM #4
TheFallen
Former Dark Night
Originally posted by OrbitModding View Post
Is that menu freezing thing fixed? Nice though!


It was never my menu that froze, it was the script freezing my menu. I commented on Lollo's first thread about why it was happening.
10-10-2014, 05:19 AM #5
SyGnUs
Give a F*** About Your Lifestyle
Originally posted by TheFallen View Post
It was never my menu that froze, it was the script freezing my menu. I commented on Lollo's first thread about why it was happening.


Your thread layout makes it seem like we are not even working with making a mod menu anymore, looks to professional XD. Nice job by the way Tiphat
10-10-2014, 11:20 AM #6
Taylor
Former Black Knight.
Originally posted by TheFallen View Post
Surge "Rise" Menu Base




Surge is finally out of beta and with that comes better features and better updates! So keep your eyes out for those!
All updates will be posted here.


Features


  • Cursor Remembrance
  • Menu Paging
  • Ultimate Control System
  • Verification
  • Live Player Menu
  • Built-in API
  • Stable
  • Multi-input functions


Controls


  • Open - Dpad Down
  • Exit - R3
  • Select - X
  • Close - O
  • Scroll Up/Down - L1/R1


API
accessability.gsc


Function Parameters Return CallOn Description
checkAccess none none client Checks if the player has access and welcome them
changePlayerAccess client player
int accessLevel
none client Changes the access level of a player with a message
setAccessLevel int accessLevel none client Sets the access level of a player
getAccessLevel none int client Gets the access level of a player
getAccessLevelStatus [string acLevel] string client Gets the access level status of a player


hud_utilities.gsc


Function Parameters Return CallOn Description
setColor string type
string elem
string color
none N/A Sets an elements color in settings (does not actually change the visible color)
addTheme string name
string label
(r,g,b) primaryColor
(r,g,b) secondaryColor
none client Adds a theme for the menu



menu.gsc


Function Parameters Return CallOn Description
addMenu string parent
string name
string title
none client Adds a menu
addOption string parent
string label
function function
var input
string type
entity entity
none client Adds an option to a menu
exitMenu none none client Exits the menu



toggle.gsc


Function Parameters Return CallOn Description
toggle var var
boolean state
none entity Toggles functions on and off with message



utilities.gsc


Function Parameters Return CallOn Description
getName none string client Gets the player's name without a clantag
isEmpty var var boolean entity Tells if the var is defined or is empty



Themes and Styling

Adding Colors
Go to main.gsc and find the function init(). Here is where you will define your colors.

Ex:
    
init()
{
level.red = (1, 0, 0);
}


Setting Colors
Go to main.gsc and find the function initSurge(). Here is where you will set your colors. You set them with setColor(type, elem, color). The type must exist in the first level of self.surge and the elem must exist in any level of self.surge[type]["hud"]. Color can be any (r, g, b) object.

Ex:
    
initSurge()
{
setColor("menu", "background", red);
// or
setColor("menu", "background", (1, 0, 0));
}


Adding Themes
Go to main.gsc and find the function initSurge(). Here is where you will add your themes. You add them by calling addTheme(name, label, primaryColor, secondaryColor) with the name being the ID of the theme (must be unique), label being the text to display in the theme menu, and primaryColor and secondaryColor being any (r, g, b) object.

Ex:
    
initSurge()
{
addTheme("cherry", "Cherry", level.red, (1, 1, 1));
}


Turning On/Off Dynamic Menu Titles
Surge allows you to have dynamic menu titles. By default this is disabled to maximize stability but it can be turned on by going to main.gsc, initSurge(), and setting self.surge["settings"]["updateTitle"] = true;

Ex:
    
initSurge()
{
self.surge["settings"]["updateTitle"] = true; // On
self.surge["settings"]["updateTitle"] = false; // Off
}



Adding to the Menu
Adding Menus
Surge allows you to have multiple menus/submenus to help you organize your mods. You can do this by going to menu.gsc, updateMenu(), and calling addMenu(parent, name, title). Parent is the menu to add the menu to, name is the ID of the menu (must be unique), and title is the text to display for the title (if dynamic titles are enabled).

Ex:
    
updateMenu()
{
self addMenu("main", "accountSettings", "Account");
}


Adding Options
Surge allows you to have multiple menus/submenus to help you organize your mods. You can do this by going to menu.gsc, updateMenu(), and calling addOption(parent, label, function, [input], [type], [entity]). Parent is the menu to add the option to, label is the text to display, function is the function to be called when selected, input (optional) is the arguments to pass to the function when called, type (optional) is the type of function it is (see below), and entity (optional) is the entity to call the function on.

Simple

Adding a simple option is easy. All you need is the menu name, the option text, the function, and the input of you need one. Everything else is taken care of.

Ex:
    
updateMenu()
{
self addOption("main", "God Mode", ::enableGod);
self addOption("main", "God Mode", ::toggle, "god"); // Optional input
}



Advanced
Do not attempt the following unless you understand programming and what everything below means.


Surge allows you to have complete control over your mods. You can customize every aspect of the call to have it do what ever you need it to.

Input is optional but you can pass up to 5 arguments at once if you choose to. To do this simply create an array and add your desired inputs to the array and pass that in.

Type is optional and defaults to "thread" which runs the function async (along side) the rest. The other value for this is "immediate" which will pause execution, branch off, run the function, and then return to the parent thread.

Entity is optional and defaults to self. This allows you to call functions on any entity accessible in the scope.

Ex:
    
updateMenu()
{
player = level.players[0];

inputArray = [];
inputArray[0] = "arg1";
inputArray[1] = 2;
...
inputArray[4] = myObj; // last;
self addOption("main", "Multi Arg Func", ::multiFunc, input, "immediate", player); // This is equivalent to player multiFunc("arg1", 2, ..., myObj);
self addOption("main", "Multi Arg Func 2", ::multiFunc, input, "thread", player); // This is equivalent to player thread multiFunc("arg1", 2, ..., myObj);
}



Adding Options to the Player Menu
To add an option to the player menu add an option like you normally would except this time the type and entity arguments are required. Type should be "thread" for more info on this) and entitiy must be the client you want to call the function on (read Adding Options - Advanced for more information on these).

Ex:
    
updatePlayerMenu()
{
player = level.players[0];
self addOption(player + "Options", "Give God Mode", ::toggle, "god", "thread" player); // This will toggle god mode for this player.
}

You must login or register to view this content.

Change Log

You must login or register to view this content.


Credits


  • ItsLollo1000 for his thread and anyone whose codes I used
  • Exelo for line_horizontal material
  • Taylor for reminding me how weird GSC when I tried doing something from a C language and for helping me test
  • iMCSx for his GSC Studio
  • Aiden729 for ideas and the release video
  • SyGnUs for testing
  • Adidas for testing


I really like how you incorporated array functioning for arguments. :p
10-10-2014, 11:55 AM #7
Geo
Don't Believe The Title
Fantastic base, unique smooth and fancy :p
10-10-2014, 02:39 PM #8
TheFallen
Former Dark Night
Originally posted by SyGnUs View Post
Your thread layout makes it seem like we are not even working with making a mod menu anymore, looks to professional XD. Nice job by the way Tiphat


I'm used to writing things like this for work so :p thanks Smile
10-10-2014, 02:39 PM #9
TheFallen
Former Dark Night
Originally posted by Taylor View Post
I really like how you incorporated array functioning for arguments. :p


Thanks it was actually really easy, hacky but easy.
10-10-2014, 03:14 PM #10
BoatyMcBoatFace
Are you high?
Noice, 90% of the downloads will be copy and pasting wizaards though :(

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo