SA-MP Forums Archive
Score not updating - 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: Score not updating (/showthread.php?tid=608540)



Score not updating - Deroxi - 02.06.2016

For some reason the score of a player is not updating in MySQL:
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new
        
query[128],
        
Float:pos[4],
        
name[24],
        
score;
    
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
    
GetPlayerFacingAngle(playeridpos[3]);
    
GetPlayerName(playeridname24);
    
GetPlayerScore(playeridPlayer[playerid][Score]);
    
mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET `Money` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f WHERE `ID` = %d",
    
GetPlayerMoney(playerid), pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]);
    
mysql_format(mysqlquerysizeof query"UPDATE 'accounts' SET 'Score' = '%i' WHERE 'Name' = '%s'"scorename);
    
mysql_tquery(mysqlquery"""");
    return 
true;




Re: Score not updating - Dayrion - 02.06.2016

Hm. Did you redefine GetPlayerScore ?
PHP код:
GetPlayerScore(playeridPlayer[playerid][Score]); 
This should be better.
PHP код:
Player[playerid][Score] = GetPlayerScore(playerid); 



Re: Score not updating - Deroxi - 02.06.2016

I got it working already, I think:
PHP код:
    mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET Money='%d',Score='%i',PosX`='%f',PosY='%f',PosZ='%f',PosA='%f' WHERE ID='%d'",GetPlayerMoney(playerid),GetPlayerScore(playerid), pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]); 



Re: Score not updating - Dayrion - 02.06.2016

Quote:
Originally Posted by Deroxi
Посмотреть сообщение
I got it working already, I think:
PHP код:
    mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET Money='%d',Score='%i',PosX`='%f',PosY='%f',PosZ='%f',PosA='%f' WHERE ID='%d'",GetPlayerMoney(playerid),GetPlayerScore(playerid), pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]); 
This is working too but your variable wont get updated.


Re: Score not updating - Deroxi - 02.06.2016

I dont get it? Why wouldn't my var update?
Its on OnPlayerDisconnect(), so when they login again it gets loaded


Re: Score not updating - oMa37 - 02.06.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
This is working too but your variable wont get updated.
Can i know why?
How he did will get it updated and everything fine.


Re: Score not updating - Deroxi - 02.06.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Can i know why?
How he did will get it updated and everything fine.
It isn't


Re: Score not updating - Dayrion - 02.06.2016

Oh, I mean this variable : Player[playerid][Score].
It will be updated anyway?


Re: Score not updating - oMa37 - 02.06.2016

This would be better:
PHP код:
Player[playerid][Score] = GetPlayerScore(playerid);
Player[playerid][Money] = GetPlayerMoney(playerid);
mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET Money='%d',Score='%i',PosX`='%f',PosY='%f',PosZ='%f',PosA='%f' WHERE ID='%d'"Player[playerid][Money],  Player[playerid][Score], pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]); 



Re: Score not updating - Deroxi - 02.06.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
This would be better:
PHP код:
Player[playerid][Score] = GetPlayerScore(playerid);
Player[playerid][Money] = GetPlayerMoney(playerid);
mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET Money='%d',Score='%i',PosX`='%f',PosY='%f',PosZ='%f',PosA='%f' WHERE ID='%d'"Player[playerid][Money],  Player[playerid][Score], pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]); 
I did that, didn't work