Blockland Forums > Modification Help
Fetching server response into a GUI
Pages: (1/1)
Mr. Wallet:
This has been driving me nuts, and I'm going in ever-more-complex circuits over this, so hopefully someone here can help me.
The idea is that the client can have a GUI, and receive a response from the server given a certain input. The problem is that this always seems to come back to some variation of
--- Code: ---%variable = commandtoserver('getsomeinfo');
--- End code ---
Unfortunately, whenever this happens, I get the same error every time client-side: Call to commandToServer in [function name] uses result of void function call.
What's going on? Any way to work around it?
Game master pro:
try %variable = serverCmdgetmesomeinfo();
commandtoserver is a way to execute the command or something, it's not the actual function name.
Mr. Wallet:
It's a way for the client to execute the command server-side. servercmdgetsomeinfo(); will fail because the function's not on the client's machine. Assuming I put it on the client's machine via the GUI, that still doesn't help me fetch anything from the server.
TheGeek:
--- Quote ---void commandToServer (string func[, arg1,...])
--- End quote ---
Here's the problem, commandToServer doesn't return anything (aka, void), so if you have a server command like this:
--- Code: ---function ServerCmdGetInfo(%client){
return "abc";
}
--- End code ---
and you call it like this (client side):
--- Code: ---%str = commandToServer('GetInfo');
--- End code ---
%str won't be "abc".
A workaround:
Server side:
--- Code: ---function ServerCmdGetInfo(%client){
commandToClient(%client, 'GetInfo', "abc");
}
--- End code ---
Client side:
--- Code: ---function ClientCmdGetInfo(%str){
$str = %str;
}
--- End code ---
Mr. Wallet:
Thanks geek, you're my :cookieMonster:
Pages: (1/1)