Examples/A_tiny_team_deathmatch
content.xml - two classes, one per team (palette colour 1 = red, 3 = blue from the sample palette):
<colour r="150" g="150" b="150" a="255"/> <!-- index 0 (grey) -->
<colour r="255" g="0" b="0" a="0"/> <!-- index 1 (red) -->
<colour r="0" g="255" b="0" a="0"/> <!-- index 2 (green) -->
<colour r="0" g="0" b="255" a="0"/> <!-- index 3 (blue) -->
<class team="1" skin="0" colour="1" x="820.0" y="-930.0" z="36.0" angle="90" sscreen="0"/>
<class team="2" skin="1" colour="3" x="780.0" y="-930.0" z="36.0" angle="270" sscreen="0"/>
<script folder="Main" />Server.nut
teamScore <- [0, 0, 0]; // global; index 1 and 2 are used
function onScriptLoad()
{
SetTime(12, 0);
SetWeather(0);
CreateVehicle(VEH_BANSHEE, Vector(800.0, -935.0, 36.0), 0.0, -1, -1);
NewTimer("AnnounceScores", 60000, 0); // every minute, forever
}
function AnnounceScores()
{
Message("Red " + teamScore[1] + " - Blue " + teamScore[2]);
}
function onPlayerSpawn(player, classID)
{
player.Health = 100.0;
player.Armour = 50.0;
player.SetWeapon(WEP_COLT45, 100);
player.SetWeapon(WEP_UZI, 200);
player.Nametag = true;
player.Marker = true;
}
function onPlayerKill(killer, victim, weapon, bodypart)
{
if (killer.ID == victim.ID) return; // suicide
if (killer.Team == victim.Team) { killer.Score = killer.Score - 1; return; }
killer.Score = killer.Score + 1;
teamScore[killer.Team] = teamScore[killer.Team] + 1;
killer.Cash = killer.Cash + 500;
local text = killer.Name + " killed " + victim.Name + " with " + GetWeaponName(weapon);
if (bodypart == BODYPART_HEAD) text = text + " (headshot)";
Message(text);
}
function onPlayerChat(player, message)
{
// block shouting
if (message == message.toupper() && message.len() > 6)
{
MessagePlayer("Please do not shout.", player, Colour(255, 80, 80));
return false; // swallow it
}
return true;
}Categories: Worked examples