15.09.2014, 18:02
Hey folks,
I've already debugged my code and recognized that my "loadaccount_user" function is not being called.
OnplayerConnect (hooked)
OnPlayerDisconnect (hooked)
Function for loading the user file
------------------------------------------------------------------------------------------------------------------
Additionally, no data is being saved even though OnPlayerDisconnect (hooked) is being called.
I've already debugged my code and recognized that my "loadaccount_user" function is not being called.
OnplayerConnect (hooked)
pawn Код:
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid, .bPassTag = true);
new pName_[MAX_PLAYER_NAME],
stringDE_[128],
stringEN_[128];
GetPlayerName(playerid, pName_, sizeof(pName_));
format(stringDE_, sizeof(stringDE_), "Willkommen zurьck, "#C_LIGHT_BLUE_E"%s"#C_DIALOG_E"! Dieser Account ist registriert!\nBitte gib das Passwort fьr diesen Account ein!", pName_);
format(stringEN_, sizeof(stringEN_), "Welcome back, "#C_LIGHT_BLUE_E"%s"#C_DIALOG_E"! This account is registered!\nPlease type in the password for this account!", pName_);
ShowLanguageDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Login", stringDE_, stringEN_, "Einloggen", "Log in", "Abbrechen", "Cancel");
}
else ShowPlayerDialog(playerid, DIALOG_LANGUAGES, DIALOG_STYLE_LIST, "Sprachauswahl | Language Selection", "[GER] Deutsch | German\n[ENG] Englisch | English", "OK", "");
pawn Код:
print("OnPlayerDisconnect executed.");
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "User Data");
INI_WriteString(file, "IP", pInfo[playerid][IP]);
INI_WriteInt(file, "AdminLevel", pInfo[playerid][AdminLevel]);
INI_WriteInt(file, "Money", GetPlayerMoney(playerid));
INI_WriteInt(file, "Bank", pInfo[playerid][Bank]);
INI_WriteInt(file, "Score", GetPlayerScore(playerid));
INI_WriteInt(file, "Kills", pInfo[playerid][Kills]);
INI_WriteInt(file, "Deaths", pInfo[playerid][Deaths]);
INI_WriteInt(file, "Language", pInfo[playerid][Language]);
INI_Close(file);
pawn Код:
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
print("loadaccount_user executed.");
INI_String("Password", pInfo[playerid][Password], 129);
INI_String("IP", pInfo[playerid][IP], 16);
INI_Int("AdminLevel", pInfo[playerid][AdminLevel]);
INI_Int("Money", pInfo[playerid][Money]);
INI_Int("Bank", pInfo[playerid][Bank]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Kills", pInfo[playerid][Kills]);
INI_Int("Deaths", pInfo[playerid][Deaths]);
INI_Int("Language", pInfo[playerid][Language]);
return 1;
}
Additionally, no data is being saved even though OnPlayerDisconnect (hooked) is being called.
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerColor(playerid, C_BLUE);
new VirtualWorld = GetPlayerVirtualWorld(playerid);
switch(VirtualWorld)
{
case 0:
{
if(pInfo[playerid][JustLoggedIn] == true)
{
print("JustLoggedIn == true");
SetCameraBehindPlayer(playerid);
GivePlayerMoneyEx(playerid, pInfo[playerid][Money]);
SetPlayerScore(playerid, pInfo[playerid][Score]);
UseTeleports[playerid] = true;
SetSpawnProtection(playerid);
pInfo[playerid][JustLoggedIn] = false;
return 1;
}
if(pInfo[playerid][JustRegistered] == true)
{
print("JustRegistered == true");
cmd_rules(playerid, "");
pInfo[playerid][JustRegistered] = false;
GivePlayerMoneyEx(playerid, 5000);
return 1;
}
if(pInfo[playerid][JustLoggedIn] == false && pInfo[playerid][JustRegistered] == false)
{
print("Common spawn");
GivePlayerMoneyEx(playerid, 5000);
UseTeleports[playerid] = true;
SetSpawnProtection(playerid);
return 1;
}
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
new cash = GetPlayerMoney(playerid);
if(killerid != INVALID_PLAYER_ID) //Killed by another player
{
print("killerid != INVALID_PLAYER_ID, executing code.");
GivePlayerMoneyEx(killerid, cash);
GivePlayerMoneyEx(playerid, -cash);
SetPlayerScore(killerid, pInfo[killerid][Score] + 1);
pInfo[killerid][Kills] += 1;
}
if(killerid == INVALID_PLAYER_ID) //Suicide
{
print("killerid == INVALID_PLAYER_ID, executing code.");
GivePlayerMoneyEx(playerid, -cash);
}
pInfo[playerid][Deaths] += 1;
return 1;
}