SA-MP Forums Archive
Spawn Problem - 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: Spawn Problem (/showthread.php?tid=271287)



Spawn Problem - JonnyDeadly - 23.07.2011

Okay so basically i implemented the Vortex Roleplay V1 Group system into my script, except the spawns aren't working and instead of spawning you in the correct locations (random spawns) after your second time playing it spawns you at the Jefferson Motel in Los Santos. Here are some things you should know, note that no errors or warning show up in the pawn compiler on this script: LVFEAR = CommandType and Group "1" and Civillian = CommandType and Group "2".

PlayerInfo[playerid][New] == 0 = The player has logged in before.

PlayerInfo[playerid][New] == 1 = The player is new to the server and has logged in for the first time.

The random spawns are between 3 spawn locations and one SetPlayerFacingAngle position (LVFEAR and Civillians have seperate random spawns. Civillian = RandPos & LVFEAR = RandPos 1)

JustLogged[playerid] == 1 = The player has just logged in.

SaveUser(playerid) = All the saved data for the user passwords etc. (Saves to an ini file in a "users" folder in scriptfiles

Код:
public OnPlayerSpawn(playerid)
{
	if(JustLogged[playerid] == 1)
	{
		if(PlayerInfo[playerid][New] == 1)
		{
		    new RandPos = random(sizeof(SpawnPositions));
		    GameTextForPlayer(playerid, "~b~Civillian", 1500, 10);
		    SetPlayerPos(playerid, SpawnPositions[RandPos][0], SpawnPositions[RandPos][1],          SpawnPositions[RandPos][2]); 
	    	SetPlayerFacingAngle(playerid, SpawnPositions[RandPos][3]);
	    	SetPlayerInterior(playerid, 0);
	    	SetPlayerVirtualWorld(playerid, 1);
	    	PlayerInfo[playerid][Group] =2;
	    	PlayerInfo[playerid][GroupRank] =1;
	    	SetPlayerColor(playerid, COLOUR_WHITE);
		}
		else if(PlayerInfo[playerid][New] == 0)
		{
  			if(Groups[PlayerInfo[playerid][Group]][CommandTypes] == 2)
  			{
		    	GameTextForPlayer(playerid, "~b~Civillian", 1500, 10);
		    	new RandPos = random(sizeof(SpawnPositions));
		    	SetPlayerPos(playerid, SpawnPositions[RandPos][0], SpawnPositions[RandPos][1], SpawnPositions[RandPos][2]);
	    		SetPlayerFacingAngle(playerid, SpawnPositions[RandPos][3]);
	    		SetPlayerInterior(playerid, 0);
	    		SetPlayerVirtualWorld(playerid, 1);
	    		SetPlayerColor(playerid, COLOUR_WHITE);
			}
			else if(Groups[PlayerInfo[playerid][Group]][CommandTypes] == 1)
			{
			    GameTextForPlayer(playerid, "~r~LVFEAR", 1500, 10);
		    	new RandPos1 = random(sizeof(LVFEARSpawnPositions));
		    	SetPlayerPos(playerid, LVFEARSpawnPositions[RandPos1][0], LVFEARSpawnPositions[RandPos1][1], LVFEARSpawnPositions[RandPos1][2]);
	    		SetPlayerFacingAngle(playerid, SpawnPositions[RandPos1][3]);
	    		SetPlayerInterior(playerid, 0);
	    		SetPlayerVirtualWorld(playerid, 1);
	    		SetPlayerColor(playerid, COLOUR_WHITE);
			}
		}
		JustLogged[playerid] = 0;
	}
	return 1;
}
Код:
new Float:SpawnPositions[][4] = {
	{175.4903,-78.3758,1.5781,19.7401},
	{172.1340,-64.7526,1.5781,203.6451},
	{173.4903,-78.3758,1.5781,19.7401},
	{174.1340,-64.7526,1.5781,203.6451}
};

new Float:LVFEARSpawnPositions[][4] = {
	{2585.4292,2793.8633,10.8203},
	{2583.4292,2793.8633,10.8203},
	{2582.4292,2793.8633,10.8203},
	{2581.4292,2793.8633,10.8203}
};
Код:
public OnPlayerRequestClass(playerid, classid)
{
	switch(classid)
	{
		case 0..45:
 		{
 			GameTextForPlayer(playerid, "~w~Select a Skin", 1500, 6);
  			SetPlayerPos(playerid, -320.5659, 1058.1082, 19.7422);
    		SetPlayerFacingAngle(playerid, 310.1756);
			SetPlayerCameraPos(playerid, -316.2834, 1061.6392, 19.7422);
 			SetPlayerCameraLookAt(playerid, -320.5659, 1058.1082, 19.7422);
 			SetPlayerVirtualWorld(playerid, 5);
	 		ApplyAnimation(playerid,"BUDDY","buddy_fire",4.1,1,0,0,1,0);
	 		PlayerInfo[playerid][New] = 0;
   			SaveUser(playerid);
		}
	}
	return 1;
}
Thanks for taking a look at this.