Set Score with Command -
Longibotti - 18.04.2011
Hello =)
I want to make an little Script, which allows to change the score of a Player.
Ive seen some levelsystems, but they dont work with commands. I need to have something like
/setplayerscore [ID/NAME] [Score]
Does anybody knows how?
Re: Set Score with Command -
Stigg - 18.04.2011
Should you out:
https://sampwiki.blast.hk/wiki/Changing_...misc_condition
AW: Set Score with Command -
Longibotti - 18.04.2011
Thanks for the fast answer, but i know how to do it, when some1 kills another player.
I just don't know how to put it in a command (/setscore [ID/NAME] [SCORE])
Re: Set Score with Command -
nuriel8833 - 18.04.2011
PHP код:
if(strcmp(cmd, "/setscore", true) == 0)
{
new sendername[MAX_PLAYER_NAME];
new tmp[256];
new tmp2[256];
tmp = strtok(cmdtext, idx);
new givenplayer = strval(tmp);
tmp2 = strtok(cmdtext, idx);
new score = strval(tmp2);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setscore [playerid] [Score]");
if(!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid, COLOR_WHITE, "Invaild player ID!");
SetPlayerScore(givenplayer,score);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "Admin \"%s\" has just set your score to %d!", sendername, score);
SendClientMessage(otherplayer, COLOR_GREEN, string);
return 1;
}
I just hope you know how to change everything else (like colors and stuff)
If you don't contact me
Re: Set Score with Command -
xir - 18.04.2011
Instead of that command above, I will give you a cmd with zcmd & sscanf which is alot better.
strcmp & strtok is old & outdated
Here is a cmd with sscanf & zcmd
pawn Код:
COMMAND:setscore(playerid, params[])
{
new string[128], pName[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], pID, score;
if(sscanf(params, "ud", pID, score)) return SendClientMessage(playerid, -1, "Usage: /setscore <playerid> <score>");
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "This player is not connected");
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(pID, pName, sizeof(pName));
format(string, sizeof(string), "%s has given you %d score", name, score);
SendClientMessage(pID, -1, string);
format(string, sizeof(string), "You have given %d score to %s", score, pName);
SendClientMessage(playerid, -1, string);
SetPlayerScore(pID, score);
return 1;
}
AW: Set Score with Command -
Longibotti - 18.04.2011
Thank you 2, helped me very much
Re: Set Score with Command -
GAMER_PS2 - 19.10.2011
@xir dude i agree