If not holding a melee weapon
#1

I made it this way http://pastebin.com/mi1wWNT5

Could i have done it more efficient?
Reply
#2

What about using && ?

Something like this -

PHP код:
 if(GetPlayerWeapon(playerid) != 10 && GetPlayerWeapon(playerid) != 11
Not sure if it would work but I guess it can be done somehow - However , Kinda better.
Reply
#3

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
What about using && ?

Something like this -

PHP код:
 if(GetPlayerWeapon(playerid) != 10 && GetPlayerWeapon(playerid) != 11
Not sure if it would work but I guess it can be done somehow - However , Kinda better.
Yeah could've done that but I love doing identation and stuff :d
Reply
#4

Don't know if that works, make a array of all melee weapons and then a loop.

pawn Код:
for(new w = 0; w < 46; w++) // LOOPS 1 > 45
    {
          if(GetPlayerWeapon(playerid) != w)
         // AND SOME OTHER SHIT HERE, lulz.
    }
Reply
#5

Quote:
Originally Posted by Tingesport
Посмотреть сообщение
Don't know if that works, make a array of all melee weapons and then a loop.

pawn Код:
for(new w = 0; w < 46; w++) // LOOPS 1 > 45
    {
          if(GetPlayerWeapon(playerid) != w)
         // AND SOME OTHER SHIT HERE, lulz.
    }
Thats a much faster way but mine works too, just tested it
Reply
#6

A switch statement would work even faster as you only need to call GetPlayerWeapon once. And also much less code.
(Not saying that less code is always better, but in this case it definitely is.)

pawn Код:
switch(GetPlayerWeapon(playerid))
{
    case 0..18,36,37,39,40..46: { /* melee */ }
    default: { /* not melee */ }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)