Raised This Month: $305 Target: $400
 76%   Almost there!

Event_PlayerHurt what weapon did the damage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 09-06-2012 , 03:06   Event_PlayerHurt what weapon did the damage?
Reply With Quote #1

I have the following code to find the attacker and person taking damage.

Is there a way to find out if the weapon doing the damage was the AWP?
This is for CSGO.

PHP Code:
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{      
  new 
client_attacker GetClientOfUserId(GetEventInt(event"attacker"));
  new 
client GetClientOfUserId(GetEventInt(event"userid"));
 return 
Plugin_Continue;
 } 
Austin is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 09-06-2012 , 03:09   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #2

Yea... check the player active weapon and check what is the weapon...


cheers... i don have CSGO, just bumping..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 09-06-2012 at 03:11.
GsiX is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-06-2012 , 04:30   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #3

http://docs.sourcemod.net/api/index....d=show&id=425& if attacker is valid.
__________________
thetwistedpanda is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-06-2012 , 06:15   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #4

Edit:
never mind, I like this way better and it works!
IgniteEntity(AWPClient)!

=> Is there a way to make them scream after igniting them? !!!

Thanks for the replies.
What I am tying to do is limit AWPing on my server by denying AWP damage and then killing the AWPER!

I have this code, but when I shoot someone the server crashes.
??

PHP Code:
public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_TraceAttackHookTraceAttack);
}

public 
Action:HookTraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxHitGroup)
{
    if (!
attacker || attacker MaxClients)
        return 
Plugin_Continue;

    
// If using AWP don't let the attacked take damage
    // instead kill the AWPer!
    
decl String:weapon[100];
    
GetClientWeapon(attackerweapon100);    
    if (
strcmp(weapon"weapon_awp") == 0)
    {
        
//ForcePlayerSuicide(attacker);
                
IgniteEntity(attacker,6.0);
        
damage 0.0;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;


Last edited by Austin; 09-06-2012 at 07:28.
Austin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-06-2012 , 10:01   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #5

According to the documentation for player_hurt in CS:GO, there's a weapon String that will tell you what weapon was used.

However, to BLOCK the damage, you should use SDKHooks's OnTakeDamage hook, which has the weapon as one of its arguments, which you can use GetEntityClassname on to find out which weapon it is (after checking that it's a valid entity).

Just remember to adjust the damage to 0, then return Plugin_Changed.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-06-2012 at 10:06.
Powerlord is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 09-06-2012 , 14:10   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #6

TwistedPanda: Don't forget that that will NOT work if the damage was done by grenade - they won't have it equipped anymore.
necavi is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-06-2012 , 14:20   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #7

necavi, indeed, but he asked about the awp, so grenades were no where in the equation.
__________________

Last edited by thetwistedpanda; 09-06-2012 at 14:20.
thetwistedpanda is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-06-2012 , 17:36   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #8

Quote:
Originally Posted by thetwistedpanda View Post
necavi, indeed, but he asked about the awp, so grenades were no where in the equation.
Wow, great comments everyone.
And even if some of them do not exactly apply to my initial question,
this feedback helps me to have better overall understanding.

I am finally beginning to have enough sm scripting experience to be able to do the things I want to fairly quickly without asking a lot of questions.

1) necavi
This helps because at some point I may try to see if the weapon was a nade and spend hours trying to figure it out. Now I know to right away to look for some other solution. Your 1 minute post could save me hours in the future.
Thanks!

2) thetwistedpanda
Your replay and link got me the info I need to get the plugin working, all in about an hours time including the initial post of my question! So thanks for the quick reply and help!

3) Powerlord
I was going to ask about this in another post.
So when I get an event passed into Player hurt, what else can I do with the event?
Where are the docs on what I can do with this structure?
The link is a great help! Thanks.
And
I am quickly learning it is better to use SDKHooks when we have the option to do so.
Thanks!

So the code below works great.
When a someone uses an AWP the attacked doesn't take damage and the AWPer ignites for 6 seconds!
Awesome!

I don't want to switch topics, but I need help from people with experience like all of you.
To have a decent bot server with csgo I need to solve one last problem with the new way CSGO limits maxplayers per team.
For GO it is now this bad thing:
(max per team) = (max players/2)

Please if you can check this and let me know if you have a solution.
I have posted in several forums (sourcemod metamod and Steam forums LOL).
Can't have a decent bot server until we fix this.

http://forums.alliedmods.net/showthr...21#post1792521

Last edited by Austin; 09-06-2012 at 17:37.
Austin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-06-2012 , 20:38   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #9

Quote:
Originally Posted by Austin View Post
3) Powerlord
I was going to ask about this in another post.
So when I get an event passed into Player hurt, what else can I do with the event?
Where are the docs on what I can do with this structure?
The link is a great help! Thanks.
And
I am quickly learning it is better to use SDKHooks when we have the option to do so.
Thanks!
Events are usually informative; the server has already processed its logic by then.

You can get specific values from events using GetEventInt, GetEventFloat, GetEventVector, or GetEventString based on what the type of the value is in the event documentation.

You can also create and fire these events from your code; why you'd want to do this varies.

SDKHooks works by detouring functions the game server would call and allowing plugins to add their own hooks to those detours. Depending on the return value from the plugin hook, the game function may be called as normal (Plugin_Continue), called with new values (Plugin_Changed), or not called at all (Plugin_Handled or Plugin_Stop; not sure which).
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-06-2012 at 20:40.
Powerlord is offline
foxhound27
Senior Member
Join Date: Sep 2019
Location: Argentina
Old 04-24-2021 , 23:18   Re: Event_PlayerHurt what weapon did the damage?
Reply With Quote #10

PHP Code:
public Action Event_PlayerHurt(Handle event, const char[] namebool dontBroadcast) {

    
char weapon[16];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    if (
StrEqual(weapon"sniper_awp")) {
        
//HERE YOU GO
        
PrintToChatAll("awp did the damage"); //LOL
    
}
    return 
Plugin_Continue;


Last edited by foxhound27; 04-25-2021 at 09:05.
foxhound27 is offline
Reply


Thread Tools
Display Modes

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 19:41.


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