diff --git a/plugins/basechat.sp b/plugins/basechat.sp index a7b96726..983d7da8 100644 --- a/plugins/basechat.sp +++ b/plugins/basechat.sp @@ -61,8 +61,6 @@ public OnPluginStart() g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0); - RegConsoleCmd("say", Command_SayChat); - RegConsoleCmd("say_team", Command_SayAdmin); RegAdminCmd("sm_say", Command_SmSay, ADMFLAG_CHAT, "sm_say - sends message to all players"); RegAdminCmd("sm_csay", Command_SmCsay, ADMFLAG_CHAT, "sm_csay - sends centered message to all players"); @@ -78,98 +76,78 @@ public OnPluginStart() RegAdminCmd("sm_msay", Command_SmMsay, ADMFLAG_CHAT, "sm_msay - sends message as a menu panel"); } -public Action:Command_SayChat(client, args) -{ - decl String:text[192]; - if (IsChatTrigger() || GetCmdArgString(text, sizeof(text)) < 1) - { - return Plugin_Continue; - } - - new startidx; - if (text[strlen(text)-1] == '"') - { - text[strlen(text)-1] = '\0'; - startidx = 1; - } - - if (text[startidx] != CHAT_SYMBOL) - return Plugin_Continue; - - new msgStart = 1; - - if (text[startidx+1] == CHAT_SYMBOL) - { - msgStart = 2; - - if (text[startidx+2] == CHAT_SYMBOL) - msgStart = 3; - } - - decl String:message[192]; - strcopy(message, 192, text[startidx+msgStart]); - - if (msgStart == 1 && CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT)) // sm_say alias - { - SendChatToAll(client, message); - LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, message); - } - else if (msgStart == 3 && CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT)) // sm_csay alias - { - DisplayCenterTextToAll(client, message); - LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, text); - } - else if (msgStart == 2 && CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT)) // sm_psay alias - { - decl String:arg[64]; - - new len = BreakString(message, arg, sizeof(arg)); - new target = FindTarget(client, arg, true, false); - - if (target == -1 || len == -1) - return Plugin_Handled; - - PrintToChat(client, "\x04(Private to %N) %N: \x01%s", target, client, message[len]); - PrintToChat(target, "\x04(Private to %N) %N: \x01%s", target, client, message[len]); - - LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message); - } - else - return Plugin_Continue; - - return Plugin_Handled; -} - -public Action:Command_SayAdmin(client, args) +public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]) { - if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !GetConVarBool(g_Cvar_Chatmode)) - { - return Plugin_Continue; - } - - decl String:text[192]; - if (IsChatTrigger() || GetCmdArgString(text, sizeof(text)) < 1) - { - return Plugin_Continue; - } - new startidx; - if (text[strlen(text)-1] == '"') - { - text[strlen(text)-1] = '\0'; - startidx = 1; - } - - if (text[startidx] != CHAT_SYMBOL) + if (sArgs[startidx] != CHAT_SYMBOL) return Plugin_Continue; - decl String:message[192]; - strcopy(message, 192, text[startidx+1]); - - SendChatToAdmins(client, message); - LogAction(client, -1, "\"%L\" triggered sm_chat (text %s)", client, message); + startidx++; - return Plugin_Handled; + if (strcmp(command, "say", false) == 0) + { + if (sArgs[startidx] != CHAT_SYMBOL) // sm_say alias + { + if (!CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT)) + { + return Plugin_Continue; + } + + SendChatToAll(client, sArgs[startidx]); + LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, sArgs[startidx]); + + return Plugin_Stop; + } + + startidx++; + + if (sArgs[startidx] != CHAT_SYMBOL) // sm_psay alias + { + if (!CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT)) + { + return Plugin_Continue; + } + + decl String:arg[64]; + + new len = BreakString(sArgs[startidx], arg, sizeof(arg)); + new target = FindTarget(client, arg, true, false); + + if (target == -1 || len == -1) + return Plugin_Stop; + + SendPrivateChat(client, target, sArgs[startidx+len]); + + return Plugin_Stop; + } + + startidx++; + + // sm_csay alias + if (!CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT)) + { + return Plugin_Continue; + } + + DisplayCenterTextToAll(client, sArgs[startidx]); + LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, sArgs[startidx]); + + return Plugin_Stop; + } + else if (strcmp(command, "say_team", false) == 0 || strcmp(command, "say_squad", false) == 0) + { + if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !GetConVarBool(g_Cvar_Chatmode)) + { + return Plugin_Continue; + } + + SendChatToAdmins(client, sArgs[startidx]); + LogAction(client, -1, "\"%L\" triggered sm_chat (text %s)", client, sArgs[startidx]); + + return Plugin_Stop; + } + + return Plugin_Continue; } public Action:Command_SmSay(client, args) @@ -307,29 +285,8 @@ public Action:Command_SmPsay(client, args) if (target == -1) return Plugin_Handled; - - decl String:name[64]; - - if (client == 0) - { - name = "Console"; - } - else - { - GetClientName(client, name, sizeof(name)); - } - - if (client == 0) - { - PrintToServer("(Private: %N) %s: %s", target, name, message); - } - else if (target != client) - { - PrintToChat(client, "\x04(Private: %N) %s: \x01%s", target, name, message); - } - - PrintToChat(target, "\x04(Private: %N) %s: \x01%s", target, name, message); - LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message); + + SendPrivateChat(client, target, message); return Plugin_Handled; } @@ -363,7 +320,7 @@ FindColor(String:color[]) return -1; } -SendChatToAll(client, String:message[]) +SendChatToAll(client, const String:message[]) { new String:nameBuf[MAX_NAME_LENGTH]; @@ -379,7 +336,7 @@ SendChatToAll(client, String:message[]) } } -DisplayCenterTextToAll(client, String:message[]) +DisplayCenterTextToAll(client, const String:message[]) { new String:nameBuf[MAX_NAME_LENGTH]; @@ -394,7 +351,7 @@ DisplayCenterTextToAll(client, String:message[]) } } -SendChatToAdmins(from, String:message[]) +SendChatToAdmins(from, const String:message[]) { new fromAdmin = CheckCommandAccess(from, "sm_chat", ADMFLAG_CHAT); for (new i = 1; i <= MaxClients; i++) @@ -406,7 +363,7 @@ SendChatToAdmins(from, String:message[]) } } -SendDialogToOne(client, color, String:text[], any:...) +SendDialogToOne(client, color, const String:text[], any:...) { new String:message[100]; VFormat(message, sizeof(message), text, 4); @@ -421,6 +378,21 @@ SendDialogToOne(client, color, String:text[], any:...) CloseHandle(kv); } +SendPrivateChat(client, target, const String:message[]) +{ + if (!client) + { + PrintToServer("(Private to %N) %N: %s", target, client, message); + } + else if (target != client) + { + PrintToChat(client, "\x04(Private to %N) %N: \x01%s", target, client, message); + } + + PrintToChat(target, "\x04(Private to %N) %N: \x01%s", target, client, message); + LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message); +} + SendPanelToAll(from, String:message[]) { decl String:title[100]; diff --git a/plugins/nominations.sp b/plugins/nominations.sp index c00e1e6f..daca5c9b 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -71,9 +71,6 @@ public OnPluginStart() g_Cvar_ExcludeOld = CreateConVar("sm_nominate_excludeold", "1", "Specifies if the current map should be excluded from the Nominations list", 0, true, 0.00, true, 1.0); g_Cvar_ExcludeCurrent = CreateConVar("sm_nominate_excludecurrent", "1", "Specifies if the MapChooser excluded maps should also be excluded from Nominations", 0, true, 0.00, true, 1.0); - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_Say); - RegConsoleCmd("sm_nominate", Command_Nominate); RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap - Forces a map to be on the next mapvote."); @@ -156,36 +153,21 @@ public Action:Command_Addmap(client, args) return Plugin_Handled; } -public Action:Command_Say(client, args) +public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]) { if (!client) { - return Plugin_Continue; - } - - decl String:text[192]; - if (!GetCmdArgString(text, sizeof(text))) - { - return Plugin_Continue; + return; } - new startidx = 0; - if(text[strlen(text)-1] == '"') - { - text[strlen(text)-1] = '\0'; - startidx = 1; - } - - new ReplySource:old = SetCmdReplySource(SM_REPLY_TO_CHAT); - - if (strcmp(text[startidx], "nominate", false) == 0) + if (strcmp(sArgs, "nominate", false) == 0) { + new ReplySource:old = SetCmdReplySource(SM_REPLY_TO_CHAT); + AttemptNominate(client); + + SetCmdReplySource(old); } - - SetCmdReplySource(old); - - return Plugin_Continue; } public Action:Command_Nominate(client, args) diff --git a/plugins/rockthevote.sp b/plugins/rockthevote.sp index 370a57ab..d1981888 100644 --- a/plugins/rockthevote.sp +++ b/plugins/rockthevote.sp @@ -74,9 +74,6 @@ public OnPluginStart() g_Cvar_ChangeTime = CreateConVar("sm_rtv_changetime", "0", "When to change the map after a succesful RTV: 0 - Instant, 1 - RoundEnd, 2 - MapEnd", _, true, 0.0, true, 2.0); g_Cvar_RTVPostVoteAction = CreateConVar("sm_rtv_postvoteaction", "0", "What to do with RTV's after a mapvote has completed. 0 - Allow, success = instant change, 1 - Deny", _, true, 0.0, true, 1.0); - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_Say); - RegConsoleCmd("sm_rtv", Command_RTV); AutoExecConfig(true, "rtv"); @@ -158,6 +155,23 @@ public OnClientDisconnect(client) } } +public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]) +{ + if (!g_CanRTV || !client) + { + return; + } + + if (strcmp(sArgs, "rtv", false) == 0 || strcmp(sArgs, "rockthevote", false) == 0) + { + new ReplySource:old = SetCmdReplySource(SM_REPLY_TO_CHAT); + + AttemptRTV(client); + + SetCmdReplySource(old); + } +} + public Action:Command_RTV(client, args) { if (!g_CanRTV || !client) @@ -170,38 +184,6 @@ public Action:Command_RTV(client, args) return Plugin_Handled; } -public Action:Command_Say(client, args) -{ - if (!g_CanRTV || !client) - { - return Plugin_Continue; - } - - decl String:text[192]; - if (!GetCmdArgString(text, sizeof(text))) - { - return Plugin_Continue; - } - - new startidx = 0; - if(text[strlen(text)-1] == '"') - { - text[strlen(text)-1] = '\0'; - startidx = 1; - } - - new ReplySource:old = SetCmdReplySource(SM_REPLY_TO_CHAT); - - if (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0) - { - AttemptRTV(client); - } - - SetCmdReplySource(old); - - return Plugin_Continue; -} - AttemptRTV(client) { if (!g_RTVAllowed || (GetConVarInt(g_Cvar_RTVPostVoteAction) == 1 && HasEndOfMapVoteFinished()))