|
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
|

01-16-2017
, 08:45
Ham_TakeDamage Weird Bug | get_user_surfing | Semiclip | Read File | find_ent_by (-1)
|
#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(victim, inflictor, attacker, Float:damage, damagebit) { if(get_user_weapon(attacker) == CSW_DEAGLE && deagle_used[attacker]) { SetHamParamFloat(4, damage * 999.0) client_print(attacker, print_chat, "It Works !!") } if(get_user_weapon(attacker) == CSW_AK47 && ak47_used[attacker]) { SetHamParamFloat(4, damage * 999.0) client_print(attacker, print_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 attacker, weapon, body, damage; attacker = get_user_attacker(victim, weapon, body) damage = read_data(2) set_dhudmessage(random_num(50,255), random_num(50,255), random_num(50,255), random_float(0.20, 0.60), random_float(0.20, 0.60), 0, 6.0, 0.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(id, EV_INT_flags); if( flags & FL_ONGROUND ) { return 0; } new Float:origin[3], Float:dest[3]; entity_get_vector(id, EV_VEC_origin, origin); dest[0] = origin[0]; dest[1] = origin[1]; dest[2] = origin[2] - 1.0; new ptr = create_tr2(); engfunc(EngFunc_TraceHull, origin, dest, 0, flags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, id, ptr); new Float:flFraction; get_tr2(ptr, TR_flFraction, flFraction); if( flFraction >= 1.0 ) { free_tr2(ptr); return 0; } get_tr2(ptr, TR_vecPlaneNormal, dest); 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(es, e, iEnt, id, hostflags, player, pSet) { 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(es, ES_Solid, SOLID_NOT) } }
public PreThink(id) { if(!get_pcvar_num(g_on) || !get_pcvar_num(g_semi) || IsAlive(id) == 0 || !(g_iTeamSemiclip & g_iTeam[id])) { return } new iPlayers[MAX_PLAYERS], iNum, iPlayer; get_players(iPlayers, iNum, "ae", g_szTeams[g_iTeam[id]]) for(new i; i<iNum; i++) { iPlayer = iPlayers[i] if(id != iPlayer) { entity_set_int(iPlayer, EV_INT_solid, SOLID_NOT) } } }
public client_PostThink(id) { if(!get_pcvar_num(g_on) || !get_pcvar_num(g_semi) || IsAlive(id) == 0 || !(g_iTeamSemiclip & g_iTeam[id])) { return } new iPlayers[MAX_PLAYERS], iNum, iPlayer; get_players(iPlayers, iNum, "ae", g_szTeams[g_iTeam[id]]) for(new i; i<iNum; i++) { iPlayer = iPlayers[i] if(id != iPlayer) { entity_set_int(iPlayer, EV_INT_solid, SOLID_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(iEnt, iAttacker, Float:fDamage, Float:vDirection[3], TraceHandle, iDamageBits ) { dllfunc(DLLFunc_Use, iEnt, iAttacker) }
__________________
Last edited by edon1337; 02-19-2017 at 10:54.
|
|