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

Getting damage done to a player, and changing it (in this case halving it)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NeoDement
Member
Join Date: Mar 2009
Old 09-14-2009 , 13:53   Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #1

Hey, simple question, with HOPEFULLY a simple answer (though I have my doubts)

I want to grab the damage that's about to be done to a player, change it to half of what it was, and then apply it. I also want to replace the fleshy hit sound, but I doubt that's possible.

I thought it was something like OnPlayerHurt or something, but to be honest I haven't done any SourcePawn in ages so I'm not sure what to search for on the API Reference.

Any help is appreciated!

__________________
I'm not being funny but guys, I'm a bit fit, y'know?
NeoDement is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 09-14-2009 , 14:10   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #2

http://wiki.alliedmods.net/Counter-S..._Source_Events

#2 player_hurt

Since that is a game event you'll need to hook it , here's a tutorial on how to do that

http://wiki.alliedmods.net/Events_(SourceMod_Scripting)

If that direct link does not work please check under Sourcemod scripting below for the Events tutorial.

http://wiki.alliedmods.net/Category:SourceMod_Scripting

also you will want to hook the event with the Pre flag like so:

PHP Code:
 
HookEvent
("player_hurt"your_function_name_hereEventHookMode_Pre
Also there is a way to change sounds, although I'm not 100% on how it's done, but try looking under the sdk sound include for features that you could use.

http://docs.sourcemod.net/api/index.php
__________________

Last edited by Peoples Army; 09-14-2009 at 14:15.
Peoples Army is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 09-14-2009 , 14:16   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #3

Using events hooking you can only know that something has happened, but you can't make any changes to it.
When I need to block damage, I use Hacks Extension. I know, there is newer DukeHacks that can do the same thing plus many more, but I'm still fine with Hacks.
So you can block damage by hooking OnTakeDamage function and then do half of it to player in another way.
__________________
Lord Canistra is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 09-14-2009 , 14:20   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #4

I've never used an extension a day in my life.
__________________
Peoples Army is offline
NeoDement
Member
Join Date: Mar 2009
Old 09-14-2009 , 14:27   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #5

Quote:
Originally Posted by Peoples Army View Post
I've never used an extension a day in my life.
Well, I need DuckHacks to perform some other functions to my code ANYWAY, so I'll be fine taking the easy way out and using OnTakeDamage, thanks you two

That is, unless you know how to hide an entitiy for a specific player?
__________________
I'm not being funny but guys, I'm a bit fit, y'know?
NeoDement is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 09-14-2009 , 14:36   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #6

You mean hide as in take away its model?
__________________
Peoples Army is offline
NeoDement
Member
Join Date: Mar 2009
Old 09-14-2009 , 14:44   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #7

Yeah, everyone else can see it, but one player can't.

Or maybe one team, depending on how things go.
__________________
I'm not being funny but guys, I'm a bit fit, y'know?
NeoDement is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 09-14-2009 , 15:01   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #8

Well if you need an extension you can always use one, me personally I like a challenge so I don't like using hacks or any other things like that, but If it accomplishes your goal then by all means use a hack.
__________________
Peoples Army is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 09-14-2009 , 15:05   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #9

Is there a way to block damage without extensions? I'd like to know.
__________________
Lord Canistra is offline
Frus
Senior Member
Join Date: Aug 2009
Old 09-14-2009 , 15:08   Re: Getting damage done to a player, and changing it (in this case halving it)
Reply With Quote #10

Quote:
Originally Posted by Lord Canistra View Post
Is there a way to block damage without extensions? I'd like to know.
You can completely block damage to a player by giving them the FL_GODMODE flag. But as far as reducing damage, you need an extension to do it properly.
Frus 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 19:15.


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