teleport question
#1

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

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

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]);
Reply
#4

Код:
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.
Reply
#5

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

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 };
Reply
#7

lol i mean the last line with coordinats
Reply
#8

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

Doesn't matter its solved now!
Reply
#10

Why don't you use the wiki?

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


Forum Jump:


Users browsing this thread: 1 Guest(s)