Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <sourcemod>
- #include <tf2>
- #include <colors>
- #define RED 0
- #define BLU 1
- #define TEAM_OFFSET 2
- //Logging-related variables
- new bool:isPaused;
- new String:sLogFileDir[64];
- new String:sLogFileName[64];
- //Demo-related variables
- new bool:teamReadyState[2] = { false, false };
- new bool:recordOnRestart = false;
- new bool:recording = false;
- new String:sDemoFileDir[64];
- new String:sDemoFileName[64];
- //Non demo/log related variables
- new redCapTotal = 0;
- new blueCapTotal = 0;
- new Handle:g_hPassword = INVALID_HANDLE;
- public Plugin:myinfo =
- {
- name = "tf2comp",
- author = "Krysk",
- description = "Automates scrimming!",
- version = "0.1",
- url = "http://cohencraven.com/tf2comp"
- };
- //Sourcemod stock commands
- public OnPluginStart()
- {
- // Logging Game Events
- HookEvent("item_pickup", Event_ItemPickup);
- HookEvent("player_hurt", Event_PlayerHurt);
- HookEvent("player_healed", Event_PlayerHealed);
- HookEvent("player_spawn", Event_PlayerSpawned);
- HookEvent("player_death", Event_PlayerDeath);
- HookEvent("medic_death", Event_MedicDeath);
- HookEvent("player_builtobject", Event_BuiltObject);
- HookEvent("teamplay_point_captured", Event_PointCaptured);
- HookEvent("player_chargedeployed", Event_ChargeDeployed);
- HookEvent("teamplay_round_win", Event_RoundWon);
- AddCommandListener(Listener_Pause, "pause");
- // Demo events
- HookEvent("tournament_stateupdate", TeamStateEvent);
- HookEvent("teamplay_restart_round", GameRestartEvent);
- HookEvent("teamplay_game_over", GameOverEvent);
- HookEvent("tf_game_over", GameOverEvent);
- RegServerCmd("mp_tournament_restart", TournamentRestartHook);
- // Chat Listeners
- AddCommandListener(Event_Player_Say, "say");
- AddCommandListener(Event_Player_Say, "say2");
- AddCommandListener(Event_Player_Say_Team, "say_team");
- //Admin Commands
- RegAdminCmd("pass", Command_ChangePassword, ADMFLAG_GENERIC);
- //Console Commands
- RegConsoleCmd("getpass", Command_GetPassword, "Returns the current server password");
- RegConsoleCmd("getstring", Command_GetString, "Returns the connect string to the client");
- }
- public OnMapStart()
- {
- // Demos
- ResetVariables();
- // Check every 30secs if there are still players on the server
- CreateTimer(30.0, CheckPlayers, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
- }
- // LOGGING EVENTS
- /*
- * Listener_Pause: Called whenever the game is paused
- * client: the clientID that issued the command
- * command: the command that was triggered
- * argc: the arguments of the command
- */
- public Action:Listener_Pause(client, const String:command[], argc)
- {
- isPaused = !isPaused;
- if (isPaused)
- Log("World triggered \"Game_Paused\"");
- else
- Log("World triggered \"Game_Unpaused\"");
- return Plugin_Continue;
- }
- /*
- * Event_ItemPickup: Called whenever an item is picked up
- * event: item_pickup
- * name: the name of the event
- * dontBroadcast: broadcast ehe event to the server
- */
- public Event_ItemPickup(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:playerName[32];
- decl String:playerSteamId[64];
- decl String:playerTeam[64];
- decl String:item[64];
- decl String:message[256];
- new playerId = GetEventInt(event, "userid");
- new player = GetClientOfUserId(playerId);
- GetClientAuthString(player, playerSteamId, sizeof(playerSteamId));
- GetClientName(player, playerName, sizeof(playerName));
- playerTeam = GetPlayerTeam(GetClientTeam(player));
- GetEventString(event, "item", item, sizeof(item));
- PrintToChatAll("\"%s<%d><%s><%s>\" picked up item \"%s\"", playerName, playerId, playerSteamId, playerTeam, item);
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" picked up item \"%s\"", playerName, playerId, playerSteamId, playerTeam, item);
- Log(message);
- }
- /*
- * Event_PlayerHealed: Called whenever a player is healed.
- * event: player_healed
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_PlayerHealed(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:patientName[32];
- decl String:healerName[32];
- decl String:patientSteamId[64];
- decl String:healerSteamId[64];
- decl String:patientTeam[64];
- decl String:healerTeam[64];
- decl String:message[256];
- new patientId = GetEventInt(event, "patient");
- new healerId = GetEventInt(event, "healer");
- new patient = GetClientOfUserId(patientId);
- new healer = GetClientOfUserId(healerId);
- new amount = GetEventInt(event, "amount");
- GetClientAuthString(patient, patientSteamId, sizeof(patientSteamId));
- GetClientName(patient, patientName, sizeof(patientName));
- GetClientAuthString(healer, healerSteamId, sizeof(healerSteamId));
- GetClientName(healer, healerName, sizeof(healerName));
- patientTeam = GetPlayerTeam(GetClientTeam(patient));
- healerTeam = GetPlayerTeam(GetClientTeam(healer));
- PrintToChatAll("\"%s<%d><%s><%s>\" triggered \"healed\" against \"%s<%d><%s><%s>\" (healing \"%d\")", healerName, healerId, healerSteamId, healerTeam, patientName, patientId, patientSteamId, patientTeam, amount);
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" triggered \"healed\" against \"%s<%d><%s><%s>\" (healing \"%d\")", healerName, healerId, healerSteamId, healerTeam, patientName, patientId, patientSteamId, patientTeam, amount);
- Log(message);
- }
- /*
- * Event_PlayerHurt: Called whenever a player is hurt
- * event: player_hurt
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:clientname[32];
- decl String:steamid[64];
- decl String:team[64];
- decl String:message[256];
- new userid = GetClientOfUserId(GetEventInt(event, "userid"));
- new attackerid = GetEventInt(event, "attacker");
- new attacker = GetClientOfUserId(attackerid);
- new damage = GetEventInt(event, "damageamount");
- if(userid != attacker && attacker != 0)
- {
- GetClientAuthString(attacker, steamid, sizeof(steamid));
- GetClientName(attacker, clientname, sizeof(clientname));
- team = GetPlayerTeam(GetClientTeam(attacker));
- PrintToChatAll("\"%s<%d><%s><%s>\" triggered \"damage\" (damage \"%d\")", clientname, attackerid, steamid, team, damage);
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" triggered \"damage\" (damage \"%d\")", clientname, attackerid, steamid, team, damage);
- }
- }
- /*
- * Event_PlayerSpawned: Called whenever a player spawns
- * event: player_spawn
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_PlayerSpawned(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:clientname[32];
- decl String:steamid[64];
- decl String:team[64];
- decl String:message[256];
- new String:classes[10][64] = {"undefined", "scout", "sniper", "soldier", "demoman", "medic", "heavyweapons", "pyro", "spy", "engineer" };
- new user = GetClientOfUserId(GetEventInt(event, "userid"));
- new clss = GetEventInt(event, "class");
- GetClientAuthString(user, steamid, sizeof(steamid));
- GetClientName(user, clientname, sizeof(clientname));
- team = GetPlayerTeam(GetClientTeam(user));
- PrintToChatAll("\"%s<%d><%s><%s>\" spawned as \"%s\"", clientname, user, steamid, team, classes[clss]);
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" spawned as \"%s\"", clientname, user, steamid, team, classes[clss]);
- }
- /*
- * Event_PlayerDeath: Called whenever a player dies
- * event: player_death
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:attackername[32];
- decl String:victimname[32];
- decl String:weapon[32];
- decl String:attackerid[64];
- decl String:victimid[64];
- decl String:attackerteam[64];
- decl String:victimteam[64];
- decl String:message[256];
- new victim = GetClientOfUserId(GetEventInt(event, "userid"));
- new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- GetEventString(event, "weapon", weapon, sizeof(weapon));
- GetClientAuthString(attacker, attackerid, sizeof(attackerid));
- GetClientAuthString(victim, victimid, sizeof(victimid));
- GetClientName(attacker, attackername, sizeof(attackername));
- GetClientName(victim, victimname, sizeof(victimname));
- attackerteam = GetPlayerTeam(GetClientTeam(attacker));
- victimteam = GetPlayerTeam(GetClientTeam(victim));
- PrintToChatAll("\"%s<%d><%s><%s>\" \"killed\" \"%s<%d><%s><%s>\" with weapon (\"%s\")", attackername, attacker, attackerid, attackerteam, victimname, victim, victimid, victimteam, weapon);
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" \"killed\" \"%s<%d><%s><%s>\" with weapon (\"%s\")", attackername, attacker, attackerid, attackerteam, victimname, victim, victimid, victimteam, weapon);
- Log(message);
- new assister = GetEventInt(event, "assister");
- PrintToChatAll("assister id: %s", assister);
- if (assister != -1)
- {
- decl String:assistername[32];
- decl String:assisterid[64];
- decl String:assisterteam[64];
- decl String:assMessage[256];
- GetClientAuthString(assister, assisterid, sizeof(assisterid));
- GetClientName(assister, assistername, sizeof(assistername));
- assisterteam = GetPlayerTeam(GetClientTeam(assister));
- Format(assMessage, sizeof(assMessage), "\"%s<%d><%s><%s>\" triggered \"kill_assist\" against \"%s<%d><%s><%s>\"", assistername, assister, assisterid, assisterteam, victimname, victim, victimid, victimteam);
- }
- }
- /*
- * Event_ChargeDeployed: Called whenever a medic uber charges
- * event: player_chargedeployed
- * name: name of thet event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_ChargeDeployed(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:medicname[32];
- decl String:medicid[64];
- decl String:medicteam[64];
- decl String:message[256];
- decl String:targetname[32];
- decl String:targetid[64];
- decl String:targetteam[64];
- new medic = GetEventInt(event, "userid");
- new target = GetEventInt(event, "targetid");
- GetClientAuthString(medic, medicid, sizeof(medicid));
- GetClientName(medic, medicname, sizeof(medicname));
- medicteam = GetPlayerTeam(GetClientTeam(medic));
- GetClientAuthString(target, targetid, sizeof(targetid));
- GetClientName(target, targetname, sizeof(targetname));
- targetteam = GetPlayerTeam(GetClientTeam(target));
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" triggered \"charge_deployed\" against \"%s<%d><%s><%s>\"", medicname, medic, medicid, medicteam, targetname, target, targetid, targetteam);
- }
- /*
- * Event_PointCaptured: Called whenever a point is captured
- * event: teamplay_point_captured
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_PointCaptured(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:pointname[32];
- decl String:cappers[32];
- decl String:capteam[64];
- decl String:message[256];
- GetEventString(event, "cpname", pointname, sizeof(pointname));
- GetEventString(event, "cappers", cappers, sizeof(cappers));
- new team = GetEventInt(event, "team");
- capteam = GetPlayerTeam(team);
- Format(message, sizeof(message), "%s captured point: %s", capteam, pointname);
- PrintToChatAll(message);
- PrintToChatAll(cappers);
- }
- /*
- * Event_MedicDeath: Called whenever a medic dies
- * event: medic_death
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_MedicDeath(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:attackername[32];
- decl String:victimname[32];
- decl String:attackerid[64];
- decl String:victimid[64];
- decl String:attackerteam[64];
- decl String:victimteam[64];
- decl String:haduber[4];
- decl String:message[256];
- new bool:uber = GetEventBool(event, "charged");
- new victim = GetClientOfUserId(GetEventInt(event, "userid"));
- new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- new healingtotal = GetEventInt(event, "healing");
- GetClientAuthString(attacker, attackerid, sizeof(attackerid));
- GetClientAuthString(victim, victimid, sizeof(victimid));
- GetClientName(attacker, attackername, sizeof(attackername));
- GetClientName(victim, victimname, sizeof(victimname));
- attackerteam = GetPlayerTeam(GetClientTeam(attacker));
- victimteam = GetPlayerTeam(GetClientTeam(victim));
- haduber = (uber == true) ? "1" : "0";
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" triggered \"medic_death\" against \"%s<%d><%s><%s>\" (healing \"%d\") (ubercharge \"%s\")", attackername, attacker, attackerid, attackerteam, victimname, victim, victimid, victimteam, healingtotal, haduber);
- Log(message);
- }
- /*
- * Log: Logs the message to the current log file
- * message: the message to log
- */
- public Log(String:message[])
- {
- // Logging
- new String:date[16];
- FormatTime(date, sizeof(date), "%Y-%m-%d");
- Format(sLogFileDir, sizeof(sLogFileDir), "logs/%s/", date);
- Format(sDemoFileDir, sizeof(sDemoFileDir), "demos/%s/", date);
- if (!DirExists(sLogFileDir))
- {
- CreateDirectory(sLogFileDir, 511);
- }
- if (!DirExists(sDemoFileDir))
- {
- CreateDirectory(sDemoFileDir, 511);
- }
- if (recording)
- {
- LogToGame(message);
- }
- PrintToChatAll(message);
- }
- /*
- * Event_Player_Say: Called whenever a player writes a message to team
- * client: the client id of who trigered the command
- * command: the command that was triggered
- * argc: the argument length
- */
- public Action:Event_Player_Say(client, const String:command[], argc)
- {
- decl String:logmessage[256];
- decl String:message[256];
- decl String:clientname[64];
- decl String:clientid[32];
- decl string:clientteam[64];
- GetCmdArg(1, message, sizeof(message));
- GetClientAuthString(client, clientid, sizeof(clientid));
- GetClientName(client, clientname, sizeof(clientname));
- clientteam = GetPlayerTeam(GetClientTeam(client));
- Format(logmessage, sizeof(logmessage), "\"%s<%d><%s><%s>\" triggered \"say\" (message \"%s\")", clientname, client, clientid, clientteam, message);
- Log(logmessage);
- }
- /*
- * Event_Player_Say_Team: Called whenever a player writes a message to team
- * client: the client id of who trigered the command
- * command: the command that was triggered
- * argc: the argument length
- */
- public Action:Event_Player_Say_Team(client, const String:command[], argc)
- {
- decl String:logmessage[256];
- decl String:message[256];
- decl String:clientname[64];
- decl String:clientid[32];
- decl string:clientteam[64];
- GetCmdArg(1, message, sizeof(message));
- GetClientAuthString(client, clientid, sizeof(clientid));
- GetClientName(client, clientname, sizeof(clientname));
- clientteam = GetPlayerTeam(GetClientTeam(client));
- Format(logmessage, sizeof(logmessage), "\"%s<%d><%s><%s>\" triggered \"say_team\" (message \"%s\")", clientname, client, clientid, clientteam, message);
- Log(logmessage);
- }
- /*
- * Event_BuiltObject: Called whenever an object is built
- * event: player_builtobject
- * name: the name of the event
- * dontBroadcast: broadcast the event to the server
- */
- public Event_BuiltObject(Handle:event, const String:name[], bool:dontBroadcast)
- {
- decl String:buildername[64];
- decl String:builderid[32];
- decl String:builderteam[64];
- decl String:objectname[64];
- decl String:message[256];
- new userid = GetEventInt(event, "userid");
- new objectid = GetEventInt(event, "object");
- GetClientAuthString(userid, builderid, sizeof(builderid));
- GetClientName(userid, buildername, sizeof(buildername));
- builderteam = GetPlayerTeam(GetClientTeam(userid));
- switch(objectid)
- {
- case 0:
- {
- objectname = "obj_dispenser";
- }
- case 1:
- {
- objectname = "obj_teleporter";
- }
- case 2:
- {
- objectname = "obj_sentry";
- }
- default:
- {
- objectname = "obj_null";
- }
- }
- PrintToChatAll("\"%s<%d><%s><%s>\" triggered \"built_object\" (object \" %s \")", buildername, userid, builderid, builderteam, objectname);
- Format(message, sizeof(message), "\"%s<%d><%s><%s>\" triggered \"built_object\" (object \" %s \")", buildername, userid, builderid, builderteam, objectname);
- Log(message);
- }
- String:GetPlayerTeam(teamIndex)
- {
- decl String:team[64];
- switch (teamIndex)
- {
- case 2:
- team = "Red";
- case 3:
- team = "Blue";
- default:
- team = "undefined";
- }
- return team;
- }
- //DEMO EVENTS (re: MatchRecorder)
- /*
- * TeamStateEvent: called whenever a change is made to the team (name/ready)
- * event: tournament_stateupdate
- * name: name of the event
- * dontBroadcast: whether or not to broadcast to the server
- */
- public TeamStateEvent(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new team = GetClientTeam(GetEventInt(event, "userid")) - TEAM_OFFSET;
- new bool:nameChange = GetEventBool(event, "namechange");
- new bool:readyState = GetEventBool(event, "readystate");
- if (!nameChange)
- {
- teamReadyState[team] = readyState;
- // If both teams are ready wait for round restart to start recording
- if (teamReadyState[RED] && teamReadyState[BLU])
- {
- recordOnRestart = true;
- }
- else
- {
- recordOnRestart = false;
- }
- }
- }
- /*
- * GameRestartEvent: Called whenever the tournament is being reset
- * event: teamplay_restart_round
- * name: name of the event
- * dontBroadcast: broadcast to the server
- */
- public GameRestartEvent(Handle:event, const String:name[], bool:dontBroadcast)
- {
- // Start recording only if both team are in ready state
- if (recordOnRestart)
- {
- StartRecording();
- recordOnRestart = false;
- teamReadyState[RED] = false;
- teamReadyState[BLU] = false;
- }
- }
- /*
- * GameOverEvent: called when a match has been won
- * event: teamplay_game_over and tf_game_over
- * name: name of the event
- * dontBroadcast: broadcast to the server
- */
- public GameOverEvent(Handle:event, const String:name[], bool:dontBroadcast)
- {
- StopRecording();
- new String:sRedMessage[32];
- new String:sMapMessage[64];
- new String:sBlueMessage[32];
- new String:sRedCaps[32];
- new String:sBlueCaps[32];
- new String:sRedTeamName[8];
- new String:sBlueTeamName[8];
- new String:sCurrentMap[64];
- GetConVarString(FindConVar("mp_tournament_redteamname"), sRedTeamName, sizeof(sRedTeamName));
- GetConVarString(FindConVar("mp_tournament_blueteamname"), sBlueTeamName, sizeof(sBlueTeamName));
- GetCurrentMap(sCurrentMap, sizeof(sCurrentMap));
- Format(sRedMessage, sizeof(sRedMessage), "Red team name: %s", sRedTeamName);
- Format(sBlueMessage, sizeof(sBlueMessage), "Blue team name: %s", sBlueTeamName);
- Format(sRedCaps, sizeof(sRedCaps), "Red caps: %i", redCapTotal);
- Format(sBlueCaps, sizeof(sBlueCaps), "Blue caps: %i", blueCapTotal);
- Format(sMapMessage, sizeof(sMapMessage), "Current map: %s", sCurrentMap);
- Log(sRedMessage);
- Log(sBlueMessage);
- Log(sMapMessage);
- Log(sRedCaps);
- Log(sBlueCaps);
- redCapTotal = 0;
- blueCapTotal = 0;
- }
- public Action:TournamentRestartHook(args)
- {
- if (recording)
- {
- StopRecording();
- }
- return Plugin_Continue;
- }
- ResetVariables()
- {
- teamReadyState[RED] = false;
- teamReadyState[BLU] = false;
- recordOnRestart = false;
- recording = false;
- }
- StartRecording()
- {
- if (recording)
- {
- PrintToChatAll("Already recording");
- return;
- }
- // Format the demo filename
- decl String:timestamp[16];
- decl String:map[32];
- decl String:command[128];
- decl String:blueTeamName[32];
- decl String:redTeamName[32];
- decl String:recordname[256];
- decl String:logname[256];
- GetConVarString(FindConVar("mp_tournament_redteamname"), redTeamName, sizeof(redTeamName));
- GetConVarString(FindConVar("mp_tournament_blueteamname"), blueTeamName, sizeof(blueTeamName));
- FormatTime(timestamp, sizeof(timestamp), "%Y%m%d-%H%M");
- GetCurrentMap(map, sizeof(map));
- Format(sDemoFileName, sizeof(sDemoFileName), "%s vs %%s-%s.dem", redTeamName, blueTeamName, timestamp, map);
- Format(sLogFileName, sizeof(sLogFileName), "%s vs %s: %s-%s.log", redTeamName, blueTeamName, timestamp, map);
- Format(recordname, sizeof(recordname), "%s%s", sDemoFileDir, sDemoFileName);
- Format(logname, sizeof(logname), "%s%s", sLogFileDir, sLogFileName);
- PrintToChatAll(sDemoFileName);
- PrintToChatAll(recordname);
- PrintToChatAll(sLogFileName);
- PrintToChatAll(logname);
- Format(command, sizeof(command), "tv_record \"%s\"", sDemoFileName);
- // Start recording
- ServerCommand(command);
- PrintToChatAll("Recording started");
- recording = true;
- }
- StopRecording()
- {
- if (recording)
- {
- // Stop recording
- ServerCommand("tv_stoprecord");
- PrintToChatAll("Recording stopped");
- recording = false;
- }
- }
- // Stop recording if there are no players on the server - thanks jasonfrog!
- public Action:CheckPlayers(Handle:timer)
- {
- if (recording)
- {
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsClientConnected(i) && !IsFakeClient(i))
- {
- return;
- }
- }
- StopRecording();
- }
- }
- // My custom private functions :3
- /*
- * Event_RoundWon: called when a round is won
- * event: teamplay_round_win
- * name: name of the event
- * dontBroadcast: broadcast to the server
- */
- public Event_RoundWon(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new String:sBlueTeamName[32];
- new String:sRedTeamName[32];
- new winningTeam = GetEventInt(event, "team");
- new Float:roundTimeFloat = GetEventFloat(event, "round_time");
- GetConVarString(FindConVar("mp_tournament_redteamname"), sRedTeamName, sizeof(sRedTeamName));
- GetConVarString(FindConVar("mp_tournament_blueteamname"), sBlueTeamName, sizeof(sBlueTeamName));
- new roundTime = RoundToNearest(roundTimeFloat);
- new mapTime = (roundTime) / 60;
- new mapSecs = (roundTime) % 60;
- switch(winningTeam)
- {
- case 2:
- {
- redCapTotal++;
- new String:logMessage[64];
- Format(logMessage, sizeof(logMessage), " won in %i.%i", mapTime, mapSecs);
- CPrintToChatAll("{red} %s def %s in %i:%i {%i : %i)", sRedTeamName, sBlueTeamName, mapTime, mapSecs, redCapTotal, blueCapTotal);
- Log(logMessage);
- }
- case 3:
- {
- blueCapTotal++;
- new String:logMessage[64];
- Format(logMessage, sizeof(logMessage), "<red> won in %i.%i", mapTime, mapSecs);
- CPrintToChatAll("{blue} %s def %s in %i:%i {%i : %i)", sBlueTeamName, sRedTeamName, mapTime, mapSecs, redCapTotal, blueCapTotal);
- Log(logMessage);
- }
- }
- }
- /*
- * GetString: Returns the connect string to anyone who requests it
- * client: the client index
- * args: the argument indicies
- */
- public Action:Command_GetString(client, args)
- {
- new pieces[4];
- new String:passstr[64];
- new String:NetIP[32];
- new String:hostport[6];
- GetConVarString(FindConVar("hostport"), hostport, sizeof(hostport));
- new longip = GetConVarInt(FindConVar("hostip"));
- pieces[0] = (longip >> 24) & 0x000000FF;
- pieces[1] = (longip >> 16) & 0x000000FF;
- pieces[2] = (longip >> 8) & 0x000000FF;
- pieces[3] = longip & 0x000000FF;
- Format(NetIP, sizeof(NetIP), "%d.%d.%d.%d", pieces[0], pieces[1], pieces[2], pieces[3]);
- GetConVarString(g_hPassword, passstr, sizeof(passstr));
- CPrintToChat(client, "connect %s:%s; password %s", NetIP, hostport, passstr);
- }
- /*
- * GetPassword: Returns the password to anyone who requests it
- * client: the client index
- * args: the argument indicies
- */
- public Action:Command_GetPassword(client, args)
- {
- new String:passstr[64];
- GetConVarString(g_hPassword, passstr, sizeof(passstr));
- CPrintToChat(client, "{red} The password is %s", passstr);
- }
- /*
- * Command_ChangePassword: The action will change the password of the server
- * client: The client that wishes to execute this command
- * args: The argument indicies
- */
- public Action:Command_ChangePassword(client, args)
- {
- if (args == 0)
- {
- new randomNumber = GetRandomInt(1000, 5000);
- new String:newPassword[8];
- Format(newPassword, sizeof(newPassword), "%d", randomNumber);
- SetConVarString(g_hPassword, newPassword);
- CPrintToChatAll("{red}Changed password to %d", randomNumber);
- }
- else if (args == 1)
- {
- new String:newPassword[64];
- GetCmdArg(1, newPassword, sizeof(newPassword));
- SetConVarString(g_hPassword, newPassword);
- CPrintToChatAll("{red}Changed password to: %s", newPassword);
- }
- else
- {
- PrintToConsole(client, "Enter in the format !password \"password\" or with no arguments");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement