Blockland Forums > Modification Help

Score donation script

Pages: (1/5) > >>

Wheatley:

I've had this idea for a while now, but, I'm attempting to create a script that would allow someone to "donate their score to another player. This would, obviously, A) subtract X score from the donor and B) add X score to the receiver. 

However, being a person who's only made one script in torque before (which needed assistance), I'm not quite sure how I define what's what. Or much of anything, really.

I know I would need to use something like
function ServerCmdDonateScore(%client, %score, %target)
{stuff
}
which I believe translates to
/donatescore <amount> <target>.

If I'm misunderstood, I can try to explain more, but I'm basically trying to figure out where to start.

Thanks in advance.

Destiny/Zack0Wack0:

Use the server command you have there and construct it with the follow information;

To check a client's score (for seeing if they have enough to donate) use:

--- Code: ---%client.score

--- End code ---

To find a client by their name (ie. finding a %client from what the person enters for %target) use:

--- Code: ---%targetClient = findClientByName(%target);
//Make sure you use isObject(%targetClient) to check if the client with that name actually exists

--- End code ---

And finally to add/substract score (officially - changing the %client.score variable won't update the player list)

--- Code: ---%client.incScore(1); //add 1 score
%client.incScore(-1); //take 1 score

--- End code ---


Wheatley:

I think I did something terribly wrong.
Can anybody tell me what? For all I know, the following script is complete gibberish to torque.

--- Code: ---function servercmddonatescore(%client, %score, %target)
{
if(%client.score < 1)
{
messageClient(%client, '', "\c6You must have at least \c51 \c6point to donate.");
}
else
{
%targetClient = findClientByName(%target);
if(isObject(%Targetclient))
{
if(%client.score >= %score)
{
%client.incScore(-%score);
%target.incscore(%score);
messageClient(%target, '', "\c5%client \c6 has donated \c5%score \c6to you.");
}
else
{
messageClient(%client, '', "\c6Not enough score.");
}
else
{
messageClient(%client, '', "\c6 Invalid name.");
}
}
}
};

--- End code ---
My console says there's a syntax error.

Kalphiter:

}; ----> }

Wheatley:

That's it?

Pages: (1/5) > >>

Go to full version