Blockland Forums > Modification Help
Event Making Help
Pages: (1/1)
A Person.:
I'm making an event that has to do with variables.
Please tell me what I did wrong:
--- Code: ---
registerOutputEvent(GameConnection,"addAVariable","string 50 50",1);
%Variable = 0;
function GameConnection::addAVariable(%client,%amount) {
%Variable+%amount;
messageClient(%client,'',"\c6You just got \c2"@%amount@"\c6 Variable.");
}
--- End code ---
lilboarder32:
Too many things. I'll point out a few most:
--- Quote from: A Person. on June 23, 2010, 01:37:29 AM ---
--- Code: ---registerOutputEvent(GameConnection,"addAVariable","string 50 50",1); //The last argument, the "1", appends the client as the last argument in the function, which is unnecessary since the target is the client anyway
%Variable = 0; //This local variable is outside of a function and really is doing absolutely nothing
function GameConnection::addAVariable(%client,%amount) {
%Variable+%amount; //Use += to make variable add the value of %amount to it
//This also isn't assigning the variable to the client, it's just on it's own
messageClient(%client,'',"\c6You just got \c2"@%amount@"\c6 Variable."); //I don't even want to explain this one, but your syntax is correct
}
--- End code ---
--- End quote ---
A Person.:
--- Quote from: lilboarder32 on June 23, 2010, 02:11:29 AM ---Too many things. I'll point out a few most:
--- End quote ---
I fixed some of them but it still doesn't work:
--- Code: ---registerOutputEvent(GameConnection,"addVariable","string 10 10");
function GameConnection::addVariable(%client,%amount) {
%client.%variable+=%amount;
messageClient(%client,'',"\c6You just got \c2"@%amount@"\c6 Variable.");
}
--- End code ---
Headcrab Zombie:
--- Code: ---%client.%variable+=%amount;
--- End code ---
should be
--- Code: ---%client.variable+=%amount;
--- End code ---
A Person.:
Thanks.
Pages: (1/1)