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;
}
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;
}
RacesFinish=1 Race1st=1 Race2nd=0 Race3rd=0
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?
|
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 |
forward RacesF(playerid);
public RacesF(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MissPath, name);
return dini_Int(file, "RacesFinish");
}
forward R1st(playerid);
public R1st(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MissPath, name);
return dini_Int(file, "Race1st");
}
forward R2nd(playerid);
public R2nd(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MissPath, name);
return dini_Int(file, "Race2nd");
}
forward R3rd(playerid);
public R3rd(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MissPath, name);
return dini_Int(file, "Race3rd");
}
RacesFinish=1 Race1st=1 Race2nd=0 Race3rd=0
> But when the mode changes to stealing mode then /mstats shows that i have won no races, its 0. |