Author Topic: More help on the GUI  (Read 11389 times)

just like the title states, i need a GUI made or help in making a GUI that has the following:
the things in bold are descriptions of what each check-box will do, and should also be on the GUI.

the gui should open with the chat command "ADVGUI" and should be admin only

Disable Iron-sights? <=(checkbox that changes the variable $UseScope between 0 and 1)

Disable Echo sound effects? (decreases sound quality, increases amount of audible sounds) <=(checkbox that changes the variable $FarSound between 0 and 1)

Disable Ammo system? <=(checkbox that changes the variable $UseAmmo between 0 and 1)

Disable Light Key reload Command? (you can use this if you have an addon that does something else with the light key)
<=(checkbox that changes the variable $CommandReload between 0 and 1)

Starting ammo on spawn: <=(an input box that changes the variable $StartingAmmo ranging between 0-1000)

and finally, some kind of three way switch for this script that changes how much ammo will be in a weapon when you pick it up:
Code: [Select]
if($WeaponSpawnAmmoCount != 1 && $WeaponSpawnAmmoCount != 2)
{
%this.toolAmmo[%slot] = getRandom(0, %data.maxAmmo);
}
else if($WeaponSpawnAmmoCount = 1)
{
%this.toolAmmo[%slot] = 0;
}
else if($WeaponSpawnAmmoCount = 2)
{
%this.toolAmmo[%slot] = %this.item.maxAmmo;
}

and be aware that i have NO IDEA how to make a GUI...
« Last Edit: September 28, 2014, 12:20:17 AM by zombekillz »

ok, so...

i just made my first attempt at a gui, i used this tutorial: http://forum.blockland.us/index.php?topic=67198.0;wap2

i decided instead of what the guide said to start from scratch, i edited the options menu...
so i saved my gui and now im stuck, i have NO idea how to open it or if it even works.

could somebody go over this zip and create a functional gui out of it? or tell me how :)
https://hostr.co/KNORMYL1PcK0


Client:
All your check boxes and the circles are all boonlean (forget spelling?)
You need to name each check box according to what they are to make it easy, and it's best to do a GUIUseScope_Blah format to be sure nothing is conflicting. Then you need to create a function for the done button, something like updatesettings() in UpdateSettings you need something like %UseScope=GUIname_UseScope.getValue();
Back in your client GUI code, you'll need to add onto the updateSettings function something like commandToServer('UpdateSettings','UseScope',%UseScope); and do this for each variable, ie each setting you want. So something like:
Code: [Select]
function UpdateSettings()
{
    %useScope=GUIname_useScope.getValue();
    commandToServer('UpdateSettings','UseScope',%useScope);
    %useAmmo=GUIname_useAmmo.getValue();
    commandToServer('UpdateSettings','UseAmmo',%useAmmo);
}

Server:
Then you need to make a server command function (be sure it's a server-sided script for this) like serverCmdUpdateSettings(%client,%globalVar,%value) add your admin check blah blah so it'll look something like
Code: [Select]
function servercmdUpdateSettings(%client,%globalVar,%value)
{
    if(!%client.SuperAdmin)
        return;
    switch$(%globalVar)
    {
        case UseScope:
            $UseScope = %var;
        case UseAmmo:
            $UseAmmo = %var;
    }
}

This can obviously be done way more efficiently but this is probably the easiest way.

cool, thanks, also i need to know how to open the gui, i want to use a chat command, as stated in the OP. i haven't actually even seen this GUI in game yet :P

oh yea, and i don't know how, or if you can, make a text field where you can input a specific number, im assuming you can because RTB prefs have these.
« Last Edit: September 21, 2014, 09:28:10 PM by zombekillz »

I need to know how to open the GUI, I want to use a chat command.
Make something like
function clientcmdOpenGui(){canvas.pushDialog(GUIname);} on the client and
function serverCmdOpenGUI(%client){if(!%client.SuperAdmin)return;commandToClient('OpenGui');} on the server.
Make a text field where you can input a specific number.
GuiTextEditCtrl or the GuiMLTextEditCtrl should be the two, the ML one allows for things like <color:blahblah> and what not. Then you name it and use the GuiName_Blah.getValue(); to pull whatever is in it.

you rock man, ill try these soon...

ok i am so lost here lol.

could you tell me why this GUI won't open? https://hostr.co/GntUe8EBEshh

i have ideas of what the problem might be but i have no idea what im doing and would enjoy if you took a look at it...
also there is server.cs for this with the affore mentioned code in it, but its in a different zip, because i don't know if you can put server code in a client_ addon

i have never made a client sided addon before, so we can say that is a good percentage of my lack of knowledge.

ok i am so lost here lol.

could you tell me why this GUI won't open? https://hostr.co/GntUe8EBEshh

i have ideas of what the problem might be but i have no idea what im doing and would enjoy if you took a look at it...
It won't open because the file you're trying to execute does not exist. You're trying to execute AdvWepsGui.gui, but you named the file AdvWeps.gui.

Also, clientCmdOpenGUI is too generic of a function name. You should name it something like clientCmdAdvWeps_openGUI.
also there is server.cs for this with the affore mentioned code in it, but its in a different zip, because i don't know if you can put server code in a client_ addon

i have never made a client sided addon before, so we can say that is a good percentage of my lack of knowledge.
You can have a server.cs and a client.cs in the same add-on. But it's suggested to name it Script_MyAddOn if you have both of the files, just to avoid confusion. The file name technically does not matter at all, as long as you follow the format Category_Name. You could name it MyAwesome_PoodlyAddOn and it wouldn't matter, it'd just be frowned upon.
« Last Edit: September 22, 2014, 07:26:13 AM by jes00 »

*FacePalm* well...

wouldn't be the first time something stupid like that has had me so confused... thanks!

i can get it to open if i type canvas.pushDialog(AdvWepsGui); into the console, but not through any script, why is that?

i can get it to open if i type canvas.pushDialog(AdvWepsGui); into the console, but not through any script, why is that?
What do you mean? How do you want to open it?

What do you mean? How do you want to open it?
I need to know how to open the GUI, I want to use a chat command.
I realize today I made a mistake on what I told you to do for this, commandToClient should have at least two arguments.
Code: [Select]
function serverCmdOpenGUI(%client)
{
    if(!%client.SuperAdmin)
        return;
    commandToClient(%client,'OpenGui');
}
and
Code: [Select]
function clientCmdOpenGui()
{
    canvas.pushDialog(AdvWepsGui);
}
should work together just fine.

hey, I only used this code

Code: [Select]
package ADVGUI
{
function serverCmdADVGUI(%Client)
{
if(%client.isAdmin || %client.isSuperAdmin)
{
   canvas.pushDialog(AdvWepsGui);
}
else
{
CommandToClient(%Client,'CenterPrint',"You are not an admin",2);
}
}
};
activatePackage(ADVGUI);

and it seems to work fine, the GUI opens correctly, the variables all change without any other code and such and it seems fine, in single player at least...

obviously correct me if im making some stupid mistake, but is all that other code even needed?
« Last Edit: September 24, 2014, 12:12:47 AM by zombekillz »

If your server goes dedicated or if you want it to work for someone else other than the host, then yes.

Ok, thanks, will fix those things tomorrow.  Glad I have u guys to steer me in the right direction 😊