AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ Knife Menu ] Help (https://forums.alliedmods.net/showthread.php?t=320907)

AlaskaxD 01-14-2020 16:41

[ Knife Menu ] Help
 
Please Help :(

Code:

L 01/14/2020 - 18:28:00: Start of error session.
L 01/14/2020 - 18:28:00: Info (map "de_dust2_china") (file "addons/amxmodx/logs/error_20200114.log")
L 01/14/2020 - 18:28:00: [AMXX] Displaying debug trace (plugin "knife_menu.amxx", version "2019")
L 01/14/2020 - 18:28:00: [AMXX] Run time error 4: index out of bounds
L 01/14/2020 - 18:28:00: [AMXX]    [0] 5b68f2f345beff16ca5eac684e89d027.sma::Player_TakeDamage (line 386)


Code:

public Player_TakeDamage (iVictim, iInflictor, iAttacker, Float:Damage, iDamageBits)
{
  if(iInflictor == iAttacker && HaveKnife1[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.1);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife2[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.1);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife3[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.1);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife4[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.1);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife5[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.2);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife6[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.2);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife7[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.2);
      return HAM_HANDLED;
  }
 
  if(iInflictor == iAttacker && HaveKnife8[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
  {
      SetHamParamFloat(4, Damage * 1.2);
      return HAM_HANDLED;
  }
 
  return HAM_IGNORED;
}


OciXCrom 01-14-2020 17:38

Re: [ Knife Menu ] Help
 
Lol, what's that. Use this - https://forums.alliedmods.net/showthread.php?t=293632

If this is actually a scripting question and not another wrong section, then your "HaveKnife" variables are not defined with an array size of 33.

PS: all of this redundant code can be replaced with less than 5 lines. You don't need to check the exact same things every time, use variables. You're doing 32 checks when you can do only 4.


All times are GMT -4. The time now is 02:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.