How to random spawn in this zone ? [help +rep] - 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: How to random spawn in this zone ? [help +rep] (
/showthread.php?tid=583951)
How to random spawn in this zone ? [help +rep] -
MasonSFW - 01.08.2015
This zone and here my code below:
PHP код:
stock SetRandomSpawn(targetid)
{
new Float:x, Float:y, Float:Z;
x = random(2655) - 2275;
y = random(201) - 368.0;
MapAndreas_FindZ_For2DCoord(x, y, Z);
SetPlayerPos(targetid, x, y, Z);
return 1;
}
How to do it work?
Re: How to random spawn in this zone ? [help +rep] -
Crayder - 01.08.2015
That looks ok as long as you got the coords right.
pawn Код:
stock SetRandomSpawn(targetid)
{
//-2646.3206, -344.8202; Bottom-Left
//-2274.9263, -213.2971; Top-Right
//X = Random(width) + Left
//Y = Random(length) + Bottom
new Float:x = float(random(372) - 2646.3206),
Float:y = float(random(131) - 344.8202),
Float:Z;
MapAndreas_FindZ_For2DCoord(x, y, Z);
SetPlayerPos(targetid, x, y, Z);
return 1;
}
Though I'm too lazy to check the coords at the moment, it's nearly 3AM and I'm on my meds (drowsy as'f).
Edit: Fuck it, you dragged me in anyways! I corrected the coordinates. Psuedo'd it a bit in the comments.
Re: How to random spawn in this zone ? [help +rep] -
DTV - 01.08.2015
If it isn't giving off any errors, you can put it under OnPlayerSpawn
pawn Код:
public OnPlayerSpawn(playerid)
{
SetRandomSpawn(playerid);
return 1;
}