How to random spawn in this zone ? [help +rep]
#1



This zone and here my code below:

PHP код:
stock SetRandomSpawn(targetid)
{
           new 
Float:xFloat:yFloat:Z;
           
random(2655) - 2275;
           
random(201) - 368.0;
           
MapAndreas_FindZ_For2DCoord(xyZ);
           
SetPlayerPos(targetidxyZ);
           return 
1;

How to do it work?
Reply
#2

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.
Reply
#3

If it isn't giving off any errors, you can put it under OnPlayerSpawn

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetRandomSpawn(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)