Raised This Month: $ Target: $400
 0% 

[Snippet] TF2 Damage


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 07-15-2008 , 10:53   [Snippet] TF2 Damage
Reply With Quote #1

Yet another snippet I know this has been posted before by naris, but it had all these unnecessary files and stocks, so I made a shorter one a while back (just in case I'd ever need it), and now I'm posting it here Enjoy.
Code:
#include <sourcemod> #include <sdktools> new g_iHealth[MAXPLAYERS + 1]; new g_iMaxClients; public OnPluginStart() {     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 OnMapStart() {     g_iMaxClients        = GetMaxClients(); } public EntityOutput_SaveHealth(const String:output[],    caller, activator, Float:delay) {     g_iHealth[activator] = GetClientHealth(activator); } public EntityOutput_SaveHealthAll(const String:output[], caller, activator, Float:delay) {     for (new i = 1; i <= g_iMaxClients; 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")),         iHealth = GetEventInt(event, "health");         PrintToChat(iClient, "Damage: %d", g_iHealth[iClient] - iHealth);         g_iHealth[iClient]   = iHealth; } public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)   {     CreateTimer(0.1, Timer_SaveHealth, GetClientOfUserId(GetEventInt(event, "userid"))); } public Action:Timer_SaveHealth(Handle:timer, any:client) {     g_iHealth[client]    = GetClientHealth(client); }
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 07-18-2008 at 18:24.
DJ Tsunami is offline
 



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 18:12.


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