SA-MP Forums Archive
Help with random spawn points - 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: Help with random spawn points (/showthread.php?tid=575038)



Help with random spawn points - 7Ahmad7 - 23.05.2015

Guys i followed this tut :
https://sampforum.blast.hk/showthread.php?tid=162488

But i got those errors:
D:\Programmes\Engabic Blood Server\gamemodes\EABS.pwn(69) : error 017: undefined symbol "RandomSpawns"
D:\Programmes\Engabic Blood Server\gamemodes\EABS.pwn(69) : error 029: invalid expression, assumed zero
D:\Programmes\Engabic Blood Server\gamemodes\EABS.pwn(69) : warning 215: expression has no effect
D:\Programmes\Engabic Blood Server\gamemodes\EABS.pwn(70) : error 017: undefined symbol "RandomSpawns"
D:\Programmes\Engabic Blood Server\gamemodes\EABS.pwn(71) : error 017: undefined symbol "RandomSpawns"

Those are lines 69,70 and 71:
pawn Код:
new Random = random(sizeof(RandomSpawns));
        SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1],RandomSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
Anyideas?


Re: Help with random spawn points - Konstantinos - 23.05.2015

Declare RandomSpawns array as global.

An example is shown here too: https://sampwiki.blast.hk/wiki/Random


Re: Help with random spawn points - 7Ahmad7 - 23.05.2015

Sorry but,this is my first created gamemode,How to declare as global?and what actully to declear?


Re: Help with random spawn points - Konstantinos - 23.05.2015

The tutorial you linked explains it:

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
pawn Код:
new Float:RandomSpawns[][] =
{
    {1249.7258, -2047.9263, 59.9209, 90.2055}, // Randomspawn
    {1241.2084, -2057.6521, 60.0190, 94.9352}, // Randomspawn
    {1241.0105, -2052.6873, 59.9975, 2.8144}, // Randomspawn
    {718.4906, -1477.3024, 5.4688, 357.9947}, // Randomspawn
    {722.3772, -1477.2856, 5.4688, 272.3814} // Randomspawn
};
Important: The array should be located outside any function!!



Re: Help with random spawn points - LMaxCo - 23.05.2015

You should to add this.

Код:
new Float:RandomSpawns[][] = 
{
	{YOUR COORDINATES}, // 
	{YOUR COORDINATES}, // 
	{YOUR COORDINATES}, // 
	{YOUR COORDINATES}, // 
	{YOUR COORDINATES} // 
};



Re: Help with random spawn points - 7Ahmad7 - 23.05.2015

I am telling the truth,i followed the tut in everything,and again make everything as you both said....


Re: Help with random spawn points - Konstantinos - 23.05.2015

The array might be declared as global (outside of any function) but should also be located before the parts of code is used. So place it under the includes and definitions.

If you still cannot fix it, then post what you've done so far.


Re: Help with random spawn points - 7Ahmad7 - 23.05.2015

Okay i done it,now i got it,It means to keep it out any function....

AND THE THING YOU BOTH DIDN't explain,is to put it under the includes -LOL Konstatninos Said that in last post-
So i have finally made that,now,How to Make some RandomSpawnPoints for a case (team) and for another case?
As i made a textdraw in the OnPlayerRequestClass for every case(team,some skins.)So,How to make RandomSpawnPoints for each case(team)?


Re: Help with random spawn points - Konstantinos - 23.05.2015

Let's say you have 2 teams, team A and team B. Declare 2 arrays with random spawn points, one for each team.
Then when you need to spawn the player, check if the player is in team A and choose a random spawn point from the first array. If the player is in team B, choose a random spawn point from the second array.


Re: Help with random spawn points - 7Ahmad7 - 23.05.2015

So i make it like this:
new Float:RandomSpawns[][4] =
{ //some spawns
};
new Float:RandomSpawns[][4] =
{
};
(making it doubled)
and then,In the OnPlayerSpawn,I make it to check if the player is in case (asda),It spawns him at
RandomSpawns[Random][0], RandomSpawns[Random][1],RandomSpawns[Random][2]

that is cool but,what about the second case(team)? it will be same?
RandomSpawns[Random][0], RandomSpawns[Random][1],RandomSpawns[Random][2]
?