SA-MP Forums Archive
Command /setscore - 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: Command /setscore (/showthread.php?tid=661055)



Command /setscore - Spawe - 20.11.2018

how can I do a command to give a score, this is the variable I use to score +1 PlayerInfo[killerid][cKills] += 1;


Re: Command /setscore - d3Pedro - 20.11.2018

pawn Код:
CMD:setscore(playerid, params[])
{
    new playername[MAX_PLAYER_NAME], sendtoname[MAX_PLAYER_NAME], targetid, value;
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerName(targetid, sendtoname, sizeof(sendtoname));
    if(sscanf(params, "dd", targetid, value))
    {
        return SendClientMessage(playerid, -1, "/setscore [targetid] [score]");
    }
    if(IsPlayerConnected(targetid))
    {
        PlayerInfo[targetid][cKills] = value; // to update it you use PlayerInfo[targetid][cKills] = PlayerInfo[targetid][cKills] + value; // or you use += value.
        //save player score function here/ or update
        new string[64];
        format(string, sizeof(string), "You've set %s score to %d", sendtoname, value);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "%s has set your score to %d", playername, value);
        SendClientMessage(targetid, -1, string);
        return 1;
    }
    return 1;
}