Replace hardcoded "/ff" check in basetriggers (bug 5863, r=drifter).
Replace hardcoded "/ff" check in basetriggers (
bug 5863, r=drifter).
1.1 --- a/plugins/basetriggers.sp Sat Aug 24 21:59:52 2013 -0400
1.2 +++ b/plugins/basetriggers.sp Sat Aug 24 21:59:52 2013 -0400
1.3 @@ -78,6 +78,7 @@
1.4 RegConsoleCmd("timeleft", Command_Timeleft);
1.5 RegConsoleCmd("nextmap", Command_Nextmap);
1.6 RegConsoleCmd("motd", Command_Motd);
1.7 + RegConsoleCmd("ff", Command_FriendlyFire);
1.8
1.9 HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval);
1.10
1.11 @@ -232,6 +233,22 @@
1.12 return Plugin_Handled;
1.13 }
1.14
1.15 +public Action:Command_FriendlyFire(client, args)
1.16 +{
1.17 + if (client == 0)
1.18 + {
1.19 + ReplyToCommand(client, "[SM] %t", "Command is in-game only");
1.20 + return Plugin_Handled;
1.21 + }
1.22 +
1.23 + if (!IsClientInGame(client))
1.24 + return Plugin_Handled;
1.25 +
1.26 + ShowFriendlyFire(client);
1.27 +
1.28 + return Plugin_Handled;
1.29 +}
1.30 +
1.31 public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[])
1.32 {
1.33 decl String:text[192];
1.34 @@ -268,29 +285,9 @@
1.35 PrintToChat(client,"[SM] %t", "Thetime", ctime);
1.36 }
1.37 }
1.38 - else if (strcmp(text[startidx], "ff", false) == 0 || strcmp(text[startidx], "/ff", false) == 0)
1.39 + else if (strcmp(text[startidx], "ff", false) == 0)
1.40 {
1.41 - if (g_Cvar_FriendlyFire != INVALID_HANDLE)
1.42 - {
1.43 - decl String:phrase[24];
1.44 - if (GetConVarBool(g_Cvar_FriendlyFire))
1.45 - {
1.46 - strcopy(phrase, sizeof(phrase), "Friendly Fire On");
1.47 - }
1.48 - else
1.49 - {
1.50 - strcopy(phrase, sizeof(phrase), "Friendly Fire Off");
1.51 - }
1.52 -
1.53 - if(GetConVarInt(g_Cvar_TriggerShow))
1.54 - {
1.55 - PrintToChatAll("[SM] %t", phrase);
1.56 - }
1.57 - else
1.58 - {
1.59 - PrintToChat(client,"[SM] %t", phrase);
1.60 - }
1.61 - }
1.62 + ShowFriendlyFire(client);
1.63 }
1.64 else if (strcmp(text[startidx], "currentmap", false) == 0)
1.65 {
1.66 @@ -519,3 +516,28 @@
1.67 PrintToServer("[SM] %s", finalOutput);
1.68 }
1.69 }
1.70 +
1.71 +ShowFriendlyFire(client)
1.72 +{
1.73 + if (g_Cvar_FriendlyFire != INVALID_HANDLE)
1.74 + {
1.75 + decl String:phrase[24];
1.76 + if (GetConVarBool(g_Cvar_FriendlyFire))
1.77 + {
1.78 + strcopy(phrase, sizeof(phrase), "Friendly Fire On");
1.79 + }
1.80 + else
1.81 + {
1.82 + strcopy(phrase, sizeof(phrase), "Friendly Fire Off");
1.83 + }
1.84 +
1.85 + if(GetConVarInt(g_Cvar_TriggerShow))
1.86 + {
1.87 + PrintToChatAll("[SM] %t", phrase);
1.88 + }
1.89 + else
1.90 + {
1.91 + PrintToChat(client,"[SM] %t", phrase);
1.92 + }
1.93 + }
1.94 +}