Player Score -
MichiCZ - 11.04.2019
Hello,
i have
Code:
CMD:givepoints(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 3) return LowLevel(playerid);
new pos;
if(!params[0]||!(pos = chrfind(' ',params)+1)||!params[pos]) return SendLanguageText(playerid, SERVER_COLOR, "Pouћitн: /givepoints [ID] [POINTS]","Usage: /givepoints [ID] [POINTS]");
if(strlen(params) > 23) return SystemMessage(playerid, "[PB] Chybnй parametry!","[PB] Incorrect parameters!");
new CMD_ID = strval(params);
if(!IsPlayerConnected(CMD_ID)) return NotConnected(playerid);
new Castka = strval(params[pos]),string[200],string1[200];
SetPlayerScore(CMD_ID, GetPlayerScore(playerid) + Castka);
if(CMD_ID == playerid)
{
format(string, 150, "[PB] Přidal sis %d bodů na svůj ъčet. Nynн mбљ %d bodů.", Castka,GetPlayerScore(CMD_ID));
format(string1, 150, "[PB] You added %d points to your account. Now u have %d points.", Castka,GetPlayerScore(CMD_ID));
SendLanguageText(playerid, SERVER_COLOR, string,string1);
}else{
format(string, 200, "[PB] Přidal si hrбči %s %d bodů. Nynн mб %d bodů.", Jmeno(CMD_ID),Castka,GetPlayerScore(CMD_ID));
format(string1, 200, "[PB] You added %d points to player %s. Now he have %d points.", Castka,Jmeno(CMD_ID),GetPlayerScore(CMD_ID));
SendLanguageText(playerid, SERVER_COLOR, string,string1);
format(string, 200, "[PB] Administrбtor %s ti přidal %d bodů. Nynн mбљ %d bodů.",Jmeno(playerid),Castka,GetPlayerScore(CMD_ID));
format(string1, 200, "[PB] Admin %s added %d points to your account. Now u have %d points.",Jmeno(playerid),Castka,GetPlayerScore(CMD_ID));
SendLanguageText(playerid, SERVER_COLOR, string,string1);
}
return true;
}
I have problem, this command add Score %d to player, but did not update PlayerInfo[playerid][Score].
Do you have any ideas how to solve it? Thanks!
// -------------- EDIT --------------
Code:
public OnPlayerUpdate(playerid)
{
PlayerInfo[playerid][Score] = GetPlayerScore(playerid);
SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
return 1;
}
Will this work?
Re: Player Score -
SiaReyes - 11.04.2019
Why don't you use that in that command itself?
Re: Player Score -
MichiCZ - 11.04.2019
Quote:
Originally Posted by SiaReyes
Why don't you use that in that command itself?
|
What do you mean?
Re: Player Score -
MicroKyrr - 11.04.2019
Quote:
Originally Posted by MichiCZ
What do you mean?
|
What he/she meant is that you should update the player score data in the command itself.
Re: Player Score -
khRamin78 - 12.04.2019
PHP Code:
CMD:givepoints(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 3) return LowLevel(playerid);
new pos;
if(!params[0]||!(pos = chrfind(' ',params)+1)||!params[pos]) return SendLanguageText(playerid, SERVER_COLOR, "Pouћitн: /givepoints [ID] [POINTS]","Usage: /givepoints [ID] [POINTS]");
if(strlen(params) > 23) return SystemMessage(playerid, "[PB] Chybnй parametry!","[PB] Incorrect parameters!");
new CMD_ID = strval(params);
if(!IsPlayerConnected(CMD_ID)) return NotConnected(playerid);
new Castka = strval(params[pos]),string[200],string1[200];
//SetPlayerScore(CMD_ID, GetPlayerScore(playerid) + Castka);
// New Line
PlayerInfo[playerid][Score] += Castka;
// New Line
if(CMD_ID == playerid)
{
format(string, 150, "[PB] Přidal sis %d bodů na svůj ъčet. Nynн mбљ %d bodů.", Castka,GetPlayerScore(CMD_ID));
format(string1, 150, "[PB] You added %d points to your account. Now u have %d points.", Castka,GetPlayerScore(CMD_ID));
SendLanguageText(playerid, SERVER_COLOR, string,string1);
}
else
{
format(string, 200, "[PB] Přidal si hrбči %s %d bodů. Nynн mб %d bodů.", Jmeno(CMD_ID),Castka,GetPlayerScore(CMD_ID));
format(string1, 200, "[PB] You added %d points to player %s. Now he have %d points.", Castka,Jmeno(CMD_ID),GetPlayerScore(CMD_ID));
SendLanguageText(playerid, SERVER_COLOR, string,string1);
format(string, 200, "[PB] Administrбtor %s ti přidal %d bodů. Nynн mбљ %d bodů.",Jmeno(playerid),Castka,GetPlayerScore(CMD_ID));
format(string1, 200, "[PB] Admin %s added %d points to your account. Now u have %d points.",Jmeno(playerid),Castka,GetPlayerScore(CMD_ID));
SendLanguageText(playerid, SERVER_COLOR, string,string1);
}
return true;
}
public OnPlayerUpdate(playerid)
{
SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
return 1;
}
and dont forget to change PlayerInfo[playerid][Score] except of setting player score in anywhere of your script