givescore problem - 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)
+--- Thread: givescore problem (
/showthread.php?tid=496994)
givescore problem -
AhmedMohamed - 24.02.2014
It's /givescore command i made it for admins only.
when admin use /givescore it give score to id 0 only even if id 0 not the requirement id.
the code:
Код:
CMD:givescore(playerid, params[])
{
if(PlayerInfo[playerid][Level] >= 4)
{
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, "ERROR: Player not found");
else if(amount > gscore) return SendClientMessage(playerid, 0xFF0000AA, "ERROE:Unknown Score");
{
SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) + amount);
SendClientMessage(playerid, 0x00FF00AA, "Score Sent");
SendClientMessage(giveplayerid, 0x00FF00AA, "You Recieved Scores From an admin");
}
if(PlayerInfo[playerid][Level] <= 4)
{
SendClientMessage(playerid, red, "ERROR: You are not a high enough level to use this command");
}
}
return 1;
}
Re: givescore problem -
Beckett - 24.02.2014
Код:
CMD:givescore(playerid, params[])
{
if(PlayerInfo[playerid][Level] >= 4)
{
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, "ERROR: Player not found");
else if(amount > gscore) return SendClientMessage(playerid, 0xFF0000AA, "ERROR:Unknown Score");
SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) + amount);
SendClientMessage(playerid, 0x00FF00AA, "Score Sent");
SendClientMessage(giveplayerid, 0x00FF00AA, "You Recieved Scores From an admin");
}
else
{
// Your msg here if hes lower than 4.
}
return 1;
}
You don't need to re-check if the player is lower than 4 then send him the message.