SA-MP Forums Archive
Rendom spawn for each team - 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: Rendom spawn for each team (/showthread.php?tid=562636)



Rendom spawn for each team - _GHT_MarK445 - 10.02.2015

Hi guys,

today I was working on random spawns for my prison. These spawns are just for prisoners. But, i didnt figure out, how to set random spawn just for specified team.

I got it like this.

Код:
new Float:RandomSpawn[][4] =
{
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
and

Код:
public OnPlayerSpawn(playerid)
{
    new val = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    return 1;
}
And my second question is, if there is something missing.

Thanks.


Re: Rendom spawn for each team - nezo2001 - 10.02.2015

I think it must be like this
PHP код:
 SetPlayerPos(playeridRandomSpawn[val][0], RandomSpawn[val][1],RandomSpawn[val][2]
SetPlayerFacingAngle(playeridRandomSpawn[val][3]); 



Re: Rendom spawn for each team - M4D - 10.02.2015

pawn Код:
public OnPlayerSpawn(playerid)
{
    new val = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[val][0], RandomSpawn[val][1],RandomSpawn[val][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[val][3]);
    return 1;
}
new val = random(sizeof(RandomSpawn));

so you have to set player position like this :
RandomSpawn[val][0] , RandomSpawn[val][1] and ..........


EDIT: guy above me was faster !


Re: Rendom spawn for each team - _GHT_MarK445 - 10.02.2015

Thanks guys!

But how about the thing about?

Quote:

today I was working on random spawns for my prison. These spawns are just for prisoners. But, i didnt figure out, how to set random spawn just for specified team.

and one more thing

I just found on wiki, this
new value = random(5);

is it something that i got to include?


Re: Rendom spawn for each team - CalvinC - 10.02.2015

Simply do this to check if he is in a team.
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(GetPlayerTeam(playerid) == 1)
    {
        new val = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[val][0], RandomSpawn[val][1],RandomSpawn[val][2]);
        SetPlayerFacingAngle(playerid, RandomSpawn[val][3]);
    }
    return 1;
}
The "random"-function is not an include, using random(5) will generate a random number of 0 - 5.


Re: Rendom spawn for each team - _GHT_MarK445 - 10.02.2015

Solved.