SetPlayerPos Problem
#1

Ok, so when a player disconnected, there x, y, z and rotation cord's get saved to a database, and if that player reconnects again, the x, y, z and rotation will be fetched, now this is working perfectly but when i'm setting the x, y, z on SetPlayerPos its not working.

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posY], pInfo[playerid][posZ]);
    SetPlayerFacingAngle(playerid, pInfo[playerid][posR]);
    pInfo[playerid][Spawned] = true;
    return 1;
}
Now the posX, posY, posZ, posR get set when the user log's in which are working as i've test doing
pawn Код:
printf("%f, %f, %f, %f", pInfo[playerid][posX], pInfo[playerid][poxY], pInfo[playerid][posZ], pInfo[playerid][posR]);
Here is the actuall code

pawn Код:
AuthPlayer(playerid)
{
    CheckMySQL();
    new
      Float: x,
      Float: y,
      Float: z,
      Float: r;
     
    format(query, 256, "SELECT firstspawn FROM `users` WHERE username = '%s'", PlayerName(playerid));
    mysql_query(query);
    mysql_store_result();
    new rows = mysql_num_rows();
    if (rows == 1)
    {
      format(query, 256, "SELECT x FROM `users` WHERE username = '%s' LIMIT 1", PlayerName(playerid));
      mysql_query(query);
      mysql_store_result();
      mysql_fetch_float(x);
     
      format(query, 256, "SELECT y FROM `users` WHERE username = '%s' LIMIT 1", PlayerName(playerid));
      mysql_query(query);
      mysql_store_result();
      mysql_fetch_float(y);
     
      format(query, 256, "SELECT z FROM `users` WHERE username = '%s' LIMIT 1", PlayerName(playerid));
      mysql_query(query);
      mysql_store_result();
      mysql_fetch_float(z);
     
      format(query, 256, "SELECT r FROM `users` WHERE username = '%s' LIMIT 1", PlayerName(playerid));
      mysql_query(query);
      mysql_store_result();
      mysql_fetch_float(r);
     
      printf("%f, %f, %f, %f", x, y, z, r); // Printing 143.452041, -68.172424, 1.429687, 267.565795 which is correct?
     
      pInfo[playerid][posX] = x;
      pInfo[playerid][posY] = y;
      pInfo[playerid][posZ] = z;
      pInfo[playerid][posR] = r;
    }
}
Am i doing anything wrong, because everything else is working perfect and to say its printing and setting the correct cords, i don't understand why it's not spawning the player in that position.
(I'm upgrading from dini!) (When the player spawns they fall through the map at 0.00000, 0.00000, 0.00000, 0.00000

And yes, my posX/Y/Z/R are floats.
Reply
#2

try the same but then OnPlayerRequestSpawn
Reply
#3

Quote:
Originally Posted by Rizard
try the same but then OnPlayerRequestSpawn
Doesn't work
Reply
#4

Are you using sscanf? if so are you using the plugin? if not change your sscanf float code to
pawn Код:
case 'f':
            {
                new
                    changestr[16],
                    changepos = 0,
                    strpos = stringPos;
                while(changepos < 16 && string[strpos] && string[strpos] != delim)
                {
                    changestr[changepos++] = string[strpos++];
                }
                changestr[changepos] = '\0';
                setarg(paramPos,0,_:floatstr(changestr));
            }
Reply
#5

Nope, im not using sscanf
Reply
#6

bump
Reply
#7

12hour bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)