#pragma semicolon 1 #include #include #include #include #undef REQUIRE_PLUGIN #include #define REQUIRE_PLUGIN #pragma newdecls required enum { AABBMinX = 0, AABBMaxX = 1, AABBMinY = 2, AABBMaxY = 3, AABBMinZ = 4, AABBMaxZ = 5, AABBTotalPoints = 6 } Handle g_hDatabase = null; Handle g_hTraceTimer = null; Handle g_hRoundEndTimer = null; Handle g_hTopMenu = null; Handle g_hWantsToSeeNSFWCookie = null; ConVar g_cvarHookedDecalFrequency = null; ConVar g_cvarDecalFrequency = null; ConVar g_cvarUseProximityCheck = null; ConVar g_cvarSendSpraysToConnectingClients = null; ConVar g_cvarUsePersistentSprays = null; ConVar g_cvarMaxSprayLifetime = null; int g_iNSFWDecalIndex; int g_iHiddenDecalIndex; int g_iTransparentDecalIndex; int g_iOldDecalFreqVal; int g_iAllowSpray; bool g_bLoadedLate; bool g_bSQLite; bool g_bGotBans; bool g_bGotBlacklist; bool g_bGotNSFWList; bool g_bFullyConnected; bool g_bSkipDecalHook; char g_sBanIssuer[MAXPLAYERS + 1][64]; char g_sBanIssuerSID[MAXPLAYERS + 1][32]; char g_sBanReason[MAXPLAYERS + 1][32]; char g_sSprayHash[MAXPLAYERS + 1][16]; int g_iClientToClientSprayLifetime[MAXPLAYERS + 1][MAXPLAYERS + 1]; int g_iClientSprayLifetime[MAXPLAYERS + 1] = { 2, ... }; int g_iSprayLifetime[MAXPLAYERS + 1]; int g_iSprayBanTimestamp[MAXPLAYERS + 1]; int g_iSprayUnbanTimestamp[MAXPLAYERS + 1] = { -1, ... }; int g_iSprayBanTarget[MAXPLAYERS + 1]; int g_iSprayUnbanTarget[MAXPLAYERS + 1]; int g_iSprayTraceTarget[MAXPLAYERS + 1]; int g_iBanTarget[MAXPLAYERS + 1]; int g_iDecalEntity[MAXPLAYERS + 1]; bool g_bWantsToSeeNSFWSprays[MAXPLAYERS + 1]; bool g_bHasNSFWSpray[MAXPLAYERS + 1]; bool g_bMarkedNSFWByAdmin[MAXPLAYERS + 1]; bool g_bSprayBanned[MAXPLAYERS + 1]; bool g_bSprayHashBanned[MAXPLAYERS + 1]; bool g_bInvokedThroughTopMenu[MAXPLAYERS + 1]; bool g_bInvokedThroughListMenu[MAXPLAYERS + 1]; bool g_bHasSprayHidden[MAXPLAYERS + 1][MAXPLAYERS + 1]; float ACTUAL_NULL_VECTOR[3] = { 16384.0, ... }; //durr float g_fNextSprayTime[MAXPLAYERS + 1]; float g_vecSprayOrigin[MAXPLAYERS + 1][3]; float g_SprayAABB[MAXPLAYERS + 1][AABBTotalPoints]; public Plugin myinfo = { name = "Spray Manager", description = "A plugin to help manage player sprays.", author = "Obus", version = "2.1.0", url = "" } public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen) { g_bLoadedLate = bLate; return APLRes_Success; } public void OnPluginStart() { LoadTranslations("common.phrases"); AddFileToDownloadsTable("materials/decals/spraymanager/1.vtf"); AddFileToDownloadsTable("materials/decals/spraymanager/1.vmt"); AddFileToDownloadsTable("materials/decals/spraymanager/2.vtf"); AddFileToDownloadsTable("materials/decals/spraymanager/2.vmt"); AddFileToDownloadsTable("materials/decals/spraymanager/3.vtf"); AddFileToDownloadsTable("materials/decals/spraymanager/3.vmt"); RegConsoleCmd("sm_marknsfw", Command_MarkNSFW, "Marks your spray as NSFW"); RegConsoleCmd("sm_marksfw", Command_MarkSFW, "Marks your spray as SFW"); RegConsoleCmd("sm_nsfw", Command_NSFW, "Opt-in or out of seeing NSFW sprays"); RegConsoleCmd("sm_hs", Command_HideSpray, "Hides a players spray"); RegConsoleCmd("sm_us", Command_UnhideSpray, "Unhides a players spray"); RegAdminCmd("sm_spray", Command_AdminSpray, ADMFLAG_GENERIC, "Spray a clients spray"); RegAdminCmd("sm_sprayban", Command_SprayBan, ADMFLAG_GENERIC, "Ban a client from spraying"); RegAdminCmd("sm_sprayunban", Command_SprayUnban, ADMFLAG_GENERIC, "Unban a client and allow them to spray"); RegAdminCmd("sm_banspray", Command_BanSpray, ADMFLAG_GENERIC, "Ban a clients spray from being sprayed (Note: This will not spray-ban the client, it will only ban the spray which they are currently using)"); RegAdminCmd("sm_unbanspray", Command_UnbanSpray, ADMFLAG_GENERIC, "Unban a clients spray (Note: This will not spray-unban the client, it will only unban the spray which they are currently using)"); RegAdminCmd("sm_tracespray", Command_TraceSpray, ADMFLAG_GENERIC, "Finds a spray under your crosshair"); RegAdminCmd("sm_spraytrace", Command_TraceSpray, ADMFLAG_GENERIC, "Finds a spray under your crosshair"); RegAdminCmd("sm_removespray", Command_RemoveSpray, ADMFLAG_GENERIC, "Finds and removes a spray under your crosshair"); RegAdminCmd("sm_forcensfw", Command_ForceNSFW, ADMFLAG_GENERIC, "Forces a spray to be marked NSFW"); RegAdminCmd("sm_forcesfw", Command_ForceSFW, ADMFLAG_GENERIC, "Forces a spray to be marked SFW"); RegAdminCmd("sm_spraymanagerupdatedb", Command_SprayManager_UpdateInfo, ADMFLAG_CHEATS, "Updates all clients info"); RegAdminCmd("sm_spraymanagerrefreshdb", Command_SprayManager_UpdateInfo, ADMFLAG_CHEATS, "Updates all clients info"); RegAdminCmd("sm_spraymanagerreloaddb", Command_SprayManager_UpdateInfo, ADMFLAG_CHEATS, "Updates all clients info"); g_hWantsToSeeNSFWCookie = RegClientCookie("spraymanager_wanttoseensfw", "Does this client want to see NSFW sprays?", CookieAccess_Private); AddTempEntHook("Player Decal", HookDecal); AddNormalSoundHook(HookSprayer); TopMenu hTopMenu; if (LibraryExists("adminmenu") && ((hTopMenu = GetAdminTopMenu()) != null)) OnAdminMenuReady(hTopMenu); g_cvarHookedDecalFrequency = FindConVar("decalfrequency"); g_iOldDecalFreqVal = g_cvarHookedDecalFrequency.IntValue; g_cvarHookedDecalFrequency.IntValue = 0; g_cvarDecalFrequency = CreateConVar("sm_decalfrequency", "10.0", "Controls how often clients can spray", FCVAR_NOTIFY); HookConVarChange(g_cvarHookedDecalFrequency, ConVarChanged_DecalFrequency); g_cvarUseProximityCheck = CreateConVar("sm_spraymanager_blockoverspraying", "1", "Blocks people from overspraying each other", FCVAR_NOTIFY); g_cvarSendSpraysToConnectingClients = CreateConVar("sm_spraymanager_sendspraystoconnectingclients", "1", "Try to send active sprays to connecting clients"); g_cvarUsePersistentSprays = CreateConVar("sm_spraymanager_persistentsprays", "1", "Re-spray sprays when their client-sided lifetime (in rounds) expires"); g_cvarMaxSprayLifetime = CreateConVar("sm_spraymanager_maxspraylifetime", "2", "If not using persistent sprays, remove sprays after their global lifetime (in rounds) exceeds this number"); AutoExecConfig(true, "plugin.SprayManager"); g_hTraceTimer = CreateTimer(0.25, Timer_PerformPlayerTraces, _, TIMER_REPEAT); if (g_bLoadedLate) { for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || IsFakeClient(i)) continue; OnClientPutInServer(i); OnClientCookiesCached(i); } } InitializeSQL(); } public void OnPluginEnd() { for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; if (IsVectorZero(g_vecSprayOrigin[i])) continue; g_iAllowSpray = i; SprayClientDecalToAll(i, 0, ACTUAL_NULL_VECTOR); } RemoveTempEntHook("Player Decal", HookDecal); RemoveNormalSoundHook(HookSprayer); UnhookConVarChange(g_cvarHookedDecalFrequency, ConVarChanged_DecalFrequency); if (g_hDatabase != null) { SQL_UnlockDatabase(g_hDatabase); delete g_hDatabase; } if (g_hTraceTimer != null) delete g_hTraceTimer; if (g_hRoundEndTimer != null) delete g_hRoundEndTimer; g_cvarHookedDecalFrequency.IntValue = g_iOldDecalFreqVal; } public void OnMapStart() { g_iNSFWDecalIndex = PrecacheDecal("decals/spraymanager/1.vtf", true); g_iHiddenDecalIndex = PrecacheDecal("decals/spraymanager/2.vtf", true); g_iTransparentDecalIndex = PrecacheDecal("decals/spraymanager/3.vtf", true); } public void OnMapEnd() { if (g_hRoundEndTimer != null) delete g_hRoundEndTimer; } public void OnClientPutInServer(int client) { if (QueryClientConVar(client, "r_spray_lifetime", CvarQueryFinished_SprayLifeTime) == QUERYCOOKIE_FAILED) g_iClientSprayLifetime[client] = 2; } public void OnClientCookiesCached(int client) { char sWantsToSeeNSFW[8]; GetClientCookie(client, g_hWantsToSeeNSFWCookie, sWantsToSeeNSFW, sizeof(sWantsToSeeNSFW)); g_bWantsToSeeNSFWSprays[client] = view_as(StringToInt(sWantsToSeeNSFW)); } public void CvarQueryFinished_SprayLifeTime(QueryCookie cookie, int client, ConVarQueryResult res, const char[] sCvarName, const char[] sCvarVal) { if (res != ConVarQuery_Okay) { g_iClientSprayLifetime[client] = 2; return; } int iVal = StringToInt(sCvarVal); g_iClientSprayLifetime[client] = iVal <= 0 ? 1 : iVal > 1000 ? 1000 : iVal; } public void OnClientPostAdminCheck(int client) { if (g_hDatabase != null) { ClearPlayerInfo(client); GetPlayerDecalFile(client, g_sSprayHash[client], sizeof(g_sSprayHash[])); UpdatePlayerInfo(client); UpdateSprayHashInfo(client); UpdateNSFWInfo(client); } if (g_cvarSendSpraysToConnectingClients.BoolValue) { for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; if (IsVectorZero(g_vecSprayOrigin[i])) continue; if (g_bHasNSFWSpray[i] && !g_bWantsToSeeNSFWSprays[client]) { PaintWorldDecalToOne(g_iNSFWDecalIndex, g_vecSprayOrigin[i], client); continue; } g_bSkipDecalHook = true; SprayClientDecalToOne(i, client, g_iDecalEntity[i], g_vecSprayOrigin[i]); g_iClientToClientSprayLifetime[client][i] = 0; g_bSkipDecalHook = false; } } } public void OnClientDisconnect(int client) { if (IsValidClient(client)) { for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i)) continue; if (!g_bHasSprayHidden[i][client] && g_bWantsToSeeNSFWSprays[i]) continue; PaintWorldDecalToOne(g_iTransparentDecalIndex, g_vecSprayOrigin[client], i); } g_bSkipDecalHook = true; SprayClientDecalToAll(client, 0, ACTUAL_NULL_VECTOR); g_bSkipDecalHook = false; } ClearPlayerInfo(client); } public Action CS_OnTerminateRound(float &fDelay, CSRoundEndReason &reason) { if (g_cvarUsePersistentSprays.BoolValue) { g_hRoundEndTimer = CreateTimer(fDelay + 0.5, Timer_ProcessPersistentSprays); return Plugin_Continue; } g_hRoundEndTimer = CreateTimer(fDelay, Timer_ResetOldSprays); return Plugin_Continue; } public Action OnPlayerRunCmd(int client, int &buttons, int &impulse) { if (!impulse || impulse != 201) return Plugin_Continue; if (CheckCommandAccess(client, "sm_sprayban", ADMFLAG_GENERIC)) { if (!g_bSprayBanned[client] && !g_bSprayHashBanned[client]) { //if (IsPlayerAlive(client)) //if (TracePlayerAnglesRanged(client, 128.0)) //return Plugin_Continue; ForceSpray(client, client, false); g_fNextSprayTime[client] = 0.0; impulse = 0; //wow return Plugin_Changed; } } else if (CheckCommandAccess(client, "", ADMFLAG_CUSTOM1)) { if (!g_bSprayBanned[client] && !g_bSprayHashBanned[client] && g_fNextSprayTime[client] <= GetGameTime()) { //if (IsPlayerAlive(client)) //if (TracePlayerAnglesRanged(client, 128.0)) //return Plugin_Continue; ForceSpray(client, client, false); g_fNextSprayTime[client] = GetGameTime() + (g_cvarDecalFrequency.FloatValue / 2); impulse = 0; //wow return Plugin_Changed; } } return Plugin_Continue; } public void OnAdminMenuReady(Handle hAdminMenu) { if (hAdminMenu == g_hTopMenu) return; g_hTopMenu = CloneHandle(hAdminMenu); TopMenuObject hMenuObj = AddToTopMenu(g_hTopMenu, "SprayManagerCommands", TopMenuObject_Category, TopMenu_Main_Handler, INVALID_TOPMENUOBJECT); if (hMenuObj == INVALID_TOPMENUOBJECT) return; AddToTopMenu(g_hTopMenu, "SprayManager_Spraybanlist", TopMenuObject_Item, Handler_SprayBanList, hMenuObj, "", ADMFLAG_GENERIC); AddToTopMenu(g_hTopMenu, "SprayManager_Tracespray", TopMenuObject_Item, Handler_TraceSpray, hMenuObj, "sm_tracespray", ADMFLAG_GENERIC); AddToTopMenu(g_hTopMenu, "SprayManager_Spray", TopMenuObject_Item, Handler_Spray, hMenuObj, "sm_spray", ADMFLAG_GENERIC); AddToTopMenu(g_hTopMenu, "SprayManager_Sprayban", TopMenuObject_Item, Handler_SprayBan, hMenuObj, "sm_sprayban", ADMFLAG_GENERIC); AddToTopMenu(g_hTopMenu, "SprayManager_Banspray", TopMenuObject_Item, Handler_BanSpray, hMenuObj, "sm_banspray", ADMFLAG_GENERIC); AddToTopMenu(g_hTopMenu, "SprayManager_Unban", TopMenuObject_Item, Handler_UnbanSpray, hMenuObj, "sm_unbanspray", ADMFLAG_GENERIC); } public void OnLibraryRemoved(const char[] sLibraryName) { if (strcmp(sLibraryName, "adminmenu") == 0) delete g_hTopMenu; } public void TopMenu_Main_Handler(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) Format(sBuffer, iBufflen, "%s", "SprayManager Commands", iParam1); else if (hAction == TopMenuAction_DisplayTitle) Format(sBuffer, iBufflen, "%s", "SprayManager Commands:", iParam1); } public void Handler_SprayBanList(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) Format(sBuffer, iBufflen, "%s", "List Spray Banned Clients", iParam1); else if (hAction == TopMenuAction_SelectOption) Menu_ListBans(iParam1); } public void Handler_TraceSpray(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) { Format(sBuffer, iBufflen, "%s", "Trace a Spray", iParam1); } else if (hAction == TopMenuAction_SelectOption) { float vecEndPos[3]; if (TracePlayerAngles(iParam1, vecEndPos)) { for (int i = 1; i <= MaxClients; i++) { if (IsPointInsideAABB(vecEndPos, g_SprayAABB[i])) { g_bInvokedThroughTopMenu[iParam1] = true; Menu_Trace(iParam1, i); return; } } } PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Trace did not hit any sprays."); if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } } public void Handler_Spray(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) Format(sBuffer, iBufflen, "%s", "Spray a Client's Spray", iParam1); else if (hAction == TopMenuAction_SelectOption) Menu_Spray(iParam1); } public void Handler_SprayBan(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) Format(sBuffer, iBufflen, "%s", "Spray Ban a Client", iParam1); else if (hAction == TopMenuAction_SelectOption) Menu_SprayBan(iParam1); } public void Handler_BanSpray(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) Format(sBuffer, iBufflen, "%s", "Ban a Client's Spray", iParam1); else if (hAction == TopMenuAction_SelectOption) Menu_BanSpray(iParam1); } public void Handler_UnbanSpray(Handle hMenu, TopMenuAction hAction, TopMenuObject hObjID, int iParam1, char[] sBuffer, int iBufflen) { if (hAction == TopMenuAction_DisplayOption) Format(sBuffer, iBufflen, "%s", "Unban a Client", iParam1); else if (hAction == TopMenuAction_SelectOption) Menu_Unban(iParam1); } void Menu_ListBans(int client) { if (!IsValidClient(client)) return; int iBannedClients; Menu ListMenu = new Menu(MenuHandler_Menu_ListBans); ListMenu.SetTitle("[SprayManager] Banned Clients:"); ListMenu.ExitBackButton = true; for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; if (g_bSprayBanned[i] || g_bSprayHashBanned[i]) { char sUserID[16]; char sBuff[64]; int iUserID = GetClientUserId(i); Format(sBuff, sizeof(sBuff), "%N (#%d)", i, iUserID); Format(sUserID, sizeof(sUserID), "%d", iUserID); ListMenu.AddItem(sUserID, sBuff); iBannedClients++; } } if (!iBannedClients) ListMenu.AddItem("", "No Banned Clients.", ITEMDRAW_DISABLED); ListMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_ListBans(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } case MenuAction_Select: { char sOption[32]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = GetClientOfUserId(StringToInt(sOption)); if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { g_bInvokedThroughListMenu[iParam1] = true; Menu_ListBans_Target(iParam1, target); } } } } void Menu_Trace(int client, int target) { char sSteamID[32]; GetClientAuthId(target, AuthId_Steam2, sSteamID, sizeof(sSteamID)); Menu TraceMenu = new Menu(MenuHandler_Menu_Trace); TraceMenu.SetTitle("Sprayed by: %N (%s)", target, sSteamID); if (g_bInvokedThroughTopMenu[client]) TraceMenu.ExitBackButton = true; TraceMenu.AddItem("1", "Warn Client"); TraceMenu.AddItem("2", "Slap and Warn Client"); TraceMenu.AddItem("3", "Kick Client"); TraceMenu.AddItem("4", "Spray Ban Client"); TraceMenu.AddItem("5", "Ban Clients Spray"); TraceMenu.AddItem("", "", ITEMDRAW_SPACER); TraceMenu.AddItem("6", "Ban Client"); g_iSprayTraceTarget[client] = target; TraceMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_Trace(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } case MenuAction_Select: { char sOption[2]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = g_iSprayTraceTarget[iParam1]; if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); g_bInvokedThroughTopMenu[iParam1] = false; if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { switch (StringToInt(sOption)) { case 1: { PrintToChat(target, "\x01\x04[SprayManager]\x01 Your spray is not allowed, change it."); Menu_Trace(iParam1, target); } case 2: { SlapPlayer(target, 0); PrintToChat(target, "\x01\x04[SprayManager]\x01 Your spray is not allowed, change it."); Menu_Trace(iParam1, target); } case 3: { g_bInvokedThroughTopMenu[iParam1] = false; KickClient(target, "Your spray is not allowed, change it"); } case 4: { Menu TraceSpraySprayBan = new Menu(MenuHandler_Menu_Trace_SprayBan); TraceSpraySprayBan.SetTitle("[SprayManager] Select a Spray Ban Length for %N (#%d)", target, GetClientUserId(target)); TraceSpraySprayBan.ExitBackButton = true; TraceSpraySprayBan.AddItem("10", "10 Minutes"); TraceSpraySprayBan.AddItem("30", "30 Minutes"); TraceSpraySprayBan.AddItem("60", "1 Hour"); TraceSpraySprayBan.AddItem("1440", "1 Day"); TraceSpraySprayBan.AddItem("10080", "1 Week"); TraceSpraySprayBan.AddItem("40320", "1 Month"); TraceSpraySprayBan.AddItem("0", "Permanent"); g_iSprayBanTarget[iParam1] = target; TraceSpraySprayBan.Display(iParam1, MENU_TIME_FOREVER); } case 5: { if (BanClientSpray(iParam1, target)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Banned \x04%N\x01's spray", target); LogAction(iParam1, target, "\"%L\" banned \"%L\"'s spray", iParam1, target); } } case 6: { Menu TraceSprayBan = new Menu(MenuHandler_Menu_Trace_Ban); TraceSprayBan.SetTitle("[SprayManager] Select a Ban Length for %N (#%d)", target, GetClientUserId(target)); TraceSprayBan.ExitBackButton = true; TraceSprayBan.AddItem("10", "10 Minutes"); TraceSprayBan.AddItem("30", "30 Minutes"); TraceSprayBan.AddItem("60", "1 Hour"); TraceSprayBan.AddItem("1440", "1 Day"); TraceSprayBan.AddItem("10080", "1 Week"); TraceSprayBan.AddItem("40320", "1 Month"); TraceSprayBan.AddItem("0", "Permanent"); g_iBanTarget[iParam1] = target; TraceSprayBan.Display(iParam1, MENU_TIME_FOREVER); } } } } } } int MenuHandler_Menu_Trace_SprayBan(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack) { if (IsValidClient(g_iSprayBanTarget[iParam1])) { Menu_Trace(iParam1, g_iSprayBanTarget[iParam1]); } else if (g_hTopMenu != null) { g_bInvokedThroughTopMenu[iParam1] = false; DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } else { g_bInvokedThroughTopMenu[iParam1] = false; delete hMenu; } } } case MenuAction_Select: { char sOption[8]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = g_iSprayBanTarget[iParam1]; if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); g_iSprayBanTarget[iParam1] = 0; g_bInvokedThroughTopMenu[iParam1] = false; if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { if (SprayBanClient(iParam1, target, StringToInt(sOption), "Inappropriate Spray")) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", target); LogAction(iParam1, target, "\"%L\" spray banned \"%L\" (Hash: \"%s\")", iParam1, target, g_sSprayHash[target]); } g_iSprayBanTarget[iParam1] = 0; g_bInvokedThroughTopMenu[iParam1] = false; } } } } int MenuHandler_Menu_Trace_Ban(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack) { if (IsValidClient(g_iBanTarget[iParam1])) { Menu_Trace(iParam1, g_iBanTarget[iParam1]); } else if (g_hTopMenu != null) { g_bInvokedThroughTopMenu[iParam1] = false; DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } else { g_bInvokedThroughTopMenu[iParam1] = false; delete hMenu; } } } case MenuAction_Select: { char sOption[8]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = g_iBanTarget[iParam1]; if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); g_iBanTarget[iParam1] = 0; g_bInvokedThroughTopMenu[iParam1] = false; if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { FakeClientCommandEx(iParam1, "sm_ban \"#%d\" \"%s\" \"Inappropriate spray\"", GetClientUserId(g_iBanTarget[iParam1]), sOption); g_iBanTarget[iParam1] = 0; g_bInvokedThroughTopMenu[iParam1] = false; } } } } void Menu_Spray(int client) { if (!IsValidClient(client)) return; Menu SprayMenu = new Menu(MenuHandler_Menu_Spray); SprayMenu.SetTitle("[SprayManager] Select a Client to Force Spray:"); SprayMenu.ExitBackButton = true; for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; char sUserID[16]; char sBuff[64]; int iUserID = GetClientUserId(i); Format(sUserID, sizeof(sUserID), "%d", iUserID); if (g_bSprayBanned[i] && g_bSprayHashBanned[i]) { Format(sBuff, sizeof(sBuff), "%N (#%d) [Spray & Hash Banned]", i, iUserID); SprayMenu.AddItem(sUserID, sBuff); } else if (g_bSprayBanned[i]) { Format(sBuff, sizeof(sBuff), "%N (#%d) [Spray Banned]", i, iUserID); SprayMenu.AddItem(sUserID, sBuff); } else if (g_bSprayHashBanned[i]) { Format(sBuff, sizeof(sBuff), "%N (#%d) [Hash Banned]", i, iUserID); SprayMenu.AddItem(sUserID, sBuff); } else { Format(sBuff, sizeof(sBuff), "%N (#%d)", i, iUserID); SprayMenu.AddItem(sUserID, sBuff); } } SprayMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_Spray(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } case MenuAction_Select: { char sOption[8]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = GetClientOfUserId(StringToInt(sOption)); if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { g_iAllowSpray = target; ForceSpray(iParam1, target); PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Sprayed \x04%N\x01's spray(s).", target); Menu_Spray(iParam1); } } } } void Menu_SprayBan(int client) { if (!IsValidClient(client)) return; int iClientsToDisplay; Menu SprayBanMenu = new Menu(MenuHandler_Menu_SprayBan); SprayBanMenu.SetTitle("[SprayManager] Select a Client to Spray Ban:"); SprayBanMenu.ExitBackButton = true; for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; if (g_bSprayBanned[i]) continue; char sUserID[16]; char sBuff[64]; int iUserID = GetClientUserId(i); Format(sBuff, sizeof(sBuff), "%N (#%d)", i, iUserID); Format(sUserID, sizeof(sUserID), "%d", iUserID); SprayBanMenu.AddItem(sUserID, sBuff); iClientsToDisplay++; } if (!iClientsToDisplay) SprayBanMenu.AddItem("", "No eligible Clients found.", ITEMDRAW_DISABLED); SprayBanMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_SprayBan(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } case MenuAction_Select: { char sOption[32]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = GetClientOfUserId(StringToInt(sOption)); if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { Menu SprayBanLengthMenu = new Menu(MenuHandler_Menu_SprayBan_Length); SprayBanLengthMenu.SetTitle("[SprayManager] Choose a Spray Ban Length for %N (#%d)", target, GetClientUserId(target)); SprayBanLengthMenu.ExitBackButton = true; SprayBanLengthMenu.AddItem("10", "10 Minutes"); SprayBanLengthMenu.AddItem("30", "30 Minutes"); SprayBanLengthMenu.AddItem("60", "1 Hour"); SprayBanLengthMenu.AddItem("1440", "1 Day"); SprayBanLengthMenu.AddItem("10080", "1 Week"); SprayBanLengthMenu.AddItem("40320", "1 Month"); SprayBanLengthMenu.AddItem("0", "Permanent"); g_iSprayBanTarget[iParam1] = target; SprayBanLengthMenu.Display(iParam1, MENU_TIME_FOREVER); } } } } int MenuHandler_Menu_SprayBan_Length(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack) Menu_SprayBan(iParam1); } case MenuAction_Select: { char sOption[8]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = g_iSprayBanTarget[iParam1]; if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); g_iSprayBanTarget[iParam1] = 0; Menu_SprayBan(iParam1); } else { if (SprayBanClient(iParam1, target, StringToInt(sOption), "Inappropriate Spray")) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray banned \x04%N", target); LogAction(iParam1, target, "\"%L\" spray banned \"%L\" (Hash: \"%s\")", iParam1, target, g_sSprayHash[target]); } g_iSprayBanTarget[iParam1] = 0; } } } } void Menu_BanSpray(int client) { if (!IsValidClient(client)) return; int iClientsToDisplay; Menu BanSprayMenu = new Menu(MenuHandler_Menu_BanSpray); BanSprayMenu.SetTitle("[SprayManager] Select a Client to Ban their Spray:"); BanSprayMenu.ExitBackButton = true; for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; if (g_bSprayHashBanned[i]) continue; char sUserID[16]; char sBuff[64]; int iUserID = GetClientUserId(i); Format(sBuff, sizeof(sBuff), "%N (#%d)", i, iUserID); Format(sUserID, sizeof(sUserID), "%d", iUserID); BanSprayMenu.AddItem(sUserID, sBuff); iClientsToDisplay++; } if (!iClientsToDisplay) BanSprayMenu.AddItem("", "No eligible Clients found.", ITEMDRAW_DISABLED); BanSprayMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_BanSpray(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } case MenuAction_Select: { char sOption[32]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = GetClientOfUserId(StringToInt(sOption)); if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); Menu_BanSpray(iParam1); } else { if (BanClientSpray(iParam1, target)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Banned \x04%N\x01's spray", target); LogAction(iParam1, target, "\"%L\" banned \"%L\"'s spray", iParam1, target); } } } } } void Menu_Unban(int client) { if (!IsValidClient(client)) return; int iBannedClients; Menu UnbanSprayMenu = new Menu(MenuHandler_Menu_UnbanSpray); UnbanSprayMenu.SetTitle("[SprayManager] Select a Client for more information:"); UnbanSprayMenu.ExitBackButton = true; for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i) || IsFakeClient(i)) continue; if (!g_bSprayHashBanned[i] && !g_bSprayBanned[i]) continue; char sUserID[16]; char sBuff[64]; int iUserID = GetClientUserId(i); Format(sBuff, sizeof(sBuff), "%N (#%d)", i, iUserID); Format(sUserID, sizeof(sUserID), "%d", iUserID); UnbanSprayMenu.AddItem(sUserID, sBuff); iBannedClients++; } if (!iBannedClients) UnbanSprayMenu.AddItem("", "No Banned Clients.", ITEMDRAW_DISABLED); UnbanSprayMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_UnbanSpray(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack && g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); } case MenuAction_Select: { char sOption[32]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = GetClientOfUserId(StringToInt(sOption)); if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); Menu_Unban(iParam1); } else { g_bInvokedThroughListMenu[iParam1] = false; Menu_ListBans_Target(iParam1, target); } } } } void Menu_ListBans_Target(int client, int target) { Menu ListTargetMenu = new Menu(MenuHandler_Menu_ListBans_Target); ListTargetMenu.SetTitle("[SprayManager] Banned Client: %N (#%d)", target, GetClientUserId(target)); ListTargetMenu.ExitBackButton = true; char sBanType[32]; char sUserID[32]; int iUserID = GetClientUserId(target); Format(sUserID, sizeof(sUserID), "%d", iUserID); if (g_bSprayHashBanned[target] && !g_bSprayBanned[target]) { strcopy(sBanType, sizeof(sBanType), "Type: Hash"); ListTargetMenu.AddItem("", sBanType, ITEMDRAW_DISABLED); ListTargetMenu.AddItem("", "", ITEMDRAW_SPACER); ListTargetMenu.AddItem(sUserID, "Unban Client?"); ListTargetMenu.Display(client, MENU_TIME_FOREVER); return; } char sBanExpiryDate[64]; char sBanIssuedDate[64]; char sBanDuration[64]; char sBannedBy[128]; char sBanReason[64]; int iBanExpiryDate = g_iSprayUnbanTimestamp[target]; int iBanIssuedDate = g_iSprayBanTimestamp[target]; int iBanDuration = iBanExpiryDate ? ((iBanExpiryDate - iBanIssuedDate) / 60) : 0; if (iBanExpiryDate) { FormatTime(sBanExpiryDate, sizeof(sBanExpiryDate), NULL_STRING, iBanExpiryDate); Format(sBanDuration, sizeof(sBanDuration), "%d %s", iBanDuration, SingularOrMultiple(iBanDuration) ? "Minutes" : "Minute"); } else { strcopy(sBanExpiryDate, sizeof(sBanExpiryDate), "Never"); strcopy(sBanDuration, sizeof(sBanDuration), "Permanent"); } FormatTime(sBanIssuedDate, sizeof(sBanIssuedDate), NULL_STRING, iBanIssuedDate); Format(sBannedBy, sizeof(sBannedBy), "Banned by: %s (%s)", g_sBanIssuer[target], g_sBanIssuerSID[target]); Format(sBanDuration, sizeof(sBanDuration), "Duration: %s", sBanDuration); Format(sBanExpiryDate, sizeof(sBanExpiryDate), "Expires: %s", sBanExpiryDate); Format(sBanIssuedDate, sizeof(sBanIssuedDate), "Issued on: %s", sBanIssuedDate); Format(sBanReason, sizeof(sBanReason), "Reason: %s", g_sBanReason[target]); if (g_bSprayBanned[target] && g_bSprayHashBanned[target]) strcopy(sBanType, sizeof(sBanType), "Type: Spray & Hash"); else if (g_bSprayBanned[target]) strcopy(sBanType, sizeof(sBanType), "Type: Spray"); ListTargetMenu.AddItem("", sBanType, ITEMDRAW_DISABLED); ListTargetMenu.AddItem("", sBannedBy, ITEMDRAW_DISABLED); ListTargetMenu.AddItem("", sBanIssuedDate, ITEMDRAW_DISABLED); ListTargetMenu.AddItem("", sBanExpiryDate, ITEMDRAW_DISABLED); ListTargetMenu.AddItem("", sBanDuration, ITEMDRAW_DISABLED); ListTargetMenu.AddItem("", sBanReason, ITEMDRAW_DISABLED); ListTargetMenu.AddItem(sUserID, "Unban Client?"); ListTargetMenu.Display(client, MENU_TIME_FOREVER); } int MenuHandler_Menu_ListBans_Target(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack) { if (g_bInvokedThroughListMenu[iParam1]) Menu_ListBans(iParam1); else Menu_Unban(iParam1); } } case MenuAction_Select: { char sOption[32]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = GetClientOfUserId(StringToInt(sOption)); if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); Menu_ListBans(iParam1); } else { if (g_bSprayBanned[target] && g_bSprayHashBanned[target]) { Menu MenuUnbanMode = new Menu(MenuHandler_Menu_UnbanMode); MenuUnbanMode.SetTitle("[SprayManager] Unban %N?", target); MenuUnbanMode.ExitBackButton = true; MenuUnbanMode.AddItem("H", "Remove Hash Ban."); MenuUnbanMode.AddItem("S", "Remove Spray Ban."); MenuUnbanMode.AddItem("B", "Remove Both."); g_iSprayUnbanTarget[iParam1] = target; MenuUnbanMode.Display(iParam1, MENU_TIME_FOREVER); return; } Menu MenuConfirmUnban = new Menu(MenuHandler_Menu_ConfirmUnban); MenuConfirmUnban.SetTitle("[SprayManager] Unban %N?", target); MenuConfirmUnban.ExitBackButton = true; MenuConfirmUnban.AddItem("Y", "Yes."); MenuConfirmUnban.AddItem("N", "No."); g_iSprayUnbanTarget[iParam1] = target; MenuConfirmUnban.Display(iParam1, MENU_TIME_FOREVER); } } } } int MenuHandler_Menu_UnbanMode(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack) { if (IsValidClient(g_iSprayUnbanTarget[iParam1])) Menu_ListBans_Target(iParam1, g_iSprayUnbanTarget[iParam1]); else if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } } case MenuAction_Select: { char sOption[2]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = g_iSprayUnbanTarget[iParam1]; if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); g_iSprayUnbanTarget[iParam1] = 0; if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { if (sOption[0] == 'H') { if (UnbanClientSpray(iParam1, target)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Unbanned \x04%N\x01's spray", target); LogAction(iParam1, target, "\"%L\" unbanned \"%L\"'s spray", iParam1, target); } } else if (sOption[0] == 'S') { if (SprayUnbanClient(target, iParam1)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray unbanned \x04%N", target); LogAction(iParam1, target, "\"%L\" spray unbanned \"%L\"", iParam1, target); } } else if (sOption[0] == 'B') { if (SprayUnbanClient(target, iParam1) && UnbanClientSpray(iParam1, target)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray unbanned \x04%N", target); LogAction(iParam1, target, "\"%L\" spray unbanned \"%L\"", iParam1, target); } } g_iSprayUnbanTarget[iParam1] = 0; } } } } int MenuHandler_Menu_ConfirmUnban(Menu hMenu, MenuAction action, int iParam1, int iParam2) { switch (action) { case MenuAction_End: delete hMenu; case MenuAction_Cancel: { if (iParam2 == MenuCancel_ExitBack) { if (IsValidClient(g_iSprayUnbanTarget[iParam1])) Menu_ListBans_Target(iParam1, g_iSprayUnbanTarget[iParam1]); else if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } } case MenuAction_Select: { char sOption[2]; hMenu.GetItem(iParam2, sOption, sizeof(sOption)); int target = g_iSprayUnbanTarget[iParam1]; if (!IsValidClient(target)) { PrintToChat(iParam1, "\x01\x04[SprayManager]\x01 Target no longer available."); g_iSprayUnbanTarget[iParam1] = 0; if (g_hTopMenu != null) DisplayTopMenu(g_hTopMenu, iParam1, TopMenuPosition_LastCategory); else delete hMenu; } else { if (sOption[0] == 'Y') { if (g_bSprayHashBanned[target] && g_bSprayBanned[target]) { if (SprayUnbanClient(target, iParam1) && UnbanClientSpray(iParam1, target)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray unbanned \x04%N", target); LogAction(iParam1, target, "\"%L\" spray unbanned \"%L\"", iParam1, target); } } else if (g_bSprayBanned[target]) { if (SprayUnbanClient(target, iParam1)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Spray unbanned \x04%N", target); LogAction(iParam1, target, "\"%L\" spray unbanned \"%L\"", iParam1, target); } } else if (g_bSprayHashBanned[target]) { if (UnbanClientSpray(iParam1, target)) { ShowActivity2(iParam1, "\x01\x04[SprayManager] ", "\x01Unbanned \x04%N\x01's spray", target); LogAction(iParam1, target, "\"%L\" unbanned \"%L\"'s spray", iParam1, target); } } g_iSprayUnbanTarget[iParam1] = 0; } else if (sOption[0] == 'N') { Menu_ListBans_Target(iParam1, g_iSprayUnbanTarget[iParam1]); g_iSprayUnbanTarget[iParam1] = 0; } } } } } public Action Command_MarkNSFW(int client, int argc) { if (!client) { PrintToServer("[SprayManager] Cannot use command from server console."); return Plugin_Handled; } if (!IsValidClient(client)) { ReplyToCommand(client, "[SprayManager] Unable to update status, please wait a few seconds and try again."); return Plugin_Handled; } if (g_hDatabase == null || !g_bFullyConnected) { ReplyToCommand(client, "\x01\x04[SprayManager]\x01 Unable to update status, please wait a few seconds and try again."); return Plugin_Handled; } if (g_bMarkedNSFWByAdmin[client] || g_bHasNSFWSpray[client]) { PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray is already marked as NSFW."); return Plugin_Handled; } g_bHasNSFWSpray[client] = true; char sQuery[256]; char sClientSteamID[32]; GetClientAuthId(client, AuthId_Steam2, sClientSteamID, sizeof(sClientSteamID)); Format(sQuery, sizeof(sQuery), "INSERT INTO `spraynsfwlist` (`sprayhash`, `sprayersteamid`, `setbyadmin`) VALUES ('%s', '%s', '%d');", g_sSprayHash[client], sClientSteamID, 0); SQL_TQuery(g_hDatabase, DummyCallback, sQuery); for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i)) continue; for (int x = 1; x <= MaxClients; x++) { if (!IsValidClient(x)) continue; if (g_bHasSprayHidden[i][x]) continue; if (g_bWantsToSeeNSFWSprays[i]) continue; PaintWorldDecalToOne(g_bHasNSFWSpray[x] ? g_iNSFWDecalIndex : g_iTransparentDecalIndex, g_vecSprayOrigin[x], i); g_bSkipDecalHook = true; SprayClientDecalToOne(x, i, g_bHasNSFWSpray[x] ? 0 : g_iDecalEntity[x], g_bHasNSFWSpray[x] ? ACTUAL_NULL_VECTOR : g_vecSprayOrigin[x]); g_iClientToClientSprayLifetime[i][x] = g_bHasNSFWSpray[x] ? g_iClientToClientSprayLifetime[i][x] : 0; g_bSkipDecalHook = false; } } PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray is now marked as NSFW."); return Plugin_Continue; } public Action Command_MarkSFW(int client, int argc) { if (!client) { PrintToServer("[SprayManager] Cannot use command from server console."); return Plugin_Handled; } if (!IsValidClient(client)) { ReplyToCommand(client, "[SprayManager] Unable to update status, please wait a few seconds and try again."); return Plugin_Handled; } if (g_hDatabase == null || !g_bFullyConnected) { ReplyToCommand(client, "\x01\x04[SprayManager]\x01 Unable to update status, please wait a few seconds and try again."); return Plugin_Handled; } if (g_bMarkedNSFWByAdmin[client]) { PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray has been marked as NSFW by an admin, you cannot change this."); return Plugin_Handled; } if (!g_bHasNSFWSpray[client]) { PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray is already marked as SFW."); return Plugin_Handled; } g_bHasNSFWSpray[client] = false; char sQuery[256]; Format(sQuery, sizeof(sQuery), "DELETE FROM `spraynsfwlist` WHERE `sprayhash` = '%s';", g_sSprayHash[client]); SQL_TQuery(g_hDatabase, DummyCallback, sQuery); for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i)) continue; if (g_bHasSprayHidden[i][client]) continue; if (g_bWantsToSeeNSFWSprays[i]) continue; PaintWorldDecalToOne(g_iTransparentDecalIndex, g_vecSprayOrigin[client], i); g_bSkipDecalHook = true; SprayClientDecalToOne(client, i, g_iDecalEntity[client], g_vecSprayOrigin[client]); g_iClientToClientSprayLifetime[i][client] = 0; g_bSkipDecalHook = false; } PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray is now marked as SFW."); return Plugin_Continue; } public Action Command_NSFW(int client, int argc) { if (!client) { ReplyToCommand(client, "[SprayManager] Cannot use command from server console."); return Plugin_Handled; } if (!AreClientCookiesCached(client)) { PrintToChat(client, "\x01\x04[SprayManager]\x01 Could not update status, please wait a few seconds and try again."); return Plugin_Handled; } g_bWantsToSeeNSFWSprays[client] = !g_bWantsToSeeNSFWSprays[client]; SetClientCookie(client, g_hWantsToSeeNSFWCookie, g_bWantsToSeeNSFWSprays[client] ? "1" : "0"); PrintToChat(client, "\x01\x04[SprayManager]\x01 You can %s", g_bWantsToSeeNSFWSprays[client] ? "now see \x07BF49FFNSFW\x01 sprays." : "no longer see \x07BF49FFNSFW\x01 sprays."); for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i)) continue; if (!g_bHasNSFWSpray[i]) continue; if (g_bHasSprayHidden[client][i]) continue; PaintWorldDecalToOne(g_bWantsToSeeNSFWSprays[client] ? g_iTransparentDecalIndex : g_iNSFWDecalIndex, g_vecSprayOrigin[i], client); g_bSkipDecalHook = true; SprayClientDecalToOne(i, client, g_bWantsToSeeNSFWSprays[client] ? g_iDecalEntity[i] : 0, g_bWantsToSeeNSFWSprays[client] ? g_vecSprayOrigin[i] : ACTUAL_NULL_VECTOR); g_iClientToClientSprayLifetime[client][i] = g_bWantsToSeeNSFWSprays[client] ? 0 : g_iClientToClientSprayLifetime[client][i]; g_bSkipDecalHook = false; } return Plugin_Handled; } public Action Command_HideSpray(int client, int argc) { if (!client) { ReplyToCommand(client, "[SprayManager] Cannot use command from server console."); return Plugin_Handled; } if (argc > 0) { int iTarget; char sArg[64]; GetCmdArg(1, sArg, sizeof(sArg)); if ((iTarget = FindTarget(client, sArg, false, false)) <= 0) return Plugin_Handled; g_bHasSprayHidden[client][iTarget] = true; PrintToChat(client, "\x01\x04[SprayManager]\x01 You have hidden \x04%N\x01's spray.", iTarget); PaintWorldDecalToOne(g_iHiddenDecalIndex, g_vecSprayOrigin[iTarget], client); g_bSkipDecalHook = true; SprayClientDecalToOne(iTarget, client, 0, ACTUAL_NULL_VECTOR); g_bSkipDecalHook = false; return Plugin_Handled; } float vecEndPos[3]; if (TracePlayerAngles(client, vecEndPos)) { for (int i = 1; i <= MaxClients; i++) { if (!IsPointInsideAABB(vecEndPos, g_SprayAABB[i])) continue; g_bHasSprayHidden[client][i] = true; PrintToChat(client, "\x01\x04[SprayManager]\x01 You have hidden \x04%N\x01's spray.", i); PaintWorldDecalToOne(g_iHiddenDecalIndex, g_vecSprayOrigin[i], client); g_bSkipDecalHook = true; SprayClientDecalToOne(i, client, 0, ACTUAL_NULL_VECTOR); g_bSkipDecalHook = false; return Plugin_Handled; } } PrintToChat(client, "\x01\x04[SprayManager]\x01 No spray could be found."); return Plugin_Handled; } public Action Command_UnhideSpray(int client, int argc) { if (!client) { ReplyToCommand(client, "[SprayManager] Cannot use command from server console."); return Plugin_Handled; } if (argc > 0) { int iTarget; char sArg[64]; GetCmdArg(1, sArg, sizeof(sArg)); if ((iTarget = FindTarget(client, sArg, false, false)) <= 0) return Plugin_Handled; g_bHasSprayHidden[client][iTarget] = false; PrintToChat(client, "\x01\x04[SprayManager]\x01 You have unhidden \x04%N\x01's spray.", iTarget); PaintWorldDecalToOne(g_iTransparentDecalIndex, g_vecSprayOrigin[iTarget], client); if (!g_bWantsToSeeNSFWSprays[client] && g_bHasNSFWSpray[iTarget]) { PaintWorldDecalToOne(g_iNSFWDecalIndex, g_vecSprayOrigin[iTarget], client); return Plugin_Handled; } g_bSkipDecalHook = true; SprayClientDecalToOne(iTarget, client, g_iDecalEntity[iTarget], g_vecSprayOrigin[iTarget]); g_iClientToClientSprayLifetime[client][iTarget] = 0; g_bSkipDecalHook = false; return Plugin_Handled; } float vecEndPos[3]; if (TracePlayerAngles(client, vecEndPos)) { for (int i = 1; i <= MaxClients; i++) { if (!IsPointInsideAABB(vecEndPos, g_SprayAABB[i])) continue; g_bHasSprayHidden[client][i] = false; PrintToChat(client, "\x01\x04[SprayManager]\x01 You have unhidden \x04%N\x01's spray.", i); PaintWorldDecalToOne(g_iTransparentDecalIndex, g_vecSprayOrigin[i], client); if (!g_bWantsToSeeNSFWSprays[client] && g_bHasNSFWSpray[i]) { PaintWorldDecalToOne(g_iNSFWDecalIndex, g_vecSprayOrigin[i], client); return Plugin_Handled; } g_bSkipDecalHook = true; SprayClientDecalToOne(i, client, g_iDecalEntity[i], g_vecSprayOrigin[i]); g_iClientToClientSprayLifetime[client][i] = 0; g_bSkipDecalHook = false; return Plugin_Handled; } } PrintToChat(client, "\x01\x04[SprayManager]\x01 No spray could be found."); return Plugin_Handled; } public Action Command_AdminSpray(int client, int argc) { if (!client) { PrintToServer("[SprayManager] Cannot use command from server console."); return Plugin_Handled; } if (argc > 0) { char sArgs[64]; char sTargetName[MAX_TARGET_LENGTH]; int iTargets[MAXPLAYERS]; int iTargetCount; bool bIsML; GetCmdArg(1, sArgs, sizeof(sArgs)); if ((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS, sTargetName, sizeof(sTargetName), bIsML)) <= 0) { ReplyToTargetError(client, iTargetCount); return Plugin_Handled; } for (int i = 0; i < iTargetCount; i++) { g_iAllowSpray = iTargets[i]; ForceSpray(client, iTargets[i], false); } PrintToChat(client, "\x01\x04[SprayManager]\x01 Sprayed \x04%s\x01's spray(s).", sTargetName); return Plugin_Handled; } g_iAllowSpray = client; ForceSpray(client, client, false); PrintToChat(client, "\x01\x04[SprayManager]\x01 Sprayed your own spray."); return Plugin_Handled; } public Action Command_SprayBan(int client, int argc) { if (argc < 2) { ReplyToCommand(client, "[SprayManager] Usage: sm_sprayban