Compiling with "case" - 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: Compiling with "case" (
/showthread.php?tid=554587)
Compiling with "case" -
Supermaxultraswag - 04.01.2015
Example :
Код HTML:
case 1..5:{
// Some stuff
}
case 6..10:{
// Some stuff
}
case 50..52:{
// Some stuff
}
case 600..769:{
// Some stuff
}
And when I compile, it compiles me very, very slowly... It took ~2 minutes to compile, when my code is only 300 lines length... Is it has to be like that when I use case or I do something wrong?
It only happens when I use many "case".
Re: Compiling with "case" -
ATGOggy - 04.01.2015
case won't cause lag. Did you include y_ini?
Because y_ini causes lag.
Re: Compiling with "case" -
dominik523 - 04.01.2015
I can also approve what ATGOggy said, I had many snippets of code in my script with cases similar to yours and it didn't cause lag.
After including y_ini in my code, it took more time to compile the script but it's never been compiling for over ~15 seconds or so.
Re: Compiling with "case" -
Supermaxultraswag - 04.01.2015
I said at the top...
Quote:
Originally Posted by Supermaxultraswag
It only happens when I use many "case".
|
And no, Im not using Y_ini, I only use a_samp and foreach
Re: Compiling with "case" -
Vince - 04.01.2015
How many cases do you actually have and what exactly are you switching through? If you need this many cases then there's usually a better way to reach your goal.
Re: Compiling with "case" -
Supermaxultraswag - 05.01.2015
Quote:
Originally Posted by ******
1) I don't see what y_ini has to do with this.
2) The rest of your post is also wrong! "switch" expands case ranges, so:
Becomes:
The larger the range, the more numbers is expands to, every one of which is then included. I've seen scripts bloat and fail to compile just because of a vast range in "switch". As Vince said, this is probably not the best thing to use - consider "if" instead:
Though "5 .. 7" is fine for switch, "100 .. 999" would kill it.
|
Lol, I was using "case 6000..90000:", so... Thanks for the answers, I change
case into
if