AlliedModders

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

Id0x. 12-20-2020 11:35

[HELP] Player_TakeDamage
 
HTML Code:

L 12/20/2020 - 16:19:00: [AMXX] Displaying debug trace (plugin "furien_shop.amxx", version "1.1")
L 12/20/2020 - 16:19:00: [AMXX] Run time error 4: index out of bounds
L 12/20/2020 - 16:19:00: [AMXX]    [0] phpQLXWlj.sma::Player_TakeDamage (line 454)


PHP Code:

public Player_TakeDamage (iVictimiInflictoriAttackerFloat:DamageiDamageBits)
{
   if(
iInflictor == iAttacker && HaveKnife1[iAttacker] && is_user_alive(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE && cs_get_user_team(iAttacker) == CS_TEAM_T)
   {
      
SetHamParamFloat(4Damage 1.1);
      return 
HAM_HANDLED;
   }
   
   return 
HAM_IGNORED;



Th3822 12-20-2020 11:49

Re: [HELP] Player_TakeDamage
 
PHP Code:

 && HaveKnife1[iAttacker] && is_user_alive(iAttacker

invert the order of those:
PHP Code:

 && is_user_alive(iAttacker) && HaveKnife1[iAttacker


Napoleon_be 12-20-2020 18:18

Re: [HELP] Player_TakeDamage
 
Quote:

Originally Posted by Th3822 (Post 2729515)
PHP Code:

 && HaveKnife1[iAttacker] && is_user_alive(iAttacker

invert the order of those:
PHP Code:

 && is_user_alive(iAttacker) && HaveKnife1[iAttacker


And why do you think that would matter or even change the error in the first place?

Show the declaration of your HaveKnife1[] bool

Th3822 12-20-2020 19:26

Re: [HELP] Player_TakeDamage
 
Quote:

Originally Posted by Napoleon_be (Post 2729565)
And why do you think that would matter or even change the error in the first place?

Show the declaration of your HaveKnife1[] bool

iAttacker may be a non-player entity, so by using the is_user_alive first, it does check if it's a player before using the array, if it happens again then it's the array size too.

Id0x. 12-21-2020 07:24

Re: [HELP] Player_TakeDamage
 
Quote:

Originally Posted by Th3822 (Post 2729515)
PHP Code:

 && HaveKnife1[iAttacker] && is_user_alive(iAttacker

invert the order of those:
PHP Code:

 && is_user_alive(iAttacker) && HaveKnife1[iAttacker


Thanks, have been solved ❤


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

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