Raised This Month: $ Target: $400
 0% 

Need some help on L4D events


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drow
Junior Member
Join Date: Feb 2009
Old 02-19-2009 , 10:42   Need some help on L4D events
Reply With Quote #1

Trying to make a plugin which pre hooks an event and removes it, but it just won't let me do it. As its a plugin for L4D am using the current 1.2 snapshot. The code is as follows..

Code:
public OnPluginStart()
{
    HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
}
...

Code:
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new userid = GetEventInt(event, "userid");
    new client = GetClientOfUserId(userid);
    if (IsGodMode(client)) {
        PrintCenterText(client, "You actually got hurt, but it got prevented!");
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
Any help would be appreciated!
drow is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-19-2009 , 15:04   Re: Need some help on L4D events
Reply With Quote #2

Returning Plugin_Handled on an event doesn't actually block the actions that trigger the event. To set godmode on a player, do this:
Code:
SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
And to remove it, just do:
Code:
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
A simple stock I use consists of this:
PHP Code:
stock PerformGodMode(client)
{
    if (
GetEntProp(clientProp_Data"m_takedamage"1) == 2)
    {
        
SetEntProp(clientProp_Data"m_takedamage"01);
    }
    else
    {
        
SetEntProp(clientProp_Data"m_takedamage"21);
    }

bl4nk is offline
drow
Junior Member
Join Date: Feb 2009
Old 02-20-2009 , 07:40   Re: Need some help on L4D events
Reply With Quote #3

Well am not really after making god mode, just an example to show the event handling. Would need some info on blocking events from occuring and need to know if it is possible on the L4D snapshot.
But to reply directly to your idea. Its exactly what i am doing now, trying to reset the specific entity property i got from the data maps. This doesnt seem to work as intended, at least not always. Sometimes its working sometimes not. Which made me find a more reliable way and try to prevent the event at all.

Last edited by drow; 02-20-2009 at 09:43.
drow is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-21-2009 , 01:07   Re: Need some help on L4D events
Reply With Quote #4

The thing with L4D is that lots of stuff gets changed where you can/can't take damage, so you'll more than likely have to hook a few events and check to see if they still have god mode enabled on them.
bl4nk is offline
kaffaljidhma
Member
Join Date: Feb 2009
Old 02-21-2009 , 06:25   Re: Need some help on L4D events
Reply With Quote #5

All the events I've used in left 4 dead are for achievement purposes only. Your best bet would be to reverse the changes the event makes, which may require a timer in some cases.
kaffaljidhma 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:14.


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