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

[Snippet] TF2 Damage


Post New Thread Reply   
 
Thread Tools Display Modes
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-18-2008 , 18:19   Re: [Snippet] TF2 Damage
Reply With Quote #11

Well, LDuke indirectly gave me the idea of hooking OnAnimationBegun on the resupply locker's model. This unfortunately doesn't send who touched the locker, so I'm forced to loop through all the clients and save their health. Not perfect, but it works. The new code is in the first post. I'm still interested though if anyone knows of a better way to do the lockers. LDuke is also looking for a way, and he needs to know who touched the locker.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 02-05-2009 , 16:06   Re: [Snippet] TF2 Damage
Reply With Quote #12

This wasn't working if the player was a medic (regen) or they were healed by a dispenser so I updated it.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
new g_iHealth[MAXPLAYERS+1];
new 
g_condOffset;
public 
OnPluginStart() {
    
g_condOffset FindSendPropInfo("CTFPlayer""m_nPlayerCond");
    
HookEntityOutput("item_healthkit_small""OnPlayerTouch"EntityOutput_SaveHealth);
    
HookEntityOutput("item_healthkit_medium""OnPlayerTouch"EntityOutput_SaveHealth);
    
HookEntityOutput("item_healthkit_full""OnPlayerTouch"EntityOutput_SaveHealth);
    
HookEntityOutput("prop_dynamic""OnAnimationBegun"EntityOutput_SaveHealthAll);
    
HookEvent("player_hurt"Event_PlayerHurt);
    
HookEvent("player_spawn"Event_PlayerSpawn);
}
public 
OnGameFrame() {
    for(new 
i=1;i<=MaxClients;i++) {
        if(
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i)>1) {
            new 
cond GetEntData(ig_condOffset);
            if(
cond 8192 || cond 32768 || TF2_GetPlayerClass(i)==TFClass_Medic) {
                
g_iHealth[i] = GetClientHealth(i);
            }
        }
    }
}
public 
EntityOutput_SaveHealth(const String:output[],    calleractivatorFloat:delay) {
    
g_iHealth[activator] = GetClientHealth(activator);
}
public 
EntityOutput_SaveHealthAll(const String:output[], calleractivatorFloat:delay) {
    for(new 
i=1;i<=MaxClients;i++) {
        if(
IsClientInGame(i) && !IsClientObserver(i)) {
            
g_iHealth[i] = GetClientHealth(i);
        }
    }
}
public 
Action:Event_PlayerHurt(Handle:event,  const String:name[], bool:dontBroadcast) {
    new 
iClient GetClientOfUserId(GetEventInt(event"userid"));
    new 
iHealth GetEventInt(event"health");
    
PrintToChatAll("Damage: %i"g_iHealth[iClient]-iHealth);
    
g_iHealth[iClient] = iHealth;
}
public 
Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) {
    
CreateTimer(0.01Timer_SaveHealthGetClientOfUserId(GetEventInt(event"userid")));
}
public 
Action:Timer_SaveHealth(Handle:timerany:client) {
    
g_iHealth[client] = GetClientHealth(client);


Last edited by MikeJS; 02-06-2009 at 15:22. Reason: fixed
MikeJS is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 02-14-2009 , 06:05   Re: [Snippet] TF2 Damage
Reply With Quote #13

Ouch, OnGameFrame That kind of defeats the whole purpose of hooking those events and outputs, you could just save their health every frame and be done. It would just be way more expensive.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 02-14-2009 , 07:45   Re: [Snippet] TF2 Damage
Reply With Quote #14

It would probably be faster to just get everyone's health in OnGameFrame than what I do now
MikeJS is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 02-14-2009 , 18:13   Re: [Snippet] TF2 Damage
Reply With Quote #15

I do appreciate you trying to fix it though, just like I forgot about healthpacks and the lockers in the first version, I didn't think about the medic and dispenser either :/
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 05-14-2009 , 10:09   Re: [Snippet] TF2 Damage
Reply With Quote #16

With the help of Fyren, I made a plugin that allows other plugins to get damage dealt by an attack.
Attached Files
File Type: sp Get Plugin or Get Source (tf2damage.sp - 591 views - 2.4 KB)
File Type: inc tf2damage.inc (496 Bytes, 147 views)
File Type: sp Get Plugin or Get Source (hitblip.sp - 133 views - 428 Bytes)
File Type: sp Get Plugin or Get Source (noselfdmg.sp - 136 views - 207 Bytes)
File Type: sp Get Plugin or Get Source (midair.sp - 118 views - 1.3 KB)
__________________

Last edited by MikeJS; 05-16-2009 at 14:45.
MikeJS is offline
CrancK
Senior Member
Join Date: Jan 2009
Location: Netherlands
Old 05-22-2009 , 05:20   Re: [Snippet] TF2 Damage
Reply With Quote #17

nvm, been said before... stupid me 0.o
CrancK 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:37.


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