Problems with the coordinates of the player
#1

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.

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_stringsizeof(query_string), "%s `player_name` = '%s',"query_stringpInfo[playerid][pName]);
    
format(query_stringsizeof(query_string), "%s `password` = '%s',"query_stringpInfo[playerid][pPassword]);
    
format(query_stringsizeof(query_string), "%s `PosX` = '%f',"query_stringpInfo[playerid][Pos][0]);
    
format(query_stringsizeof(query_string), "%s `PosY` = '%f',"query_stringpInfo[playerid][Pos][1]);
    
format(query_stringsizeof(query_string), "%s `PosZ` = '%f'"query_stringpInfo[playerid][Pos][2]);
    
format(query_stringsizeof(query_string), "%s WHERE `id` = '%d'"query_stringpInfo[playerid][pID]);
    
mysql_function_query(mysql_connect_IDquery_stringfalse"""");
    
SavePos(playerid);
    
SaveInv(playerid);
    return 
1;

Screenshot:
Reply
#2

Inside OnPlayerDisconnect Set the values to 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)