Blockland Forums > Modification Help

Variables in Chat Commands

Pages: (1/2) > >>

Mapster:

Here is my code.


--- Code: ---function serverCmdbla(%client)
{
messageclient(%client,'',"Bla: ");
}
--- End code ---

In its current state all it does is when you type /bla it sends     Bla:     as a chat message to your client.
I need to know what I would do to make it if you had 2 bla variables it would say Bla: 2.
Basically the <var:cl:bla> thing only for coding.
Hope you can understand what I want, Thanks.

Nexus:

for every word that a person types in a /command, it shows up as a new argument in your function.

For example: if someone typed "/bla 5"
Your server sided code would need to be

--- Code: ---function servercmdbla(%client, %firstargument)
{
      if(%firstargument $= "5")
      {
            messageclient(%client, '', "Bla: you said two arguments.");
      }
      else
      {
            messageclient(%client, '', "Bla:");
      }
}
--- End code ---

the more words you want to be able to detect, the more %arguments you need after the %client

Mapster:

Thats not what I'm asking. What I want to do is have it show the variable number for bla after you type /bla. So instead of it just saying Bla: when you type /bla it says Bla: 2, asuming you have 2 bla variables.

Its just like the <var:cl:bla> thing that you type in events only I need it in code form.

Nexus:


--- Quote from: Mapster on January 22, 2012, 12:21:08 PM ---Thats not what I'm asking. What I want to do is have it show the variable number for bla after you type /bla. So instead of it just saying Bla: when you type /bla it says Bla: 2, asuming you have 2 bla variables.

Its just like the <var:cl:bla> thing that you type in events only I need it in code form.

--- End quote ---

define "bla variables"

I am not sure what you mean by "having 2 bla variables"

Greek2me:

He's saying that he wants to know the number of arguments there are.

Pages: (1/2) > >>

Go to full version