Quote:
Originally Posted by Fratello
A much lightweight snippet of your code would look like this:
PHP код:
GetWeaponNameEx(weaponid)
{
new w_name[16];
switch(weaponid)
{
case 0: w_name = "Fist";
case 24: w_name = "Deagle";
case 31: w_name = "M4";
case 30: w_name = "AK-47";
}
return w_name;
}
Maximum words per a weapon are 15. You don't need to create a string variable that has 24 + cells. Also, switch statement will do faster job than the if statement. This function is pretty small, why not optimize it properly? Also, stock keyword isn't required.
https://sampforum.blast.hk/showthread.php?tid=570635
|
he's using his named weapons, so we dont know how many values are required, but yeah we can use cases and this way too, both is acceptable.