Score not saving !
#1

PHP код:
SavePlayer(playerid)
{
    new 
PlayerName[24];
    
GetPlayerName(playerid,PlayerName,24);
    new 
file[256]; format(file,256,"/ladmin/users/%s.sav",udb_encode(PlayerName));
    if(
PlayerInfo[playerid][LoggedIn] == 1)
{
           
dUserSetINT(PlayerName2(playerid)).("money",GetPlayerMoney(playerid));
           
dUserSetINT(PlayerName2(playerid)).("Score",GetPlayerScore(playerid));  //Here is the code
           
dUserSetINT(PlayerName2(playerid)).("kills",PlayerInfo[playerid][Kills]);
           
dUserSetINT(PlayerName2(playerid)).("deaths",PlayerInfo[playerid][Deaths]);
           
    }
}
LoginPlayer(playerid)
{
    if(
ServerInfo[GiveMoney] == 1) {ResetPlayerMoney(playerid); GivePlayerMoney(playeriddUserINT(PlayerName2(playerid)).("money") ); }
    
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
    
PlayerInfo[playerid][Deaths] = (dUserINT(PlayerName2(playerid)).("deaths"));
    
PlayerInfo[playerid][Kills] = (dUserINT(PlayerName2(playerid)).("kills"));
    
PlayerInfo[playerid][BTLevel] = (dUserINT(PlayerName2(playerid)).("btlevel"));
     
PlayerInfo[playerid][Level] = (dUserINT(PlayerName2(playerid)).("level"));
     
PlayerInfo[playerid][VipLevel] = (dUserINT(PlayerName2(playerid)).("viplevel"));
     
PlayerInfo[playerid][PMBlock] = (dUserINT(PlayerName2(playerid)).("PMBlock"));
    
SetPlayerScore(playerid,dUserINT(PlayerName2(playerid)).("Score"));  // And here also
    
PlayerInfo[playerid][Registered] = 1;
     
PlayerInfo[playerid][LoggedIn] = 1;
}
CMD:register(playerid,params[])
{
    if (
PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: You are already registered and logged in.");
    if (
udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: This account already exists, please use '/login [password]'.");
    if (
strlen(params) == 0) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Correct usage: '/register [password]'");
    if (
strlen(params) < || strlen(params) > 20) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Password length must be greater than three characters");
    if (
udb_Create(PlayerName2(playerid),params))
    {
        new 
file[256],rname[MAX_PLAYER_NAME], tmp3[100];
        new 
strdate[20], year,month,day;
        
getdate(yearmonthday);
        
GetPlayerName(playerid,rname,sizeof(rname));
        
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(rname));
         
GetPlayerIp(playerid,tmp3,100);
        
dini_Set(file,"ip",tmp3);
        
dUserSetINT(PlayerName2(playerid)).("registered",1);
           
format(strdatesizeof(strdate), "%d/%d/%d",day,month,year);
        
dini_Set(file,"RegisteredDate",strdate);
        
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
        
dUserSetINT(PlayerName2(playerid)).("banned",0);
        
dUserSetINT(PlayerName2(playerid)).("level",0);
        
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
        
dUserSetINT(PlayerName2(playerid)).("money",0);
        
dUserSetINT(PlayerName2(playerid)).("kills",0);
           
dUserSetINT(PlayerName2(playerid)).("deaths",0);
           
dUserSetINT(PlayerName2(playerid)).("Score",0);  // and here in cmd
        
dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
        
PlayerInfo[playerid][LoggedIn] = 1;
        
PlayerInfo[playerid][Registered] = 1;
        
SavePlayer(playerid);
        
LoginPlayer(playerid);
        
LoadPlayer(playerid);
        
SendClientMessage(playeridgreen"ACCOUNT: You are now registered, and have been automaticaly logged in");
        
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        return 
1;
    }
    return 
1;

Reply
#2

stocks SavePlayer and LoadPlayer and cmd is register
Reply
#3

Bump
Reply
#4

Try this

PHP код:
SavePlayer(playerid)
{
    new 
PlayerName[24];
    
GetPlayerName(playerid,PlayerName,24);
    new 
file[256]; format(file,256,"/ladmin/users/%s.sav",udb_encode(PlayerName));
    if(
PlayerInfo[playerid][LoggedIn] == 1)
    {
           
dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
           
dUserSetINT(PlayerName(playerid)).("Score",GetPlayerScore(playerid));  //Here is the code
           
dUserSetINT(PlayerName(playerid)).("kills",PlayerInfo[playerid][Kills]);
           
dUserSetINT(PlayerName(playerid)).("deaths",PlayerInfo[playerid][Deaths]);
           
    }

Reply
#5

Are stats saving in the file or only score not?
And everything loads exept score?
Reply
#6

Quote:
Originally Posted by Shinja
Посмотреть сообщение
Are stats saving in the file or only score not?
And everything loads exept score?
everything writes on playeer note file even score but when i rejoin everything load as it saves except score it keep show 0
Reply
#7

And Money? because they have same syntax
Reply
#8

1. Why are you encoding the name lol?
You mean your score cant load or save? Try opening the user file and see if the score is written, If the score is written replace:
Код:
SetPlayerScore(playerid,dUserINT(PlayerName2(playerid)).("Score"));  // And here also
->
Код:
int pScore = (dUserINT(PlayerName2(playerid)).("Score")); 
SetPlayerScore(playerid, pScore);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)