AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hooking bots hurt (https://forums.alliedmods.net/showthread.php?t=107275)

Doc-Holiday 10-24-2009 19:01

Hooking bots hurt
 
Does any one a way to hook if a bot is hurt.

Ham dosent work so is there another way more efficient then this

PHP Code:

public Event_Damageid )
{
 new 
weaponbodypart
 
new attacker get_user_attackeridweaponbodypart )
 
 if ( !
is_user_aliveid ) || !is_user_aliveattacker ) )
  return 
PLUGIN_CONTINUE
 
 
if ( weapon != CSW_KNIFE )
  return 
PLUGIN_CONTINUE
 
 
new iHealth get_user_healthid )
 new 
iDamage floatroundfloatread_data(2) ) * get_cvar_float"ncb_knife_damage" ) )
 if ( 
iHealth iDamage 
  
fakedamageid"weapon_knife"floatiDamage ), read_data) )
 else
 {
  
user_silentkillid )
  
make_deathmsgattackerid0"knife" )
 }
 
set_user_frags(attackerget_user_frags(attacker)+1)
 
 return 
PLUGIN_CONTINUE



Arkshine 10-24-2009 20:08

Re: Hooking bots hurt
 
Ham_TakeDamage works fine with bots.

Doc-Holiday 10-24-2009 20:51

Re: Hooking bots hurt
 
Quote:

Originally Posted by Arkshine (Post 971269)
Ham_TakeDamage works fine with bots.


No it dosent ive tested a milion times in multiple ways...

If the damage is doen to the bot it doesnt register.

Arkshine 10-24-2009 21:08

Re: Hooking bots hurt
 
I've just tried with only bots, and the forward is called. There are reasons to not work, a bot is also a "player".

Doc-Holiday 10-24-2009 21:09

Re: Hooking bots hurt
 
Quote:

Originally Posted by Arkshine (Post 971316)
I've just tried with only bots, and the forward is called. There are reasons to not work, a bot is also a "player".


then do this

set damage to 0 and shoot a bot. bot still gets hurt.

Arkshine 10-24-2009 21:13

Re: Hooking bots hurt
 
Just tried to supercede the forward, and bots are not hurt... It works fine.

Doc-Holiday 10-24-2009 21:21

Re: Hooking bots hurt
 
Quote:

Originally Posted by Arkshine (Post 971322)
Just tried to supercede the forward, and bots are not hurt... It works fine.


.....what the hell... mine didnt work using this code.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
new g_Switchbtdmg_multi;
public 
plugin_init()
{
 
register_plugin("Survivor Mod""1.0""=(GrG)=")
 
 
RegisterHam(Ham_Spawn"player""PlayerSpawn"1)
 
 
RegisterHam(Ham_TakeDamage"player""PlayerHurt"0)
 
 
g_Switch register_cvar("Bones_On""1"//Turns plugin on and off
 
 
bt register_cvar("Bones_team""2"// 2 CT bones 1 T Bones
 
 
dmg_multi register_cvar("dmg_multiplier""2.0")
 
}
public 
PlayerSpawn(id)
{
 new 
team get_pcvar_num(bt)
 
 if(
is_user_alive(id) && get_pcvar_num(g_Switch))
 {
  
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
  switch(
team)
  {
   case 
1:
   {
    
//Humans on T
    
if(cs_get_user_team(id) == CS_TEAM_T)
    {
     
ham_strip_weapon(id"weapon_glock")
     
ham_strip_weapon(id"weapon_knife")
     
ham_give_weapon(id"weapon_knife")
    }
   }
   case 
2:
   {
    
//Humans on CT
    
if(cs_get_user_team(id) == CS_TEAM_CT)
    {
     
ham_strip_weapon(id"weapon_usp")
     
ham_strip_weapon(id"weapon_knife")
     
ham_give_weapon(id"weapon_knife")
    }
   }
  }
  
 }
}
public 
PlayerHurt(idinflictorattackerdamagedamagebits)
{
 if(
is_user_alive(id) && is_user_alive(attacker))
 {
  if(
cs_get_user_team(attacker) == CS_TEAM_CT)
  {
   if(
get_user_weapon(attacker) == CSW_KNIFE)
   {
    
SetHamParamFloat(4damage get_pcvar_float(dmg_multi))
    return 
HAM_SUPERCEDE;
   }
  }
  return 
HAM_IGNORED;
 }
 return 
HAM_IGNORED;
}
 
//*************************[Stocks]*************************
// takes a weapon from a player efficiently
stock ham_strip_weapon(id,weapon[])
{
 if(!
equal(weapon,"weapon_",7)) return 0;
 
 new 
wId get_weaponid(weapon);
 if(!
wId) return 0;
 
 new 
wEnt;
 while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
 if(!
wEnt) return 0;
 
 if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
 
 if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
 
ExecuteHamB(Ham_Item_Kill,wEnt);
 
 
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
 
 
// this block should be used for Counter-Strike:
 
if(wId == CSW_C4)
 {
  
cs_set_user_plant(id,0,0);
  
cs_set_user_bpammo(id,CSW_C4,0);
 }
 else if(
wId == CSW_SMOKEGRENADE || wId == CSW_FLASHBANG || wId == CSW_HEGRENADE)
  
cs_set_user_bpammo(id,wId,0);
 
 return 
1;
}
// gives a player a weapon efficiently
stock ham_give_weapon(id,weapon[])
{
 if(!
equal(weapon,"weapon_",7)) return 0;
 
 new 
wEnt engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,weapon));
 if(!
pev_valid(wEnt)) return 0;
 
 
set_pev(wEnt,pev_spawnflags,SF_NORESPAWN);
 
dllfunc(DLLFunc_Spawn,wEnt);
 
 if(!
ExecuteHamB(Ham_AddPlayerItem,id,wEnt))
 {
  if(
pev_valid(wEnt)) set_pev(wEnt,pev_flags,pev(wEnt,pev_flags) | FL_KILLME);
  return 
0;
 }
 
 
ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)
 return 
1;



G-Dog 10-24-2009 21:55

Re: Hooking bots hurt
 
what kind of bot? you can try RegisterHamFromEntity when the bot is put in server to fix your issue.

Doc-Holiday 10-24-2009 22:04

Re: Hooking bots hurt
 
Quote:

Originally Posted by G-Dog (Post 971350)
what kind of bot? you can try RegisterHamFromEntity when the bot is put in server to fix your issue.


conor tried that still didnt work

czbots only bots i use



Untill some one can show me how they get czbots working i have to use this

PHP Code:

public Event_Damageid )
{
 new 
weaponbodypart
 
new attacker get_user_attackeridweaponbodypart )
 
 if ( !
is_user_aliveid ) || !is_user_aliveattacker ) )
  return 
PLUGIN_CONTINUE
 
 
if ( weapon == CSW_KNIFE )
 {   
  if(
cs_get_user_team(id) != cs_get_user_team(attacker))
  {
   
user_silentkillid )
   
fm_fakedamage(id,"weapon_knife"2.0 ,DMG_SLASH);
   
make_deathmsgattackerid0"knife" )
  }
  
set_user_frags(attackerget_user_frags(attacker)+1)
 }
 
 return 
PLUGIN_CONTINUE



Doc-Holiday 10-25-2009 00:22

Re: Hooking bots hurt
 
1 Attachment(s)
Here is my code if you figure out ill love you.


The part where its giving the health to the bots its a test to see if they are getting there hp...

Which they are not.


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

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