SA-MP Forums Archive
Just a tip - 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: Just a tip (/showthread.php?tid=392567)



Just a tip - Face9000 - 14.11.2012

Hello, im making a Tax system for my server and i have a problem.

I use cases (20 of them) for my tax system and Pawno it takes 2 minutes to compile, also the .amx size is big (1,50mb).

Removing the cases, it takes 5 seconds to compile and the .amx size is 500kb.

My question is: Is normal?


Re: Just a tip - zDivine - 14.11.2012

Obviously not. The size shouldn't increase that much from simply using cases. There is obviously more to it.


Re: Just a tip - Face9000 - 14.11.2012

Quote:
Originally Posted by zDivine
Посмотреть сообщение
Obviously not. The size shouldn't increase that much from simply using cases. There is obviously more to it.
That's strange, because if i remove the cases, it takes less time to compile.


Re: Just a tip - Stylock - 14.11.2012

Size actually increases if you use switch statement when it would be more appropriate to use if statement, for example:
pawn Код:
switch (var)
{
    case 1 .. 10000:
}
That's bad.


Re: Just a tip - Face9000 - 14.11.2012

Quote:
Originally Posted by YJIET
Посмотреть сообщение
Size actually increases if you use switch statement when it would be more appropriate to use if statement, for example:
pawn Код:
switch (var)
{
    case 1 .. 10000:
}
That's bad.
That's my problem. The tax system im developing is abit complex, is based on kills, deaths, last average ping, admin actions and more.

Last case is:

pawn Код:
case 45001 .. 65000:



Re: Just a tip - Stylock - 14.11.2012

Convert that to if statement, like so:
pawn Код:
if (45000 < var < 65001)
{
}
else if (65000 < var < 85001)
{
}
More efficient.


Re: Just a tip - Face9000 - 14.11.2012

Quote:
Originally Posted by YJIET
Посмотреть сообщение
Convert that to if statement, like so:
pawn Код:
if (45000 < var < 65001)
{
}
else if (65000 < var < 85001)
{
}
More efficient.
I need it from 45000 to a max of 65001


Re: Just a tip - Stylock - 14.11.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
I need it from 45000 to a max of 65001
Okay, I just posted an example.


Re: Just a tip - Face9000 - 14.11.2012

Quote:
Originally Posted by YJIET
Посмотреть сообщение
Okay, I just posted an example.
Yes, thank you