diff --git a/entWatch4/scripting/entWatch-messages.sp b/entWatch4/scripting/entWatch-messages.sp index 7ab307a5..99787dbf 100644 --- a/entWatch4/scripting/entWatch-messages.sp +++ b/entWatch4/scripting/entWatch-messages.sp @@ -10,6 +10,7 @@ #pragma newdecls required #include +#include #include #include @@ -59,11 +60,7 @@ public void EW_OnClientItemDrop(int client, int index) item.dConfig.GetColor(sItemColor, sizeof(sItemColor)); CRemoveTags(sClientName, sizeof(sClientName)); - for(int i = 1; i <= MaxClients; i++) - { - if(CheckIfTeamOrAdmin(iTeam, i)) - CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Drop", sItemColor, sItemName); - } + CPrintToTeamAndAdmins(iTeam, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Drop", sItemColor, sItemName); } } @@ -92,11 +89,7 @@ public void EW_OnClientItemDeath(int client, int index) item.dConfig.GetColor(sItemColor, sizeof(sItemColor)); CRemoveTags(sClientName, sizeof(sClientName)); - for(int i = 1; i <= MaxClients; i++) - { - if(CheckIfTeamOrAdmin(iTeam, i)) - CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "F1B567", "B2B2B2", sClientAuth, "F1B567", "Item Death", sItemColor, sItemName); - } + CPrintToTeamAndAdmins(iTeam, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "F1B567", "B2B2B2", sClientAuth, "F1B567", "Item Death", sItemColor, sItemName); } } @@ -125,11 +118,7 @@ public void EW_OnClientItemPickup(int client, int index) item.dConfig.GetColor(sItemColor, sizeof(sItemColor)); CRemoveTags(sClientName, sizeof(sClientName)); - for(int i = 1; i <= MaxClients; i++) - { - if(CheckIfTeamOrAdmin(iTeam, i)) - CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "C9EF66", "B2B2B2", sClientAuth, "C9EF66", "Item Pickup", sItemColor, sItemName); - } + CPrintToTeamAndAdmins(iTeam, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "C9EF66", "B2B2B2", sClientAuth, "C9EF66", "Item Pickup", sItemColor, sItemName); } } @@ -158,11 +147,7 @@ public void EW_OnClientItemDisconnect(int client, int index) item.dConfig.GetColor(sItemColor, sizeof(sItemColor)); CRemoveTags(sClientName, sizeof(sClientName)); - for(int i = 1; i <= MaxClients; i++) - { - if(CheckIfTeamOrAdmin(iTeam, i)) - CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "67ADDF", "B2B2B2", sClientAuth, "67ADDF", "Item Activate", sItemColor, sItemName); - } + CPrintToTeamAndAdmins(iTeam, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "67ADDF", "B2B2B2", sClientAuth, "67ADDF", "Item Activate", sItemColor, sItemName); } } @@ -191,21 +176,24 @@ public void EW_OnClientItemActivate(int client, int index) item.dConfig.GetColor(sItemColor, sizeof(sItemColor)); CRemoveTags(sClientName, sizeof(sClientName)); - for(int i = 1; i <= MaxClients; i++) - { - if(CheckIfTeamOrAdmin(iTeam, i)) - CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Activate", sItemColor, sItemName); - } + CPrintToTeamAndAdmins(iTeam, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Activate", sItemColor, sItemName); } } //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public bool CheckIfTeamOrAdmin(int team, int client) +stock void CPrintToTeamAndAdmins(int team, const char[] format, any ...) { - if(client > 0 && client <= MaxClients && IsClientInGame(client) && (team == GetClientTeam(client) || team <= 1 || CheckCommandAccess(client, "", ADMFLAG_GENERIC))) - return true; - else - return false; -} \ No newline at end of file + char message[255]; + VFormat(message, sizeof(message), format, 3); + + for(int client = 1; client <= MaxClients; client++) + { + if(!IsClientInGame(client)) + continue; + + if(team <= CS_TEAM_SPECTATOR || team == GetClientTeam(client) || CheckCommandAccess(client, "", ADMFLAG_GENERIC)) + CPrintToChat(client, "%s", message); + } +}