Skip to content

Commit 90b9979

Browse files
author
Motive
committed
- Added !log command to allow moderators or admins to see the last 25 commands used globally, or use a color after it, to see the last 25 commands used by a player.
- Added Spawner to Restricted Units
1 parent f8893ad commit 90b9979

File tree

6 files changed

+128
-1
lines changed

6 files changed

+128
-1
lines changed

Chat/ChatHandler.galaxy

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ void libcrtx_chat_parsechat(int lp_player, string lp_message, int lp_recursionLi
193193
libcrtx_variable_delete(lp_player, libcrtx_variable_name_return);
194194

195195
libcrtx_chat_set_parse_line( lp_player, lp_message );
196+
libcrtx_log_event(lp_player, lp_message);
196197
TriggerExecute(t, false, false);
197198
} else {
198199
// No such command for this iteration

Commands/AdminCommands.galaxy

+20-1
Original file line numberDiff line numberDiff line change
@@ -868,4 +868,23 @@ bool libcrtx_command_trolls(bool testConds, bool runActions)
868868
}
869869

870870
return true;
871-
}
871+
}
872+
873+
bool libcrtx_command_log(bool checkConds, bool runActions)
874+
{
875+
int plr = -1;
876+
string val = StringWord( libcrtx_chat_get_parse_line(EventPlayer()), 2 );
877+
plr = libcrtx_color_to_player( val );
878+
879+
if( libcrtx_admin_getpermissions( EventPlayer() ) < libcrtx_admin_permissionlevel_moderator ) {
880+
return true;
881+
}
882+
883+
if( plr != -1 )
884+
{
885+
libcrtx_write_text(PlayerGroupSingle(EventPlayer()), libcrtx_log_getlog(plr));
886+
} else {
887+
libcrtx_write_text(PlayerGroupSingle(EventPlayer()), libcrtx_log_getgloballog());
888+
}
889+
return true;
890+
}

Commands/Commands.galaxy

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void libcrtx_commands_init()
118118
libcrtx_command_create("!light", "libcrtx_command_light");
119119
libcrtx_command_create("!creepspeed", "libcrtx_command_creepspeed");
120120
libcrtx_command_create("!trolls", "libcrtx_command_trolls");
121+
libcrtx_command_create("!log", "libcrtx_command_log");
121122

122123

123124
// region commands

Common/Global.galaxy

+2
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ include "Cortex/Common/SharedData.galaxy"
7878
include "Cortex/Common/CortexID.galaxy"
7979
include "Cortex/Common/Utility.galaxy"
8080
include "Cortex/Common/ComputerAI.galaxy"
81+
include "Cortex/Common/Log.galaxy"
82+

Common/Log.galaxy

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Cortex SC2 Roleplaying Engine
2+
// Copyright (C) 2009-2011 <http://www.cortexrp.com/>
3+
//
4+
// This program is free software; you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation; version 2 of the License.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
13+
const int c_cortexMaxLoggedCommands = 25;
14+
15+
string[libcrtx_max_players][c_cortexMaxLoggedCommands] libcrtx_log_perplayerlog;
16+
string[c_cortexMaxLoggedCommands] libcrtx_log_globallog;
17+
int[c_cortexMaxLoggedCommands] libcrtx_log_globallogplayers;
18+
19+
static void libcrtx_log_event_individual(int player, string message)
20+
{
21+
int currentLevel = 0;
22+
23+
// Find free index and insert, if possible
24+
while(currentLevel < c_cortexMaxLoggedCommands)
25+
{
26+
if( libcrtx_log_perplayerlog[player][currentLevel] == "" ) {
27+
libcrtx_log_perplayerlog[player][currentLevel] = message;
28+
return;
29+
}
30+
currentLevel += 1;
31+
}
32+
33+
// We're out of space! Discard one message and move the rest upward one level, and use last index.
34+
currentLevel = 1;
35+
while(currentLevel < c_cortexMaxLoggedCommands)
36+
{
37+
libcrtx_log_perplayerlog[player][currentLevel - 1] = libcrtx_log_perplayerlog[player][currentLevel];
38+
currentLevel += 1;
39+
}
40+
libcrtx_log_perplayerlog[player][c_cortexMaxLoggedCommands - 1] = message;
41+
}
42+
43+
static void libcrtx_log_event_global(int player, string message)
44+
{
45+
int currentLevel = 0;
46+
47+
// Find free index and insert, if possible
48+
while(currentLevel < c_cortexMaxLoggedCommands)
49+
{
50+
if( libcrtx_log_globallog[currentLevel] == "" ) {
51+
libcrtx_log_globallog[currentLevel] = message;
52+
libcrtx_log_globallogplayers[currentLevel] = player;
53+
return;
54+
}
55+
currentLevel += 1;
56+
}
57+
58+
// We're out of space! Discard one message and move the rest upward one level, and use last index.
59+
currentLevel = 1;
60+
while(currentLevel < c_cortexMaxLoggedCommands)
61+
{
62+
libcrtx_log_globallog[currentLevel - 1] = libcrtx_log_globallog[currentLevel];
63+
currentLevel += 1;
64+
}
65+
libcrtx_log_globallog[c_cortexMaxLoggedCommands - 1] = message;
66+
libcrtx_log_globallogplayers[c_cortexMaxLoggedCommands - 1] = player;
67+
}
68+
69+
void libcrtx_log_event(int player, string message)
70+
{
71+
libcrtx_log_event_individual(player, message);
72+
libcrtx_log_event_global(player, message);
73+
}
74+
75+
text libcrtx_log_getlog(int player)
76+
{
77+
text ret = StringToText(libcrtx_log_perplayerlog[player][0]);
78+
int i = 1;
79+
while(i < c_cortexMaxLoggedCommands)
80+
{
81+
if( libcrtx_log_perplayerlog[player][i] != "" )
82+
{
83+
ret += StringToText("<n />") + libcrtx_colored_player_name(player) + StringToText(": " + libcrtx_log_perplayerlog[player][i]);
84+
}
85+
i += 1;
86+
}
87+
return ret;
88+
}
89+
90+
text libcrtx_log_getgloballog()
91+
{
92+
text ret = StringToText(libcrtx_log_globallog[0]);
93+
int i = 1;
94+
while(i < c_cortexMaxLoggedCommands)
95+
{
96+
if( libcrtx_log_globallog[i] != "" )
97+
{
98+
ret += StringToText("<n />") + libcrtx_colored_player_name(libcrtx_log_globallogplayers[i]) + StringToText(": " + libcrtx_log_globallog[i]);
99+
}
100+
i += 1;
101+
}
102+
return ret;
103+
}

Toolkit/DefaultToolkit/UnitToolkit.galaxy

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void libcrtx_toolkit_default_initunittools()
5757

5858
void libcrtx_toolkit_default_initrestrictedunits()
5959
{
60+
libcrtx_toolkit_addrestrictedunit("Spawner");
6061
libcrtx_toolkit_addrestrictedunit("nukenoodle");
6162
}
6263

0 commit comments

Comments
 (0)