SA-MP Forums Archive
Is it possible ? - 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: Is it possible ? (/showthread.php?tid=276068)



Is it possible ? - Setkus - 12.08.2011

Hey guys!
I want to ask you about mode changer. I'm using this code to change a mode: SendRconCommand("changemode bla bla"); And for example i have three maps and is it possible that mode change to random ? I mean first mode change to second and second mode change to third, so for example first mode change to third mode for random. Is it possible ?
I hope you understand me, sorry for my bad english. I'm Lithuanian


Re: Is it possible ? - Wesley221 - 12.08.2011

Well, just use the "random" function.
pawn Код:
new rand = random(4);
switch(rand)
{
    case 0: SendRconCommand("changemode map 1");
    case 1: SendRconCommand("changemode map 2");
    case 2: SendRconCommand("changemode map 3");
    case 3: SendRconCommand("changemode map 4");
    case 4: SendRconCommand("changemode map 5");
}
It will give you a random map, and always different. Just change the map name, and the amount of cases to the amount of maps you got.


Re: Is it possible ? - AndreT - 12.08.2011

Wesley, why create a new variable for it? Unless it is going to be used again, this can be done instead:
pawn Код:
switch(random(4))



Re: Is it possible ? - Setkus - 12.08.2011

Oh, thank you Wesley221! Also AndreT thank you too!