SA-MP Forums Archive
Problem with my back after crash spawn - 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: Problem with my back after crash spawn (/showthread.php?tid=157985)



Problem with my back after crash spawn - Script - 08.07.2010

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


Re: Problem with my back after crash spawn - cessil - 08.07.2010

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


Re: Problem with my back after crash spawn - Script - 08.07.2010

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.. :/


Re: Problem with my back after crash spawn - dice7 - 08.07.2010

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


Re: Problem with my back after crash spawn - Script - 08.07.2010

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


Re: Problem with my back after crash spawn - Script - 08.07.2010

My x,y,z mySQL rows are:

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


Re: Problem with my back after crash spawn - dice7 - 08.07.2010

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


Re: Problem with my back after crash spawn - CAR - 08.07.2010

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



Re: Problem with my back after crash spawn - Script - 09.07.2010

Still the same problem!....
anyone got another idea?


Re: Problem with my back after crash spawn - Betamaster - 09.07.2010

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...