Skip to content

Commit

Permalink
Added sm_hosties_chat_activitytype
Browse files Browse the repository at this point in the history
Also added missing semicolon
  • Loading branch information
azalty committed Jul 10, 2023
1 parent 5c6f82c commit 02ed736
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 13 deletions.
Binary file modified addons/sourcemod/plugins/sm_hosties_e.smx
Binary file not shown.
12 changes: 6 additions & 6 deletions addons/sourcemod/scripting/hosties/gunsafety.sp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int MenuHandler_Slay(Handle menu, MenuAction action, int param1, int param2)
char name[32];
GetClientName(target, name, sizeof(name));
PerformSlay(param1, target);
CShowActivity2(param1, gShadow_Hosties_ChatBanner, "%t", "Slayed target", "_s", name);
Hosties_ShowActivity2(param1, "%t", "Slayed target", "_s", name);
}

DisplaySlayMenu(param1);
Expand Down Expand Up @@ -316,7 +316,7 @@ int MenuHandler_Kick(Handle menu, MenuAction action, int param1, int param2)
{
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
CShowActivity2(param1, gShadow_Hosties_ChatBanner, "%t", "Kicked target", "_s", name);
Hosties_ShowActivity2(param1, "%t", "Kicked target", "_s", name);
PerformKick(param1, target, "");
}

Expand Down Expand Up @@ -356,16 +356,16 @@ void PrepareBan(int client, int target, int time, const char[] reason)
{
if (reason[0] == '\0')
{
CShowActivity(client, "%t", "Permabanned player", name);
Hosties_ShowActivity(client, "%t", "Permabanned player", name);
} else {
CShowActivity(client, "%t", "Permabanned player reason", name, reason);
Hosties_ShowActivity(client, "%t", "Permabanned player reason", name, reason);
}
} else {
if (reason[0] == '\0')
{
CShowActivity(client, "%t", "Banned player", name, time);
Hosties_ShowActivity(client, "%t", "Banned player", name, time);
} else {
CShowActivity(client, "%t", "Banned player reason", name, time, reason);
Hosties_ShowActivity(client, "%t", "Banned player reason", name, time, reason);
}
}

Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/hosties/lastrequest.sp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ void StopActiveLRs(int client)
RemoveFromArray(gH_DArray_LR_Partners, iArraySize-1);
iArraySize--;
}
CShowActivity(client, "%s %t", gShadow_Hosties_ChatBanner, "LR Aborted");
Hosties_ShowActivity(client, "%t", "LR Aborted");
}

void LastRequest_RoundEnd(Event event, const char[] name, bool dontBroadcast)
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/hosties/respawn.sp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Action Command_Respawn(int client, int args)
PerformRespawn(client, target_list[i]);
}

CShowActivity(client, "%s %t", gShadow_Hosties_ChatBanner, "Respawned Target", target_name);
Hosties_ShowActivity(client, "%t", "Respawned Target", target_name);

return Plugin_Handled;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ int MenuHandler_Respawn(Menu menu, MenuAction action, int param1, int param2)
char name[32];
GetClientName(target, name, sizeof(name));
PerformRespawn(param1, target);
CShowActivity(param1, "%s %t", gShadow_Hosties_ChatBanner, "Respawned Target", name);
Hosties_ShowActivity(param1, "%t", "Respawned Target", name);
}

DisplayRespawnMenu(param1);
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/hosties/startweapons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void StartWeapons_Spawn(Event event, const char[] name, bool dontBroadcast)
/* Ignore check if starts with "item_", as you can also give items like kevlars+helmet "item_assaultsuit", which are not weapons.
* Not checking will crash the game. */
if (StrContains(gs_T_WeaponList[Tidx], "item_") == 0)
GivePlayerItem(client, gs_T_WeaponList[Tidx])
GivePlayerItem(client, gs_T_WeaponList[Tidx]);
else if (!Client_HasWeapon(client, gs_T_WeaponList[Tidx]))
EMP_GiveWeapon(client, gs_T_WeaponList[Tidx]); // Gives the weapon with the skin if a player has one (CS:GO)
}
Expand All @@ -117,7 +117,7 @@ void StartWeapons_Spawn(Event event, const char[] name, bool dontBroadcast)
/* Ignore check if starts with "item_", as you can also give items like kevlars+helmet "item_assaultsuit", which are not weapons.
* Not checking will crash the game. */
if (StrContains(sWeapon, "item_") == 0)
GivePlayerItem(client, sWeapon)
GivePlayerItem(client, sWeapon);
else if (!Client_HasWeapon(client, sWeapon))
EMP_GiveWeapon(client, sWeapon); // Gives the weapon with the skin if a player has one (CS:GO)
}
Expand Down
69 changes: 67 additions & 2 deletions addons/sourcemod/scripting/sm_hosties_e.sp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#pragma semicolon 1

#define PLUGIN_VERSION "5.0.3"
#define PLUGIN_VERSION "5.0.4"
#define PLUGIN_NAME "Hosties+"
#define MAX_DISPLAYNAME_SIZE 64
#define MAX_DATAENTRY_SIZE 5
Expand Down Expand Up @@ -103,7 +103,8 @@ ConVar gH_Cvar_Add_ServerTag,
gH_Cvar_ChatTag,
gH_Cvar_CT_Name,
gH_Cvar_T_Name,
gH_Cvar_LR_Debug_Enabled;
gH_Cvar_LR_Debug_Enabled,
gH_Cvar_Chat_ActivityType;

#if (MODULE_FREEKILL == 1)
ConVar gH_Cvar_Freekill_Sound,
Expand Down Expand Up @@ -188,6 +189,7 @@ public void OnPluginStart()
gH_Cvar_LR_Debug_Enabled = AutoExecConfig_CreateConVar("sm_hosties_debug_enabled", "0", "Allow prisoners to set race points in the air.", 0, true, 0.0, true, 1.0);
gH_Cvar_CT_Name = AutoExecConfig_CreateConVar("sm_hosties_team_name_ct", "Guards", "Edit CT Team Name - Leave empty for no change");
gH_Cvar_T_Name = AutoExecConfig_CreateConVar("sm_hosties_team_name_t", "Prisoners", "Edit T Team Name - Leave empty for no change");
gH_Cvar_Chat_ActivityType = AutoExecConfig_CreateConVar("sm_hosties_chat_activitytype", "1", "0 = Use the [SM] tag for admin activity messages\n1 = Use the plugin tag for admin activity messages", 0, true, 0.0, true, 1.0);

#if (MODULE_STARTWEAPONS == 1)
StartWeapons_OnPluginStart();
Expand Down Expand Up @@ -530,4 +532,67 @@ stock bool DirExistsEx(const char[] path)
}

return true;
}

/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
* Also respects the sm_hosties_chat_activitytype cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* CShowActivity2() is slightly more useful.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
void Hosties_ShowActivity(int client, const char[] message, any ...)
{
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 3);

if (gH_Cvar_Chat_ActivityType.IntValue == 0)
{
CShowActivity(client, buffer);
}
else
{
CShowActivityEx(client, gShadow_Hosties_ChatBanner, buffer);
}
}

/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* Also respects the sm_hosties_chat_activitytype cvar.
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to prepend to the message.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
void Hosties_ShowActivity2(int client, const char[] message, any ...)
{
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 3);

if (gH_Cvar_Chat_ActivityType.IntValue == 0)
{
CShowActivity2(client, "[SM] ", buffer);
}
else
{
CShowActivity2(client, gShadow_Hosties_ChatBanner, buffer);
}
}

0 comments on commit 02ed736

Please sign in to comment.