20.11.2018, 18:24
how can I do a command to give a score, this is the variable I use to score +1 PlayerInfo[killerid][cKills] += 1;
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;
}