SA-MP Forums Archive
teleport question - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: teleport question (/showthread.php?tid=70603)



teleport question - Drift_04 - 26.03.2009

when i make a teleport, how do imake it so it randomly teleports the player to different coordiantes instead of just 1 teleport..


Re: teleport question - StrickenKid - 26.03.2009

just add a string float like this at the top:

pawn Код:
new Float:RandomTeles[4][3] = // 4 for how much total, 3 for co-ords (1 for x 1 for y 1 for z) 1+1+1 = 3
{
    {x,y,z},
    {x,y,z},
    {x,y,z},
    {x,y,z}
};
Then where you want the random tele to be executed.....
pawn Код:
new rand;
        rand = random(sizeof(RandomTeles));
        SetPlayerPos(playerid, RandomTeles[rand][0], RandomTeles[rand][1], RandomTeles[rand][2]);
all done!


Re: teleport question - Drift_04 - 26.03.2009

ok i did exactly as you said and i get this error

Код:
C:\Users\rac\Desktop\gtasa and samp\gamemodes\choice.pwn(70) : error 018: initialization data exceeds declared size
and heres my code

Код:
new Float:RandomTeles[4][3] = // 4 for how much total, 3 for co-ords (1 for x 1 for y 1 for z) 1+1+1 = 3
{
{3221.2466,-2430.5266,2.5561},
{3171.0720,-2432.4939,2.5561},
{3172.3948,-2423.6113,2.5561},
{3221.2227,-2418.0542,2.5631},
};
and where the code is executed this is what it looks like..

Код:
new rand;
	rand = random(sizeof(RandomTeles));
	SetPlayerPos(playerid, RandomTeles[rand][0], RandomTeles[rand][1], RandomTeles[rand][2]);



Re: teleport question - 56avenue - 26.03.2009

Код:
new Float:RandomTeles[4][3] = // 4 for how much total, 3 for co-ords (1 for x 1 for y 1 for z) 1+1+1 = 3
{
{3221.2466,-2430.5266,2.5561},
{3171.0720,-2432.4939,2.5561},
{3172.3948,-2423.6113,2.5561},
{3221.2227,-2418.0542,2.5631}
};
Do that without the ',' on the last one.


Re: teleport question - Oxside - 26.03.2009

Always rember when you use coordinats with {}
put NO , on the laste line!


Re: teleport question - Dujma - 26.03.2009

Quote:
Originally Posted by Oxside
Always rember when you use coordinats with {}
put NO , on the laste line!
lol and can you explain why is that only when you use coordinates? The last line doesn't have a coma but it has a closeing brace };


Re: teleport question - Oxside - 26.03.2009

lol i mean the last line with coordinats


Re: teleport question - Drift_04 - 26.03.2009

LOL i didnt even notice i had a "," on the last one.


Re: teleport question - Oxside - 31.03.2009

Doesn't matter its solved now!


Re: teleport question - Mikep - 31.03.2009

Why don't you use the wiki?

https://sampwiki.blast.hk/wiki/Random