AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by (-1) (https://forums.alliedmods.net/showthread.php?t=292865)

edon1337 01-16-2017 08:45

Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by (-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



OciXCrom 01-16-2017 09:41

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
 
Obviously your deagle_used and ak47_used aren't working.

edon1337 01-16-2017 10:08

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
 
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)
                }
                
            } 


OciXCrom 01-16-2017 10:17

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
 
Try without them. Also, the damage won't change without returning HAM_SUPERCEDE.

edon1337 01-16-2017 10:34

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File
 
Still didn't work.

OciXCrom 01-16-2017 15:01

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
 
Post the full code.

jimaway 01-16-2017 18:32

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
 
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

edon1337 01-16-2017 19:29

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
 
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.

EFFx 01-16-2017 20:16

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
 
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

edon1337 01-17-2017 09:56

Re: Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by
 
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


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

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