Author Topic: Event Making Help  (Read 442 times)

I'm making an event that has to do with variables.

Please tell me what I did wrong:

Code: [Select]

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.");

}
« Last Edit: June 23, 2010, 01:54:05 AM by A Person. »

Too many things. I'll point out a few most:
Code: [Select]
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

}

Too many things. I'll point out a few most:

I fixed some of them but it still doesn't work:

Code: [Select]
registerOutputEvent(GameConnection,"addVariable","string 10 10");


function GameConnection::addVariable(%client,%amount) {

%client.%variable+=%amount;

messageClient(%client,'',"\c6You just got \c2"@%amount@"\c6 Variable.");

}

Code: [Select]
%client.%variable+=%amount;
should be
Code: [Select]
%client.variable+=%amount;