Making a random 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)
+--- Thread: Making a random spawn (
/showthread.php?tid=379848)
Making a random spawn -
HeLiOn_PrImE - 23.09.2012
I need some help scripting a random spawn.
I have 2 classes, and each one has a set of 3 spawn points.
I made the player choose where they spawn when they enter the server, but I need them to spawn randomly after they die. How can I do that?
Re: Making a random spawn -
newbienoob - 23.09.2012
https://sampforum.blast.hk/showthread.php?tid=162488
Re: Making a random spawn -
HeLiOn_PrImE - 23.09.2012
thank you
Re: Making a random spawn -
clarencecuzz - 23.09.2012
pawn Код:
new Died[MAX_PLAYERS];
new SpawnPoints[][4] = {
{X, Y, Z, Angle},
{X2, Y2, Z2, Angle2},
{X3, Y3, Z3, Angle3} //Replace X, Y, Z and Angle with the X, Y, Z coordinates and the angle that the player is facing, respectively.
};
public OnPlayerConnect(playerid)
{
Died[playerid] = 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
if(Died[playerid] == 1)
{
new rand = random(sizeof(SpawnPoints));
SetPlayerPos(playerid, SpawnPoints[rand][0], SpawnPoints[rand][1], SpawnPoints[rand][2]);
SetPlayerFacingAngle(playerid, SpawnPoints[rand][3]);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
Dead[playerid] = 1;
return 1;
}
EDIT: Bit late? xD