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

BUMP anyone?
Reply
#3

BUMP...
Reply
#4

You should explain a bit more, the command you use in a filterscript? and the race code is run in a gamemode?

If you change the gamemode the corresponding race function which get the data aren't there anymore, so where is the problem?
Reply
#5

Quote:
Originally Posted by Nero_3D
View Post
You should explain a bit more, the command you use in a filterscript? and the race code is run in a gamemode?
Yes.

Quote:
Originally Posted by Nero_3D
View Post
If you change the gamemode the corresponding race function which get the data aren't there anymore, so where is the problem?
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.
Reply
#6

To clarify something, if you are speaking from modes than you man gamemodes? and you change these with the rcon command "changemode"?, is the mstats command in a filterscripts, hence the CallRemoteFunction?

If all answers are YES than see second sentence from my previous reply, the solution would be to add a fallback code if the race mode is unavailable
Reply
#7

If the command is in the filterscript then there is no need to use CallRemoteFunction since it will work in every gamemode you have.

Just use normal player variables to see player(s) stats.

And, i suggest you to upgrade from dini (old, slow and boring) to mysql (fast, light and secure). To start you can use the awesome Easy MySQL by ThePhenix which im using in my server too.
Reply
#8

Quote:
Originally Posted by Nero_3D
View Post
To clarify something, if you are speaking from modes than you man gamemodes? and you change these with the rcon command "changemode"?, is the mstats command in a filterscripts, hence the CallRemoteFunction?

If all answers are YES than see second sentence from my previous reply, the solution would be to add a fallback code if the race mode is unavailable
Sorry, but i can't understand you :c
Reply
#9

may you resting the state some where try to get the numbers directly from dini like the below >

PHP Code:
forward RacesF(playerid);
public  
RacesF(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), MissPathname);
    return 
dini_Int(file"RacesFinish");
}
forward R1st(playerid);
public  
R1st(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), MissPathname);
    return 
dini_Int(file"Race1st");
}
forward R2nd(playerid);
public  
R2nd(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), MissPathname);
    return 
dini_Int(file"Race2nd");
}
forward R3rd(playerid);
public  
R3rd(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), MissPathname);
    return 
dini_Int(file"Race3rd");

Reply
#10

look the .db file showing everything right

Code:
RacesFinish=1
Race1st=1
Race2nd=0
Race3rd=0
Quote:

> But when the mode changes to stealing mode then /mstats shows that i have won no races, its 0.

Up
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)