spawns not working - 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)
+--- Thread: spawns not working (
/showthread.php?tid=655261)
spawns not working -
div - 17.06.2018
Hello, i've made the spawns, im not getting any error.. i've tried placing them on OnPlayerSpawn too, but doesn't work..
Code:
public OnPlayerRequestSpawn(playerid)
{
if(GetPlayerTeam(playerid) == TEAM_FBI)
{
new Random = random(sizeof(teamFBIspawns));
SetPlayerPos(playerid, teamFBIspawns[Random][0], teamFBIspawns[Random][1], teamFBIspawns[Random][2]);
}
if(GetPlayerTeam(playerid) == TEAM_CIA)
{
new Random = random(sizeof(teamCIAspawns));
SetPlayerPos(playerid, teamCIAspawns[Random][0], teamCIAspawns[Random][1], teamCIAspawns[Random][2]);
}
if(GetPlayerTeam(playerid) == TEAM_ARMY)
{
new Random = random(sizeof(teamArmyspawns));
SetPlayerPos(playerid, teamArmyspawns[Random][0], teamArmyspawns[Random][1], teamArmyspawns[Random][2]);
}
if(GetPlayerTeam(playerid) == TEAM_FIREMAN)
{
new Random = random(sizeof(teamFiremanspawns));
SetPlayerPos(playerid, teamFiremanspawns[Random][0], teamFiremanspawns[Random][1], teamFiremanspawns[Random][2]);
}
if(GetPlayerTeam(playerid) == TEAM_MEDIC)
{
new Random = random(sizeof(teamMedicspawns));
SetPlayerPos(playerid, teamMedicspawns[Random][0], teamMedicspawns[Random][1], teamMedicspawns[Random][2]);
}
if(GetPlayerTeam(playerid) == TEAM_POLICE)
{
new Random = random(sizeof(teamCopspawns));
SetPlayerPos(playerid, teamCopspawns[Random][0], teamCopspawns[Random][1], teamCopspawns[Random][2]);
}
if(GetPlayerTeam(playerid) == TEAM_CIVILIAN)
{
new Random = random(sizeof(teamCivilspawns));
SetPlayerPos(playerid, teamCivilspawns[Random][0], teamCivilspawns[Random][1], teamCivilspawns[Random][2]);
}
return 1;
}
PS: I am not getting any ERROR
Re: spawns not working -
Mike861 - 17.06.2018
Well im pretty sure that they should be under OnPlayerSpawn, but random function seems alright for me.Could you paste the code how you define those spawn positions?
Re: spawns not working -
Exhibit - 17.06.2018
Use SetSpawnInfo
https://sampwiki.blast.hk/wiki/SetSpawnInfo
Re: spawns not working -
Zeth - 17.06.2018
OnPlayerRequestSpawn returns SpawnPlayer on returning 1 and returning 0 wont SpawnPlayer, therefore using SetPlayerPos wont do anything here.
try it under OnPlayerSpawn or use SetSpawnInfo.