With any INI include my stats doesn't save on gmx or when I restart my console, same is with MySQL
pawn Код:
enum pInfo
{
pKills,
pDeaths,
pAdmin,
pScore,
pMoney,
pVIP,
pOnline,
pWarns,
pCode
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerConnect(playerid)
{
CustomBanCheck(playerid);
ResetPlayerMoney(playerid);
SetWorldTime(12);
TogglePlayerClock(playerid, 0);
format(string, sizeof(string), "Dobrodoљli na iStunt %s by System32", VERSION);
SendClientMessage(playerid, 0xFF6C6C99, string);
SendClientMessage(playerid, 0x80FF0099, "Upiљite /help da vidite listu komandi!");
new escpname[24];
mysql_real_escape_string(GetName(playerid), escpname);
format(Query, sizeof(Query), "SELECT * FROM `racuni` WHERE `Korisnik` = '%s' LIMIT 1", escpname);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SetPlayerCameraPos(playerid, 1584.69, -1310.56, 124.02);
SetPlayerCameraLookAt(playerid, 1581.30, -1314.24, 126.07);
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} je registrirano!\nPrijavite se!", GetName(playerid));
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT , title, text2, "Ok", "Izlaz");
}
else
{
PlayerPlaySound(playerid, 1185, 0.0, 0.0, 10.0);
TogglePlayerSpectating(playerid, 1);
ForceClassSelection(playerid);
ClearChatForPlayer(playerid, 30);
TextDrawShowForPlayer(playerid, IntroBackground);
TextDrawShowForPlayer(playerid, IntroPresents);
TextDrawShowForPlayer(playerid, IntroRevolution);
TextDrawShowForPlayer(playerid, IntroSystem32);
TextDrawShowForPlayer(playerid, IntroFlare);
IntroTimer[playerid] = SetTimerEx("Intro", 10000, 0, "d", playerid);
}
mysql_free_result();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(rBit1_Get(IsPlayerLogged, playerid))
{
new escpname[24];
mysql_real_escape_string(GetName(playerid), escpname);
format(Query, sizeof(Query), "UPDATE `racuni` SET `Bodovi` = %d, `Novac` = %d, `Ubojstva` = %d, `Smrti` = %d, `Code` = %d, `Warns` = %d, `Online` = %d, `VIP` = %d, `Admin` = %d WHERE `Korisnik` = '%s'", GetPlayerScore(playerid), GetPlayerCash(playerid), PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pCode], PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pOnline], PlayerInfo[playerid][pVIP], PlayerInfo[playerid][pAdmin], escpname);
mysql_query(Query);
mysql_free_result();
}
players --;
TextDrawDestroy(esp[playerid]);
TextDrawDestroy(esph[playerid]);
TextDrawDestroy(espi[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 100.0);
TextDrawShowForPlayer(playerid,iStunt);
TextDrawShowForPlayer(playerid, ShadowsRandom);
TextDrawShowForAll(tdplayers);
TextDrawShowForAll(Time);
PingTimer[playerid] = SetTimerEx("CheckPing", 1000, 1, "i", playerid);
SetPlayerInterior(playerid, 0);
if(rBit1_Get(InJailZone, playerid))
{
rBit1_Set(InDmZone, playerid, 1);
SetPlayerInterior(playerid, 6);
SetPlayerPos(playerid, 264.2483,77.5985,1001.03914);
}
if(rBit1_Get(InDmZone, playerid))
{
rBit1_Set(InDmZone, playerid, 0);
}
if(rBit1_Get(IsPlayerLogged, playerid) && GetPVarInt(playerid, "MoneyGiven") > 0)
{
GivePlayerMoney(playerid, GetPVarInt(playerid, "MoneyGiven"));
SetPVarInt(playerid, "MoneyGiven", 0);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[playerid][pDeaths] = PlayerInfo[playerid][pDeaths] + 1;
if(killerid != INVALID_PLAYER_ID) PlayerInfo[playerid][pKills] = PlayerInfo[playerid][pKills] + 1;
SendDeathMessage(killerid, playerid, reason);
rBit1_Set(InDmZone, playerid, 0);
SetPlayerHealth(killerid, 100.0);
}
public OnGameModeInit()
{
mysql_debug(1);
mysql_connect("localhost", "root", "sa:mp", "");
WasteDeAMXersTime();
SetGameModeText("iStunt "VERSION);
DisableInteriorEnterExits();
UsePlayerPedAnims();
SetWeather(1);
EnableStuntBonusForAll(0);
CreateDynamicHouse(-2521.3315,-623.4722,132.7717, 3, 1527.229980,-11.574499,1002.097106, 1000, 0, 0);
CreateDynamicHouse(-2504.2537,-624.8500,132.7227, 5, 2350.339843,-1181.649902,1027.976562, 15000, 2, 2);
CreateDynamicHouse(-2514.5139,-631.3778,134.0594, 12, 2324.419921,-1145.568359,1050.710083, 5000, 1, 1);
CreateRentVehicle(405,-2396.89990234,-601.00000000,132.60000610,0.00000000,-1,-1,15, 1000); //Sentinel
AddStaticVehicle(411,-2405.60009766,-594.00000000,132.39999390,260.00000000,-1,-1); //Infernus
SetTimer("Online", 3600000, 1);
SetTimer("RandomMessage", 10000, 1);
SetTimer("MoneyTimer", 1000, 1);
SetTimer("TimeUp", 1000, 1);
return 1;
}
public OnGameModeExit()
{
mysql_close();
TextDrawDestroy(iStunt);
TextDrawDestroy(ShadowsRandom);
TextDrawDestroy(tdplayers);
TextDrawDestroy(Time);
TextDrawDestroy(IntroPresents);
TextDrawDestroy(IntroRevolution);
TextDrawDestroy(IntroSystem32);
TextDrawDestroy(IntroScripter);
TextDrawDestroy(IntroScripterName);
TextDrawDestroy(IntroMapper);
TextDrawDestroy(IntroMapperName);
TextDrawDestroy(IntroFlare);
TextDrawDestroy(IntroBackground);
TextDrawDestroy(IntroBackground1);
TextDrawDestroy(IntroBackground2);
TextDrawDestroy(IntroBackground3);
TextDrawDestroy(IntroBackground4);
TextDrawDestroy(IntroBackground5);
TextDrawDestroy(IntroBackground6);
TextDrawDestroy(IntroBackground7);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 1:
{
if(!response) return Kick(playerid);
if(!strlen(inputtext))
{
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} nije registrirano!\nRegistrirajte se!", GetName(playerid));
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT , title, text2, "Ok", "Izlaz");
}
new escpname[24], escpass[100];
mysql_real_escape_string(inputtext, escpass);
mysql_real_escape_string(GetName(playerid), escpname);
format(Query, sizeof(Query), "INSERT INTO `racuni` (`Korisnik`, `Lozinka`, `Ubojstva`, `Smrti`, `Admin`, `Bodovi`, `Novac`, `VIP`, `Online`, `Warns`, `Code`, `IP`) VALUES ('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", escpname, escpass, GetIP(playerid));
mysql_query(Query);
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} je registrirano!\nPrijavite se!\n\nUpiљite vaљ aktivacijski kod!", GetName(playerid));
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, title, text2, "Ok", "");
rBit1_Set(IsPlayerLogged, playerid, 1);
}
case 2:
{
if(!response) return Kick(playerid);
new escpname[24];
mysql_real_escape_string(GetName(playerid), escpname);
format(Query, sizeof(Query), "SELECT * FROM `racuni` WHERE `Korisnik` = '%s' AND `Lozinka` = '%s' LIMIT 1", escpname, inputtext);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() == 0)
{
SetPVarInt(playerid, "WrongPass", GetPVarInt(playerid, "WrongPass") + 1);
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} je registrirano!\nPrijavite se!\n\n{F81414}Upisali ste pogreљnu lozinku!", GetName(playerid));
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT , title, text2, "Ok", "Izlaz");
if(GetPVarInt(playerid, "WrongPass") == 3)
{
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} je registrirano!\nPrijavite se!\n\nUpiљite vaљ aktivacijski kod!", GetName(playerid));
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_INPUT, title, text2, "Ok", "");
}
}
else
{
new line[750];
if(mysql_fetch_row_format(line, "|"))
{
TogglePlayerSpectating(playerid, 0);
rBit1_Set(IsPlayerLogged, playerid, 1);
sscanf(line, "e<p<|>ddddddddd>", PlayerInfo[playerid]);
mysql_free_result();
}
}
}
case 3:
{
new escpname[24];
if(IsNumeric(inputtext))
{
PlayerInfo[playerid][pCode] = strval(inputtext);
mysql_real_escape_string(GetName(playerid), escpname);
format(Query, sizeof(Query), "UPDATE `racuni` SET `code` = '%d' WHERE `Korisnik` = '%s'", PlayerInfo[playerid][pCode], escpname);
mysql_query(Query);
}
else
{
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} je registrirano!\nPrijavite se!\n\nUpiљite vaљ aktivacijski kod!\nKod mora biti samo brojevi!", GetName(playerid));
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, title, text2, "Ok", "");
}
}
case 4:
{
new escpname[24];
mysql_real_escape_string(GetName(playerid), escpname);
format(Query, sizeof(Query), "SELECT * FROM `racuni` WHERE `Korisnik` = '%s' AND `Code` = '%d' LIMIT 1", escpname, inputtext);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() == 1 && IsNumeric(inputtext))
{
new line[750];
if(mysql_fetch_row_format(line, "|"))
{
rBit1_Set(IsPlayerLogged, playerid, 1);
sscanf(line, "e<p<|>ddddddddd>", PlayerInfo[playerid]);
mysql_free_result();
}
}
else
{
SetPVarInt(playerid, "WrongCode", GetPVarInt(playerid, "WrongCode") + 1);
format(title, sizeof(title), "{00CCFF} Dobrodoљao{FFFFFF} %s!", GetName(playerid));
format(text2, sizeof(text2), "{FFFFFF}______________________________\n\n{00CCFF}Ime{FFFFFF} %s{00CCFF} je registrirano!\nPrijavite se!\n\n{F81414}Upisali ste pogreљan aktivacijski kod!", GetName(playerid));
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_INPUT , title, text2, "Ok", "");
if(GetPVarInt(playerid, "WrongCode") == 3)
{
Kick(playerid);
}
}
}
Show us the IsPlayerlogged whatsoever function. Also, the strings (query string, etc.) might be too small. Also what are the MYSQL debug messages?
query size is 300, I also tried in OnDialogResponse put return 0; but the same...
System64 its the same here, I tried Kush, Seven Of Nine and etc registeration tutorials and finshed versions of it, but stats does not saves, though it creates the ini file only.
Is this only happening with GMX's? Also, generally if you close your server and re-open it, the players don't 'disconnect' so it won't save.
If it's only at the GMX you need to create a custom GMX command. Call a function at the GMX command that's saving everything for the player(s).
Also, System64 don't use 'mysql_free_result' unless you've stored the result.
TK - Yes, when I restar my console (samp-server.exe) or do a /gmx my stats doesn't save!
I have my custom /gmx command, I tried with calling OnPlayerDisconnect in /gmx but it's the same....