AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catch legs and arms shot (https://forums.alliedmods.net/showthread.php?t=83826)

Doc-Holiday 01-16-2009 00:39

Catch legs and arms shot
 
i need a functin that will catch the following
HIT_LEFTLEG
HIT_RIGHTLEG
HIT_LEFTARM
HIT_RIGHTARM
PHP Code:

public ham_traceattack_player(iVictimiAttackerFloat:damageFloat:direction[3], traceresultdamagebitsid)
{
 if(
get_tr2(traceresultTR_iHitgroup) == HIT_LEFTLEG)
 {
            
//shot in legs?
 
}
else if(
get_tr2(traceresultTR_iHitgrou) == HIT_LEFTARM)
{
            
//shot in arms?
}
 return 
HAM_IGNORED



ConnorMcLeod 01-16-2009 01:11

Re: Catch legs and arms shot
 
If this doesn't work, try to post register.
PHP Code:

new g_iMaxPlayers

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
RegisterHam(Ham_TraceAttack"player""Player_TraceAttack")

    
g_iMaxPlayers get_maxplayers()
}

public 
Player_TraceAttack(ididattackerFloat:damageFloat:direction[3], trdamagebits)
{
    if( !(
<= idattacker <= g_iMaxPlayers) )
    {
        return
    }

    switch( 
get_tr2(trTR_iHitgroup) )
    {
        case 
HIT_LEFTARM:
        case 
HIT_RIGHTARM:
        case 
HIT_LEFTLEG:
        case 
HIT_RIGHTLEG:
    }



Doc-Holiday 01-16-2009 01:21

Re: Catch legs and arms shot
 
say i want HIT_RIGHTARM and HIT_LEFTARM to call this function

and the legs to call anohter how would i do that i dont really understand thiskinda stuff to behonest withyou guys...

Just trying to expand on my VR(Virtual Reality) plugin

Bugsy 01-16-2009 01:57

Re: Catch legs and arms shot
 
Quote:

Originally Posted by NcB_Sav (Post 745023)
say i want HIT_RIGHTARM and HIT_LEFTARM to call this function

and the legs to call anohter how would i do that i dont really understand thiskinda stuff to behonest withyou guys...

Just trying to expand on my VR(Virtual Reality) plugin

Using ConnorMcLeods code, edit the portion to this:

PHP Code:

    switch( get_tr2(trTR_iHitgroup) )
    {
        case 
HIT_LEFTARM ,HIT_RIGHTARM:
        {
            
//call arm hit function
        
}
        case 
HIT_LEFTLEG,HIT_RIGHTLEG:
        {
            
//call leg hit function
        
}
    } 


Doc-Holiday 01-16-2009 02:20

Re: Catch legs and arms shot
 
Thanks but it gives me these errors

/home/groups/amxmodx/tmp3/phpmySI2v.sma(60 -- 61) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpmySI2v.sma(66 -- 67) : error 029: invalid expression, assumed zero


on those 2 case's

edit... i lied lol didnt see :

ConnorMcLeod 01-16-2009 06:51

Re: Catch legs and arms shot
 
Dunno what you exactly do, but i could be better to only hook TakeDamage POST, then retrieve the actual damage with pev_dmg_take, and hitgroup with offset 75 :

75 - m_LastHitGroup
76 - m_bitsDamageType

http://forums.alliedmods.net/showthread.php?t=68113

Doc-Holiday 01-16-2009 12:38

Re: Catch legs and arms shot
 
Quote:

Originally Posted by ConnorMcLeod (Post 745099)
Dunno what you exactly do, but i could be better to only hook TakeDamage POST, then retrieve the actual damage with pev_dmg_take, and hitgroup with offset 75 :

75 - m_LastHitGroup
76 - m_bitsDamageType

http://forums.alliedmods.net/showthread.php?t=68113

basically if your shot in the leg i want it to slow you down.
if shot in arm weapon shake

Exolent[jNr] 01-16-2009 14:41

Re: Catch legs and arms shot
 
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> #define m_LastHitGroup 75 new ScreenShake; public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage", 1);         ScreenShake = get_user_msgid("ScreenShake"); } public FwdPlayerDamage(client, inflictor, attacker, Float:damage, damagebits) {     if( !is_user_alive(client) ) return HAM_IGNORED;         switch( get_pdata_int(client, m_LastHitGroup) )     {         case HIT_LEFTARM, HIT_RIGHTARM:         {             message_begin(MSG_ONE, ScreenShake, _, client);             write_byte(255<<14);             write_byte(10<<14);             write_byte(255<<14);             message_end();         }         case HIT_LEFTLEG, HIT_RIGHTLEG:         {             new Float:velocity[3];             pev(client, pev_velocity, velocity);                         if( pev(client, pev_flags) & FL_ONGROUND )             {                 velocity[0] *= 0.25;                 velocity[1] *= 0.25;             }             else             {                 velocity[0] *= 1.5;                 velocity[1] *= 1.5;             }                         set_pev(client, pev_velocity, velocity)         }     }         return HAM_HANDLED; }

danielkza 01-16-2009 21:48

Re: Catch legs and arms shot
 
Just checking, are these offsets CS-only or do they work for all mods?

Doc-Holiday 01-16-2009 23:42

Re: Catch legs and arms shot
 
ok so thanks for telling me how to get if damage was done to legs arms..

i was using the ham take damage to that..

If i want it to check to addin the set task to make them bleed
thats what i added below

set_task(1.0,"victim_stuff", victim+35435,"",0, "b")
PHP Code:

/* CREDITS
Exolent[jNr] & Connor for Catching arm leg shot
Exolent[jNr] for Slow down and screen shake
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <fun>

#define m_LastHitGroup 75
new ScreenShake;
new 
limitreductiontoggle_pluginsave;
new 
bleeding[32] = //is bleeding
public plugin_init() 
{
 
register_plugin("Virtual Reality","2.0","NcB_Sav"); 
 
 
reduction register_cvar("vr_reduction""1");
 
toggle_plugin register_cvar("vr_mod","1");
 
limit register_cvar("vr_limit""65");
 
save register_cvar("vr_stop" "10");
 
 
//Player Spawn
 
RegisterHam(Ham_Spawn"player""playerspawn"1)
 
 
//Leg Shot 
 
RegisterHam(Ham_TakeDamage"player""FwdPlayerDamage"1);
    
 
ScreenShake get_user_msgid("ScreenShake");
 
 
register_event("DeathMsg""death_msg""a")
 
 
register_logevent("round_end"2"1=Round_End")
 
}
public 
FwdPlayerDamage(clientinflictorattackerFloat:damagedamagebitsvictim)

 if( !
is_user_alive(client) ) return HAM_IGNORED;
    
 if(
get_user_health(victim) > get_pcvar_num(limit)) return HAM_HANDLED;
 
 if(!
get_pcvar_num(toggle_plugin)) return HAM_IGNORED;
    
 switch( 
get_pdata_int(clientm_LastHitGroup) )
 {
  case 
HIT_LEFTARMHIT_RIGHTARM:
  {
   
message_begin(MSG_ONEScreenShake_client);
   
write_byte(255<<14);
   
write_byte(10<<14);
   
write_byte(255<<14);
   
message_end();
  }
  case 
HIT_LEFTLEGHIT_RIGHTLEG:
  {
   new 
Float:velocity[3];
   
pev(clientpev_velocityvelocity);
            
   if( 
pev(clientpev_flags) & FL_ONGROUND )
   {
    
velocity[0] *= 0.25;
    
velocity[1] *= 0.25;
   }
   else
   {
    
velocity[0] *= 1.5;
    
velocity[1] *= 1.5;
   }
            
   
set_pev(clientpev_velocityvelocity)
  }
 }
 
 
set_task(1.0,"victim_stuff"victim+35435,"",0"b")
    
 return 
HAM_HANDLED;
}
public 
death_msg()
{
 new 
victim read_data(2)
 
 if(
task_exists(victim+35435))
  
remove_task(victim+35435);
}
public 
victim_stuff(taskid)
{
 new 
victim taskid 35435;
 
 new 
health get_user_health(victim);
 
 if(
health get_pcvar_num(save))
  
remove_task(victim+35435);
 
 
set_user_health(victimhealth get_pcvar_num(reduction));
 ++
bleeding[victim]
 
 new 
iOrigin[3]
 
get_user_origin(victim,iOrigin)
 
 
fx_bleed(iOrigin)
}
public 
round_end()
{
 new 
players[32], num
 get_players
(playersnum)
 
 new 
player
 
for(new 0numi++)
 {
  
player players[i]
  
  if(
task_exists(player+35435))
   
remove_task(player+35435);
 }
}
public 
fx_bleed(origin[3])
{
 
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
 
write_byte(TE_BLOODSTREAM);
 
write_coord(origin[0]);
 
write_coord(origin[1]);
 
write_coord(origin[2]+10);
 
write_coord(random_num(-360,360));
 
write_coord(random_num(-360,360));
 
write_coord(-10);
 
write_byte(70);
 
write_byte(random_num(50,100));
 
message_end()
}
public 
playerspawn(id)
{
 
round_end();
 
bleeding[id] = 0


when i compile it and upload it i get laged out when i shoot a player.


All times are GMT -4. The time now is 01:40.

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