Raised This Month: $51 Target: $400
 12% 

[HowTo] Properly catch shot event in CS


Post New Thread Reply   
 
Thread Tools Display Modes
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 07-31-2008 , 18:28   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #11

VEN (or any1 else), i need some help...
I used this code to see when a player was shot, then i used an if statement to see if a player has <= 0 health to see if they died.
What i need now is to stop them from dieing, but i dont know how to
If the player who was shot did "die", i need to keep them alive and transfer them to a different team
Here is my code so far, but i'm stuck now

PHP Code:
public fwPlaybackEvent(flagsinvokereventid
{
    if(!(
g_guns_eventids_bitsum & (1<<eventid)) || !(<= invoker <= g_max_clients))
    {
        return 
FMRES_IGNORED
    
}
    
         if(
get_user_health(player) <= 0)
         {
              
// Player has died
         
}   
         return 
FMRES_HANDLED

__________________
minimiller is offline
Send a message via MSN to minimiller
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-01-2008 , 15:17   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #12

Quote:
Originally Posted by minimiller View Post
VEN (or any1 else), i need some help...
I used this code to see when a player was shot, then i used an if statement to see if a player has <= 0 health to see if they died.
What i need now is to stop them from dieing, but i dont know how to
If the player who was shot did "die", i need to keep them alive and transfer them to a different team
Here is my code so far, but i'm stuck now

PHP Code:
public fwPlaybackEvent(flagsinvokereventid
{
    if(!(
g_guns_eventids_bitsum & (1<<eventid)) || !(<= invoker <= g_max_clients))
    {
        return 
FMRES_IGNORED
    
}
    
         if(
get_user_health(player) <= 0)
         {
              
// Player has died
         
}   
         return 
FMRES_HANDLED

PHP Code:
#include <hamsandwich>
public plugin_init()
    
RegisterHam(Ham_Killed,"player","fwPlayerKilled")

public 
fwPlayerKilled(id,killer,gib)
{
    
// Do your think here

    // This is needed
    
set_pev(id,pev_health,1.0)

    return 
HAM_SUPERCED

danielkza is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 08-05-2008 , 12:19   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #13

minimiller: since the above method is for post variant you can't use it for that. See the above post for a solution. FYI: should be "HAM_SUPERCEDE" instead of "HAM_SUPERCED".
VEN is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-05-2008 , 14:02   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #14

Quote:
Originally Posted by VEN View Post
minimiller: since the above method is for post variant you can't use it for that. See the above post for a solution. FYI: should be "HAM_SUPERCEDE" instead of "HAM_SUPERCED".
You can also hook TakeDamage, and HamSandwich can alter function parameters on the fly. And I typed without paying much attention,sorry for that.
danielkza is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-19-2008 , 12:23   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #15

Hi!
Sorry if what I say is a little bit offtopic.
But do the functions Ham_Weapon_PrimaryAttack/Ham_Weapon_SecondaryAttack do the same thing as this?
I've tried them in my plugin and didn't seem to work ...

This is how I used them... in case it was my error:

PHP Code:
RegisterHam(Ham_Weapon_PrimaryAttack"player""fw_primary_attack")
RegisterHam(Ham_Weapon_SecondaryAttack"player""fw_secondary_attack")


public 
fw_primary_attack(id)
{
    if (!
is_user_alive(id))
        return 
HAM_IGNORED
    
// code
        
    
return HAM_IGNORED

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-19-2008 , 12:24   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #16

Theses forward work. How did you register them ? You have to register with the weapon name.
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-19-2008 , 12:25   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #17

Quote:
Originally Posted by arkshine View Post
Theses forward work. How did you register them ? You have to register with the weapon name.
I edited my post.
Edit: Can you give me an example please? So I won't make any errors.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 09-19-2008 at 12:30.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-19-2008 , 12:37   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #18

RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_primary_attack") for example.

For all weapons, you can do :

Code:
        #define MAX_WEAPONS 30                 new s_WeaponName[ 24 ];         for ( new i_Wpn= 1; i_Wpn <= MAX_WEAPONS; i_Wpn++ )         {             get_weaponname ( i_Wpn, s_WeaponName, charsmax ( s_WeaponName ) );             if ( s_WeaponName[ 0 ] ) RegisterHam ( Ham_Weapon_PrimaryAttack, s_WeaponName, "fwd_PrimaryAttack" );         }
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-19-2008 , 12:38   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #19

Quote:
Originally Posted by arkshine View Post
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "fw_primary_attack") for example.

For all weapons, you can do :

Code:
        #define MAX_WEAPONS 30                 new s_WeaponName[ 24 ];         for ( new i_Wpn= 1; i_Wpn <= MAX_WEAPONS; i_Wpn++ )         {             get_weaponname ( i_Wpn, s_WeaponName, charsmax ( s_WeaponName ) );             if ( s_WeaponName[ 0 ] ) RegisterHam ( Ham_Weapon_PrimaryAttack, s_WeaponName, "fwd_PrimaryAttack" );         }
Thanks man!
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-19-2008 , 12:40   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #20

Don't forget that it passes the weapon entity index, so to retrieve the player's id, you have to use pev_owner.
__________________
Arkshine 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 00:36.


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