Author Topic: how to make a gui only useable by the host?  (Read 1896 times)

how would i make a gui host-only while still being dedicated-compatible?
in other words, how do i make a gui non-hackable. (by hack i mean mess with client-sided functions to make it work when its not supposed to)

Make it client-sided.

What's the purpose of the GUI?

If it interacts with the server, make everything it does be checked by the server to see if they're the host. This includes opening the GUI and any commands they might be able to do with it. Of course, they could change the client script to allow them to open the GUI, but the server prevents them from changing anything.

If the GUI is purely client-sided, I don't think you can block it.

Let me make this clear:
There is absolutely nothing you can do to keep people from messing with client-sided scripts. Absolutely NOTHING. You can open your admin gui as a non-admin in Blockland, as well.

But you CAN make sure things are peachy server-side.

client.cs
Code: [Select]
// $IAmAdmin can be manually altered or this check can be removed altogether.
function SomethingGUI::doSomething(%gui)
{
if($IAmAdmin)
commandToServer('doSomething');
}

server.cs
Code: [Select]
// This check cannot be forged unless the server admin does something stupid.
function serverCmdDoSomething(%client)
{
if(%client.isAdmin)
%client.doSomething();
}

that sounds good, allright.
but i have a few questions:
1. do they have to be servercmds?
2. how do i make it dedicated compatible? in other words, how do i make it function properly without using canvas.
3. would makeing it dedicated compatible require client files?

that sounds good, allright.
but i have a few questions:
1. do they have to be servercmds?
2. how do i make it dedicated compatible? in other words, how do i make it function properly without using canvas.
3. would makeing it dedicated compatible require client files?
It sounds like you're trying to make a GUI open on the dedicated server window, what.

The hell are you trying to do?

There's no point in vaguely covering up whatever your mod is, especially if you want help.

2. how do i make it dedicated compatible? in other words, how do i make it function properly without using canvas.
You always have to use canvas. I think what you really want to know is how to make the client open your GUI.

You seriously need to be less vague on your coding help topics. No one can you help you when you give stuff all information.

You seriously need to be less vague on your coding help topics. No one can you help you when you give stuff all information.
"I'm working on a project that involves stuff. Basically, this thing won't work. Any advice?"


Protip: Nobody is going to run off and try to beat you to the finish line with whatever you're working on.

Allright, here is what I'm trying to do, EXACTLY:
I'm tying to make a host-only GUI that goes along with my mod (if you really care that much, it's called WhiteList) so that people can use the mod easier. I've made the GUI itself, named all the right parts, and entered the commands for the buttons, here are the rest of the details:
there is a scrollable text list that lists all the blids on the whitelist. I'm trying to use a server-sided console function that returns 1 blid associated with a specific number, and a onWake function (client-sided) that is supposed to get all the blids from that function and put them in the list. That's problem 1.
I'm using a clientcmd to open and close the GUI (client-sided). That works.
I'm using a clientcmd to refresh the GUI. I don't know if it works.
There is a text box to enter in blids which is stored in a variable, and a button to add that blid to the whitelist using a server-sided console function. That's problem 2.

That specific enough?
I'm typing this on a iPod, so I can't get any code ATM. 

Quote
I'm tying to make a host-only GUI
As previously explained, anybody can open that GUI client-side. You can just have it so it doesn't give them any information, though.
Quote
I'm trying to use a server-sided console function that returns 1 blid associated with a specific number
You could send a tabbed list of 10-15 at a time. Wouldn't run over the character limit, saves on number of commandtoclient functions called.
Quote
and a onWake function (client-sided) that is supposed to get all the blids from that function and put them in the list. That's problem 1.
Bad. This means you're sending however many server commands whether you're an admin or not if someone gets the GUI open, which'd be annoying for the server. Make it send one "requestWhitelist", then if they're the host the above can update the list. This also solves trying to get the number of IDs clientside when that isn't necessary - just clear the list then add every received one to the end of the list, either sorted on the server or after all of them have been recieved on the client.
Quote
I'm using a clientcmd to open and close the GUI (client-sided). That works.
Alternately you could have this accessible from something like the Admin menu, provided it doesn't get in the way of RTB or other mods. Just don't make it another useless keybind I have to set.
Quote
I'm using a clientcmd to refresh the GUI. I don't know if it works.
Clearing the GUI then requesting the whitelist again. Does this need a separate client-command? I don't see a use for it (all they'd have to do is close/reopen it) unless you want it to send only on first join and when the list is updated.
Quote
There is a text box to enter in blids which is stored in a variable, and a button to add that blid to the whitelist using a server-sided console function. That's problem 2.
Well, what have you tried? You seem to know what you want so show an attempt before asking it to be spoon-fed to you.
« Last Edit: May 31, 2011, 04:31:42 PM by Space Guy »

that sounds good, allright.
but i have a few questions:
1. do they have to be servercmds?
2. how do i make it dedicated compatible? in other words, how do i make it function properly without using canvas.
3. would makeing it dedicated compatible require client files?

Having had this thing crash my own dedicated server...heres a few tips:

1) TEST it on a dedicated server (start a dedicated LAN server on your own pc, join it and go from there).
2) use a client.cs file to exec() the .gui files

3) use a /command to open the gui.  The setup looks something like this:

in server.cs
  function serverCmdOpenMyGui(%client)
  {
   if (%client== getNumKeyID() )
     commandToClient(%client, 'openMyGui' );
  }


in client.cs
   exec("mygui.gui");

   function clientCmdOpenMyGui()
    {
     Canvas.pushDialog(MyGui);
    }


You can also try making completely seperate addons, and only distribute the client-sided one to those people you want.

Thats step 1

Once the gui is opened, you also have to check every single servercmd to make sure the client is the host.  Like Iban said -- there is nothing to stop people from hacking the gui to open on their own client.

my own comments on what your trying to do:
I'm trying to use a server-sided console function that returns 1 blid associated with a specific number, and a onWake function (client-sided) that is supposed to get all the blids from that function and put them in the list. That's problem 1.
I'm using a clientcmd to open and close the GUI (client-sided). That works.
I'm using a clientcmd to refresh the GUI. I don't know if it works.
There is a text box to enter in blids which is stored in a variable, and a button to add that blid to the whitelist using a server-sided console function. That's problem 2.
I suspect a bad design of problem 1 is leading to problem #2
what I would do is this:
  inside the onWake function you do 'commandToServer' and request the list of bl_ids from the server.
create a clientcmd to accept the bl_id and add it to your scrolling list in the gui
create a servercmd to loop through all your values and send them back to the client using the client cmd you just created.  Send them to the client one at a time.  This wont be a problem unless your whitelist includes more than 1,000 entries.


next create a servercmd that adds/creates a new entry in your global variable, and then sends that back to the client -- reuse your client cmd here as well.

Lastly -- in your gui, you just call the servercmd that creates a new entry.  the servercmd then sends the result back to your client using the clientcmd you already created to add it to your scrolling list.

And in the 2 new server cmds you created, make sure to put in a check to make sure the client is the host.

Sounds like i've got my work cut out for me.

sounds like i basically did the entire thing wrong, if i need any further help i'll post another reply.