SA-MP Forums Archive
SetPlayerPos Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetPlayerPos Problem (/showthread.php?tid=129352)



SetPlayerPos Problem - Anwix - 21.02.2010

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.


Re: SetPlayerPos Problem - Rizard - 21.02.2010

try the same but then OnPlayerRequestSpawn


Re: SetPlayerPos Problem - Anwix - 21.02.2010

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


Re: SetPlayerPos Problem - Daren_Jacobson - 22.02.2010

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));
            }



Re: SetPlayerPos Problem - Anwix - 22.02.2010

Nope, im not using sscanf


Re: SetPlayerPos Problem - Anwix - 22.02.2010

bump


Re: SetPlayerPos Problem - Anwix - 23.02.2010

12hour bump