AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Event_PlayerHurt what weapon did the damage? (https://forums.alliedmods.net/showthread.php?t=195312)

Austin 09-06-2012 03:06

Event_PlayerHurt what weapon did the damage?
 
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;
 } 


GsiX 09-06-2012 03:09

Re: Event_PlayerHurt what weapon did the damage?
 
Yea... check the player active weapon and check what is the weapon...


cheers... i don have CSGO, just bumping.. :)

thetwistedpanda 09-06-2012 04:30

Re: Event_PlayerHurt what weapon did the damage?
 
http://docs.sourcemod.net/api/index....d=show&id=425& if attacker is valid.

Austin 09-06-2012 06:15

Re: Event_PlayerHurt what weapon did the damage?
 
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;



Powerlord 09-06-2012 10:01

Re: Event_PlayerHurt what weapon did the damage?
 
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.

necavi 09-06-2012 14:10

Re: Event_PlayerHurt what weapon did the damage?
 
TwistedPanda: Don't forget that that will NOT work if the damage was done by grenade - they won't have it equipped anymore.

thetwistedpanda 09-06-2012 14:20

Re: Event_PlayerHurt what weapon did the damage?
 
necavi, indeed, but he asked about the awp, so grenades were no where in the equation.

Austin 09-06-2012 17:36

Re: Event_PlayerHurt what weapon did the damage?
 
Quote:

Originally Posted by thetwistedpanda (Post 1792848)
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

Powerlord 09-06-2012 20:38

Re: Event_PlayerHurt what weapon did the damage?
 
Quote:

Originally Posted by Austin (Post 1792972)
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).

foxhound27 04-24-2021 23:18

Re: Event_PlayerHurt what weapon did the damage?
 
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;




All times are GMT -4. The time now is 12:11.

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