13.02.2013, 17:50
It spawns my character at the standard Las Venturas spawn point instead of my saved coordinates when I log out.
Can someone tell me how to fix this problem?
Can someone tell me how to fix this problem?
pawn Код:
forward LoadUser_files(playerid, name[], value[]);
public LoadUser_files(playerid, name[], value[])
{
INI_Int("EncryptedPassword", P_DATA[playerid][Pass]);
INI_Int("Level", P_DATA[playerid][Level]);
INI_Int("Cash", P_DATA[playerid][Cash]);
INI_Int("Admin", P_DATA[playerid][Admin]);
INI_Int("Supporter", P_DATA[playerid][Supporter]);
INI_Int("Donator", P_DATA[playerid][Donator]);
INI_Float("PXPOS", P_DATA[playerid][PXPOS]);
INI_Float("PYPOS", P_DATA[playerid][PYPOS]);
INI_Float("PZPOS", P_DATA[playerid][PZPOS]);
INI_Float("PAPOS", P_DATA[playerid][PAPOS]);
return 1;
}
stock SaveUser_files(playerid)
{
new Float:currentPos[4];
GetPlayerPos(playerid, currentPos[0], currentPos[1], currentPos[2]);
GetPlayerFacingAngle(playerid, currentPos[3]);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "User Variables");
INI_WriteInt(File, "Level", P_DATA[playerid][Level]);
INI_WriteInt(File, "Cash", P_DATA[playerid][Cash]);
INI_WriteInt(File, "Admin", P_DATA[playerid][Admin]);
INI_WriteInt(File, "Supporter", P_DATA[playerid][Supporter]);
INI_WriteInt(File, "Donater", P_DATA[playerid][Donator]);
INI_WriteFloat(File, "PXPOS", currentPos[0]);
INI_WriteFloat(File, "PYPOS", currentPos[1]);
INI_WriteFloat(File, "PZPOS", currentPos[2]);
INI_WriteFloat(File, "PAPOS", currentPos[3]);
INI_Close(File);
print("User Variables have been saved.");
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, LOG_DIALOG, DIALOG_STYLE_INPUT, "{AFAFAF}Login", "{FFFFFF}This account is registered, please enter your password to login.", "Enter", "Quit");
}
else
{
ShowPlayerDialog(playerid, REG_DIALOG, DIALOG_STYLE_INPUT, "{AFAFAF}Register", "{FFFFFF}Welcome to Intelligent Roleplay\n{FFFFFF}Please register your account by typing the password below.", "Register", "Quit");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SaveUser_files(playerid);
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case REG_DIALOG:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, REG_DIALOG, DIALOG_STYLE_INPUT, "{AFAFAF}Register", "{FFFFFF}Welcome to Intelligent Roleplay\n{FFFFFF}Please register your account by typing the password below.", "Register", "Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "User Variables");
INI_WriteInt(File, "EncryptedPassword", udb_hash(inputtext));
INI_WriteInt(File, "Cash", 0);
INI_WriteInt(File, "Admin", 0);
INI_WriteInt(File, "Level", 0);
INI_WriteInt(File, "Supporter", 0);
INI_WriteInt(File, "Donator", 0);
INI_WriteFloat(File, "PXPOS", 1224.8784);
INI_WriteFloat(File, "PYPOS", -1815.1611);
INI_WriteFloat(File, "PZPOS", 16.5938);
INI_WriteFloat(File, "PAPOS", 246.7154);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1224.8784,-1815.1611,16.5938,246.7154, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
}
case LOG_DIALOG:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_hash(inputtext) == P_DATA[playerid][Pass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, P_DATA[playerid][Cash]);
//LoadUser_files(playerid, 0, 0);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{AFAFAF}Login (error)", "{FFFFFF}You've entered a wrong password, please enter the correct password to login.", "Enter", "Quit");
return 1;
}
}
}
}
return 1;
}