load custom weps

Started by umar4911, Oct 23, 2017, 10:18 AM

Previous topic - Next topic

umar4911

Quote from: ! on Dec 24, 2017, 02:44 PM//<?php
   
if ( strName.len() > // make sure to use the correct one here

Only ak wont work since it checks for 4 words for custom weps

Change it to

//<?php
   
if ( strName.len() > // make sure to use the correct one here

It's better to limit the search words to 2 or 3 instead of removing it.
Still no
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter

!

Modify the function
/* <?php */
function 
getWeaponIDstrName )
{
   if ( 
strName.len() > // make sure to use the correct one here
   
{
      if ( 
strName.findgetWeaponName102 ) ) )
      {
         return 
102;
      }
      if ( 
strName.findgetWeaponName103 ) ) )
      {
         return 
103;
      }
      
      return 
GetWeaponIDstrName );
   }
   
   return 
GetWeaponIDstrName );
}
to
/* <?php */
function 
getWeaponIDstrName )
{
   if ( 
strName.len() > // make sure to use the correct one here
   
{
      if ( 
strName.tolower().findgetWeaponName102 ).tolower() ) )
      {
         return 
102;
      }
      if ( 
strName.tolower().findgetWeaponName103 ).tolower() ) )
      {
         return 
103;
      }
   }
   
   return 
GetWeaponIDstrName );
}

Discord: zeus#5155

umar4911

Quote from: ! on Dec 24, 2017, 04:47 PMModify the function
/* <?php */
function 
getWeaponIDstrName )
{
   if ( 
strName.len() > // make sure to use the correct one here
   
{
      if ( 
strName.findgetWeaponName102 ) ) )
      {
         return 
102;
      }
      if ( 
strName.findgetWeaponName103 ) ) )
      {
         return 
103;
      }
      
      return 
GetWeaponIDstrName );
   }
   
   return 
GetWeaponIDstrName );
}
to
/* <?php */
function 
getWeaponIDstrName )
{
   if ( 
strName.len() > // make sure to use the correct one here
   
{
      if ( 
strName.tolower().findgetWeaponName102 ).tolower() ) )
      {
         return 
102;
      }
      if ( 
strName.tolower().findgetWeaponName103 ).tolower() ) )
      {
         return 
103;
      }
   }
   
   return 
GetWeaponIDstrName );
}
Still Invalid Weapon :(
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter

!

Quote from: umar4911 on Dec 25, 2017, 09:45 AMStill Invalid Weapon :(

try this once again there was a mistake now its fixed.
http://forum.vc-mp.org/?topic=5237.msg38626#msg38626

Quote from: ! on Dec 22, 2017, 04:36 PMTry
//<?php
else if( cmd == "wep" || cmd == "we" )
{
   if( !
text ) return MessagePlayer"[#FFDD33]Command Error:[#FFFFFF] /"+cmd+" <wep 1> <wep 2> <...>"player );
   else
   {
      
local params splittext" " ); 
      
local weapons;
      for( 
local i 0<= params.len() - 1i++ ) 
      {
         if( !
IsNumparams[i] ) && getWeaponIDparams[i] ) != 255 
         {
            
player.SetWeapongetWeaponIDparams[i] ), 99999 ); 
            if ( !
weapons weapons getWeaponNamegetWeaponIDparams[i] ) );
            else 
weapons weapons+", "+getWeaponNamegetWeaponIDparams[i] ) );
         }
         else if( 
IsNumparams[i] ) && getWeaponNameparams[i].tointeger() ) != "Unknown" )
         {
            
player.SetWeaponparams[i].tointeger(), 99999 ); 
            
weapons getWeaponNameparams[i].tointeger() );
            if ( !
weapons weapons getWeaponNameparams[i].tointeger() );
            else 
weapons weapons+", "+getWeaponNameparams[i].tointeger() );
         }
      }
      if ( 
weapons MessagePlayer("[#FFDD33]Information:[#FFFFFF] You received the following weapon: "+weapons+"."player);
      else 
MessagePlayer"[#FFDD33]Information:[#FFFFFF] Invalid Weapon Name/ID"player );
   }
}

//will return 255 when invalid weapon name is used
function getWeaponIDstrName )
{
   if ( 
strName.len() > // make sure to use the correct one here
   
{
      if ( 
strName.tolower().findgetWeaponName102 ).tolower() ) != null )
      {
         return 
102;
      }
      if ( 
strName.tolower().findgetWeaponName103 ).tolower() ) != null )
      {
         return 
103;
      }
   }
   
   return 
GetWeaponIDstrName );
}
//This one by Xmair
//will return Unknown when invalid weapon ID is used
function getWeaponNameintID )
{
   switch( 
intID )
   { 
      case 
102
         {
            return 
"AK-47";
         }
      break;
      case 
103:
         {
            return 
"IV Rocket Launcher";
         }
      break;
      default:
         {
            return 
GetWeaponNameintID );
         }
      break;
   }
}

Discord: zeus#5155

umar4911

Quote from: ! on Dec 25, 2017, 11:31 AM
Quote from: umar4911 on Dec 25, 2017, 09:45 AMStill Invalid Weapon :(

try this once again there was a mistake now its fixed.
http://forum.vc-mp.org/?topic=5237.msg38626#msg38626

Quote from: ! on Dec 22, 2017, 04:36 PMTry
//<?php
else if( cmd == "wep" || cmd == "we" )
{
   if( !
text ) return MessagePlayer"[#FFDD33]Command Error:[#FFFFFF] /"+cmd+" <wep 1> <wep 2> <...>"player );
   else
   {
      
local params splittext" " ); 
      
local weapons;
      for( 
local i 0<= params.len() - 1i++ ) 
      {
         if( !
IsNumparams[i] ) && getWeaponIDparams[i] ) != 255 
         {
            
player.SetWeapongetWeaponIDparams[i] ), 99999 ); 
            if ( !
weapons weapons getWeaponNamegetWeaponIDparams[i] ) );
            else 
weapons weapons+", "+getWeaponNamegetWeaponIDparams[i] ) );
         }
         else if( 
IsNumparams[i] ) && getWeaponNameparams[i].tointeger() ) != "Unknown" )
         {
            
player.SetWeaponparams[i].tointeger(), 99999 ); 
            
weapons getWeaponNameparams[i].tointeger() );
            if ( !
weapons weapons getWeaponNameparams[i].tointeger() );
            else 
weapons weapons+", "+getWeaponNameparams[i].tointeger() );
         }
      }
      if ( 
weapons MessagePlayer("[#FFDD33]Information:[#FFFFFF] You received the following weapon: "+weapons+"."player);
      else 
MessagePlayer"[#FFDD33]Information:[#FFFFFF] Invalid Weapon Name/ID"player );
   }
}

//will return 255 when invalid weapon name is used
function getWeaponIDstrName )
{
   if ( 
strName.len() > // make sure to use the correct one here
   
{
      if ( 
strName.tolower().findgetWeaponName102 ).tolower() ) != null )
      {
         return 
102;
      }
      if ( 
strName.tolower().findgetWeaponName103 ).tolower() ) != null )
      {
         return 
103;
      }
   }
   
   return 
GetWeaponIDstrName );
}
//This one by Xmair
//will return Unknown when invalid weapon ID is used
function getWeaponNameintID )
{
   switch( 
intID )
   { 
      case 
102
         {
            return 
"AK-47";
         }
      break;
      case 
103:
         {
            return 
"IV Rocket Launcher";
         }
      break;
      default:
         {
            return 
GetWeaponNameintID );
         }
      break;
   }
}
Worked.
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter