Problem with my back after crash spawn
#1

I dont know why did i get this problem..
but after i crashed im not stating the the crashed pos..
im starting at the sky of blueberry....
Everything is ok.. i dont know why i get this problem its saved the x,y,z pos. fine.. but after i spawn its automatic change it to blueberry sky..


this is my script

PlayerInfo get float: pPos_x,float:pPos_x,float:pPos_z;


OnPlayerDisconnect:

Quote:

if(reason == 0)
{
PlayerInfo[playerid][pCrashed] = 1;
OnPlayerUpdate(playerid);
}

SetPlayerSpawn:


if(PlayerInfo[playerid][pCrashed] == 1)
Code:
		{
		    if(PlayerInfo[playerid][pTut] == 1)
		    {
                SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
		        SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pVirWorld]);
		        SafeSetPlayerInterior(playerid,PlayerInfo[playerid][pInt]);
		        new Float:fx,Float:fy,Float:fz;
		        fx = PlayerInfo[playerid][pPos_x];
		        fy = PlayerInfo[playerid][pPos_y];
		        fz = PlayerInfo[playerid][pPos_z]+1;
		    	SetPlayerPos(playerid, fx,fy,fz);
                        return 1;
                      }
                 }
OnPlayerUpdate:



Code:
				if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0))
				{
   	                PlayerInfo[playerid][pPos_x] = 1684.9;
					PlayerInfo[playerid][pPos_y] = -2244.5;
					PlayerInfo[playerid][pPos_z] = 13.5;
				}
				if(Spectate[playerid] != 255)
				{
					PlayerInfo[playerid][pPos_x] = Unspec[playerid][sPx];
					PlayerInfo[playerid][pPos_y] = Unspec[playerid][sPy];
					PlayerInfo[playerid][pPos_z] = Unspec[playerid][sPz];
					PlayerInfo[playerid][pInt] = Unspec[playerid][sPint];
					PlayerInfo[playerid][pLocal] = Unspec[playerid][sLocal];
				}
				new Float:x, Float:y, Float:z;
     			GetPlayerPos(playerid,x,y,z);
				PlayerInfo[playerid][pPos_x] = x;
				PlayerInfo[playerid][pPos_y] = y;
				PlayerInfo[playerid][pPos_z] = z;

And its fucking save the x,y,z position but not spawn good...
thanks for help
Reply
#2

are you even saving that data to a file? also, I'd just get the players position when they leave and not in onplayerupdate
Reply
#3

Im saving it to MySQL.. and its saving perefectly

its getting the pos.. its not the problem.. the spawn is the problem... its spawn me at the blueberry and not the position and its fucking saving.. :/
Reply
#4

Blueberry is at location x = 0, y = 0, z = 0 which means that you're incorrectly loading the data from your db into the script
Reply
#5

after i disconnect the pos_x pos_y and pos_z changed to my crashed pos..
i checked my character in the MySQL.. only when i login it's automatic changed to 0 0 0.. like you said.. from where can be the problem?

Nothing in my script change the pos to 0 0 0
Reply
#6

My x,y,z mySQL rows are:

Type: float(10,5)
Null: no
Default: my default positions (not 0 0 0)
Reply
#7

In PAWN, when variables are created, they automatically get assigned the value zero. You are either incorrectly reading from your database or are incorrectly assigning the values to the x, y and z variables in your script (not database) which are then used to spawn the player
Reply
#8

Save it also at: OnPlayerDisconnect
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0:   // crashed
        {
            // your saving code
        }
    }
    return 1;
}
Reply
#9

Still the same problem!....
anyone got another idea?
Reply
#10

Are you checking if the player that crashed (playerid in OnPlayerDisconnect) is the same player that rejoins (playerid in OnPlayerConnect)? Also, where in your code do you use SetPlayerSpawn? I hope you are not calling it in OnPlayerConnect...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)