Posts: 570
Threads: 55
Joined: Oct 2016
Posts: 102
Threads: 10
Joined: Sep 2016
Reputation:
0
Nice filterscript i will try to my server.
Posts: 153
Threads: 35
Joined: Mar 2016
Reputation:
0
Awesome! Keep up the good work +rep
Posts: 1,174
Threads: 251
Joined: May 2012
Reputation:
0
Ok it`s nice, I really like it, but do some optimisation, first thing, reduce statement if with loop switch, second thing is instead of using "function", use stock.
Posts: 1,219
Threads: 51
Joined: Jul 2012
Quote:
Originally Posted by Sanady
Ok it`s nice, I really like it, but do some optimisation, first thing, reduce statement if with loop switch, second thing is instead of using "function", use stock.
|
https://sampforum.blast.hk/showthread.php?tid=570635
No more to say
Posts: 118
Threads: 10
Joined: May 2013
24.02.2017, 14:53
(
Last edited by Yousha; 24/02/2017 at 07:05 PM.
)
Quote:
Originally Posted by Humza
Hello. It's look good but you can do some optimization to your code.
Code:
WeaponObject(wid) {
if(wid == 1) return 331;
else if(wid == 2) return 332;
else if(wid == 3) return 333;
else if(wid == 5) return 334;
else if(wid == 6) return 335;
else if(wid == 7) return 336;
else if(wid == 10) return 321;
else if(wid == 11) return 322;
else if(wid == 12) return 323;
else if(wid == 13) return 324;
else if(wid == 14) return 325;
else if(wid == 15) return 326;
else if(wid == 23) return 347;
else if(wid == 24) return 348;
else if(wid == 25) return 349;
else if(wid == 26) return 350;
else if(wid == 27) return 351;
else if(wid == 28) return 352;
else if(wid == 29) return 353;
else if(wid == 30) return 355;
else if(wid == 31) return 356;
else if(wid == 32) return 372;
else if(wid == 33) return 357;
else if(wid == 4) return 335;
else if(wid == 34) return 358;
else if(wid == 41) return 365;
else if(wid == 42) return 366;
else if(wid == 43) return 367;
return 0;
}
You could simply change it in switch would be much more good and efficient.
|
No.
In this case,
SWITCH must be used. It has better performance(faster) and readability...
IF checks EVERY case, but
SWITCH goes directly to the correct one.
Posts: 176
Threads: 29
Joined: Aug 2012
Reputation:
0
I have a script like this but except I use dynamicobjects rather rhan pickups look more realistic than pickups