Created
May 17, 2018 21:23
-
-
Save jkelin/043487a22a42bf8d23ff20ae182b4339 to your computer and use it in GitHub Desktop.
tribes ChatAdmin mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChatAdmin extends Gameplay.Mutator config(FireMods); | |
var string SelfServerPackage; | |
var string AnticsServerPackage; | |
function PreBeginPlay() | |
{ | |
Log("[ChatAdmin] PreBeginPlay"); | |
super.PreBeginPlay(); | |
SelfServerPackage = "FireMods"; | |
AnticsServerPackage = "antics_v5"; | |
// AddServerPackage(AnticsServerPackage); | |
// AddServerPackage(SelfServerPackage); | |
LoadCharacterController(); | |
} | |
function LoadCharacterController() | |
{ | |
local Gameplay.ModeInfo MI; | |
foreach AllActors(class'Gameplay.ModeInfo', MI) | |
{ | |
if (MI != None) | |
{ | |
MI.PlayerControllerClassName = SelfServerPackage $ ".ChatAdminPlayerCharacterController"; | |
Log("ChatAdminPlayerCharacterController player controller loaded successfully!"); | |
break; | |
} | |
} | |
} | |
defaultproperties | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChatAdminPlayerCharacterController extends Gameplay.PlayerCharacterController; | |
function printCommandForPosterity(bool isAdmin, string command) { | |
local string name; | |
if(isAdmin) { | |
name = "[admin|" $ PlayerReplicationInfo.PlayerName $ "]"; | |
} else { | |
name = "[" $ PlayerReplicationInfo.PlayerName $ "]"; | |
} | |
super.Say("!" $ command); | |
// Following does not seem to work for any other commands than admin | |
// Level.Game.Broadcast(self, name @ command, 'Say'); | |
// MultiplayerGameInfo(Level.Game).Broadcast(Level.Game, name @ command, 'say'); | |
} | |
function bool isCommandAuthorized(string command) { | |
if(command == "get" || command == "set") { | |
return false; | |
} | |
return true; | |
} | |
exec function Admin(string cmd) | |
{ | |
local string cmdCommand; | |
local string cmdLower; | |
local string fullCmd; | |
fullCmd = "admin" @ cmd; | |
cmdLower = Locs(cmd); | |
cmdCommand = Left(cmdLower, InStr(cmdLower, " ")); | |
if (isCommandAuthorized(cmdCommand) && AdminManager != None) { | |
Log("[ChatAdminPlayerCharacterController] Admin command executed" @ cmd); | |
printCommandForPosterity(true, fullCmd); | |
ConsoleCommand(cmd); | |
} | |
} | |
exec function AdminLogin(string usernameAndPassword) { | |
local string username; | |
username = Left(Locs(usernameAndPassword), InStr(Locs(usernameAndPassword), " ")); | |
Log("[ChatAdminPlayerCharacterController] Adminlogin" @ PlayerReplicationInfo.PlayerName @ "as" @ username); | |
if(InStr(Locs(PlayerReplicationInfo.PlayerName), Locs(username)) > -1) { | |
super.AdminLogin(usernameAndPassword); | |
} | |
} | |
exec function Name(coerce string newname) { | |
printCommandForPosterity(false, "name" @ newname); | |
super.AdminLogout(); | |
super.Name(newname); | |
} | |
exec function kickvote(string name) { | |
printCommandForPosterity(false, "kickvote" @ name); | |
super.kickvote(name); | |
} | |
exec function mapvote(string map, string gametype) { | |
super.mapvote(map, gametype); | |
printCommandForPosterity(false, "mapvote" @ map @ gametype); | |
} | |
exec function teamdamagevote(bool vote) { | |
super.teamdamagevote(vote); | |
printCommandForPosterity(false, "teamdamagevote" @ vote); | |
} | |
exec function tournamentvote(bool vote) { | |
super.tournamentvote(vote); | |
printCommandForPosterity(false, "tournamentvote" @ vote); | |
} | |
defaultProperties { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment