Raised This Month: $ Target: $400
 0% 

Hooking bots hurt


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-24-2009 , 19:01   Hooking bots hurt
Reply With Quote #1

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

Doc-Holiday is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-24-2009 , 20:08   Re: Hooking bots hurt
Reply With Quote #2

Ham_TakeDamage works fine with bots.
__________________
Arkshine is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-24-2009 , 20:51   Re: Hooking bots hurt
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
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.
Doc-Holiday is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-24-2009 , 21:08   Re: Hooking bots hurt
Reply With Quote #4

I've just tried with only bots, and the forward is called. There are reasons to not work, a bot is also a "player".
__________________
Arkshine is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-24-2009 , 21:09   Re: Hooking bots hurt
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
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.
Doc-Holiday is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-24-2009 , 21:13   Re: Hooking bots hurt
Reply With Quote #6

Just tried to supercede the forward, and bots are not hurt... It works fine.
__________________
Arkshine is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-24-2009 , 21:21   Re: Hooking bots hurt
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
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;


Last edited by Doc-Holiday; 10-24-2009 at 21:29.
Doc-Holiday is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 10-24-2009 , 21:55   Re: Hooking bots hurt
Reply With Quote #8

what kind of bot? you can try RegisterHamFromEntity when the bot is put in server to fix your issue.
__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-24-2009 , 22:04   Re: Hooking bots hurt
Reply With Quote #9

Quote:
Originally Posted by G-Dog View Post
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


Last edited by Doc-Holiday; 10-24-2009 at 22:12.
Doc-Holiday is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-25-2009 , 00:22   Re: Hooking bots hurt
Reply With Quote #10

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.
Attached Files
File Type: sma Get Plugin or Get Source (survior-mod.sma - 515 views - 3.2 KB)
Doc-Holiday 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 17:42.


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