SA-MP Forums Archive
Need help with building - 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: Need help with building (/showthread.php?tid=660273)



Need help with building - v1k1nG - 29.10.2018

What's up?
So I wrote this snippet
PHP код:
     switch(P[playerid][Level]){
        case 
0..20SetPlayerColor(playeridCOLOR_NOOB);
        case 
21..50SetPlayerColor(playeridCOLOR_PRISONER);
        case 
51..200SetPlayerColor(playeridCOLOR_SKILLED_PRISONER);
        case 
201..500SetPlayerColor(playeridCOLOR_PROFESSIONAL_PRISONER);
        case 
501..1000SetPlayerColor(playeridCOLOR_DISCORDIA_GOD);
        case 
1001..200000SetPlayerColor(playeridCOLOR_GOD);
    } 
and now compiler frozens! If I comment this snippet up, it will build.
I am using SublimeText to edit/build


Re: Need help with building - kristo - 29.10.2018

Don't use switch with such large ranges. The compiler generates a jump table with 200002 elements (there is an extra element at the beginning that stores the count of all other elements), which takes at least a minute to compile, if not more. It also affects the runtime performance, so a chain of else if's will probably even be faster here.


Re: Need help with building - v1k1nG - 29.10.2018

Hue thanks for the fast reply!
EDIT: Works indeed, thanks a lot