Raised This Month: $ Target: $400
 0% 

Hooking bots hurt


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-24-2009 , 21:13   Re: Hooking bots hurt
Reply With Quote #1

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 #2

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 #3

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 #4

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 #5

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
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-25-2009 , 05:39   Re: Hooking bots hurt
Reply With Quote #6

Quote:
Originally Posted by NcB_Sav View Post
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.
For CZ bots, see this method http://forums.alliedmods.net/showthr...409#post650409 ; those bots don't have "player" as classname, you have to use another method.
__________________

Last edited by Arkshine; 10-25-2009 at 05:46.
Arkshine is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-25-2009 , 04:54   Re: Hooking bots hurt
Reply With Quote #7

Quote:
Originally Posted by NcB_Sav View Post
conor tried that still didnt work

czbots only bots i use
If you'd have used my code in the thread it would have worked. Connor made one mistake, but I believe he fixed it, though I'm not sure if he tested his code. But I did.
SnoW is offline
Send a message via MSN to SnoW
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-26-2009 , 02:44   Re: Hooking bots hurt
Reply With Quote #8

Quote:
Originally Posted by SnoW View Post
If you'd have used my code in the thread it would have worked. Connor made one mistake, but I believe he fixed it, though I'm not sure if he tested his code. But I did.

Using yours then will all functions of ham work or just registering the bot spawned because i want to give weapons, register takedamge and all that crap

Like this

Code:
#include <amxmodx> #include <hamsandwich> #define PLUGIN "Registering bots with ham" #define VERSION "1.0" #define AUTHOR "SnoW" new bool:gBotsRegistered; new dmg_reduce; public plugin_init( ) {     register_plugin( PLUGIN, VERSION, AUTHOR );     RegisterHam( Ham_Spawn, "player", "hamSpawnPlayer", 1 );     RegisterHam( Ham_TakeDamage, "player", "PlayerHurt");         dmg_reduce = register_cvar("vff_ammount", "0.25") } public client_authorized( id )     if( !gBotsRegistered && is_user_bot( id ) ) {     set_task( 0.1, "register_bots", id ); } public register_bots( id ) {     if( !gBotsRegistered && is_user_connected( id ) )     {         RegisterHamFromEntity( Ham_Spawn, id, "PlayerSpawn", 1 );         RegisterHamFromEntity( Ham_TakeDamage, id, "PlayerHurt");         gBotsRegistered = true;     } } public hamSpawnPlayer( id ) {     if( is_user_alive( id ) )     {         //Give Armor         if( is_user_bot( id ) )         {             //give random weapons to bots         }                 if( !is_user_bot( id ) )         {             //Strip all weapons give knife to humans         }     } } public PlayerHurt( victim, inflictor, attacker, Float:damage, damagebits )// Not sure on the last one {     if(is_user_alive( victim ) && is_user_alive( attacker ) )     {         if(cs_get_user_team( victim ) == cs_get_user_team( attacker ) )         {              SetHamParamFloat(4, damage * get_pcvar_float(dmg_reduce))         }     } }

Last edited by Doc-Holiday; 10-26-2009 at 03:08.
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