Author Topic: Variables in Chat Commands  (Read 1110 times)

Here is my code.

Code: [Select]
function serverCmdbla(%client)
{
messageclient(%client,'',"Bla: ");
}

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.

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: [Select]
function servercmdbla(%client, %firstargument)
{
      if(%firstargument $= "5")
      {
            messageclient(%client, '', "Bla: you said two arguments.");
      }
      else
      {
            messageclient(%client, '', "Bla:");
      }
}

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

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.

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.

define "bla variables"

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

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

Sorry I should have elaborated, the VCE variables.

For Example:

OnActivate-->Client-->VCE_modVariable-->bla[Set]2
OnActivate-->Client-->CenterPrint-->Bla: <var:cl:bla>
It would say in centerprint, Bla: 2.

I need to make it so when you type /bla it says Bla: 2. (Asuming you have 2 Bla Variables.)
« Last Edit: January 22, 2012, 01:09:15 PM by Mapster »

So you want the /bla command to show the value of the VCE variable named bla?
VCE variables are handled completely differently that normal variables, I can dig it up for you

Code: [Select]
function serverCmdbla(%client)
{
    messageclient(%client,'',"Bla: " @ %client.brickgroup.vargroup.getVariable("Client","bla",%client));
}
Don't use VCE vars unless you absolutely need it to also be accessible by VCE. If you don't, do something like this

Code: [Select]
function serverCmdSetbla(%client,%bla)
{
    %client.bla = %bla;
}

function serverCmdBla(%client)
{
    messageclient(%client,'',"Bla: " @ %client.bla);
}
« Last Edit: January 22, 2012, 01:27:57 PM by Headcrab Zombie »

Thank you this will work.

i think all he wanted to know was how to add on to a string?
i think if you use SPC instead of @ it puts a space between them too

i think all he wanted to know was how to add on to a string?
i think if you use SPC instead of @ it puts a space between them too
All he wanted to know was how to make a code that displays a VCE variable in the chat when you type a server command.

You are correct, SPC can be used instead of @ and it will put a space.