[Question] How to give score? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Question] How to give score? (
/showthread.php?tid=272243)
[Question] How to give score? -
Superrollo - 27.07.2011
Hi. I'm trying to make a filterscript where someone can /givescore.
This means he gives his own score to someone else, just like giving money.
I've tried everything but not I have no idea what to do.
Can someone please help me with this?
Re: [Question] How to give score? -
Riddick94 - 27.07.2011
Using sscanf?
Re: [Question] How to give score? - HuSs3n - 27.07.2011
Код:
dcmd_givescore(playerid, params[])
{
new
giveplayerid,
amount,
gscore,
score;
if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givescore [playerid/partname] [amount]");
else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else if (amount > GetPlayerScore(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds");
else
{
GetPlayerScore(giveplayerid,gscore);
GetPlayerScore(playerid,score);
SetPlayerScore(giveplayerid,gscore+ amount);
SetPlayerScore(playerid, score - amount);
SendClientMessage(playerid, 0x00FF00AA, "Score sent");
SendClientMessage(giveplayerid, 0x00FF00AA, "Score received");
}
return 1;
}
not tested but i think it works
Re: [Question] How to give score? -
Superrollo - 02.08.2011
I tried that, but for some reason it sets the score (of both the giver and the reciever) to 0... How can I change that?
Re: [Question] How to give score? -
=WoR=Varth - 03.08.2011
pawn Код:
dcmd_givescore(playerid, params[])
{
new giveplayerid,
amount,
gscore = GetPlayerScore(playerid);
if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /givescore [playerid/partname] [amount]");
else if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else if(amount > gscore) return SendClientMessage(playerid, 0xFF0000AA, "Insufficient Score");
else
{
SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) + amount);
SetPlayerScore(playerid,gscore - amount);
SendClientMessage(playerid, 0x00FF00AA, "Score sent");
SendClientMessage(giveplayerid, 0x00FF00AA, "Score received");
}
return 1;
}