Author Topic: serverCmd with spaces?  (Read 962 times)

How can people setup a command with a space in it? I tried serverCmdHelp_List_Jobs and it doesn't work either.

You mean arguments?

function serverCmdHello(%client,%arg)
{
messageAll('',%arg);
}


no. like some server have these commands that have spaces in them. Like /help list jobs

Code: [Select]
function serverCmdhelp(%client,%arg1,%arg2)
{
if(%arg1 == "list")
{
if(%arg2 == "jobs")
{
messageClient(%client,'',"This is how arguements work!");
}
}
}
Now, if you type /help list jobs it says "This is how arguements work!"

http://forum.blockland.us/index.php?topic=154416.0
Read this if you need more help.

Code: [Select]
function serverCmdhelp(%client,%arg1,%arg2)
{
if(%arg1 == "list")
{
if(%arg2 == "jobs")
{
messageClient(%client,'',"This is how arguements work!");
}
}
}
Now, if you type /help list jobs it says "This is how arguements work!"

http://forum.blockland.us/index.php?topic=154416.0
Read this if you need more help.
Thanks man

Found a little flaw. For future readers... In his script he uses "==", instead use "$=" (string to string)

Code: [Select]
function serverCmdhelp(%client,%arg1,%arg2)
{
if(%arg1 $= "list")
{
if(%arg2 $= "jobs")
{
messageClient(%client,'',"This is how arguements work!");
}
}
}

Code: [Select]
function serverCmdhelp(%client, %text)
{
if(!%text $= "")
{
if(strLwr(getWord(%text, 0)) $= "help")
{
if(strLwr(getWord(%text, 1)) $= "jobs")
{
messageClient(%client, '', "\c6Jobs List:
for(%a = 0; %a < $JobCount; %a++)
{
messageClient(%client, '', $JobName[%a] SPC $JobPay[%a] SPC $JobRequirement1[%a] SPC $JobRequirement2[%a] @ ".");
}
messageClient(%client, '', "\c6Page Up to see the full list of jobs.");
}
else
messageClient(%client, '', "\c6That sub-section does not exist!");
}
else
messageClient(%client, '', "\c6Please enter a valid section to view!");
}
else
messageClient(%client, '', "\c6Please enter something!");
}
There you go.

It uses only one argument variable, thanks to the help of getWord. Using this, you can make any number of arguments you want while only using one variable. it saves variables.
« Last Edit: June 12, 2011, 06:10:41 PM by Ipquarx »

snip
error line 9: you forgot ");
lol

but yeah other than that it should work.

Also, I'd use a switch instead of a huge if statement.

There you go.

It uses only one argument variable, thanks to the help of getWord. Using this, you can make any number of arguments you want while only using one variable. it saves variables.
That won't even work, spaces in slash commands are automatically used as new arguments.

That won't even work, spaces in slash commands are automatically used as new arguments.
That's right, isn't it?

That's right, isn't it?
%text will only ever be "help" because if you typed "/help help jobs" it would set %text to "help" and set the next argument to "jobs".

%text will only ever be "help" because if you typed "/help help jobs" it would set %text to "help" and set the next argument to "jobs".
Why did I type "That's right, isn't it?"?

He must've thought that because of serverCmdMessageSent.

That won't even work, spaces in slash commands are automatically used as new arguments.
wow, didn't know that. so it's not possible to use like, a %msg to get the rest of the "arguments" (what he was trying to do) without assigning it specifically to the words?


wow, didn't know that. so it's not possible to use like, a %msg to get the rest of the "arguments" (what he was trying to do) without assigning it specifically to the words?
If the command is called via / commands, then every word is a new argument.

However, commands called otherwise (e.g., typing in a normal message calls messageSent) can send multiple words in a single argument. These will require a client sided GUI or script.