i want to put

Started by Cool, May 06, 2016, 11:48 AM

Previous topic - Next topic

Cool

i want to put isallowed wep function to spawnwep cmds but goting error any one will help me
   if ( cmd == "spawnwep" )
    {
       
        if ( !text ) ClientMessage( "[#ea4335]-> Error: [#fbbc05]Type /spawnwep <Wep1> <Wep2> <Wep3> <Wep4> <Wep5> <Wep6>...", player,0,0,0 );
        else
        {
            local weps = split( text, " " ),ID, wepsset = null;
            for( local i = 0; i < weps.len(); i++ )
            {
                ( IsNum( weps[ i ] ) ) ? ID = weps[ i ].tointeger() : ID = GetWeaponID( weps[ i ] );                         
                if ( ID >= 33 ) ClientMessage( "[#ea4335]-> Error: [#c0c0c0]Invalid Weapon ID/Name.", player,0,0,0 );
                else
                {
                    player.SetWeapon( ID, 99999 );
                    ClientMessage( "-> [#daff00]Saving " + GetWeaponName( ID ) + " to your spawn.",player,255,0,102);
                    if (wepsset == null) wepsset = " "+ ID;
                    else wepsset += (" " + ID);
                }
            }
            if (wepsset) SpawnwepPlayer[ player.ID ] = wepsset;   
        }
i want to put this wep isallowed function in spawnwep cmds
else if ( cmd == "wep" )
    {
   if ( !text ) ePrivMessage( "[#32CD32][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( "[#32CD32][Info][#FFFFFF]You Received A " + GetWeaponName( GetWeaponID( wep ) ), player );
                    }
              }
          }
}



Thijn

So where is the error, and where's your IsAllowed function?

Cool

and by error my mean is that when i try its not working and giving error wep does not existsfunction 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;
}

Thijn

Try adding the ID to the error message, so you can debug what the ID variable actually holds.

Mötley

I'm on my phone but try

wep = GetWeaponID( text.tointeger() );And change all the w's to wep
See what error happens with this,