Raised This Month: $ Target: $400
 0% 

CS:GO No Drown DMG


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
live4net
AlliedModders Donor
Join Date: Jul 2014
Old 06-09-2015 , 10:58   CS:GO No Drown DMG
Reply With Quote #1

Hi
I'm trying to write a plugin that turns off the damage from drowning. That code does not work. Does anyone have an idea how to fix it?

Code:
public OnClientPutInServer(client)
{
   SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
   SDKHook(client, SDKHook_TraceAttack, TraceAttack);
}

public Action:TraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
if (damagetype == DMG_DROWN || damagetype == DMG_DROWNRECOVER)
   {
       damage = 0.0;
   }
   return Plugin_Continue;
}
__________________

live4net is offline
maningrey
Member
Join Date: Sep 2014
Location: Farswitch Newton 1
Old 06-09-2015 , 11:06   Re: CS:GO No Drown DMG
Reply With Quote #2

Heres a thread that answers your question

https://forums.alliedmods.net/showthread.php?t=70545
maningrey is offline
maningrey
Member
Join Date: Sep 2014
Location: Farswitch Newton 1
Old 06-09-2015 , 11:20   Re: CS:GO No Drown DMG
Reply With Quote #3

Oh sorry thats amx, always gets me.

Code:
#include <sourcemod>
#include <sdkhooks>

public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
	if (damagetype == DMG_DROWN || damagetype == DMG_DROWNRECOVER)
	{
		damage = 0.0;
	}
	
	return Plugin_Changed;
}

Last edited by maningrey; 06-09-2015 at 11:24. Reason: Darkness: You need to return Plugin_Changed if you modify the damage.
maningrey is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 06-09-2015 , 11:23   Re: CS:GO No Drown DMG
Reply With Quote #4

You need to return Plugin_Changed if you modify the damage.
Darkness_ is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-09-2015 , 13:23   Re: CS:GO No Drown DMG
Reply With Quote #5

damagetype is a bitfield...

PHP Code:
if (damagetype & (DMG_DROWN DMG_DROWNRECOVER) > 0)
{
    
damage 0.0
    
return Plugin_Changed;

Edit: Added parentheses to make sure order of execution is correct.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-09-2015 at 13:47.
Powerlord is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 06-09-2015 , 13:55   Re: CS:GO No Drown DMG
Reply With Quote #6

I can't imagine how it'd have DMG_DROWN and something else at the same time
Miu is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-09-2015 , 15:52   Re: CS:GO No Drown DMG
Reply With Quote #7

Quote:
Originally Posted by Miu View Post
I can't imagine how it'd have DMG_DROWN and something else at the same time
*eyes DMG_ACID*

...and that's not even considering DMG_PREVENT_PHYSICS_FORCE, DMG_NEVERGIB, or DMG_REMOVENORAGDOLL.

Incidentally, if you don't like the > 0, you could also put it as != DMG_GENERIC instead.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-09-2015 at 15:57.
Powerlord is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 06-09-2015 , 16:09   Re: CS:GO No Drown DMG
Reply With Quote #8

Quote:
Originally Posted by Powerlord View Post
*eyes DMG_ACID*

...and that's not even considering DMG_PREVENT_PHYSICS_FORCE, DMG_NEVERGIB, or DMG_REMOVENORAGDOLL.
okay, point taken, didn't notice those XD

Quote:
Incidentally, if you don't like the > 0, you could also put it as != DMG_GENERIC instead.
or you could remove it altogether and it'd be shorter and make more sense edit: and work on the highest flag!

Last edited by Miu; 06-09-2015 at 16:18.
Miu 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 11:35.


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