Set Score with Command
#1

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?
Reply
#2

Should you out:

https://sampwiki.blast.hk/wiki/Changing_...misc_condition
Reply
#3

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])
Reply
#4

PHP код:
    if(strcmp(cmd"/setscore"true) == 0)
    {
        new 
sendername[MAX_PLAYER_NAME];
        new 
tmp[256];
        new 
tmp2[256];
        
tmp strtok(cmdtextidx);
        new 
givenplayer strval(tmp);
        
tmp2 strtok(cmdtextidx);
        new 
score strval(tmp2);
        if(!
strlen(tmp)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /setscore [playerid] [Score]");
        if(!
IsPlayerConnected(otherplayer)) return SendClientMessage(playeridCOLOR_WHITE"Invaild player ID!");
        
SetPlayerScore(givenplayer,score);
        
GetPlayerName(playeridsendernamesizeof(sendername));
        
format(stringsizeof(string), "Admin \"%s\" has just set your score to %d!"sendernamescore);
        
SendClientMessage(otherplayerCOLOR_GREENstring);
        return 
1;
    } 
I just hope you know how to change everything else (like colors and stuff)
If you don't contact me
Reply
#5

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;
}
Reply
#6

Thank you 2, helped me very much
Reply
#7

@xir dude i agree
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)