Database issue
#1

Hi, I have an issue, I am making saving system for mission stats for my gamemode. So suppose, I finished a race and got 1st position, The 1st pos and race finish will get saved into the .db file. and its saving. & actually when there is Race mode running, The dialog shows how much races i won and how much time i got 1st pos. and the problem is when the mission gets change to any steal mode so the Races finished shows "0" and 1st position in races shows me "0". It only shows when racing mode is running.

The problem is in the loading of the data from .db file.
> if the mode is race so the /mstats command just show that how many races i have won
> But when the mode changes to stealing mode then /mstats shows that i have won no races, its 0.
> when i open .db file, it shows correctly that how many races i have won. Hope you understand

here are the codes:

PHP Code:
enum PlayerData
{
    
RacesFinish,
    
Race1st,
    
Race2nd,
    
Race3rd
};
new 
AccInfo[MAX_PLAYERS][PlayerData];
public 
OnPlayerConnect(playerid)
{
//=========================
    
new name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), MissPathname);
    if (!
dini_Exists(file))
    {
        
dini_Create(file);
        
dini_IntSet(file"RacesFinish"AccInfo[playerid][RacesFinish] = 0);
        
dini_IntSet(file"Race1st"AccInfo[playerid][Race1st] = 0);
        
dini_IntSet(file"Race2nd"AccInfo[playerid][Race2nd] = 0);
        
dini_IntSet(file"Race3rd"AccInfo[playerid][Race3rd] = 0);
    }
    if(
fexist(file))
    {
        
AccInfo[playerid][RacesFinish] = dini_Int(file"RacesFinish");
        
AccInfo[playerid][Race1st] = dini_Int(file"Race1st");
        
AccInfo[playerid][Race2nd] = dini_Int(file"Race2nd");
        
AccInfo[playerid][Race3rd] = dini_Int(file"Race3rd");
    }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
      
SaveMissStats(playerid);
      return 
1;
}
forward RacesF(playerid);
public  
RacesF(playerid)
{
    return 
AccInfo[playerid][RacesFinish];
}
forward R1st(playerid);
public  
R1st(playerid)
{
    return 
AccInfo[playerid][Race1st];
}
forward R2nd(playerid);
public  
R2nd(playerid)
{
    return 
AccInfo[playerid][Race2nd];
}
forward R3rd(playerid);
public  
R3rd(playerid)
{
    return 
AccInfo[playerid][Race3rd];
}
stock SaveMissStats(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), MissPathname);
    
dini_IntSet(file"RacesFinish"AccInfo[playerid][RacesFinish]);
    
dini_IntSet(file"Race1st"AccInfo[playerid][Race1st]);
    
dini_IntSet(file"Race2nd"AccInfo[playerid][Race2nd]);
    
dini_IntSet(file"Race3rd"AccInfo[playerid][Race3rd]);
    return 
1;

COMMAND THAT SHOWS THE MISSION STATS!!
PHP Code:
CMD:mstats(playeridparams[])
{
    new 
string[128], dialog[5000];
    
strcat(dialog,string);
    
format(stringsizeof(string),"{72A6FF}Races Finished: {FFFFFF}%d\n",CallRemoteFunction("RacesF""d"playerid));
    
strcat(dialog,string);
    
format(stringsizeof(string),"{72A6FF}1st Position: {FFFFFF}%d\n",CallRemoteFunction("R1st""d"playerid));
    
strcat(dialog,string);
    
format(stringsizeof(string),"{72A6FF}2nd Position: {FFFFFF}%d\n",CallRemoteFunction("R2nd""d"playerid));
    
strcat(dialog,string);
    
format(stringsizeof(string),"{72A6FF}3rd Position: {FFFFFF}%d\n",CallRemoteFunction("R3rd""d"playerid));
    
strcat(dialog,string);
    
ShowPlayerDialog(playerid3515DIALOG_STYLE_MSGBOX,"{FFFF00}eX-MM - {FFFFFF}Mission Statistics",dialog,"Close","");
    return 
1;

and the .db file shows:
Code:
RacesFinish=1
Race1st=1
Race2nd=0
Race3rd=0
Reply


Messages In This Thread
Database issue - by SpikY_ - 03.10.2015, 07:30
Re: Database issue - by SpikY_ - 03.10.2015, 11:56
Re: Database issue - by SpikY_ - 04.10.2015, 08:51
AW: Database issue - by Nero_3D - 04.10.2015, 12:34
Re: AW: Database issue - by SpikY_ - 04.10.2015, 15:29
AW: Database issue - by Nero_3D - 04.10.2015, 21:01
Re: Database issue - by Face9000 - 04.10.2015, 21:51
Re: AW: Database issue - by SpikY_ - 07.10.2015, 06:07
Re: Database issue - by jlalt - 07.10.2015, 06:24
Re: Database issue - by SpikY_ - 07.10.2015, 06:29

Forum Jump:


Users browsing this thread: 1 Guest(s)