Raised This Month: $ Target: $400
 0% 

Solved Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by (-1)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-16-2017 , 08:45   Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by (-1)
Reply With Quote #1

Hey.

1. In my code Ham_TakeDamage is being weird. No I'm not hooking it in Post, yes it is in Pre. The weapon damages aren't working nor the "It Works !!" print , but the fall & grenade damage block is working. I tried setting a colored HUD when player makes damage but it wasn't working so I switched to Event_Damage

PHP Code:
RegisterHam(Ham_TakeDamage"player""fw_HamTakeDamage")


public 
fw_HamTakeDamage(victiminflictorattackerFloat:damagedamagebit) {
    
    if(
get_user_weapon(attacker) == CSW_DEAGLE && deagle_used[attacker]) {
        
        
SetHamParamFloat(4damage 999.0)
        
client_print(attackerprint_chat"It Works !!")
    }
    
    if(
get_user_weapon(attacker) == CSW_AK47 && ak47_used[attacker]) {
        
        
SetHamParamFloat(4damage 999.0)
        
client_print(attackerprint_chat"It Works !!")
    }    
    
    if(
damagebit DMG_FALL) {
        
        return 
HAM_SUPERCEDE // don't take damage
    
}
    
    if(
attacker == victim && damagebit DMG_GRENADE) {
        
        return 
HAM_SUPERCEDE // no damage to owner of HE
    
}
    
    return 
HAM_IGNORED;

The damage that the attacker makes shows in HUD this way
PHP Code:
    register_event"Damage""Event_Damage""b""2!0""3=0""4!0" )


public 
Event_Damage(victim) {
    
    new 
attackerweaponbodydamage;
    
attacker get_user_attacker(victimweaponbody)
    
damage read_data(2)
    
    
set_dhudmessage(random_num(50,255), random_num(50,255), random_num(50,255), random_float(0.200.60), random_float(0.200.60), 06.00.5)
    
show_dhudmessage(attacker"%d"damage)
    

but the weapon damage isn't working in both ways. I need to fix the weapon damage and the HUD to work both in Ham_TakeDamage.

I've also tried :
1. Setting the damage in Post, still didn't work.
2. Setting damage in the Event_Damge, still didn't work.


2. Any stock to check if user is surfing?

solution :
PHP Code:
public IsUserSurfing(id)
{
    if( 
is_user_alive(id) )
    {
        new 
flags entity_get_int(idEV_INT_flags);
        if( 
flags FL_ONGROUND )
        {
            return 
0;
        }
        
        new 
Float:origin[3], Float:dest[3];
        
entity_get_vector(idEV_VEC_originorigin);
        
        
dest[0] = origin[0];
        
dest[1] = origin[1];
        
dest[2] = origin[2] - 1.0;
        
        new 
ptr create_tr2();
        
engfunc(EngFunc_TraceHullorigindest0flags FL_DUCKING HULL_HEAD HULL_HUMANidptr);
        new 
Float:flFraction;
        
get_tr2(ptrTR_flFractionflFraction);
        if( 
flFraction >= 1.0 )
        {
            
free_tr2(ptr);
            return 
0;
        }
        
        
get_tr2(ptrTR_vecPlaneNormaldest);
        
free_tr2(ptr);
        return 
dest[2] <= 0.7;
        
    }
    return 
0

3. I've added these codes from Connor's semiclip but it still doesn't work
Link : --> Here <--

PHP Code:
register_forward(FM_AddToFullPack"AddToFullPack"1)


public 
AddToFullPack(eseiEntidhostflagsplayerpSet)
{
    if(
get_pcvar_num(g_on) && get_pcvar_num(g_semi) && player && id != iEnt && IsAlive(id) && g_iTeamSemiclip g_iTeam[id] && IsAlive(iEnt) && g_iTeam[id] == g_iTeam[iEnt] && get_orig_retval())
    { 
        
set_es(esES_SolidSOLID_NOT)
    }


public 
PreThink(id)
{
    if(!
get_pcvar_num(g_on) || !get_pcvar_num(g_semi) || IsAlive(id) == || !(g_iTeamSemiclip g_iTeam[id]))
    { 
        return
    }
    
    new 
iPlayers[MAX_PLAYERS], iNumiPlayer;
    
get_players(iPlayersiNum"ae"g_szTeams[g_iTeam[id]])
    
    for(new 
ii<iNumi++)
    {
        
iPlayer iPlayers[i]
        if(
id != iPlayer)
        {
            
entity_set_int(iPlayerEV_INT_solidSOLID_NOT)
        }
    }
}

public 
client_PostThink(id)
{
    if(!
get_pcvar_num(g_on) || !get_pcvar_num(g_semi) || IsAlive(id) == || !(g_iTeamSemiclip g_iTeam[id]))
    {
        return
    }
    
    new 
iPlayers[MAX_PLAYERS], iNumiPlayer;
    
get_players(iPlayersiNum"ae"g_szTeams[g_iTeam[id]])
    
    for(new 
ii<iNumi++)
    {
        
iPlayer iPlayers[i]
        if(
id != iPlayer)
        {
            
entity_set_int(iPlayerEV_INT_solidSOLID_SLIDEBOX)
        }
    }



4. How Can I read a file ? Like if I want to make a new VIP system and want to read infos from file.


5. Why in find_ent_by_x , "-1" is always as the index?

6. Which classname is surf's jail button ? I've tried this but it doesn't open the jail
PHP Code:
RegisterHam(Ham_TraceAttack"func_button""fw_ButtonFunc"

public 
fw_ButtonFunc(iEntiAttackerFloat:fDamageFloat:vDirection[3], TraceHandleiDamageBits ) {
    
    
dllfunc(DLLFunc_UseiEntiAttacker

__________________

Last edited by edon1337; 02-19-2017 at 10:54.
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-16-2017 , 09:41   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
Reply With Quote #2

Obviously your deagle_used and ak47_used aren't working.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-16-2017 , 10:08   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
Reply With Quote #3

They are though.
PHP Code:
if(cs_get_user_money(id) >= 14000 && !ak47_used[id]) {
                
client_printidprint_chat"[ESM] You Just Bought ^"Golden AK47^"" );
                
cs_set_user_money(idcs_get_user_money(id) - 14000)
                
ak47_used[id] = true
                give_item
(id"weapon_ak47")
                
cs_set_user_bpammo(idCSW_AK4790)
                
                if(
get_user_weapon(id) == CSW_AK47) {
                    
                    
SetGoldenAKModel(id)
                }
                
            } 
__________________

Last edited by edon1337; 01-16-2017 at 10:10.
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-16-2017 , 10:17   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
Reply With Quote #4

Try without them. Also, the damage won't change without returning HAM_SUPERCEDE.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-16-2017 , 10:34   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
Reply With Quote #5

Still didn't work.
__________________
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-16-2017 , 15:01   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
Reply With Quote #6

Post the full code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 01-16-2017, 16:56
edon1337
This message has been deleted by edon1337. Reason: -aint nobody gonna look at my code- :D
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 01-16-2017 , 18:32   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
Reply With Quote #7

are you sure the ham_takedamage forward even gets called? i mean the fall and grenade damage "block" could be due to godmode never being removed from players
jimaway is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-16-2017 , 19:29   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
Reply With Quote #8

I haven't even tried the Godmode reward. Will test printing when Ham_TakeDamage is called tomorrow, I think, maybe by returning HAM_SUPERCEDE the damage doesn't get called but it doesn't make any sense because I tried the damage first.
__________________
edon1337 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-16-2017 , 20:16   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
Reply With Quote #9

1. About the damage event, try it

PHP Code:
public Event_Damage(id
{
    static 
iAttackeriAttacker get_user_attacker(id)
    static 
iDamageiDamage read_data(2)
    
    
set_dhudmessage(random_num(50,255), random_num(50,255), random_num(50,255), random_float(0.200.60), random_float(0.200.60), 06.00.5)
    
show_dhudmessage(iAttacker"Damage given: %d"damage)
    

About the Ham_TakeDamage, I've tested here without your arrays and it works, I think what OciXCrom is correct. And you can do your code like this, looks more fine

PHP Code:
public fw_HamTakeDamage(victiminflictorattackerFloat:damagedamagebit
{
    if(!
is_user_alive(victim) || !is_user_alive(attacker))
        return 
HAM_IGNORED
        
    
if(!victim || !attacker)
        return 
HAM_IGNORED

    
switch(damagebit)
    {
        case 
DMG_FALL
        {
            
SetHamReturnInteger(0)
            return 
HAM_SUPERCEDE
        
}
        case 
DMG_GRENADE:
        {
            if(
attacker == victim)
            {
                
SetHamReturnInteger(0)
                return 
HAM_SUPERCEDE
            
}
        }
        default: 
// Idk if it is correct
        
{
            new 
iWeapon get_user_weapon(attacker)
            switch(
iWeapon)
            {
                case 
CSW_DEAGLE:
                {
                    if(
deagle_used[attacker]) 
                    {
                        
SetHamParamFloat(4damage 999.0)
                        
client_print(attackerprint_chat"It Works !!")
                    }
                }
                case 
CSW_AK47:
                {
                    if(
ak47_used[attacker]) 
                    {
                        
SetHamParamFloat(4damage 999.0)
                        
client_print(attackerprint_chat"It Works !!")
                    }
                }    
            }
        }
    }
    return 
HAM_IGNORED

2. I think not
3. About the Semiclip, this is the version i'm using

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

new const VERSION[] = "0.7.0"

const MAX_PLAYERS 32

new g_iPlayers[MAX_PLAYERS], g_iNumg_iPlayeri
new const g_szAliveFlags[] = "a"
#define RefreshPlayersList()    get_players(g_iPlayers, g_iNum, g_szAliveFlags)

public plugin_init()
{
    
register_plugin("Semiclip"VERSION"ConnorMcLeod")

    
register_forward(FM_AddToFullPack"FM_client_AddToFullPack_Post"1)

    
RegisterHam(Ham_Player_PreThink"player""Ham_CBasePlayer_PreThink_Post"1)
}

public 
FM_client_AddToFullPack_Post(eseiEntidhostflagsplayerpSet)
{
    if( 
player && id != iEnt && get_orig_retval() && is_user_alive(id) )
    {
        
set_es(esES_SolidSOLID_NOT)
    }
}

public 
Ham_CBasePlayer_PreThink_Post(id)
{
    if( !
is_user_alive(id) )
    {
        return
    }

    
RefreshPlayersList()

    for(
0i<g_iNumi++)
    {
        
g_iPlayer g_iPlayers[i]
        if( 
id != g_iPlayer && get_user_team(id) == get_user_team(g_iPlayer))
        {
            
set_pev(g_iPlayerpev_solidSOLID_NOT)
        }
    }
}

public 
client_PostThink(id)
{
    if( !
is_user_alive(id) )
    {
        return
    }

    
RefreshPlayersList()

    for(
0i<g_iNumi++)
    {
        
g_iPlayer g_iPlayers[i]
        if( 
g_iPlayer != id && get_user_team(id) == get_user_team(g_iPlayer))
        {
            
set_pev(g_iPlayerpev_solidSOLID_SLIDEBOX)
        }
    }

4. https://forums.alliedmods.net/showpo...93&postcount=5 - I think is that what you're searching
5. https://wiki.alliedmods.net/Finding_...es_(amx_mod_x)
6. This? https://forums.alliedmods.net/showpo...80&postcount=5
May be this? https://forums.alliedmods.net/showpo...2&postcount=14
Or this https://forums.alliedmods.net/showthread.php?t=123684
If all those links doesn't work for you - https://forums.alliedmods.net/showpo...7&postcount=10
Ah, another one - https://forums.alliedmods.net/showpo...60&postcount=8
Ops, another - https://forums.alliedmods.net/showpo...2&postcount=52
LOL, I found another - https://forums.alliedmods.net/showth...=123684&page=6

Ok, I'll stop it
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-16-2017 at 20:45.
EFFx is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-17-2017 , 09:56   Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
Reply With Quote #10

1. There's no problem with Event_Damage ,also that method of ham_takedamage doesn't work
3. thanks
4. can u make an example on how to read steamid password and flags
5. there's nothing associated to -1 index
6. func_button doesn't do anything and func_door_rotating opens jail when the jail door is shot, i want jail to be opened when button is shot

@jim it prints text so it means it's called
__________________
edon1337 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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