PDA

View Full Version : Player Data Failing to Save After Updating Includes


Zmith
08/06/2017, 10:14 PM
I was updating my pawno\include folder and deleted all the includes (there was a ton of includes I didn't believe were required) and started fresh with the updated includes.

(!)My gamemode finally complied and all seemed well. However, player data is now failing to save and I've tried fixing it myself but I can't find the problem. I'm assuming I am missing an essential include which I cannot recover :/


My includes: http://i.imgur.com/jJuxu7n.png

My plugins: http://i.imgur.com/68SOYU2.png

#include <a_samp>
#include <YSI\y_ini>
#include <zcmd>
#include <sscanf2>
#include "../include/gl_common.inc"

enum PlayerInfo
{
Pass[129],
Adminlevel,
Premlevel,
CharSkin,
CharMoney,
CharScore,
CharKills,
CharDeaths,
IsJailed,
}

forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
printf("%s -> %s", name, value);
INI_String("Password", pInfo[playerid][Pass], 129);
INI_Int("Adminlevel" ,pInfo[playerid][Adminlevel]);
INI_Int("Premlevel", pInfo[playerid][Premlevel]);
INI_Int("CharSkin", pInfo[playerid][CharSkin]);
INI_Int("CharMoney", pInfo[playerid][CharMoney]);
INI_Int("CharScore", pInfo[playerid][CharScore]);
INI_Int("CharKills", pInfo[playerid][CharKills]);
INI_Int("CharDeaths", pInfo[playerid][CharDeaths]);
INI_Int("IsJailed", pInfo[playerid][IsJailed]);
return 1;
}

public OnPlayerConnect(playerid)
{

format(string2, sizeof(string2), "{A9C4E4}# [Server] %s {EAEAEA}has connected to the server.", GetName(playerid));
SendClientMessageToAll(COLOR_SERVER ,string2);
SetTimerEx("ClearScreen", 1, false, "i", playerid);

new string1[300]; new registerid; new loginid; new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
format(string1, sizeof(string1), "{EAEAEA}Enter your password below to login!", GetName(loginid), loginid);
ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "{A9C4E4}Server {EAEAEA}- Login:", string1, "Login", "Quit");
}
else
{
format(string, sizeof(string), "{EAEAEA}Enter a password below to register!", GetName(registerid), registerid);
ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_PASSWORD, "{A9C4E4}Server {EAEAEA}- Register:", string, "Register", "Quit");
return 1;
}

stock save(playerid)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Character");
INI_WriteInt(file, "Adminlevel", pInfo[playerid][Adminlevel]);
INI_WriteInt(file, "Premlevel", pInfo[playerid][Premlevel]);
INI_WriteInt(file, "CharSkin", pInfo[playerid][CharSkin]);
INI_WriteInt(file, "CharMoney", GetPlayerMoney(playerid));
INI_WriteInt(file, "CharScore", GetPlayerScore(playerid));
INI_WriteInt(file, "CharKills", pInfo[playerid][CharKills]);
INI_WriteInt(file, "CharDeaths", pInfo[playerid][CharDeaths]);
INI_WriteInt(file, "IsJailed", pInfo[playerid][IsJailed]);
INI_Close(file);
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

if(dialogid == REGISTER_DIALOG)
{
if(!response)return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
new string[300];
new registerid;
format(string, sizeof(string), "{EAEAEA}Hello, {A9C4E4}%s{EAEAEA}.\n\nPlease enter a password below.", GetName(registerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_PASSWORD, "{A9C4E4}Server {EAEAEA}- Register:", string, "Register", "Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Character");
INI_WriteString(file, "Password", hashpass);
INI_WriteInt(file, "Adminlevel", 0);
INI_WriteInt(file, "Premlevel", 0);
INI_WriteInt(file, "CharSkin", 60);
INI_WriteInt(file, "CharMoney", 15000);
INI_WriteInt(file, "CharScore", 1);
INI_WriteInt(file, "CharKills", 1);
INI_WriteInt(file, "CharDeaths", 1);
INI_WriteInt(file, "IsJailed", 0);
INI_Close(file);
new rstring[200];
new registerid;
format(rstring, sizeof(rstring), "{A9C4E4}Server {EAEAEA}- You have successfully registered, {A9C4E4}%s{EAEAEA}!", GetName(registerid));
SendClientMessage(playerid, COLOR_SERVER, "Reminder: {EAEAEA}The server is currently underdevelopment - You might experience bugs");
SendClientMessage(playerid, COLOR_GREEN, rstring);
muted[playerid] = 0;
return 1;
}
}
if(dialogid == LOGIN_DIALOG)
{
if(!response)return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(!strcmp(hashpass, pInfo[playerid][Pass]))
{
new loginid = playerid;
new lstring[300];
INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
SetPlayerScore(playerid, pInfo[playerid][CharScore]);
GivePlayerMoney(playerid, pInfo[playerid][CharMoney]);
format(lstring, sizeof(lstring), "{EAEAEA}Welcome Back, {A9C4E4}%s{EAEAEA}. {EAEAEA}You have successfully logged in!", GetName(loginid));
SendClientMessage(playerid, COLOR_SERVER, "Reminder: {EAEAEA}The server is currently underdevelopment - You might experience bugs");
SendClientMessage(playerid, COLOR_GREEN, lstring);
muted[playerid] = 0;
}
else
{
new string1[300];
format(string1, sizeof(string1), "{EAEAEA}Enter your password below to login!", GetName(playerid), playerid);
ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "{A9C4E4}Server - {EAEAEA}Login:", string1, "Login", "Quit");
SendClientMessage(playerid, COLOR_RED, "{ff6347}Error: Wrong Password!");
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}

return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}

Also; the .ini file(s) update after changes ingame (admin, kills etc) but gmx and reconnecting they all will reset.

Any suggestions/solutions?

Zmith
09/06/2017, 03:18 AM
Update; the .ini file(s) update after changes ingame (admin, kills etc) but gmx or closing/restarting samp-server.exe and they all reset back to 0.

Yashas
09/06/2017, 04:40 AM
http://forum.sa-mp.com/showthread.php?t=574754

Zmith
09/06/2017, 06:42 AM
http://forum.sa-mp.com/showthread.php?t=574754

I appreciate the response but I'm not quite sure how this helps in my case. My "INI" were working perfectly fine prior to updating my includes and all the player's data was being saved. I had too much information thrown at me when reading your thread and none of it seemed to be related to my issue.

I even recovered my old includes and pasted them into pawno/include (didn't overwrite any of the updated) and still it's failing.

Vince
09/06/2017, 07:02 AM
The includes "core" and "float" are implicitly included by a_samp and don't need to be included on their own. You should not include a_npc since that is exclusively for npcmodes. Thirdly and most importantly don't use spaces or special characters in key names when working with ini ("Player's Data") because they royally screw things up.

Zmith
09/06/2017, 08:49 AM
Thanks.

It worked fine as "Player's Data" previously (changed anyway ty). I tried an old copy of the gamemode to confirm my suspicion and it's not a gamemode error.

It's updating live when I'm ingame but once I restart the server (samp-server.exe) and reconnect to the server everything resets back to zero. It's fine if I just reconnect without gmx though so it isn't onplayerconnect etc error.

It makes no sense to me, it's frustrating.

http://i.imgur.com/hSup8wf.png
[Character]
IsJailed = 0
CharDeaths = 0
CharKills = 0
CharScore = 60
CharMoney = 15000
CharSkin = 3
Premlevel = 1
Adminlevel = 5
Password = 1542..-

Whatname
09/06/2017, 11:08 AM
try to check if player logged onplayerdisconnect if yes save all stats then set logged to false or zero

Zmith
10/06/2017, 04:31 AM
try to check if player logged onplayerdisconnect if yes save all stats then set logged to false or zero

It saves OnPlayerDisconnect with my stock (see original post).

[1] Register // Working
[2] Spawn // Working (add pInfo)
[6] Disconnect // Working (save pInfo)
[4] Connect // Allows you to use incorrect password
[5] Spawn // Working (excluding [4])
[6] Disconnect // Working (saved pInfo: excluding [4])
[7] Follow with GMX: // Working (saved pInfo: excluding [4])
[8] Connect // All reset; [1]

Zmith
05/08/2017, 07:37 PM
BUMP.