03.10.2015, 07:30
(
Last edited by SpikY_; 06/10/2015 at 02:49 PM.
)
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:
COMMAND THAT SHOWS THE MISSION STATS!!
and the .db file shows:
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(playerid, name, sizeof(name));
format(file, sizeof(file), MissPath, name);
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(playerid, reason)
{
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(playerid, name, sizeof(name));
format(file, sizeof(file), MissPath, name);
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;
}
PHP Code:
CMD:mstats(playerid, params[])
{
new string[128], dialog[5000];
strcat(dialog,string);
format(string, sizeof(string),"{72A6FF}Races Finished: {FFFFFF}%d\n",CallRemoteFunction("RacesF", "d", playerid));
strcat(dialog,string);
format(string, sizeof(string),"{72A6FF}1st Position: {FFFFFF}%d\n",CallRemoteFunction("R1st", "d", playerid));
strcat(dialog,string);
format(string, sizeof(string),"{72A6FF}2nd Position: {FFFFFF}%d\n",CallRemoteFunction("R2nd", "d", playerid));
strcat(dialog,string);
format(string, sizeof(string),"{72A6FF}3rd Position: {FFFFFF}%d\n",CallRemoteFunction("R3rd", "d", playerid));
strcat(dialog,string);
ShowPlayerDialog(playerid, 3515, DIALOG_STYLE_MSGBOX,"{FFFF00}eX-MM - {FFFFFF}Mission Statistics",dialog,"Close","");
return 1;
}
Code:
RacesFinish=1 Race1st=1 Race2nd=0 Race3rd=0