Player Score
#1

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

Why don't you use that in that command itself?
Reply
#3

Quote:
Originally Posted by SiaReyes
View Post
Why don't you use that in that command itself?
What do you mean?
Reply
#4

Quote:
Originally Posted by MichiCZ
View Post
What do you mean?
What he/she meant is that you should update the player score data in the command itself.
Reply
#5

PHP Code:
CMD:givepoints(playeridparams[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 3) return LowLevel(playerid);
    new 
pos;
    if(!
params[0]||!(pos chrfind(' ',params)+1)||!params[pos]) return SendLanguageText(playeridSERVER_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(string150"[PB] Přidal sis %d bodů na svůj ъčet. Nynн mбљ %d bodů."Castka,GetPlayerScore(CMD_ID));
        
format(string1150"[PB] You added %d points to your account. Now u have %d points."Castka,GetPlayerScore(CMD_ID));
        
SendLanguageText(playeridSERVER_COLORstring,string1);
    }
    else
    {
        
format(string200"[PB] Přidal si hrбči %s %d bodů. Nynн mб %d bodů."Jmeno(CMD_ID),Castka,GetPlayerScore(CMD_ID));
        
format(string1200"[PB] You added %d points to player %s. Now he have %d points."Castka,Jmeno(CMD_ID),GetPlayerScore(CMD_ID));
        
SendLanguageText(playeridSERVER_COLORstring,string1);
        
format(string200"[PB] Administrбtor %s ti přidal %d bodů. Nynн mбљ %d bodů.",Jmeno(playerid),Castka,GetPlayerScore(CMD_ID));
        
format(string1200"[PB] Admin %s added %d points to your account. Now u have %d points.",Jmeno(playerid),Castka,GetPlayerScore(CMD_ID));
        
SendLanguageText(playeridSERVER_COLORstring,string1);
    }
    return 
true;
}
public 
OnPlayerUpdate(playerid)
{
    
SetPlayerScore(playeridPlayerInfo[playerid][Score]);
    return 
1;

and dont forget to change PlayerInfo[playerid][Score] except of setting player score in anywhere of your script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)