AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Double Damage don't work (https://forums.alliedmods.net/showthread.php?t=249496)

pentakill 10-06-2014 14:26

Double Damage don't work
 
So, I have a weapons menu, and the player can choose the normal menu, gold menu and super menu

Gold menu weapons take double damage, and super take 3x damage

PHP Code:

public Damage(victiminflictorattackerFloat:damagedamagebits

    if(
is_user_connected(victim) || is_user_alive(victim))  
    { 
        if( 
get_user_weapon(attacker) == CSW_AK47 )
        {
            if (
AreGoldenAk[attacker])
            {
                
SetHamParamFloat4damage )
                return 
HAM_HANDLED
            
}
            if (
AreSuperAk[attacker])
            {
                
SetHamParamFloat4damage 3)
                return 
HAM_HANDLED
            
}
        }
    }
    return 
HAM_IGNORED


But this isn't working and I don't know why...

I use the same bools (AreGoldenAk and AreSuperAk) to change the skins and works!

Can someone help me?

HamletEagle 10-06-2014 14:33

Re: Double Damage don't work
 
Give us full code or explain better what you mean by not working, because it's not something wrong with the code you posted, just: is_user_connected(victim) || is_user_alive(victim) is should be &&

pentakill 10-06-2014 14:35

Re: Double Damage don't work
 
Quote:

Originally Posted by HamletEagle (Post 2207978)
Give us full code or explain better what you mean by not working, because it's not something wrong with the code you posted, just: is_user_connected(victim) || is_user_alive(victim) is should be &&

I gave all the informations, what you want to know more?

&& and || have the same function I think, for me works fine using ||

Balck 10-06-2014 14:55

Re: Double Damage don't work
 
Quote:

Originally Posted by pentakill (Post 2207979)
&& and || have the same function I think, for me works fine using ||

:nono:
|| == or
&& == and
so it's not the same

aron9forever 10-06-2014 15:36

Re: Double Damage don't work
 
oh I see you guys didn't notice he's returning HAM_HANDLED instead of HAM_SUPERCEDE and not overwriting the normal damage inflicted

gotta pay more attention next time

jimaway 10-06-2014 16:19

Re: Double Damage don't work
 
Quote:

Originally Posted by aron9forever (Post 2208006)
oh I see you guys didn't notice he's returning HAM_HANDLED instead of HAM_SUPERCEDE and not overwriting the normal damage inflicted

gotta pay more attention next time

HAM_SUPERCEDE blocks the function, definitely not what he wants.

you don't have to check if user is connected when you use is_user_alive(), it already checks that.
post how you are hooking ham_takedamage

pentakill 10-06-2014 16:32

Re: Double Damage don't work
 
Quote:

Originally Posted by jimaway (Post 2208017)
you don't have to check if user is connected when you use is_user_alive(), it already checks that.

Big mistake, edited to only check is_user_alive

Quote:

Originally Posted by jimaway (Post 2208017)
post how you are hooking ham_takedamage

RegisterHam(Ham_TakeDamage, "player", "Damage")

EDITED: I don't know what I've done, but know the plugin works! Thanks anyway

Decak 10-06-2014 17:46

Re: Double Damage don't work
 
Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new bool:AreGoldenAk[33], bool:AreSuperAk[33];

public plugin_init() {
    register_plugin("Register Name", "1.0", "Author")
    RegisterHam(Ham_TakeDamage, "player", "Damage")
}

public Damage(victim, inflictor, attacker, Float:damage, damagebits)
{
    if(is_user_connected(victim) || is_user_alive(victim)) 
    {
        if( get_user_weapon(attacker) == CSW_AK47 )
        {
            if (AreGoldenAk[attacker])
            {
                SetHamParamFloat( 4, damage * 2 )
                return HAM_HANDLED
            }
            if (AreSuperAk[attacker])
            {
                SetHamParamFloat( 4, damage * 3)
                return HAM_HANDLED
            }
        }
    }
    return HAM_IGNORED
}

... add code with bool AreGoldenAk and AreSuperAk.

pentakill 10-06-2014 18:22

Re: Double Damage don't work
 
Quote:

Originally Posted by Decak (Post 2208038)
Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new bool:AreGoldenAk[33], bool:AreSuperAk[33];

public plugin_init() {
    register_plugin("Register Name", "1.0", "Author")
    RegisterHam(Ham_TakeDamage, "player", "Damage")
}

public Damage(victim, inflictor, attacker, Float:damage, damagebits)
{
    if(is_user_connected(victim) || is_user_alive(victim)) 
    {
        if( get_user_weapon(attacker) == CSW_AK47 )
        {
            if (AreGoldenAk[attacker])
            {
                SetHamParamFloat( 4, damage * 2 )
                return HAM_HANDLED
            }
            if (AreSuperAk[attacker])
            {
                SetHamParamFloat( 4, damage * 3)
                return HAM_HANDLED
            }
        }
    }
    return HAM_IGNORED
}

... add code with bool AreGoldenAk and AreSuperAk.

My plugin already works but thanks anyway :)

aron9forever 10-07-2014 07:28

Re: Double Damage don't work
 
Quote:

Originally Posted by jimaway (Post 2208017)
HAM_SUPERCEDE blocks the function, definitely not what he wants.

you don't have to check if user is connected when you use is_user_alive(), it already checks that.
post how you are hooking ham_takedamage

woops, sorry, I was high as fuck , that's when I start shitposting
he still needs return HAM_OVERRIDE instead of supercede


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

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