SA-MP Forums Archive
How to? - 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: How to? (/showthread.php?tid=316233)



How to? - SpankMe2 - 05.02.2012

Hey I was woundering how can I do somthing like this?

rand = random(sizeof(STD[0][]));

If I try this it returns errors?

Thanks

P.S The very last bracket is the one I need to randomise I need the other to be what I enter


Re: How to? - Vince - 05.02.2012

sizeof array -> First dimension
sizeof array[] -> Second dimension
sizeof array[][] -> Third dimension


Re: How to? - SpankMe2 - 05.02.2012

(2651) : error 001: expected token: "]", but found "-integer value-"
(2651) : warning 215: expression has no effect
(2651) : error 001: expected token: ";", but found "]"
(2651) : error 029: invalid expression, assumed zero
(2651) : fatal error 107: too many error messages on one line

When I change it to this

rand = random(sizeof(STD[0]));

it gives those errors

I need to put 0 in there to say the first row then randomise the rest.


Re: How to? - grand.Theft.Otto - 05.02.2012

Try:

rand = random(sizeof(STD[0][]));

or

rand = random(sizeof(STD[0][][]));