Weapon CMD

Started by Myse, Jun 09, 2016, 02:49 PM

Previous topic - Next topic

Myse

How can I make a weapon cmd from which I can get weapons ( from both number and alphabets ) and it selects if weapon is not allowed from a function ????

jayant

Get them by weapon id or by name, and if you don't want a weapon,block them..

Cool

else if ( cmd == "wep" )
    {
   if ( !text ) ePrivMessage( " [#4682B4][Syntax][#FFFFFF] - /wep <Wep Name/ID>", player );
   else
      {
            local i = 0, wep = "";
            for ( i = 1; i <= NumTok( text, " " ); i++ ) //Run a loop from 1 to n (n is the number of weps typed)
              {
    wep = GetTok( text, " ", i ); //Split the text, get the name of the i'th  weapon.
                 if ( IsAllowed( wep ) )
                {
                   player.SetWeapon( GetWeaponID( wep ), 9999 ); //Give player that weapon.
                   ePrivMessage( " [#4682B4][Info][#FFFFFF]You Received A " + GetWeaponName( GetWeaponID( wep ) ), player );
                    }
              }
          }
}


function
function IsAllowed( wep )
{
    local w = GetWeaponID( wep );
     if( w == 33 )  return false;
else if( w == 14 )  return false;
else if( w == 15 )  return false;
else if( w == 16 )  return false;
else if( w == 30 )  return false;
else if( w == 12 )  return false;
else if( w == 13 )  return false;
else if( w == 33 )  return false;
else if( w == 34 )  return false;
else if( w == 36 )  return false;
else return true;
}

KAKAN

Why not use switch case instead, @Hercules?
And too, your command can be made better.
There's nothing like wep 35, so simply use:-
if( w > 32 ) return;
oh no

Cool

Quote from: KAKAN on Jun 09, 2016, 04:13 PMWhy not use switch case instead, @Hercules?
And too, your command can be made better.
There's nothing like wep 35, so simply use:-
if( w > 32 ) return;
Thanks @KAKAN I will make it better :D