SpawnPlayer - Straight up in air.
#1

Hello, I am having some troubles with spawning the player on login. The user just go straight up in air, with the camera locked.

Here is a picture of what happens:



This is my code:

Код:
if(Player[playerid][LastX] == 0 && Player[playerid][LastY] == 0 && Player[playerid][LastZ] == 0)
 	{
        SpawnPlayer(playerid);
	SetPlayerPos(playerid, 2057.219970, -1926.541015, 13.546875); // THE SPAWN D
    	SetPlayerFacingAngle(playerid, 179.03);
     	SetCameraBehindPlayer(playerid);
      	SetPlayerInterior(playerid, 0);
       	SetPlayerVirtualWorld(playerid, 0);
    }
    else
    {

        SpawnPlayer(playerid);
	SetPlayerVirtualWorld(playerid, Player[playerid][pVW]);
    	SetPlayerInterior(playerid, Player[playerid][pInt]);
	SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
   	SetPlayerFacingAngle(playerid, Player[playerid][LastA]);
	SetCameraBehindPlayer(playerid);

  	}
This is the script, which basiclly spawns the player, no other place beside that do I have "SpawnPlayer(playerid);"
Reply
#2

Maybe it doesnt save the position when leaving the server, else search for TogglePlayerControllable fuctions in your gamemode.
Reply
#3

May I ask where this code is actually situated, under what callback?? If this is under OnPlayerSpawn, it will constantly spawn the player and I don't know if it will even reach the SetPlayerPos function...
Reply
#4

The player is in spectator mode. Note the lack of the HUD.
Reply
#5

What if you remove the SpawnPlayer function? Because I think it conflicts with SetPlayerPos and it tries to spawn the player at their spawnpoint (instead of at SetPlayerPos location). Also, SpawnPlayer also triggers OnPlayerSpawn and all the code inside that callback, which might cause more conflicts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)