So is the first argument always the player who activated the event?
offtopic question: how do you do the absolute value of something without doing a whole if statement and multiplying by -1? abs(
?
Another question: I can call function Player::addgold someplace else without using an event right?
Yes, the first argument is always the object calling the method.
And the function you're looking for is
mAbs I believe, ie;
function Player::addGold(%player,%gold)
{
%player.client.gold += mAbs(%gold);
messageClient(%player.client,'',"\c6You have\c3" SPC %gold SPC "gold\c6.");
}
Although, if you leave that
mAbs out, then you can use
%player.addGold(-10) to subtract gold as well which is convenient enough.
And yes, you can call it from script. Just using
%client.player.addGold(1); or whatever. Events are just a way to call functions, you can even use other event outputs for players like
%player.spawnProjectile() and things like that, provided you have the right arguments.