19.04.2018, 23:08
When spawning a player, it appears at zero coordinates, when teleporting to any other coordinates and if you go to the server again, it appears where it came out.
When registering a new player, the coordinates of the previous player are duplicated in its line.
Screenshot:
When registering a new player, the coordinates of the previous player are duplicated in its line.
PHP код:
public OnPlayerSpawn(playerid)
{
new RandomGS = random(sizeof(gRandomSkin));
SetPlayerSkin(playerid,gRandomSkin[RandomGS]);
SetPos(playerid);
}
stock SetPos(playerid)
{
SetPlayerPos(playerid,pInfo[playerid][Pos][0],pInfo[playerid][Pos][1],pInfo[playerid][Pos][2]);
return 1;
}
stock SavePos(playerid)
{
new Float:PosX;
new Float:PosY;
new Float:PosZ;
GetPlayerPos(playerid,PosX,PosY,PosZ);
pInfo[playerid][Pos][0] = PosX;
pInfo[playerid][Pos][1] = PosY;
pInfo[playerid][Pos][2] = PosZ;
SaveAccount(playerid);
return true;
}
stock SaveAccount(playerid)
{
new query_string[(256)+(50+11)+(50+MAX_PLAYER_NAME)+(50+30)] = "UPDATE `accounts` SET";
format(query_string, sizeof(query_string), "%s `player_name` = '%s',", query_string, pInfo[playerid][pName]);
format(query_string, sizeof(query_string), "%s `password` = '%s',", query_string, pInfo[playerid][pPassword]);
format(query_string, sizeof(query_string), "%s `PosX` = '%f',", query_string, pInfo[playerid][Pos][0]);
format(query_string, sizeof(query_string), "%s `PosY` = '%f',", query_string, pInfo[playerid][Pos][1]);
format(query_string, sizeof(query_string), "%s `PosZ` = '%f'", query_string, pInfo[playerid][Pos][2]);
format(query_string, sizeof(query_string), "%s WHERE `id` = '%d'", query_string, pInfo[playerid][pID]);
mysql_function_query(mysql_connect_ID, query_string, false, "", "");
SavePos(playerid);
SaveInv(playerid);
return 1;
}