else if(level >= 101 && level <= 200) // truck level 3 { switch(random(3)) // random 9mm va sdpistol { case 0: // 9mm { SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Ban nhan duoc mien phi 9mm cho viec van chuyen vu khi trai phep."); SendClientMessageEx(playerid, COLOR_YELLOW, "* Khong duoc su dung vu khi duoc thuong cho muc dich xau nhu KOS/DM nonRP, neu vi pham se bi han che vu khi."); GivePlayerValidWeapon(playerid, 22, 60000); } case 1: // sdpistol { SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Ban nhan duoc mien phi sdpistol cho viec van chuyen vu khi trai phep."); SendClientMessageEx(playerid, COLOR_YELLOW, "* Khong duoc su dung vu khi duoc thuong cho muc dich xau nhu KOS/DM nonRP, neu vi pham se bi han che vu khi."); GivePlayerValidWeapon(playerid, 23, 60000); } case 2: // shotgun { SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Ban nhan duoc mien phi Shotgun cho viec van chuyen vu khi trai phep."); SendClientMessageEx(playerid, COLOR_YELLOW, "* Khong duoc su dung vu khi duoc thuong cho muc dich xau nhu KOS/DM nonRP, neu vi pham se bi han che vu khi."); GivePlayerValidWeapon(playerid, 25, 60000); } } }
else if(level >= 101 && level <= 200) // truck level 3
{
switch(random(100)) // random 9mm va sdpistol
{
case 0..44: // 9mm
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Ban nhan duoc mien phi 9mm cho viec van chuyen vu khi trai phep.");
SendClientMessageEx(playerid, COLOR_YELLOW, "* Khong duoc su dung vu khi duoc thuong cho muc dich xau nhu KOS/DM nonRP, neu vi pham se bi han che vu khi.");
GivePlayerValidWeapon(playerid, 22, 60000);
}
case 45..89: // sdpistol
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Ban nhan duoc mien phi sdpistol cho viec van chuyen vu khi trai phep.");
SendClientMessageEx(playerid, COLOR_YELLOW, "* Khong duoc su dung vu khi duoc thuong cho muc dich xau nhu KOS/DM nonRP, neu vi pham se bi han che vu khi.");
GivePlayerValidWeapon(playerid, 23, 60000);
}
case 90..99: // shotgun
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Ban nhan duoc mien phi Shotgun cho viec van chuyen vu khi trai phep.");
SendClientMessageEx(playerid, COLOR_YELLOW, "* Khong duoc su dung vu khi duoc thuong cho muc dich xau nhu KOS/DM nonRP, neu vi pham se bi han che vu khi.");
GivePlayerValidWeapon(playerid, 25, 60000);
}
}
}
Using some thing like "case 0..44" is in-efficient because it is like creating 44 if statements.
source: http://forum.sa-mp.com/showpost.php?...0&postcount=15 |
#include <a_samp> public OnFilterScriptInit() { new tick = GetTickCount(); for(new i = 0; i < 1000000; i++) { switch(random(100)) { case 0..44: { } case 45..89: { } case 90..99: { } } } printf("Took: %d", GetTickCount() - tick); tick = GetTickCount(); for(new i = 0; i < 1000000; i++) { new val = random(100); if(val >= 0 && val <= 44) { } else if(val >= 45 && val <= 89) { } else if(val >= 90 && val <= 99) { } } printf("Took: %d", GetTickCount() - tick); }
Filterscript 'w.amx' unloaded.
Took: 92
Took: 232
Filterscript 'w.amx' loaded.
Using some thing like "case 0..44" is in-efficient because it is like creating 44 if statements.
source: http://forum.sa-mp.com/showpost.php?...0&postcount=15 |