Raised This Month: $ Target: $400
 0% 

Get Damage in TF2


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
mtrxsol
Junior Member
Join Date: Jan 2008
Old 01-11-2008 , 05:23   Re: Get Damage in TF2
Reply With Quote #6

Quote:
Originally Posted by ferret View Post
Look in the hl2 folder. SourceMods have a search path. They first check the mod's folder (Ie, "tf", "cstrike"), then fall into the default hl2 folder. The HL2 folders also have a modevents.res, and its loaded as well.

If TF2's modevents.res doesn't have player_hurt, then it's coming from the hl2 copy of modevents.res
The events you are mentioning are there in gameevents.res file in hl2 dir. Still my plugin is unable to handle the events. The code is as follows, can you suggest me what's wrong with the code. The code is getting compiled well without any error.

Is there any other setting for hooking hl2 events anywhere in the game's config files.


HTML Code:
/* Plugin Template generated by Pawn Studio */

#include <sourcemod>

#define MAX_DATA 255

public Plugin:myinfo = 
{
    name = "Game Events",
    author = "mtrxsol",
    description = "<- Description ->",
    version = "1.0",
    url = "<- URL ->"
}

public OnPluginStart()
{
    LogMessage("Game Events Plugin Started");
    
    // Game events
    HookEvent("game_init",GameInitEvent);
    HookEvent("game_start",GameStartedEvent);
    HookEvent("round_start",RoundStartEvent);
    HookEvent("round_end",RoundEndEvent);
    HookEvent("game_end",GameEndEvent);
    
    // Player death event
    HookEvent("player_death",PlayerDeathEvent);
}

public GameInitEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    LogToGame("@MSG$1$Game Init@");
}

public GameStartedEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    new nRoundsLimit    = GetEventInt(event,"roundslimit");
    new nTimeLimit         = GetEventInt(event,"timelimit");
    new nFragLimit         = GetEventInt(event,"fraglimit");
    
    decl String:strObjective[MAX_DATA];
    decl String:strLogData[MAX_DATA];
    
    GetEventString(event,"objective",strObjective,sizeof(strObjective));
    
    Format(strLogData,sizeof(strLogData),"@MSG$2$Game Started$RoundsLimit = %d$TimeLimit = %d$FragLimit = %d$Objective = %s@",
        nRoundsLimit,nTimeLimit,nFragLimit,strObjective);
        
    LogToGame(strLogData);
}

public RoundStartEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    new nTimeLimit    = GetEventInt(event,"timelimit");
    new nFragLimit     = GetEventInt(event,"fraglimit");
    
    decl String:strObjective[MAX_DATA];
    decl String:strLogData[MAX_DATA];
    
    GetEventString(event,"objective",strObjective,sizeof(strObjective));
    
    Format(strLogData,sizeof(strLogData),"@MSG$3$Round Started$TimeLimit = %d$FragLimit = %d$Objective = %s@",
        nTimeLimit,nFragLimit,strObjective);
        
    LogToGame(strLogData);
}

public RoundEndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    new nWinnerID    = GetEventInt(event,"winner");
    new nReason     = GetEventInt(event,"reason");
    
    decl String:strMessage[MAX_DATA];
    decl String:strLogData[MAX_DATA];
    
    GetEventString(event,"message",strMessage,sizeof(strMessage));
    
    Format(strLogData,sizeof(strLogData),"@MSG$4$Round End$WinnerID = %d$Reason = %d$Message = %s@",
        nWinnerID,nReason,strMessage);
        
    LogToGame(strLogData);
}

public GameEndEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    new nWinnerID = GetEventInt(event,"winner");
    LogToGame("@MSG$5$Game End$WinnerID = %d@",nWinnerID);
}

public PlayerDeathEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    decl String:strUserDied[MAX_NAME_LENGTH];
    decl String:strUserKilled[MAX_NAME_LENGTH];
    decl String:strUserAssisted[MAX_NAME_LENGTH];
    decl String:strLogData[MAX_DATA];
        
    // Id of the player who died
    new nUserDied     = GetEventInt(event,"userid");
    
    if( nUserDied != 0 )
    {
        GetClientName(GetClientUserId(nUserDied),strUserDied,sizeof(strUserDied));
    }
    
    // Id of the player who killed
    new nUserKilled = GetEventInt(event,"attacker");
    
    if( nUserKilled != 0 )
    {
        GetClientName(GetClientUserId(nUserKilled),strUserKilled,sizeof(strUserKilled));
    }
    
    // Weapon name used to kill
    decl String:strWeapon[MAX_DATA];
    GetEventString(event,"weapon",strWeapon,sizeof(strWeapon));    
    
    // Damage bits
    new nDamageBits = GetEventInt(event,"damagebits");
    
    // Type of custom kill
    new nCustomKillType = GetEventInt(event,"customkill");
    
    // Id of the player who assisted
    new nUserAssisted = GetEventInt(event,"assister");
    
    if( nUserAssisted != 0 )
    {
        GetClientName(GetClientUserId(nUserAssisted),strUserAssisted,sizeof(strUserAssisted));
    }
    
    // Did killer dominate victim with this kill
    new nKillerDominated = GetEventInt(event,"dominated");
    
    // Did assister dominate victim with this kill
    new nAssisterDominated = GetEventInt(event,"assister_dominated");
    
    // Did killer get revenge on victim with this kill
    new nKillerRevenge = GetEventInt(event,"revenge");
    
    // Did assister get revenge on victim with this kill
    new nAssisterRevenge = GetEventInt(event,"assister_revenge");
    
    // TODO: Log message to c# engine
    Format(strLogData,sizeof(strLogData),"@MSG$2$Died=%s$Killer=%s$Assister=%s$Weapon=%s$KillerDominated=%d$AssisterDominated=%d$KillerRevenge=%d$AssisterRevenge=%d",
        strUserDied,
        strUserKilled,
        strUserAssisted,
        strWeapon,
        nKillerDominated,
        nAssisterDominated,
        nKillerRevenge,
        nAssisterRevenge);
    LogToGame(strLogData);
}
mtrxsol 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 21:48.


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