Author Topic: CommandToServer(); causes game to crash  (Read 1443 times)

I am trying to create a way so that players are able to use / commands without typing them into the chat.

When they type out the command they want to use (ex: "Self Delete") into a gui, and that is saved as a global variable: $globalvariable

in order for this to accomplish anything, I need to send the command to the server

Code: [Select]
commandtoserver($globalvariable);
as soon as that line is hit, the game crashes with no error code.

I have tried to do things like:

Code: [Select]
eval("commandtoserver($globalvariable);");
but it still crashes.

Is there a way around this?  How does blockland convert the string you enter into the chat into a variable so it can be sent as a command to the server?

I played around with this for a bit and I did the following:
Code: [Select]
==>commandtoserver('Self Delete');
==>commandtoserver($variable = 'Self Delete');
==>echo($variable);
62
==>commandtoserver(62);
Remote Command Error - command must be a tag.
==>commandtoserver($variable);

none of these caused me to crash, but then I tried this:

Code: [Select]
commandtoserver("Self Delete");and the game crashed

So now my question is, how can I convert a variable from a "" string to a '' string?  How can I get it so that this:

Code: [Select]
$globalvariable = randomgui_textentry.getvalue();
saves $globalvariable as a '' type string instead of a "" one?
Is the trick using a different kind of gui text box?

Because you don't know how to use it
commandToServer('Self Delete');

« Last Edit: June 04, 2011, 03:14:24 PM by Nexus »

Commandtoserver runs a servercmd, do you even know how servercmds work.

Commandtoserver runs a servercmd, do you even know how servercmds work.

Are people reading my problem?  Am I really so vague that you think this applies to what I am talking about?

commandtoserver on the client side will call a servercmd on the server
commandtoclient on the server side will call a clientcmd on the client.

That isn't what I'm having a problem with.

My problem is that commandtoserver(); will crash you if you input a "" string or a variable saved as a "" string.  I need to know how to convert a "" string into a '' one, or how to get an input from the client as a '' string through a gui.

Because commandtoserver("Self Delete"); which you had down, is wrong.

Where commandtoserver('Self Delete'); is right, which Kalphiter had down.

In order to get a variable in there,
eval("commandToServer('" @ $GlovalVariable @ "');");

Because commandtoserver("Self Delete"); which you had down, is wrong.

Where commandtoserver('Self Delete'); is right, which Kalphiter had down.

In order to get a variable in there,
eval("commandToServer('" @ $GlovalVariable @ "');");

I had both down, Kalphiter didn't read.
I know what is right and what is wrong, I just didn't know how to convert between tags.

Thanks for your solution, testing to see if this works.  I'll leave this unlocked for a bit to see if anyone knows the name of a function to convert the tags on the strings.

Ok, chrono's way works, but for some reason doing "'"@$variable@"'" does not.  It only works when the function is inside an eval.

commandToServer(addTaggedString($variable));

Ok, chrono's way works, but for some reason doing "'"@$variable@"'" does not.  It only works when the function is inside an eval.
Because doing it that way makes it a string with 's in it, rather than a tagged string.

But use Zack's method instead.

commandToServer(addTaggedString($variable));

Perfect, thanks both of you for the help.