::CONST <- getconsttable() ::ROOT <- getroottable() if (!("ConstantNamingConvention" in ROOT)) { foreach(a, b in Constants) foreach(k, v in b) { CONST[k] <- v != null ? v : 0 ROOT[k] <- v != null ? v : 0 } } CONST.setdelegate({ _newslot = @(k, v) compilestring("const " + k + "=" + (typeof(v) == "string" ? ("\"" + v + "\"") : v))() }) CONST.MAX_CLIENTS <- MaxClients().tointeger() foreach(k, v in ::NetProps.getclass()) if (k != "IsValid" && !(k in ROOT)) ROOT[k] <- ::NetProps[k].bindenv(::NetProps) foreach(k, v in ::Entities.getclass()) if (k != "IsValid" && !(k in ROOT)) ROOT[k] <- ::Entities[k].bindenv(::Entities) foreach(k, v in ::EntityOutputs.getclass()) if (k != "IsValid" && !(k in ROOT)) ROOT[k] <- ::EntityOutputs[k].bindenv(::EntityOutputs) foreach(k, v in ::NavMesh.getclass()) if (k != "IsValid" && !(k in ROOT)) ROOT[k] <- ::NavMesh[k].bindenv(::NavMesh) // Weapon slots const SLOT_PRIMARY = 0 const SLOT_SECONDARY = 1 const SLOT_MELEE = 2 const SLOT_UTILITY = 3 const SLOT_BUILDING = 4 const SLOT_PDA = 5 const SLOT_PDA2 = 6 const SLOT_COUNT = 7 ::CLASSES <- ["", "scout", "sniper", "soldier", "demo", "medic", "heavy", "pyro", "spy", "engineer", "civilian"]; function GetItemInSlot(player, slot) { for (local i = 0; i < SLOT_COUNT; i++) { local wep = GetPropEntityArray(player, "m_hMyWeapons", i) if ( wep == null || wep.GetSlot() != slot) continue return wep; } } function ChangePlayerTeamMVM(player, teamnum) { local gamerules = Entities.FindByClassname(null, "tf_gamerules") NetProps.SetPropBool(gamerules, "m_bPlayingMannVsMachine", false); player.ForceChangeTeam(teamnum, false); NetProps.SetPropBool(gamerules, "m_bPlayingMannVsMachine", true); } function ForceChangeClass(player, classIndex) { player.SetPlayerClass(classIndex); NetProps.SetPropInt(player, "m_Shared.m_iDesiredPlayerClass", classIndex); player.ForceRegenerateAndRespawn(); } ::botmaker <- SpawnEntityFromTable("bot_generator", { "targetname": "_botmaker", "origin": "650 -2800 525", "team": "red", "class": "Scout", "count": "1", "maxActive": "999", "interval": "0", "useTeamSpawnPoint": "false", "spawnOnlyWhenTriggered": "true", "difficulty": "1", }); function SpawnBot(playerid) { local player = EntIndexToHScript(playerid); EntFireByHandle(botmaker, "SpawnBot", "", -1, null, null); EntFireByHandle(botmaker, "RunScriptCode", @" for (local i = 1; i <= MAX_CLIENTS ; i++) { local player = PlayerInstanceFromIndex(i); if (player == null) continue; if (!player.IsBotOfType(1337) || player.GetTeam() != TF_TEAM_RED) continue; local classname = CLASSES[player.GetPlayerClass()]; player.SetCustomModelWithClassAnimations(format(""models/player/%s.mdl"", classname)); } ", 0.015, null, null); } function Switch() { local j = 0; for (local i = 1; i <= MAX_CLIENTS ; i++) { local player = PlayerInstanceFromIndex(i); if (player == null) continue; if (!player.IsBotOfType(1337) || player.GetTeam() != TEAM_SPECTATOR) continue; ChangePlayerTeamMVM(player, TF_TEAM_RED); ForceChangeClass(player, TF_CLASS_SCOUT) ++j; if (j > 30) break } }