Community Contributions
< Team Fortress 2 | Scripting
Jump to navigation
Jump to search


This page contains code contributions and tips from the TF2Maps.net Discord for VScript in
Team Fortress 2

Hooks
Some of these contributions are Hooks or Game events, learn Here on how to listen to them.
Script List
Name | Description | Usage | Code |
---|---|---|---|
Change Halloween Scenario | Allows to enable hardcoded stuff from specific halloween maps anywhere else. Check this list for all of them
Scenarios
![]() |
Run the following code on tf_gamerules. | NetProps.SetPropInt(self, "m_halloweenScenario", 0-5)
|
Health gain on HUD | Show to a player a custom amount of gained HP ![]()
|
Call the following event, specifying who is the player. | SendGlobalGameEvent("player_healonhit", {
entindex = player.entindex(),
amount = healAmount
});
|
Add or Remove score in RD/PD Destruction (Player and Objective less) | This is so far the only way to change the score if the base gamemode is used differently than his original intent. | Run this script anywhere, and call the two Functions. |
Contents
local logic_destruction = Entities.FindByClassname(null, "tf_logic_player_destruction")
::ScorePoints <- function(team, killscore)
{
//Score Points by using a dummy flag and send it -Burguers
printl("Added: " + killscore)
FlagDummy <- SpawnEntityFromTable("item_teamflag", {
TeamNum = team,
PointValue = killscore,
GameType = 5,
trail_effect = 0,
})
FlagDummy.AcceptInput("RoundActivate", "!self", null, null)
FlagDummy.Kill()
}
::RemovePoints <- function(team, killscore)
{
local currentScore = NetProps.GetPropInt(logic_destruction,team == 2 ? "m_nRedScore" : "m_nBlueScore");
local newScore = currentScore - killscore;
printl("Current Score: " + currentScore)
RemoverFlag <- SpawnEntityFromTable("item_teamflag", {
TeamNum = team,
GameType = 5,
trail_effect = 0,
})
//This Sets the points to 0 caused by an overflow, then deliver a new ammount by calling the scoring above
if (currentScore != 0)
{
RemoverFlag.KeyValueFromString("PointValue", "4294967295")
RemoverFlag.AcceptInput("RoundActivate", "!self", null, null)
RemoverFlag.Kill()
if (newScore > 0)
CG_ScorePoints(team, newScore)
}
}
|
Hook ↑ Changing Killicon | Force to display custom killicons if the user died to something specific, by spawning a dummy entity and changing his classname. ![]() |
myCustomInflictor <- SpawnEntityFromTable("info_target", { classname = "bumper_kart" }); //Replace "bumper_kart" with the kill icon you want to use
OnScriptHook_OnTakeDamage = function(params)
{
if (/* insert your condition */)
params.inflictor = myCustomInflictor;
}
|