GetPlayerPos doesn't work
#1

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?
Reply
#2

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

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

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
Reply
#5

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 ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)