SA-MP Forums Archive
GetPlayerPos doesn't work - 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: GetPlayerPos doesn't work (/showthread.php?tid=263777)



GetPlayerPos doesn't work - Jochemd - 23.06.2011

Hello,

Probably it's me, that's why I am posting here.

pawn Код:
new target,Float:Pos[3];
            if(!sscanf(params,"u",target))
            {
                if(IsPlayerConnected(target) && target != playerid)
                {
                    SendFormatMessage(playerid,COLOR_ORANGE,"(( You have started spectating %s (ID: %d). ))",Playername(target),target);
                    TogglePlayerSpectating(playerid,1);
                    PlayerSpectatePlayer(playerid,target,SPECTATE_MODE_NORMAL);
                    SetPVarInt(playerid,"Spectating",1);
                    KillTimer(GetPVarInt(playerid,"JailCountDownTimer"));
                    GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
                    format(QueryString,sizeof(QueryString),"UPDATE `PlayerInfo` SET `PosX` = '%f',`PosY` = '%f',`PosZ` = '%f', `Interior` = '%d',`Money` = '%d' WHERE `Playername` = '%s'",Pos[0],Pos[1],Pos[2],GetPlayerInterior(playerid),GetPlayerMoney(playerid),Playername(playerid));
                    mysql_query(QueryString);
                    return 1;
                }
                else return SendClientMessage(playerid,COLOR_RED,"Invalid ID");
            }
            else return SendClientMessage(playerid,COLOR_RED,"Syntax Error: /spec [ID / Part of Name].");
This is what MySQL log gives:

Код:
[14:24:51] CMySQLHandler::Query(UPDATE `PlayerInfo` SET `PosX` = '0.000000',`PosY` = '0.000000',`PosZ` = '0.000000', `Interior` = '0',`Money` = '0' WHERE `Playername` = 'Jeff Venturas') - Successfully executed.
What did I do wrong?


Re: GetPlayerPos doesn't work - ScottCFR - 23.06.2011

Why are you saving it to MySQL if it's a spectate command?


Re: GetPlayerPos doesn't work - Babul - 23.06.2011

the playerid, when spectating, is not spawned, so his coordiantes arent present. try to put the GetPlayerPos before the TogglePlayerSpectating?


Re: GetPlayerPos doesn't work - Jochemd - 23.06.2011

Quote:
Originally Posted by ScottCFR
Посмотреть сообщение
Why are you saving it to MySQL if it's a spectate command?
Cause the server may restart while the player is spectating.

Quote:
Originally Posted by Babul
Посмотреть сообщение
the playerid, when spectating, is not spawned, so his coordiantes arent present. try to put the GetPlayerPos before the TogglePlayerSpectating?
Worked, didn't look cause I was in a hurry :P


Re: GetPlayerPos doesn't work - Babul - 23.06.2011

i had the same problem with the spectating and saving my position in a timer. thats why i had that idea. it saved 0,0,0 aswell... i honestly cant believe that it works now ^^