Untested. This is from a addon I was writing to hook several tf2 only events and award XP for them but I ran into some trouble and gave up.
#pragma semicolon 1
#include "W3SIncs/War3Source_Interface"
public OnPluginStart()
{
if(War3_GetGame() != Game_TF){
SetFailState("Only works in TF2");
}
else
{
HookEvent("player_chargedeployed", PlantedUber);
}
}
public PlantedUber(Handle:event, const String:name[], bool:dontBroadcast)
{
new medic = GetClientOfUserId(GetEventInt(event, "userid"));
awardEXP(medic, 25);
PrintHintText(medic, "You gained 25 EXP for deploying an uber.");
}
public awardEXP(client, amount)
{
new race = War3_GetRace(client);
new totalXP = War3_GetXP(client, race) + amount;
War3_SetXP(client, race, totalXP);
}
In case anyone wants to pick the full thing up:
#pragma semicolon 1
#include "W3SIncs/War3Source_Interface"
public Plugin:myinfo =
{
name = "War3Source - TF2 EXP Addon",
author = "Ted Theodore Logan",
description = "Give exp for various TF2 only things",
version = "1.0",
};
public OnPluginStart()
{
if(War3_GetGame() != Game_TF){
SetFailState("Only works in TF2");
}
else
{
HookEvent("object_destroyed",ObjectDestroyed);
HookEvent("player_chargedeployed", PlantedUber);
HookEvent("player_upgradedobject", UpgradedBuilding);
HookEvent("player_extinguished", Event_player_extinguished);
}
}
public ObjectDestroyed(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker = GetEventInt(event, "attacker");
new assister = GetEventInt(event, "assister");
new objectType = GetEventInt(event, "objecttype");
new bool:IncompleteStructure = GetEventBool(event, "was_building");
new awarded;
if(ValidPlayer(attacker))
{
switch(objectType)
{
case 0: // Dispenser
{
awarded = 20;
}
case 1: // Teleporter, both entry and exit
{
awarded = 30;
}
case 2: // Sentry
{
awarded = 35;
}
}
if(IncompleteStructure) // Half the exp if it was still in progress
{
awarded = RoundToFloor(awarded / 2.0);
}
awardEXP(attacker, awarded);
awardEXP(assister, awarded);
PrintHintText(attacker, "You gained EXP for destroying a structure!");
PrintHintText(assister, "You gained EXP for assisting in the destruction of a structure!");
}
}
public PlantedUber(Handle:event, const String:name[], bool:dontBroadcast)
{
new medic = GetClientOfUserId(GetEventInt(event, "userid"));
awardEXP(medic, 25);
PrintHintText(medic, "You gained 25 EXP for deploying an uber.");
}
public Event_player_extinguished(Handle:event, const String:name[], bool:dontBroadcast)
{
new healer = GetClientOfUserId(GetEventInt(event, "healer"));
if(ValidPlayer(healer)) // Could also be world
{
awardEXP(healer, 10);
PrintHintText(healer, "You gained 10 EXP for extinguishing a player!");
}
}
public UpgradedBuilding(Handle:event, const String:name[], bool:dontBroadcast)
{
new engineer = GetClientOfUserId(GetEventInt(event, "userid"));
new bool:isbuilder = GetEventBool(event, "isbuilder");
if(!isbuilder)
{
awardEXP(engineer, 10);
PrintHintText(engineer, "You gained 10 EXP for upgrading someone elses structure!");
}
}
public awardEXP(client, amount)
{
new race = War3_GetRace(client);
new totalXP = War3_GetXP(client, race) + amount;
War3_SetXP(client, race, totalXP);
}
http://wiki.alliedmods.net/Team_Fortress_2_Events