SavePlayer(playerid)
{
if(sInfo[playerid][loggedin] == 1)
{
if(sInfo[playerid][spawned]==1)
{
new Float:x,Float:y,Float:z,Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
GetPlayerPos(playerid, x, y, z);
sInfo[playerid][money] = GetPlayerMoney(playerid);
sInfo[playerid][level] = GetPlayerScore(playerid);
sInfo[playerid][s_posx] = x;
sInfo[playerid][s_posy] = y;
sInfo[playerid][s_posz] = z;
sInfo[playerid][s_angle] = Angle;
sInfo[playerid][skin] = GetPlayerCustomSkin(playerid);
sInfo[playerid][inter] = GetPlayerInterior(playerid);
sInfo[playerid][vw] = GetPlayerVirtualWorld(playerid);
new query[512];
format(query, sizeof(query), "UPDATE users SET money='%i', level='%i', pos_x='%f', pos_y='%f', pos_z='%f', angle='%f', inter='%i', vw='%i', skin='%i', job='%i' WHERE id='%i'", sInfo[playerid][money],sInfo[playerid][level],sInfo[playerid][s_posx],sInfo[playerid][s_posy],sInfo[playerid][s_posz],sInfo[playerid][s_angle],sInfo[playerid][inter],sInfo[playerid][vw],sInfo[playerid][skin],sInfo[playerid][job],sInfo[playerid][db_id]);
mysql_function_query(dbhandle, query, false, "", "");
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SavePlayer(playerid);
return 1;
}
public OnPasswordResponse(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(num_rows==1)
{
//LoggedIn
sInfo[playerid][loggedin] = 1;
print("Player logged");
sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
SetPlayerScore(playerid,sInfo[playerid][level]);
sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
GivePlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
sInfo[playerid][f_rank] = cache_get_field_content_int(0,"f_rank",dbhandle);
sInfo[playerid][s_posx] = cache_get_field_content_float(0,"pos_x",dbhandle);
sInfo[playerid][s_posy] = cache_get_field_content_float(0,"pos_y",dbhandle);
sInfo[playerid][s_posz] = cache_get_field_content_float(0,"pos_z",dbhandle);
sInfo[playerid][s_angle] = cache_get_field_content_float(0,"angle",dbhandle);
sInfo[playerid][skin] = cache_get_field_content_int(0,"skin",dbhandle);
sInfo[playerid][inter] = cache_get_field_content_int(0,"inter",dbhandle);
sInfo[playerid][vw] = cache_get_field_content_int(0,"vw",dbhandle);
sInfo[playerid][job] = cache_get_field_content_int(0,"job",dbhandle);
NiDInfo[playerid][NiDNumber] = cache_get_field_content_int(0,"nid",dbhandle);
NiDInfo[playerid][NiDSkin] = cache_get_field_content_int(0,"nidskin",dbhandle);
new m[512];
format(m, sizeof(m), "NiD Number : 1%i", NiDInfo[playerid][NiDNumber]);
PlayerTextDrawSetString(playerid, NidTD[playerid][4], m);
PlayerTextDrawSetPreviewModel(playerid, NidTD[playerid][6], NiDInfo[playerid][NiDSkin]);
new f_tmpn[128];
cache_get_field_content(playerid, "f_name", f_tmpn);
strmid(sInfo[playerid][f_name], f_tmpn, 0, sizeof(f_tmpn), sizeof(f_tmpn));
SetPlayerPos(playerid, sInfo[playerid][s_posx], sInfo[playerid][s_posy], sInfo[playerid][s_posz]);
SetPlayerSkin(playerid, sInfo[playerid][skin]);
SetCameraBehindPlayer(playerid);
}
else
{
//Wrong password
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Wrong password.\n\nEnter password:","Login","Quit");
}
return 1;
}
Remove if(sInfo[playerid][spawned]==1) check at saving
Dont use if(num_rows==1) unless you used LIMIT 1 on your SELECT query, better let it if(num_rows) |