diff --git a/AFKManager/scripting/AFKManager.sp b/AFKManager/scripting/AFKManager.sp index 73b6e2b9..e816bcbe 100644 --- a/AFKManager/scripting/AFKManager.sp +++ b/AFKManager/scripting/AFKManager.sp @@ -90,7 +90,7 @@ public void OnPluginStart() HookConVarChange((cvar = CreateConVar("sm_afk_immunity", "1", "AFK admins immunity: 0 = DISABLED, 1 = COMPLETE, 2 = KICK, 3 = MOVE")), Cvar_Immunity); g_iImmunity = GetConVarInt(cvar); - CloseHandle(cvar); + delete cvar; AddCommandListener(Command_Say, "say"); AddCommandListener(Command_Say, "say_team"); @@ -373,7 +373,7 @@ public Action Timer_CheckPlayer(Handle Timer, any Data) if(IdleTime_ > IdleTime) Position++; } - PrintCenterText(client, "You have been kick-flagged for being inactive. [%d/%d]", Position, FlaggedPlayers); + PrintCenterText(client, "You have been kick-flagged for being inactive. Your Position: [%d of %d]", Position, FlaggedPlayers); } } } diff --git a/AmmoManager/scripting/AmmoManager.sp b/AmmoManager/scripting/AmmoManager.sp index bf704963..f14a2e12 100644 --- a/AmmoManager/scripting/AmmoManager.sp +++ b/AmmoManager/scripting/AmmoManager.sp @@ -36,14 +36,14 @@ public void OnPluginStart() int iMaxClipOffset; if ((iMaxClipOffset = GameConfGetOffset(hGameConf, "GetMaxClip")) == -1) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("GameConfGetOffset(hGameConf, \"GetMaxClip\") failed!"); return; } if ((g_hGetMaxClip = DHookCreate(iMaxClipOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxClip)) == INVALID_HANDLE) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("DHookCreate(iMaxClipOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxClip) failed!"); return; } @@ -54,14 +54,14 @@ public void OnPluginStart() int iMaxReserveOffset; if ((iMaxReserveOffset = GameConfGetOffset(hGameConf, "GetMaxReserve")) == -1) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("GameConfGetOffset(hGameConf, \"GetMaxReserve\") failed!"); return; } if ((g_hGetMaxReserve = DHookCreate(iMaxReserveOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxReserve)) == INVALID_HANDLE) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("DHookCreate(iMaxReserveOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxReserve) failed!"); return; } @@ -74,7 +74,7 @@ public void OnPluginStart() OnEntityCreated(entity, "weapon_*"); } - CloseHandle(hGameConf); + delete hGameConf; } //---------------------------------------------------------------------------------------------------- diff --git a/CTimer/ctimer.sp b/CTimer/ctimer.sp new file mode 100644 index 00000000..0781577e --- /dev/null +++ b/CTimer/ctimer.sp @@ -0,0 +1,188 @@ +#pragma semicolon 1 + +#define PLUGIN_AUTHOR "TRANSLUCENT" +#define PLUGIN_VERSION "0.62wtf" +#define MAXLENGTH_MESSAGE 256 + +#define STARTZONE 0 +#define ENDZONE 1 + +#define FRAMEINTERVAL 330 +#define REPLAYS_PATH "data/ctimer" // Path to where replays are stored +#define BACKUP_REPLAYS +#define MAXVELOCITY 280.0 +#define MAX_DIST 1536.0 +#define MAX_DIST_SQ MAX_DIST * MAX_DIST + +#include +#include +#include +#include +#include + +/* Global variables */ +enum +{ + RUNDATA_POSITION_X, + RUNDATA_POSITION_Y, + RUNDATA_POSITION_Z, + RUNDATA_PITCH, + RUNDATA_YAW, + RUNDATA_BUTTONS, + RUNDATA_IMPULSE, + RUNDATA_WEAPONID, + RUNDATA_MAX +} + +///TIMER HANDLES +Handle g_hDrawFullZone = INVALID_HANDLE; +Handle g_hDrawZone = INVALID_HANDLE; +Handle g_hHudLoop = INVALID_HANDLE; +Handle g_hSideHudLoop = INVALID_HANDLE; + +///DATABASE +Database g_hDatabase = null; + +///PLAYERS +float g_fMapTime[MAXPLAYERS + 1]; +float g_fStartTime[MAXPLAYERS + 1]; +int g_iActivity[MAXPLAYERS + 1] = -1; //-1 - Inactive, 0 - Running, 1 - StartZone, 2 - EndZone + +///BOTS AND RECORDING +//ArrayList g_arrayGhost; +ArrayList g_arrayRun[MAXPLAYERS + 1]; //Record array +//char g_sGhostNames[MAX_NAME_LENGTH]; +//int g_iGhost = -1; +//int g_iGhostFrame = -1; +//int g_fGhostVel = -1; +float g_fTickrate; + +///ZONEMAP INFO +int g_iSnapToClient = -1; +bool g_bEditorComesFromMenu; +float g_fStartOrigins[2][3]; +float g_fEndOrigins[2][3]; +int g_iEditor = -1; +int g_iTriggerEnt[2] = -1; + +///MAP INFO +bool g_bActive = false; +int g_iTier = 1; +int g_iMapID = -1; +float g_fWrTime = -1.0; +char g_sMapName[64]; +char g_sWrHolder[MAX_NAME_LENGTH]; + +///OTHERS +bool g_bLateLoad = false; +int g_iBeam; +ConVar g_hCvarLasers = null; +bool g_bLasers = false; + +// Offsets (netprops) +int m_vecOrigin; // CBaseEntity::m_vecOrigin +int m_hActiveWeapon; // CBaseCombatCharacter::m_hActiveWeapon + +public Plugin myinfo = +{ + name = "Under Average Timer", + author = PLUGIN_AUTHOR, + description = "", + version = PLUGIN_VERSION, + url = "" +}; + +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + CreateNative("CTimer_Stop", Native_StopTime); + + RegPluginLibrary("ctimer"); + + g_bLateLoad = late; + return APLRes_Success; +} + +public void OnPluginStart() +{ + LoadTranslations("ctimer.phrases"); + + HookEvent("round_start", Event_RoundStart); + HookEvent("player_death", Event_PlayerDeath); + + RegAdminCmd("sm_timeradmin", Command_TimerAdmin, ADMFLAG_CHEATS, "Your one stop for timer management"); + RegAdminCmd("sm_zones", Command_Zones, ADMFLAG_CHEATS, "Create zones"); + + RegConsoleCmd("sm_stop", Command_Stop, "Stops your timer"); + RegConsoleCmd("sm_time", Command_Time, "Get a players time"); + RegConsoleCmd("sm_top", Command_Top, "Get a maps top times"); + RegConsoleCmd("sm_wr", Command_WR, "Get a maps best time"); + + RegAdminCmd("sm_origins", Command_Origins, ADMFLAG_CHEATS); + + g_hCvarLasers = CreateConVar("ctimer_zone_lazers", "1", "Lazors", FCVAR_NONE, true, 0.0, true, 1.0); + + if(g_hCvarLasers != null) + { + g_hCvarLasers.AddChangeHook(OnLazorsChange); + } + + g_hDrawFullZone = CreateTimer(0.2, DrawFullZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hDrawZone = CreateTimer(1.0, DrawZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hHudLoop = CreateTimer(0.2, HudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hSideHudLoop = CreateTimer(1.0, SideHudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + + for (new i = 1; i <= MaxClients; i++) + { + g_arrayRun[i] = new ArrayList(RUNDATA_MAX); + } + + m_vecOrigin = FindSendPropInfo("CBaseEntity", "m_vecOrigin"); + + if (m_vecOrigin == -1) + { + SetFailState("Couldn't find CBaseEntity::m_vecOrigin"); + } + if (m_vecOrigin == 0) + { + SetFailState("No offset available for CBaseEntity::m_vecOrigin"); + } + + m_hActiveWeapon = FindSendPropInfo("CBaseCombatCharacter", "m_hActiveWeapon"); + + if (m_hActiveWeapon == -1) + { + SetFailState("Couldn't find CBaseCombatCharacter::m_hActiveWeapon"); + } + if (m_hActiveWeapon == 0) + { + SetFailState("No offset available for CBaseCombatCharacter::m_hActiveWeapon"); + } + + //g_arrayGhost = new ArrayList(9, 0); + + g_fTickrate = (1.0 / GetTickInterval()); + + EstablishConnection(); +} + +#include "ctimer/actions.sp" +#include "ctimer/bots.sp" +#include "ctimer/commands.sp" +#include "ctimer/menus.sp" +#include "ctimer/timers.sp" +#include "ctimer/utility.sp" +#include "ctimer/sql.sp" +#include "ctimer/zones.sp" + +public Action Command_Origins(int client, int args) +{ + PrintToChatAll("Start: %f|%f|%f %f|%f|%f", g_fStartOrigins[0][0], g_fStartOrigins[0][1], g_fStartOrigins[0][2], g_fEndOrigins[0][0], g_fEndOrigins[0][1], g_fEndOrigins[0][2]); + PrintToChatAll("End: %f|%f|%f %f|%f|%f", g_fStartOrigins[1][0], g_fStartOrigins[1][1], g_fStartOrigins[1][2], g_fEndOrigins[1][0], g_fEndOrigins[1][1], g_fEndOrigins[1][2]); + PrintToChatAll("MapID: %i", g_iMapID); + PrintToChatAll("Active: %s", g_bActive ? "active":"inactive"); + PrintToChatAll("Tier: %i", g_iTier); + PrintToChatAll("Wr: %.2f, %s", g_fWrTime, g_sWrHolder); + PrintToChatAll("Speccount: %i", GetSpecCount(client)); + return Plugin_Handled; +} + diff --git a/CTimer/ctimer/actions.sp b/CTimer/ctimer/actions.sp new file mode 100644 index 00000000..30b1cfdf --- /dev/null +++ b/CTimer/ctimer/actions.sp @@ -0,0 +1,219 @@ +public void OnMapStart() +{ + PrecacheModel("models/error.mdl", true); + g_iBeam = PrecacheModel("materials/sprites/physbeam.vmt"); + + AddFileToDownloadsTable("sound/unl1/disco.wav"); + PrecacheSound("unl1/disco.wav"); + + AddFileToDownloadsTable("sound/unl1/steamedyes.mp3"); + PrecacheSound("unl1/steamedyes.mp3"); + + GetCurrentMap(g_sMapName, sizeof(g_sMapName)); + LowerString(g_sMapName, sizeof(g_sMapName)); + + RestartTimers(); + ClearMapInfo(); + CheckDirectories(); + + if (g_hDatabase != null) + { + LoadMapInfo(); + } + +} + +public void OnConfigsExecuted() +{ + g_bLasers = g_hCvarLasers.BoolValue; +} + +public void OnLazorsChange(ConVar convar, char[] oldValue, char[] newValue) +{ + g_bLasers = g_hCvarLasers.BoolValue; +} + +public void OnClientPostAdminCheck(int client) +{ + if (isValidClient(client)) + { + ClearPlayerCache(client); + GetPlayerInfo(client); + } +} + +public void OnClientDisconnect(int client) +{ + if (client == g_iEditor) + { + g_iEditor = -1; + g_bEditorComesFromMenu = false; + } +} + +public void Event_RoundStart(Handle event, char[] name, bool dontBroadcast) +{ + for (int i = 0; i <= 1; i++) + { + CreateTrigger(i); + } + for (int i = 0; i <= MAXPLAYERS; i++) + { + g_iActivity[i] = -1; + } +} + +/*public Action CS_OnTerminateRound(float& delay, CSRoundEndReason& reason) +{ + +}*/ + +public void Event_PlayerDeath(Handle event, char[] name, bool dontBroadcast) +{ + int client = GetClientOfUserId(GetEventInt(event, "userid")); + g_iActivity[client] = -1; +} + +void CheckDirectories() +{ + char path[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, path, sizeof(path), REPLAYS_PATH); + + if (!DirExists(path)) + CreateDirectory(path, 711); + + BuildPath(Path_SM, path, sizeof(path), "%s/%s", REPLAYS_PATH, g_sMapName); + + if (!DirExists(path)) + CreateDirectory(path, 711); + +} + +public void RestartTimers() +{ + delete g_hDrawFullZone; + delete g_hDrawZone; + delete g_hHudLoop; + delete g_hSideHudLoop; + + g_hDrawFullZone = CreateTimer(0.2, DrawFullZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hDrawZone = CreateTimer(1.0, DrawZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hHudLoop = CreateTimer(0.2, HudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + g_hSideHudLoop = CreateTimer(1.0, SideHudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); +} + +public void ClearMapInfo() +{ + for (int i = 0; i <= 1; i++) + { + g_iTriggerEnt[i] = -1; + for (int f = 0; f <= 2; f++) + { + g_fStartOrigins[i][f] = 0.0; + g_fEndOrigins[i][f] = 0.0; + } + } + g_iTier = 1; + g_iMapID = -1; + g_bActive = false; + g_iEditor = -1; + g_bEditorComesFromMenu = false; + g_iSnapToClient = -1; + g_fWrTime = -1.0; + + Format(g_sWrHolder, sizeof(g_sWrHolder), "\0"); +} + +public void ProcessFinish(int client) +{ + float fTime, fTimeToWR; + char name[MAX_NAME_LENGTH], cTime[16], cTimeToWR[16]; + + GetClientName(client, name, sizeof(name)); + fTime = GetEngineTime() - g_fStartTime[client]; + fTimeToWR = fTime - g_fWrTime; + TimerFormat(fTime, cTime, sizeof(cTime), true, false); + + if (fTimeToWR == fTime) + Format(cTimeToWR, sizeof(cTimeToWR), "WR"); + + else + TimerFormat(fTimeToWR, cTimeToWR, sizeof(cTimeToWR), true, true); + + if (g_fMapTime[client] > fTime) + { + float fTimeDif; + char cTimeDif[16]; + + fTimeDif = g_fMapTime[client] - fTime; + g_fMapTime[client] = fTime; + TimerFormat(fTimeDif, cTimeDif, sizeof(cTimeDif), true, false); + + TimerPrintToChat(client, true, "%T", "FinishedImproved", LANG_SERVER, name, cTime, cTimeToWR, cTimeDif); + UpdateTime(client); + + if (fTimeToWR < 0.0) + UpdateWR(client, fTime, name); + } + else + { + TimerPrintToChat(client, true, "%T", "Finished", LANG_SERVER, name, cTime, cTimeToWR); + + if (g_fMapTime[client] == 0.0) + { + g_fMapTime[client] = fTime; + + UpdateTime(client); + if (fTimeToWR < 0.0 || g_fWrTime == 0.0) + { + UpdateWR(client, fTime, name); + } + + } + else + { + AddCompletion(client); + } + } +} + +public void UpdateWR(int client, float time, char[] name) +{ + if (g_fWrTime == -1.0) + { + LogError("WR never loaded, reload map"); + return; + } + + if (g_fWrTime < time && g_fWrTime != 0.0) + { + LogError("Time submitted is not faster"); + return; + } + + SaveRecord(client); + + g_fWrTime = time; + + strcopy(g_sWrHolder, sizeof(g_sWrHolder), name); +} + +public void ProcessRankMessage(int client, int rank, int total) +{ + char name[MAX_NAME_LENGTH]; + GetClientName(client, name, sizeof(name)); + if (rank > 10) + TimerPrintToChat(client, false, "%T", "Rank", LANG_SERVER, name, rank, total); + + else if (rank <= 10 && rank != 1) + { + TimerPrintToChat(client, true, "%T", "RankTop10", LANG_SERVER, name, rank, total); + EmitSoundToAll("unl1/steamedyes.mp3"); + } + + else if (rank == 1) + { + TimerPrintToChat(client, true, "%T", "RankWR", LANG_SERVER, name, rank, total); + EmitSoundToAll("unl1/disco.wav"); + } +} \ No newline at end of file diff --git a/CTimer/ctimer/bots.sp b/CTimer/ctimer/bots.sp new file mode 100644 index 00000000..9b2d32af --- /dev/null +++ b/CTimer/ctimer/bots.sp @@ -0,0 +1,152 @@ + + +/*public void LoadMainGhost() +{ + //Something went wrong, escape. + if (!g_iGhost) + return; + + char path[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, path, sizeof(path), "data/ctimer/replay/%s.bin", g_sMapName); + if (!FileExists(path)) + { + Format(g_sGhostNames, MAX_NAME_LENGTH, "No replay available"); + g_iGhostFrame = -1; + return; + } + File file = OpenFile(path, "rb", false, "GAME"); + if (file) + { + g_arrayGhost.Clear(); + float pos[3], ang[2], vel[3]; + int currentframe, buttons; + while (!file.EndOfFile()) + { + currentframe = g_arrayGhost.Length; + currentframe++; + g_arrayGhost.Resize(currentframe); + file.Read(view_as(pos), 3, 4); + file.Read(view_as(ang), 2, 4); + file.Read(view_as(vel), 3, 4); + file.ReadInt32(buttons); + SetArrayCell(g_arrayGhost, currentframe, pos[0], 0); + SetArrayCell(g_arrayGhost, currentframe, pos[1], 1); + SetArrayCell(g_arrayGhost, currentframe, pos[2], 2); + SetArrayCell(g_arrayGhost, currentframe, ang[0], 3); + SetArrayCell(g_arrayGhost, currentframe, ang[1], 4); + SetArrayCell(g_arrayGhost, currentframe, vel[0], 5); + SetArrayCell(g_arrayGhost, currentframe, vel[1], 6); + SetArrayCell(g_arrayGhost, currentframe, vel[2], 7); + SetArrayCell(g_arrayGhost, currentframe, buttons, 8); + + } + file.Close(); + PrintToServer("Main replay loaded"); + g_iGhostFrame = -2; + pos[0] = GetArrayCell(g_arrayGhost, 0, 0); + pos[1] = GetArrayCell(g_arrayGhost, 0, 1); + pos[2] = GetArrayCell(g_arrayGhost, 0, 2); + TeleportEntity(g_iGhost, pos, NULL_VECTOR, NULL_VECTOR); + } +}*/ + +bool SaveRecord(int client) +{ + if ( !isValidClient(client) ) + { + LogError("Client %d is not valid", client); + return false; + } + + char path[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, path, sizeof(path), "%s/%s/%s.steamedhams", REPLAYS_PATH, g_sMapName, g_sMapName); + + if (FileExists(path)) + { + #if defined BACKUP_REPLAYS + BackupRecord(path); + #endif + + DeleteFile(path); // Kinda unnecessary? Opening the file later will truncate it. + } + + File file = OpenFile(path, "wb"); + if (file) + { + int size = g_arrayRun[client].Length; + if (!size) + { + LogError("Couldn't save record. Run array is empty."); + return false; + } + + int values[RUNDATA_MAX]; + + for (int i = 0; i < size; ++i) + { + g_arrayRun[client].GetArray(i, values, RUNDATA_MAX); + + file.Write(values, RUNDATA_MAX-1, 4); + file.WriteInt8(values[RUNDATA_WEAPONID]); + + } + file.Close(); + return true; + } + LogError("Could not open the file \"%s\" for writing.", path); + return false; +} + +void BackupRecord(char[] recordPath) +{ + char sPath[PLATFORM_MAX_PATH]; + FormatEx(sPath, sizeof(sPath), "%s_old", recordPath); + + // Delete the last backup + if (FileExists(sPath)) + { + DeleteFile(sPath); + } + + RenameFile(sPath, recordPath); +} + +public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2]) +{ + // Handle humans + if (isValidClient(client)) + { + if (IsPlayerAlive(client)) + { + // Is the player running? + if (g_iActivity[client] == 0) + { + if(GetEntityMoveType(client) != MOVETYPE_NOCLIP) + { + // Record run data + int values[RUNDATA_MAX]; + + float origin[3]; + GetEntDataVector(client, m_vecOrigin, origin); + + values[RUNDATA_POSITION_X] = view_as(origin[0]); + values[RUNDATA_POSITION_Y] = view_as(origin[1]); + values[RUNDATA_POSITION_Z] = view_as(origin[2]); + values[RUNDATA_PITCH] = view_as(angles[0]); + values[RUNDATA_YAW] = view_as(angles[1]); + values[RUNDATA_BUTTONS] = buttons; + values[RUNDATA_IMPULSE] = impulse; + values[RUNDATA_WEAPONID] = view_as( GetWeaponID(client) ); + + g_arrayRun[client].PushArray(values, RUNDATA_MAX); + } + + else + { + g_iActivity[client] = -1; + TimerPrintToChat(client, false, "%T", "TimerCheatStopped", LANG_SERVER); + } + } + } + } +} \ No newline at end of file diff --git a/CTimer/ctimer/commands.sp b/CTimer/ctimer/commands.sp new file mode 100644 index 00000000..3dca91cc --- /dev/null +++ b/CTimer/ctimer/commands.sp @@ -0,0 +1,137 @@ +public Action Command_Time(int client, int args) +{ + if (!g_bActive) + return Plugin_Handled; + + if (g_fMapTime[client] != 0.0) + { + char cTime[16]; + TimerFormat(g_fMapTime[client], cTime, sizeof(cTime), true, false); + TimerPrintToChat(client, false, "%T", "PlayerTime", LANG_SERVER, cTime); + } + else + TimerPrintToChat(client, false, "%T", "PlayerNoTime", LANG_SERVER); + return Plugin_Handled; +} + +public Action Command_Stop(int client, int args) +{ + if (!g_bActive) + return Plugin_Handled; + + if (g_iActivity[client] == 0) + { + g_iActivity[client] = -1; + TimerPrintToChat(client, false, "%T", "TimerStopped", LANG_SERVER); + } + else if (g_iActivity[client] == 1) + { + TimerPrintToChat(client, false, "%T", "TimerCantBeStopped", LANG_SERVER); + } + else if (g_iActivity[client] == -1) + { + TimerPrintToChat(client, false, "%T", "TimerNotRunning", LANG_SERVER); + } + return Plugin_Handled; +} + +public Action Command_Zones(int client, int args) +{ + if (g_iEditor != -1) + { + TimerPrintToChat(client, false, "%T", "ZoneMenuUnavailable", LANG_SERVER); + //PrintToChat(client, "Zone menu currently unavailable"); + return Plugin_Handled; + } + g_iEditor = client; + g_iActivity[client] = -1; + g_bEditorComesFromMenu = false; + ZoneMenu(client, g_bEditorComesFromMenu); + return Plugin_Handled; +} + +public Action Command_Top(int client, int args) +{ + char sMapName[129]; + if (args > 0) + { + GetCmdArg(1, sMapName, sizeof(sMapName)); + if (strlen(sMapName) > 64) + { + TimerPrintToChat(client, false, "%T", "MapNameTooLong", LANG_SERVER); + return Plugin_Handled; + } + g_hDatabase.Escape(sMapName, sMapName, sizeof(sMapName)); + } + else + { + if (!g_bActive) + return Plugin_Handled; + strcopy(sMapName, sizeof(sMapName), g_sMapName); + } + int userid = GetClientUserId(client); + RequestTop(userid, sMapName, 10); + return Plugin_Handled; +} + +public Action Command_TimerAdmin(int client, int args) +{ + TimerAdminMenu(client); + return Plugin_Handled; +} + +public Action Command_WR(int client, int args) +{ + if (args == 0) + { + if (!g_bActive) + return Plugin_Handled; + + if (g_fWrTime == 0.0) + { + TimerPrintToChat(client, false, "%T", "TimesNotFound", LANG_SERVER, g_sMapName); + return Plugin_Handled; + } + else + { + char cWRTime[16]; + TimerFormat(g_fWrTime, cWRTime, sizeof(cWRTime), true, false); + TimerPrintToChat(client, false, "%T", "WR", LANG_SERVER, g_sWrHolder, g_sMapName, cWRTime); + return Plugin_Handled; + } + } + + else + { + char sMapName[129]; + GetCmdArg(1, sMapName, sizeof(sMapName)); + if (strlen(sMapName) > 64) + { + TimerPrintToChat(client, false, "%T", "MapNameTooLong", LANG_SERVER); + return Plugin_Handled; + } + g_hDatabase.Escape(sMapName, sMapName, sizeof(sMapName)); + + int userid = GetClientUserId(client); + RequestWR(userid, sMapName); + } + return Plugin_Handled; +} + +public int Native_StopTime(Handle hPlugin, int numParams) +{ + int client = GetNativeCell(1); + + if (!isValidClient(client)) + return; + + if (g_iActivity[client] == -1) + return; + + g_iActivity[client] = -1; + TimerPrintToChat(client, false, "%T", "TimerCheatStopped", LANG_SERVER); + return; +} + + + diff --git a/CTimer/ctimer/menus.sp b/CTimer/ctimer/menus.sp new file mode 100644 index 00000000..4ceebac2 --- /dev/null +++ b/CTimer/ctimer/menus.sp @@ -0,0 +1,281 @@ +public void TimerAdminMenu(int client) +{ + char buffer[16]; + Menu menu = new Menu(TimerAdminMenuHandler); + menu.SetTitle("Timer Control Panel"); + if (g_iEditor != -1) + menu.AddItem("zone", "Zones (Currently in use)", ITEMDRAW_DISABLED); + else + menu.AddItem("zone", "Zones"); + menu.AddItem("tier", "Set Map Tier"); + Format(buffer, sizeof(buffer), "%s map", g_bActive ? "Deactivate":"Activate"); + menu.AddItem("active", buffer); + menu.ExitButton = true; + menu.Display(client, MENU_TIME_FOREVER); +} + +public int TimerAdminMenuHandler(Handle menu, MenuAction action, int client, int choice) +{ + switch(action) + { + case MenuAction_Select: + { + switch(choice) + { + case 0: + { + if (g_iEditor != -1) + { + PrintToChat(client, "Zone menu currently unavailable"); + TimerAdminMenu(client); + } + else + { + g_iEditor = client; + g_iActivity[client] = -1; + g_bEditorComesFromMenu = true; + ZoneMenu(client, g_bEditorComesFromMenu); + } + + } + case 1: + { + TierMenu(client); + } + case 2: + { + g_bActive = !g_bActive; + SetMapState(view_as(g_bActive)); + PrintToChat(client, "%s the map...", g_bActive ? "Activating":"Deactivating"); + CS_TerminateRound(1.0, CSRoundEnd_Draw, true); + TimerAdminMenu(client); + } + } + } + case MenuAction_End: + { + delete menu; + } + } +} + +public void ZoneMenu(int client, bool comesFromMenu) +{ + Menu menu = new Menu(ZoneMenuHandler); + menu.SetTitle("Zone Menu"); + menu.AddItem("start", "Set Start Zone"); + menu.AddItem("end", "Set End Zone"); + menu.AddItem("rr", "Respawn Zones"); + menu.AddItem("save", "Save Zones"); + menu.ExitButton = true; + if (comesFromMenu) + menu.ExitBackButton = true; + menu.Display(client, MENU_TIME_FOREVER); +} + +public int ZoneMenuHandler(Handle menu, MenuAction action, int client, int choice) +{ + switch(action) + { + case MenuAction_Select: + { + switch(choice) + { + case 0: + CreateZoneMenu(client, STARTZONE, false); + + case 1: + CreateZoneMenu(client, ENDZONE, false); + + case 2: + { + CS_TerminateRound(1.0, CSRoundEnd_Draw, true); + ZoneMenu(client, g_bEditorComesFromMenu); + } + case 3: + { + SaveZones(client); + ZoneMenu(client, g_bEditorComesFromMenu); + } + } + } + + case MenuAction_Cancel: + { + g_iEditor = -1; + g_bEditorComesFromMenu = false; + if (choice == MenuCancel_ExitBack) + { + TimerAdminMenu(client); + } + } + + case MenuAction_End: + { + delete menu; + } + } +} + +public void CreateZoneMenu(int client, int zone, bool point) +{ + char buffer[32], zonePoint[5]; + Menu menu = new Menu(CreateZoneMenuHandler); + Format(buffer, sizeof(buffer), "Set the %s position", point ? "second":"first"); + //Format(zonePoint, sizeof(zonePoint), "%i|%s", zone, view_as(point)); + Format(zonePoint, sizeof(zonePoint), "%i|%s", zone, point ? "1":"0"); + menu.AddItem(zonePoint, buffer); + menu.ExitBackButton = false; + menu.ExitButton = false; + menu.Display(client, MENU_TIME_FOREVER); +} + +public int CreateZoneMenuHandler(Menu menu, MenuAction action, int client, int choice) +{ + if (action == MenuAction_Select) + { + char buffer[5], array[2][2]; + int zone, point; + menu.GetItem(0, buffer, sizeof(buffer)); + ExplodeString(buffer, "|", array, 2, 2); + zone = StringToInt(array[0]); + point = StringToInt(array[1]); + //PrintToChatAll("%s - %s %s - %i %i", buffer, array[0], array[1], zone, point); + + if (point == 0) + { + GetClientAbsOrigin(client, g_fStartOrigins[zone]); + g_iSnapToClient = zone; + CreateZoneMenu(client, zone, true); + } + if (point == 1) + { + GetClientAbsOrigin(client, g_fEndOrigins[zone]); + g_iSnapToClient = -1; + CreateTrigger(zone); + ZoneMenu(client, g_bEditorComesFromMenu); + } + } + if (action == MenuAction_End) + { + delete menu; + } +} + +public void TierMenu(int client) +{ + Menu menu = new Menu(TierMenuHandler); + menu.SetTitle("Choose a tier"); + menu.AddItem("1", "Tier 1"); + menu.AddItem("2", "Tier 2"); + menu.AddItem("3", "Tier 3"); + menu.AddItem("4", "Tier 4"); + menu.AddItem("5", "Tier 5"); + menu.AddItem("6", "Tier 6"); + menu.ExitButton = true; + menu.ExitBackButton = true; + menu.Display(client, MENU_TIME_FOREVER); +} + +public int TierMenuHandler(Handle menu, MenuAction action, int client, int choice) +{ + switch(action) + { + case MenuAction_Select: + { + g_iTier = choice + 1; + SetMapTier(g_iTier); + PrintToChat(client, "Setting the maps tier to %i", g_iTier); + TimerAdminMenu(client); + } + case MenuAction_Cancel: + { + if (choice == MenuCancel_ExitBack) + { + TimerAdminMenu(client); + } + } + + case MenuAction_End: + { + delete menu; + } + } +} + +public void SQL_RequestTop(Database db, int userid, int numQueries, DBResultSet[] results, any[] queryData) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + int client = GetClientOfUserId(userid); + + if (!isValidClient(client)) + return; + + if (results[0].RowCount == 0) + { + TimerPrintToChat(client, false, "%T", "MapNotFound", LANG_SERVER); + return; + } + + char cMap[64]; + results[0].FetchRow(); + results[0].FetchString(0, cMap, sizeof(cMap)); + + if (results[1].RowCount == 0) + { + TimerPrintToChat(client, false, "%T", "TimesNotFound", LANG_SERVER, cMap); + return; + } + + char cBuffer[128], cTime[16], cTimeToWR[16], cName[64]; + float fTime, fTimeToWR, fWR; + int timescompleted; + + Menu menu = new Menu(TopTimeMenuHandler); + + Format(cBuffer, sizeof(cBuffer), "Top Times for %s", cMap); + menu.SetTitle(cBuffer); + + results[1].FetchRow(); + results[1].FetchString(0, cName, sizeof(cName)); + fTime = fWR = results[1].FetchFloat(1); + timescompleted = results[1].FetchInt(2); + + TimerFormat(fTime, cTime, sizeof(cTime), true, false); + Format(cBuffer, sizeof(cBuffer), "%s\n%s (+00:00.00) (%i)", cName, cTime, timescompleted); + + menu.AddItem("", cBuffer); + + while (results[1].FetchRow()) + { + results[1].FetchString(0, cName, sizeof(cName)); + fTime = results[1].FetchFloat(1); + fTimeToWR = fTime - fWR; + timescompleted = results[1].FetchInt(2); + + TimerFormat(fTime, cTime, sizeof(cTime), true, false); + TimerFormat(fTimeToWR, cTimeToWR, sizeof(cTimeToWR), true, true); + Format(cBuffer, sizeof(cBuffer), "%s\n%s (%s) (%i)", cName, cTime, cTimeToWR, timescompleted); + + menu.AddItem("", cBuffer); + } + menu.ExitButton = true; + menu.Display(client, MENU_TIME_FOREVER); + +} + +public int TopTimeMenuHandler(Handle menu, MenuAction action, int client, int choice) +{ + switch(action) + { + case MenuAction_End: + { + delete menu; + } + } +} \ No newline at end of file diff --git a/CTimer/ctimer/sql.sp b/CTimer/ctimer/sql.sp new file mode 100644 index 00000000..35198bc1 --- /dev/null +++ b/CTimer/ctimer/sql.sp @@ -0,0 +1,504 @@ +public void EstablishConnection() +{ + if (SQL_CheckConfig("ctimer")) + Database.Connect(ConnectionCallback, "ctimer"); + else + SetFailState("'ctimer' not found in 'sourcemod/configs/databases.cfg'"); +} + +public void ConnectionCallback(Database db, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Failed to connect to the database, will attempt to reconnect on map change"); + return; + } + + g_hDatabase = db; + + LoadMapInfo(); +} + +public void GetPlayerInfo(client) +{ + int steamid = GetTimerSteamId(client); + char query[512], username[65], ip[16]; + + GetClientName(client, username, sizeof(username)); + g_hDatabase.Escape(username, username, sizeof(username)); + GetClientIP(client, ip, sizeof(ip)); + + Format(query, sizeof(query), "INSERT INTO ctimer_users (userid, name, ip, lastconnected) values ('%i', '%s', INET_ATON('%s'), CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE name = VALUES(name), ip = VALUES(ip), lastconnected = CURRENT_TIMESTAMP;", steamid, username, ip); + g_hDatabase.Query(SQL_InsertUser, query, DBPrio_High); + + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid, can't load players time %N<%i>", client, client); + return; + } + + int userid = GetClientUserId(client); + Format(query, sizeof(query), "SELECT time FROM ctimer_times WHERE mapid = %i AND userid = %i;", g_iMapID, GetTimerSteamId(client)); + g_hDatabase.Query(SQL_GetUserTime, query, userid); +} + +public void SQL_InsertUser(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on inserting user: %s", error); + return; + } +} + +public void SQL_GetUserTime(Database db, DBResultSet results, const char[] error, int userid) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on getting user time: %s", error); + return; + } + + int client = GetClientOfUserId(userid); + + if (!isValidClient(client)) + return; + + if (results.RowCount == 0) + { + g_fMapTime[client] = 0.0; + return; + } + + if (results.RowCount > 1) + { + LogError("Unexpected amount of rows: %i", results.RowCount); + return; + } + + results.FetchRow(); + g_fMapTime[client] = results.FetchFloat(0); + +} + +public void LoadMapInfo() +{ + char query[512]; + Format(query, sizeof(query), "INSERT INTO ctimer_maps (mapname, lastplayed) values ('%s', CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE lastplayed = CURRENT_TIMESTAMP", g_sMapName); + g_hDatabase.Query(SQL_InsertMap, query, DBPrio_High); ///Insert map or update lastplayed + Format(query, sizeof(query), "SELECT mapid, tier, enabled FROM ctimer_maps WHERE mapname = '%s'", g_sMapName); + g_hDatabase.Query(SQL_GetMapInfo, query); +} + +public void SQL_InsertMap(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on inserting map: %s", error); + return; + } + +} + +public void SQL_GetMapInfo(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on inserting map: %s", error); + return; + } + + if (results.RowCount == 0) + { + LogError("Map not found"); + return; + } + + if (results.RowCount > 1) + { + LogError("Unexpected amount of rows: %i", results.RowCount); + return; + } + + results.FetchRow(); + g_iMapID = results.FetchInt(0); + g_iTier = results.FetchInt(1); + g_bActive = view_as(results.FetchInt(2)); + + LoadZones(); + GetWRInfo(); + + if (g_bLateLoad) + { + for (int i = 1; i <= MaxClients; i++) + { + if (IsClientConnected(i) && IsClientInGame(i)) + { + OnClientPostAdminCheck(i); + } + } + } +} + +public void GetWRInfo() +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + char query[512]; + Format(query, sizeof(query), "SELECT u.name , wr.time FROM ctimer_users u, ctimer_times wr WHERE u.userid = wr.userid AND wr.mapid = %i AND u.userid = getWrUserId(%i);", g_iMapID, g_iMapID); + g_hDatabase.Query(SQL_GetWRInfo, query); +} + +public void SQL_GetWRInfo(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on getting map WR info: %s", error); + return; + } + + if (results.RowCount == 0) + { + g_fWrTime = 0.0; + return; + } + + if (results.RowCount > 2) + { + LogError("Unexpected amount of rows: %i", results.RowCount); + return; + } + results.FetchRow(); + results.FetchString(0, g_sWrHolder, sizeof(g_sWrHolder)); + g_fWrTime = results.FetchFloat(1); +} + + +public void SaveZones(int client) +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + char query[512], startcord[42], endcord[42]; + for (int i = 0; i <= 1; i++) + { + VectorToString(startcord, sizeof(startcord), g_fStartOrigins[i]); + VectorToString(endcord, sizeof(endcord), g_fEndOrigins[i]); + Format(query, sizeof(query), "INSERT INTO ctimer_zones(mapid, zonetype, startcord, endcord) VALUES (%i, %i, '%s', '%s') ON DUPLICATE KEY UPDATE startcord = values(startcord), endcord = values(endcord)", g_iMapID, i, startcord, endcord); + g_hDatabase.Query(SQL_SaveZones, query); + } + PrintToChat(client, "Zones Saved"); +} + +public void SQL_SaveZones(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on saving zones: %s", error); + return; + } +} + +public void LoadZones() +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + + char query[512]; + Format(query, sizeof(query), "SELECT zonetype, startcord, endcord from ctimer_zones where mapid = %i ORDER BY zonetype", g_iMapID); + g_hDatabase.Query(SQL_LoadZones, query); + +} + +public void SQL_LoadZones(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on inserting map: %s", error); + return; + } + + if (results.RowCount == 0) + { + return; + } + + if (results.RowCount > 2) + { + LogError("Unexpected amount of rows: %i", results.RowCount); + return; + } + + int zonetype; + char startcord[42], endcord[42]; + float vec[3]; + + while (results.FetchRow()) + { + zonetype = results.FetchInt(0); + results.FetchString(1, startcord, sizeof(startcord)); + results.FetchString(2, endcord, sizeof(endcord)); + StringToVector(vec, startcord); + g_fStartOrigins[zonetype] = vec; + StringToVector(vec, endcord); + g_fEndOrigins[zonetype] = vec; + CreateTrigger(zonetype); + //CreateTimer(1.0, Timer_CreateTrigger, zonetype); + } + //CS_TerminateRound(0.0, CSRoundEnd_Draw, true); +} + +public void SetMapTier(int tier) +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + char query[512]; + Format(query, sizeof(query), "UPDATE ctimer_maps SET tier = %i WHERE mapname = '%s'", tier, g_sMapName); + g_hDatabase.Query(SQL_SetMapTier, query); +} + +public void SQL_SetMapTier(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on setting map tier: %s", error); + return; + } +} + +public void SetMapState(int state) +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + char query[512]; + Format(query, sizeof(query), "UPDATE ctimer_maps SET enabled = %i WHERE mapname = '%s'", state, g_sMapName); + g_hDatabase.Query(SQL_SetMapState, query); +} + +public void SQL_SetMapState(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on setting map active state: %s", error); + return; + } +} + +public void UpdateTime(int client) +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + char query[512]; + int userid = GetClientUserId(client); + Format(query, sizeof(query), "SELECT updateTime(%i, %i, %f), getTimeRank(%i, %i), getTimeComps(%i);", g_iMapID, GetTimerSteamId(client), g_fMapTime[client], g_iMapID, GetTimerSteamId(client), g_iMapID); + g_hDatabase.Query(SQL_UpdateTime, query, userid); +} + +public void SQL_UpdateTime(Database db, DBResultSet results, const char[] error, int userid) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on updating time: %s", error); + return; + } + + int client = GetClientOfUserId(userid); + + if (!isValidClient(client)) + return; + + results.FetchRow(); + int rank = results.FetchInt(1); + int total = results.FetchInt(2); + + ProcessRankMessage(client, rank, total); +} + +public void AddCompletion(int client) +{ + if (g_iMapID == -1) + { + LogError("Error, map ID is invalid"); + return; + } + char query[512]; + Format(query, sizeof(query), "UPDATE ctimer_times SET timescompleted = timescompleted + 1 where mapid = %i AND userid = %i", g_iMapID, GetTimerSteamId(client)); + g_hDatabase.Query(SQL_AddCompletion, query); +} + +public void SQL_AddCompletion(Database db, DBResultSet results, const char[] error, any data) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + if (results == null) + { + LogError("Error on setting map active state: %s", error); + return; + } +} + +public void RequestTop(int userid, char[] mapname, int limit) +{ + Transaction transaction = new Transaction(); + char query[512]; + Format(query, sizeof(query), "SELECT mapname FROM ctimer_maps WHERE enabled = 1 AND mapname LIKE '%%%s%%' ORDER BY mapname LIMIT 1", mapname); + transaction.AddQuery(query); + Format(query, sizeof(query), "SELECT u.name , times.time, times.timescompleted FROM ctimer_users u, ctimer_times times, ctimer_maps maps WHERE u.userid = times.userid AND times.mapid = maps.mapid AND maps.mapid = (SELECT mapid FROM ctimer_maps WHERE enabled = 1 AND mapname LIKE '%%%s%%' ORDER BY mapname LIMIT 1) ORDER BY time, runid LIMIT %i;", mapname, limit); + transaction.AddQuery(query); + g_hDatabase.Execute(transaction, SQL_RequestTop, SQL_RequestTopError, userid); +} + +public void SQL_RequestTopError(Database db, int userid, int numQueries, const char[] error, int failIndex, any[] queryData) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + LogError("Error on requesting top time records on query %i: %s", failIndex, error); +} + +public void RequestWR(int userid, char[] mapname) +{ + Transaction transaction = new Transaction(); + char query[512]; + Format(query, sizeof(query), "SELECT mapname FROM ctimer_maps WHERE enabled = 1 AND mapname LIKE '%%%s%%' ORDER BY mapname LIMIT 1", mapname); + transaction.AddQuery(query); + Format(query, sizeof(query), "SELECT name, time FROM ctimer_times times INNER JOIN ctimer_users u ON u.userid = times.userid WHERE mapid=(SELECT mapid FROM ctimer_maps WHERE enabled = 1 AND mapname LIKE '%%%s%%' ORDER BY mapname LIMIT 1) ORDER BY time, runid LIMIT 1;", mapname); + transaction.AddQuery(query); + g_hDatabase.Execute(transaction, SQL_RequestWR, SQL_RequestWRError, userid); +} + +public void SQL_RequestWRError(Database db, int userid, int numQueries, const char[] error, int failIndex, any[] queryData) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + LogError("Error on requesting world record time on query %i: %s", failIndex, error); +} + +public void SQL_RequestWR(Database db, int userid, int numQueries, DBResultSet[] results, any[] queryData) +{ + if (db == null) + { + SetFailState("Lost connection to the database, will attempt to reconnect on map change"); + return; + } + + int client = GetClientOfUserId(userid); + + if (!isValidClient(client)) + return; + + if (results[0].RowCount == 0) + { + TimerPrintToChat(client, false, "%T", "MapNotFound", LANG_SERVER); + return; + } + + char cMap[64]; + results[0].FetchRow(); + results[0].FetchString(0, cMap, sizeof(cMap)); + + if (results[1].RowCount == 0) + { + TimerPrintToChat(client, false, "%T", "TimesNotFound", LANG_SERVER, cMap); + return; + } + + char cTime[16], cName[64]; + float fTime; + + results[1].FetchRow(); + results[1].FetchString(0, cName, sizeof(cName)); + fTime = results[1].FetchFloat(1); + + TimerFormat(fTime, cTime, sizeof(cTime), true, false); + + TimerPrintToChat(client, false, "%T", "WR", LANG_SERVER, cName, cMap, cTime); +} \ No newline at end of file diff --git a/CTimer/ctimer/timers.sp b/CTimer/ctimer/timers.sp new file mode 100644 index 00000000..98b6209c --- /dev/null +++ b/CTimer/ctimer/timers.sp @@ -0,0 +1,210 @@ +public Action DrawFullZoneTimer(Handle timer) +{ + int colorarray[][] = { { 124, 252, 0, 255 }, { 255, 0, 0, 255 } }; + + if (!g_bLasers || g_iEditor == -1) + return Plugin_Continue; + + for (int i = 0; i <= 1; i++) + { + if (g_iSnapToClient == i) + { + float vec[3]; + GetClientAbsOrigin(g_iEditor, vec); + DrawFullZone(vec, g_fStartOrigins[i], colorarray[i], 0.1); + continue; + } + DrawFullZone(g_fEndOrigins[i], g_fStartOrigins[i], colorarray[i], 0.2); + } + return Plugin_Continue; +} + +public Action DrawZoneTimer(Handle timer) +{ + if (!g_bLasers || !g_bActive) + return Plugin_Continue; + + int colorarray[][] = { { 124, 252, 0, 255 }, { 255, 0, 0, 255 } }; + + if (g_iEditor != -1) + return Plugin_Continue; + + float pos[3], eye[3]; + + int[] clients = new int[MaxClients]; + int nClients = 0; + + for (int i = 0; i <= 1; i++) + { + for (int j = 1; j <= MaxClients; j++) + { + if (isValidClient(j)) + { + //https://github.com/InfluxTimer/sm-timer/blob/master/addons/sourcemod/scripting/influx_zones_beams.sp + GetClientEyePosition(j, eye); + + GetMiddleOfABox(g_fEndOrigins[i], g_fStartOrigins[i], pos); + + if (GetVectorDistance(eye, pos, true) < MAX_DIST_SQ) + { + clients[nClients++] = j; + } + else + { + TR_TraceRayFilter(eye, pos, CONTENTS_SOLID, RayType_EndPoint, TraceFilter_WorldOnly); + + if (!TR_DidHit()) + { + clients[nClients++] = j; + } + } + } + } + DrawZone(clients, nClients, g_fEndOrigins[i], g_fStartOrigins[i], colorarray[i], 1.0); + } + return Plugin_Continue; +} + +public bool TraceFilter_WorldOnly( int ent, int mask ) +{ + return ( ent == 0 ); +} + +public Action HudLoop(Handle timer) +{ + if (g_iMapID != -1 && g_bActive) + { + for (int i = 1; i <= MaxClients; i++) + { + if (isValidClient(i)) + { + UpdateHUD(i); + } + } + return Plugin_Continue; + } + return Plugin_Continue; +} + +public void UpdateHUD(int client) +{ + int target = client; + if (IsClientObserver(client)) + { + int mode = GetEntProp(client, Prop_Send, "m_iObserverMode"); + if (mode == 4 || mode == 5) + { + target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); + if (!isValidClient(target)) + return; + } + else + return; + } + + if (g_iActivity[target] == -1) + { + return; + } + + char HintTextBuffer[256]; + + if (client != target) + Format(HintTextBuffer, sizeof(HintTextBuffer), "Player: %N\n \n", target); + + if (g_iActivity[target] == 1) + Format(HintTextBuffer, sizeof(HintTextBuffer), "%sIn Start Zone\n \n", HintTextBuffer); + + if (g_iActivity[target] == 0) + { + char cTime[16]; + float fTime; + fTime = GetEngineTime() - g_fStartTime[target]; + TimerFormat(fTime, cTime, sizeof(cTime), true, false); + Format(HintTextBuffer, sizeof(HintTextBuffer), "%sTime: %s\n \n", HintTextBuffer, cTime); + } + + Format(HintTextBuffer, sizeof(HintTextBuffer), "%sSpeed: %i u/s", HintTextBuffer, Get2VecVelocity(target)); + + PrintHintText(client, HintTextBuffer); +} + +public Action SideHudLoop(Handle timer) +{ + if (g_iMapID != -1 && g_bActive) + { + for (int i = 1; i <= MaxClients; i++) + { + if (isValidClient(i)) + { + UpdateSideHUD(i); + } + } + return Plugin_Continue; + } + return Plugin_Continue; +} + +public void UpdateSideHUD(int client) +{ + int target = client; + if (IsClientObserver(client)) + { + int mode = GetEntProp(client, Prop_Send, "m_iObserverMode"); + if (mode == 4 || mode == 5) + { + target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); + if (!isValidClient(target)) + return; + } + else + return; + } + + if (g_iActivity[target] == -1) + { + return; + } + + char KeyHintBuffer[254]; + char cTimeLeft[16]; + GetTimerTimeLeft(cTimeLeft, sizeof(cTimeLeft)); + + Format(KeyHintBuffer, sizeof(KeyHintBuffer), "Timeleft: %s\n \n", cTimeLeft); + + if (g_fMapTime[target] <= 0.0) + Format(KeyHintBuffer, sizeof(KeyHintBuffer), "%sPR: None\n", KeyHintBuffer); + + else + { + char cTime[16], cTimeToWR[16]; + float fTimeToWR; + fTimeToWR = g_fMapTime[target] - g_fWrTime; + if (fTimeToWR == 0) + Format(cTimeToWR, sizeof(cTimeToWR), "WR"); + else + TimerFormat(fTimeToWR, cTimeToWR, sizeof(cTimeToWR), true, true); + + TimerFormat(g_fMapTime[target], cTime, sizeof(cTime), true, false); + Format(KeyHintBuffer, sizeof(KeyHintBuffer), "%sPR: %s (%s)\n", KeyHintBuffer, cTime, cTimeToWR); + } + + if (g_fWrTime <= 0.0) + Format(KeyHintBuffer, sizeof(KeyHintBuffer), "%sWR: None\n \n", KeyHintBuffer); + + else + { + char cWR[16]; + TimerFormat(g_fWrTime, cWR, sizeof(cWR), true, false); + Format(KeyHintBuffer, sizeof(KeyHintBuffer), "%sWR: %s (%s)\n \n", KeyHintBuffer, cWR, g_sWrHolder); + } + + Format(KeyHintBuffer, sizeof(KeyHintBuffer), "%sSpectators: %i", KeyHintBuffer, GetSpecCount(target)); + + PrintKeyHintText(client, KeyHintBuffer); +} + +/*public Action Timer_CreateTrigger(Handle timer, int zonetype) +{ + CreateTrigger(zonetype); +}*/ \ No newline at end of file diff --git a/CTimer/ctimer/utility.sp b/CTimer/ctimer/utility.sp new file mode 100644 index 00000000..0471f0a5 --- /dev/null +++ b/CTimer/ctimer/utility.sp @@ -0,0 +1,433 @@ +public bool isValidClient(int client) { + if (client <= 0 + || client > MaxClients + || !IsValidEntity(client) + || !IsClientConnected(client) + || IsFakeClient(client) + || !IsClientInGame(client) + || !PM_IsPlayerSteam(client)){ + return false; + } + return true; +} + +public int GetTimerSteamId(int client) +{ + char steamid[32]; + GetClientAuthId(client, AuthId_Steam3, steamid, sizeof(steamid)); + ReplaceString(steamid, sizeof(steamid), "[U:1:", "\0"); + ReplaceString(steamid, sizeof(steamid), "]", "\0"); + return StringToInt(steamid); +} + +public void ClearPlayerCache(int client) +{ + g_iActivity[client] = -1; + g_fStartTime[client] = -1.0; + g_fMapTime[client] = 0.0; + if (g_arrayRun[client] != INVALID_HANDLE) + g_arrayRun[client].Clear(); + else + g_arrayRun[client] = new ArrayList(RUNDATA_MAX); +} + +public void LowerString(char[] sString, int len) +{ + char sTemp[PLATFORM_MAX_PATH]; + Format(sTemp, sizeof(sTemp), "%s", sString); + for (int i = 0; i < len; i++) + { + if (!IsCharLower(sTemp[i])) + { + sTemp[i] = CharToLower(sTemp[i]); + } + } + Format(sString, len, "%s", sTemp); +} + +public void DrawFullZone(float fMin[3], float fMax[3], int color[4], float life) +{ + float point[8][3]; + float size = 3.0; + + point[0][0] = fMin[0]; + point[0][1] = fMin[1]; + point[0][2] = fMax[2]; + + point[1][0] = fMax[0]; + point[1][1] = fMin[1]; + point[1][2] = fMax[2]; + + point[2][0] = fMin[0]; + point[2][1] = fMax[1]; + point[2][2] = fMax[2]; + + point[3][0] = fMax[0]; + point[3][1] = fMax[1]; + point[3][2] = fMax[2]; + + point[4][0] = fMin[0]; + point[4][1] = fMin[1]; + point[4][2] = fMin[2]+100; + + point[5][0] = fMax[0]; + point[5][1] = fMin[1]; + point[5][2] = fMin[2]+100; + + point[6][0] = fMin[0]; + point[6][1] = fMax[1]; + point[6][2] = fMin[2]+100; + + point[7][0] = fMax[0]; + point[7][1] = fMax[1]; + point[7][2] = fMin[2]+100; + + if (g_iEditor == -1) + return; + + TE_SetupBeamPoints(point[4],point[5],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[4],point[6],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[7],point[6],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[7],point[5],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[0],point[1],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[0],point[2],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[0],point[4],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[3],point[2],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[3],point[1],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[3],point[7],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[1],point[5],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); + TE_SetupBeamPoints(point[2],point[6],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_SendToClient(g_iEditor, 0.0); +} + +public void DrawZone(int[] clients, int numClients, float fMin[3], float fMax[3], int color[4], float life) +{ + float point[4][3]; + float size = 6.0; + + point[0][0] = fMin[0]; + point[0][1] = fMin[1]; + + point[1][0] = fMax[0]; + point[1][1] = fMin[1]; + + point[2][0] = fMin[0]; + point[2][1] = fMax[1]; + + point[3][0] = fMax[0]; + point[3][1] = fMax[1]; + + if (fMax[2] <= fMin[2] + 100) + { + point[0][2] = fMax[2] + 2; + point[1][2] = fMax[2] + 2; + point[2][2] = fMax[2] + 2; + point[3][2] = fMax[2] + 2; + } + else + { + point[0][2] = fMin[2] + 102; + point[1][2] = fMin[2] + 102; + point[2][2] = fMin[2] + 102; + point[3][2] = fMin[2] + 102; + } + + TE_SetupBeamPoints(point[0],point[1],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_Send(clients, numClients); + TE_SetupBeamPoints(point[0],point[2],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_Send(clients, numClients); + TE_SetupBeamPoints(point[3],point[2],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_Send(clients, numClients); + TE_SetupBeamPoints(point[3],point[1],g_iBeam, 0, 0, 30, life, size, size, 1, 0.0, color, 0);TE_Send(clients, numClients); +} + +public void VectorToString(char[] buffer, int maxlength, float vector[3]) +{ + Format(buffer, maxlength, "%f|%f|%f", vector[0], vector[1], vector[2]); +} + +public float StringToVector(float vector[3], char[] buffer){ + char cords[3][24]; + + ExplodeString(buffer, "|", cords, sizeof cords, sizeof cords[]); + + for (int i = 0; i < 3; i++) + vector[i] = StringToFloat(cords[i]); +} + +public void TimerFormat(float fTime, char[] sBuffer, int len, bool showMS, bool addsymbol) +{ + Format(sBuffer, len, ""); + + int Min, Sec; + float Ms; + + if(fTime < 0) + { + fTime *= -1; + if (addsymbol) + Format(sBuffer, len, "-"); + } + else + if (addsymbol) + Format(sBuffer, len, "+"); + + Min = RoundToFloor(fTime) / 60; + Sec = RoundToFloor(fTime) - (Min * 60); + if (showMS) + Ms = fTime - ((Min * 60) + Sec); + + char Mins[3], Secs[3], MiliSecond[16]; + if (Min < 10) + Format(Mins, sizeof(Mins), "0%i", Min); + else + Format(Mins, sizeof(Mins), "%i", Min); + + if (Sec < 10) + Format(Secs, sizeof(Secs), "0%i", Sec); + else + Format(Secs, sizeof(Secs), "%i", Sec); + + if (Ms < 10 && showMS) + Format(MiliSecond, sizeof(MiliSecond), "0%.2f", Ms); + else + Format(MiliSecond, sizeof(MiliSecond), "%.2f", Ms); + + if (!showMS) + Format(sBuffer, len, "%s%s:%s", sBuffer, Mins, Secs); + else + Format(sBuffer, len, "%s%s:%s.%s", sBuffer, Mins, Secs, MiliSecond[3]); +} + +public void GetTimerTimeLeft(char[] buffer, int maxlength) +{ + int timeleft; + + GetMapTimeLeft(timeleft); + + if (timeleft <= 60) + { + if (timeleft < 1) + Format(buffer, maxlength, "Map ending", timeleft); + else if (timeleft == 1) + Format(buffer, maxlength, "1 second", timeleft); + else + Format(buffer, maxlength, "%i seconds", timeleft); + } + + + else + { + int iMinutes = (timeleft / 60); + + Format(buffer, maxlength, "%i", iMinutes); + + if (iMinutes == 1) + Format(buffer, maxlength, "%s minute", buffer); + else + Format(buffer, maxlength, "%s minutes", buffer); + + } +} + +public void TimerPrintToChat(int client, bool toall, char[] sText, any:...) +{ + int[] targets = new int[MaxClients]; + int numTargets; + if (toall) + { + for (int i = 1; i <= MaxClients; i++) + { + if (IsClientInGame(i)) + { + targets[numTargets] = i; + numTargets++; + } + } + } + else + { + targets[0] = client; + numTargets = 1; + } + + char finalmessage[MAXLENGTH_MESSAGE], cBuffer[MAXLENGTH_MESSAGE]; + strcopy(cBuffer, sizeof(cBuffer), sText); + VFormat(finalmessage, MAXLENGTH_MESSAGE, cBuffer, 4); + Format(cBuffer, MAXLENGTH_MESSAGE, "%T", "Tag", LANG_SERVER); + CFormat(finalmessage, MAXLENGTH_MESSAGE, "%s%s", cBuffer, finalmessage); + + SayText2(targets, numTargets, client, finalmessage); + +} + +//forums.alliedmods.net/showpost.php?p=1709517&postcount=35?p=1709517&postcount=35 +public void CFormat(char[] buffer, int maxlength, char[] sText, any:...) +{ + char cBuffer[MAXLENGTH_MESSAGE]; + + strcopy(cBuffer, sizeof(cBuffer), sText); + VFormat(buffer, maxlength, cBuffer, 4); + + ReplaceString(buffer, maxlength, "{default}", "\x01", false); + + int iStart, iEnd, iTotal; + char sHex[9], sCodeBefore[12], sCodeAfter[10]; + + while ((iStart = StrContains(buffer[(iTotal)], "{#")) != -1) + { + if ((iEnd = StrContains(buffer[iTotal+iStart+2], "}")) != -1) + { + if (iEnd == 6 || iEnd == 8) + { + strcopy(sHex, iEnd+1, buffer[iTotal+iStart+2]); + Format(sCodeBefore, sizeof(sCodeBefore), "{#%s}", sHex); + Format(sCodeAfter, sizeof(sCodeAfter), (iEnd == 6 ? "\x07%s" : "\x08%s"), sHex); + ReplaceString(buffer, maxlength, sCodeBefore, sCodeAfter); + iTotal += iStart + iEnd + 1; + } + else { + iTotal += iStart + iEnd + 3; + } + } + else { + break; + } + } +} + +public void SayText2(int[] targets, int numTargets, int author, char[] szMessage) +{ + Handle hBuffer = StartMessage("SayText2", targets, numTargets, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS); + + if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) + { + PbSetInt(hBuffer, "ent_idx", author); + PbSetBool(hBuffer, "chat", true); + PbSetString(hBuffer, "msg_name", szMessage); + PbAddString(hBuffer, "params", ""); + PbAddString(hBuffer, "params", ""); + PbAddString(hBuffer, "params", ""); + PbAddString(hBuffer, "params", ""); + } + else + { + BfWriteByte(hBuffer, author); + BfWriteByte(hBuffer, true); + BfWriteString(hBuffer, szMessage); + } + + EndMessage(); +} + +public void PrintKeyHintText(int client, char[] format, any:...) +{ + Handle userMessage = StartMessageOne("KeyHintText", client); + + if (userMessage == INVALID_HANDLE) { + return; + } + + char buffer[254]; + + SetGlobalTransTarget(client); + VFormat(buffer, sizeof(buffer), format, 3); + + if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available + && GetUserMessageType() == UM_Protobuf) { + + PbSetString(userMessage, "hints", buffer); + } + else { + BfWriteByte(userMessage, 1); + BfWriteString(userMessage, buffer); + } + + EndMessage(); +} + +public int Get2VecVelocity(int client) +{ + float vel[3]; + GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel); + + for(int i = 0; i <= 2; i++) + vel[i] *= vel[i]; + + return RoundToFloor(SquareRoot(vel[0] + vel[1])); +} + +//https://github.com/InfluxTimer/sm-timer/blob/master/addons/sourcemod/scripting/influx_prespeed.sp +public void CheckSpeed(int client) +{ + float vel[3]; + GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel); + + + /*for(int i = 0; i <= 2; i++) + vel[i] *= vel[i];*/ + + float speed = SquareRoot(vel[0] * vel[0] + vel[1] * vel[1]); + + //PrintToChatAll("Exit Vel: %.2f", speed); + + if (speed > MAXVELOCITY) + { + float m = speed / MAXVELOCITY; + + //PrintToChatAll("Max Velocity. Factor: %.2f", m); + + vel[0] /= m; + vel[1] /= m; + vel[2] /= m; + + TimerPrintToChat(client, false, "%T", "MaxVelocityWarning", LANG_SERVER); + + //PrintToChatAll("Velocity reduced to: %i", RoundToFloor(SquareRoot(vel[0] * vel[0] + vel[1] * vel[1]))); + + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel); + } +} + +public int GetSpecCount(int client) +{ + int count; + for (int i = 1; i <= MaxClients; i++) + { + if (isValidClient(i) && IsClientObserver(i)) + { + int mode = GetEntProp( i, Prop_Send, "m_iObserverMode" ); + if ( mode == 4 || mode == 5 ) + { + int target = GetEntPropEnt( i, Prop_Send, "m_hObserverTarget"); + if (target == client) + count++; + } + } + } + return count; +} + +public void GetMiddleOfABox(float vec1[3], float vec2[3], float buffer[3]) +{ + float mid[3]; + MakeVectorFromPoints(vec1, vec2, mid); + mid[0] = mid[0] / 2.0; + mid[1] = mid[1] / 2.0; + mid[2] = mid[2] / 2.0; + AddVectors(vec1, mid, buffer); +} + +CSWeaponID GetWeaponID(int client) +{ + CSWeaponID weaponID = CSWeapon_NONE; + + int weaponIndex = GetEntDataEnt2(client, m_hActiveWeapon); + if (weaponIndex != -1) + { + static char classname[64]; + GetEdictClassname(weaponIndex, classname, sizeof(classname)); + ReplaceString(classname, sizeof(classname), "weapon_", ""); + + static char wepAlias[64]; + CS_GetTranslatedWeaponAlias(classname, wepAlias, sizeof(wepAlias)); + weaponID = CS_AliasToWeaponID(wepAlias); + } + return weaponID; +} \ No newline at end of file diff --git a/CTimer/ctimer/zones.sp b/CTimer/ctimer/zones.sp new file mode 100644 index 00000000..99782137 --- /dev/null +++ b/CTimer/ctimer/zones.sp @@ -0,0 +1,151 @@ +public void CreateTrigger(int zone) +{ + if ((g_fStartOrigins[zone][0] == 0.0) && (g_fStartOrigins[zone][1] == 0.0) && (g_fStartOrigins[zone][2] == 0.0) && (g_fEndOrigins[zone][0] == 0.0) && (g_fEndOrigins[zone][1] == 0.0) && (g_fEndOrigins[zone][2] == 0.0)) + return; + + if (g_iTriggerEnt[zone] > -1) + { + if (IsValidEntity(g_iTriggerEnt[zone])) + { + AcceptEntityInput(g_iTriggerEnt[zone], "Kill"); + } + g_iTriggerEnt[zone] = -1; + } + + float max[3]; + float min[3]; + + min = g_fStartOrigins[zone]; + max = g_fEndOrigins[zone]; + + char name[12]; + if (zone == 0) + Format(name, sizeof name, "start"); + if (zone == 1) + Format(name, sizeof name, "end"); + + float mid[3] = 0.0; + max[2]+=100; + + GetMiddleOfABox(max, min, mid); + min[0] = min[0] - mid[0]; + if(min[0] > 0.0) + min[0] *= -1.0; + min[1] = min[1] - mid[1]; + if(min[1] > 0.0) + min[1] *= -1.0; + min[2] = min[2] - mid[2]; + if(min[2] > 0.0) + min[2] *= -1.0; + + max[0] = max[0] - mid[0]; + if(max[0] < 0.0) + max[0] *= -1.0; + max[1] = max[1] - mid[1]; + if(max[1] < 0.0) + max[1] *= -1.0; + max[2] = max[2] - mid[2]; + if(max[2] < 0.0) + max[2] *= -1.0; + + g_iTriggerEnt[zone] = CreateEntityByName("trigger_multiple"); + + DispatchKeyValue(g_iTriggerEnt[zone], "spawnflags", "1"); + DispatchKeyValue(g_iTriggerEnt[zone], "targetname", name); + + DispatchKeyValue(g_iTriggerEnt[zone], "wait", "0"); + + DispatchSpawn(g_iTriggerEnt[zone]); + ActivateEntity(g_iTriggerEnt[zone]); + + //PrintToServer("Dispatched and activated %s", name); + + TeleportEntity(g_iTriggerEnt[zone], mid, NULL_VECTOR, NULL_VECTOR); + SetEntityModel(g_iTriggerEnt[zone], "models/error.mdl"); + + //PrintToServer("Teleported and set model %s", name); + + SetEntPropVector(g_iTriggerEnt[zone], Prop_Send, "m_vecMins", min); + SetEntPropVector(g_iTriggerEnt[zone], Prop_Send, "m_vecMaxs", max); + SetEntProp(g_iTriggerEnt[zone], Prop_Send, "m_nSolidType", 2); + + //PrintToServer("Set vecs and solidtype %s", name); + + int iEffects = GetEntProp(g_iTriggerEnt[zone], Prop_Send, "m_fEffects"); + iEffects |= 0x020; + SetEntProp(g_iTriggerEnt[zone], Prop_Send, "m_fEffects", iEffects); + + //PrintToServer("Set effects %s", name); + + SDKHook(g_iTriggerEnt[zone], SDKHook_StartTouch, zoneStartTouch); + SDKHook(g_iTriggerEnt[zone], SDKHook_EndTouch, zoneEndTouch); + + //PrintToServer("Hooks Hooked %s", name); +} + +public Action zoneEndTouch (int caller, int client) +{ + if (!isValidClient(client) || client == g_iEditor || !g_bActive) + return; + + + char trigName[16]; + GetEntPropString(caller, Prop_Data, "m_iName", trigName, sizeof trigName); + + //Player is Exiting Start Zone + if (StrEqual(trigName, "start")) + { + //Player is on starzone state, start run + if (g_iActivity[client] == 1) + { + CheckSpeed(client); + g_iActivity[client] = 0; + g_fStartTime[client] = GetEngineTime(); + g_arrayRun[client].Clear(); + } + } + + //Player is Exiting End Zone + if (StrEqual(trigName, "end")) + { + //Set Player Inactive + g_iActivity[client] = -1; + //EndZoneRoutine(client); + } +} + +public Action zoneStartTouch (int caller, int client) +{ + if (!isValidClient(client) || client == g_iEditor || !g_bActive) + return; + + char trigName[16]; + GetEntPropString(caller, Prop_Data, "m_iName", trigName, sizeof trigName); + + //Player is Entering Start Zone + if (StrEqual(trigName, "start")) + { + //Player teleported from endzone, exec endzoneroutine before reset + if (g_iActivity[client] == 2) + { + //EndZoneRoutine(client); + } + //TODO: Reset record array; + g_iActivity[client] = 1; + } + + if (StrEqual(trigName, "end")) + { + if (g_iActivity[client] == 0) + { + ProcessFinish(client); + g_iActivity[client] = 2; + } + } +} + +/*public void EndZoneRoutine(int client) +{ + //TODO: Save Bot if needed + +}*/ \ No newline at end of file diff --git a/ConnectAnnounce/scripting/ConnectAnnounce.sp b/ConnectAnnounce/scripting/ConnectAnnounce.sp index f529fa98..49e8e355 100644 --- a/ConnectAnnounce/scripting/ConnectAnnounce.sp +++ b/ConnectAnnounce/scripting/ConnectAnnounce.sp @@ -196,8 +196,7 @@ public Action Command_JoinMsg(int client, int args) char sAuth[32]; GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth)); - if (g_hCustomMessageFile != null) - CloseHandle(g_hCustomMessageFile); + delete g_hCustomMessageFile; g_hCustomMessageFile = CreateKeyValues("custom_messages"); @@ -270,8 +269,7 @@ public Action Command_ResetJoinMsg(int client, int args) char sAuth[32]; GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth)); - if (g_hCustomMessageFile != null) - CloseHandle(g_hCustomMessageFile); + delete g_hCustomMessageFile; g_hCustomMessageFile = CreateKeyValues("custom_messages"); @@ -323,7 +321,7 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data) { ReadFileLine(hFile, sRawMsg, sizeof(sRawMsg)); TrimString(sRawMsg); - CloseHandle(hFile); + delete hFile; } else { @@ -411,8 +409,7 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data) return; } - if (g_hCustomMessageFile2 != null) - CloseHandle(g_hCustomMessageFile2); + delete g_hCustomMessageFile2; g_hCustomMessageFile2 = CreateKeyValues("custom_messages"); diff --git a/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp b/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp index 548bae6a..e1283235 100644 --- a/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp +++ b/ConnectAnnounce/scripting/ConnectAnnounceNewPlayers.sp @@ -2,8 +2,10 @@ #include #include +#include bool g_bNewPlayer[MAXPLAYERS + 1] = { false, ... }; +bool g_bNewPlayerChatBlock[MAXPLAYERS + 1] = { false, ...}; ConVar g_cvServerType; char g_cServerMessage[128]; @@ -15,7 +17,7 @@ public Plugin myinfo = name = "ConnectAnnounceNewPlayers", author = "Dogan", description = "Connect Announcer for new Players", - version = "1.2.0", + version = "1.3.0", url = "" } @@ -161,7 +163,9 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] } g_bNewPlayer[client] = true; + g_bNewPlayerChatBlock[client] = true; NewPlayerMessage(client); + CreateTimer(10.0, BlockChat, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE); char sQuery[512]; Format(sQuery, sizeof(sQuery), "INSERT INTO connections (auth) VALUES ('%s')" , sAuthID); @@ -170,21 +174,44 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] public Action NewPlayerMessage(int client) { - char sName[128]; - GetClientName(client, sName, sizeof(sName)); - - CPrintToChatAll("{cyan}Player {blueviolet}%s {cyan}has just connected to an UNLOZE Server for the first time! Welcome!", sName); + CPrintToChatAll("{cyan}Player {lightgreen}%N {cyan}has just connected to an UNLOZE Server for the first time! Welcome!", client); if(g_cvServerType.IntValue >= 1 && g_cvServerType.IntValue <= 3) { - CPrintToChat(client, "{cyan}Hi %s. Welcome to the {blueviolet}Unloze %s Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", sName, g_cServerMessage); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{cyan}Hi {lightgreen}%N{cyan}. Welcome to the {blueviolet}Unloze %s Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", client, g_cServerMessage); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); } else { - CPrintToChat(client, "{cyan}Hi %s. Welcome to this {blueviolet}Unloze Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", sName); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{cyan}Hi {lightgreen}%N. Welcome to this {blueviolet}Unloze Server{cyan}! We hope you enjoy your stay here and add our server to your favorites. Make sure to check out our website at {blueviolet}www.unloze.com{cyan}.", client); + CPrintToChat(client, "{purple}****************************************************"); + CPrintToChat(client, "{purple}****************************************************"); } } public void OnClientDisconnect(int client) { g_bNewPlayer[client] = false; + g_bNewPlayerChatBlock[client] = false; +} + +public Action BlockChat(Handle timer, int serialid) +{ + int client; + if ((client = GetClientFromSerial(serialid)) == 0) + return; + + g_bNewPlayerChatBlock[client] = false; +} + +public Action CCC_OnChatMessage(int client, int author, const char[] message) +{ + if(g_bNewPlayerChatBlock[client]) + return Plugin_Handled; + + return Plugin_Continue; } \ No newline at end of file diff --git a/CrowdSpawnAndFailNadeWarning/scripting/CrowdSpawnAndFailNadeWarning.sp b/CrowdSpawnAndFailNadeWarning/scripting/CrowdSpawnAndFailNadeWarning.sp index 4de8b65c..50628f01 100644 --- a/CrowdSpawnAndFailNadeWarning/scripting/CrowdSpawnAndFailNadeWarning.sp +++ b/CrowdSpawnAndFailNadeWarning/scripting/CrowdSpawnAndFailNadeWarning.sp @@ -71,9 +71,9 @@ public Action OnRoundStartPostCrowdSpawn(Handle timer) { if (!GetConVarBool(FindConVar("zr_infect_mzombie_respawn")) && GetConVarBool(g_cvCrowdSpawnWarningEnabled)) { - CPrintToChatAll("{red}[WARNING] {white}Zombies will be spawning {red}inbetween {white}the humans!!!"); - CPrintToChatAll("{red}[WARNING] {white}Zombies will be spawning {red}inbetween {white}the humans!!!"); - CPrintToChatAll("{red}[WARNING] {white}Zombies will be spawning {red}inbetween {white}the humans!!!"); + CPrintToChatAll("{red}[WARNING] {white}Zombies will be spawning {red}inbetween {white}the humans !!!"); + CPrintToChatAll("{red}[WARNING] {white}Zombies will be spawning {red}inbetween {white}the humans !!!"); + CPrintToChatAll("{red}[WARNING] {white}Zombies will be spawning {red}inbetween {white}the humans !!!"); } } diff --git a/HappyHour/scripting/HappyHour.sp b/HappyHour/scripting/HappyHour.sp index a4c58956..c6dff385 100644 --- a/HappyHour/scripting/HappyHour.sp +++ b/HappyHour/scripting/HappyHour.sp @@ -20,7 +20,7 @@ public Plugin myinfo = name = "Happy Hour", author = "Dogan + Neon", description = "Create an happy hour with more rank points", - version = "1.2.0", + version = "1.3.0", url = "" }; @@ -54,7 +54,7 @@ public void OnPluginStart() HookConVarChange((cvar = CreateConVar("sm_happyhour_message_interval", "60.0", "interval for repetetive message of happy hour in chat")), g_cvMessageTimer); g_fMessageTimer = cvar.FloatValue; - CloseHandle(cvar); + delete cvar; RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not"); @@ -87,8 +87,7 @@ public void g_cvMessageTimer(ConVar convar, const char[] oldValue, const char[] { g_fMessageTimer = convar.FloatValue; - if (g_h_MessageTimer != INVALID_HANDLE && CloseHandle(g_h_MessageTimer)) - g_h_MessageTimer = INVALID_HANDLE; + delete g_h_MessageTimer; g_h_MessageTimer = CreateTimer(g_fMessageTimer, MessageHappyHour, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); } @@ -98,7 +97,7 @@ public Action Timer_CheckTime(Handle timer) if(g_bHappyHourAdmin) return Plugin_Continue; - if((InsideTimeFrame(g_iMorningStart, g_iMorningEnd)) || (InsideTimeFrame(g_iNightStart, g_iNightEnd))) + if((InsideTimeFrame(g_iMorningStart, g_iMorningEnd) == 0) || (InsideTimeFrame(g_iNightStart, g_iNightEnd) == 0)) { g_bHappyHour = true; } @@ -110,7 +109,7 @@ public Action Timer_CheckTime(Handle timer) return Plugin_Continue; } -public bool InsideTimeFrame(int MinTime, int MaxTime) +public int InsideTimeFrame(int MinTime, int MaxTime) { char sTime[8]; FormatTime(sTime, sizeof(sTime), "%H%M"); @@ -122,9 +121,22 @@ public bool InsideTimeFrame(int MinTime, int MaxTime) MaxTime = (MaxTime <= MinTime) ? MaxTime + 2400 : MaxTime; if (MinTime <= CurTime <= MaxTime) - return true; + { + return 0; + } + else + { + //Wrap around. + MinTime = (MinTime <= CurTime) ? MinTime + 2400 : MinTime; + MinTime = (MinTime <= MaxTime) ? MinTime + 2400 : MinTime; - return false; + // Convert our 'time' to minutes. + CurTime = (RoundToFloor(float(CurTime / 100)) * 60) + (CurTime % 100); + MinTime = (RoundToFloor(float(MinTime / 100)) * 60) + (MinTime % 100); + MaxTime = (RoundToFloor(float(MaxTime / 100)) * 60) + (MaxTime % 100); + + return MinTime - CurTime; + } } public void OnMapStart() @@ -145,7 +157,25 @@ public Action Command_DisplayHappyHour(int client, int args) } else { - ReplyToCommand(client, "[SM] Happy Hour is currently not active."); + int iTimeleftMorning = InsideTimeFrame(g_iMorningStart, g_iMorningEnd); + int iTimeleftNight = InsideTimeFrame(g_iNightStart, g_iNightEnd); + int iTimeleft; + char sTimeleft[32]; + + if(iTimeleftMorning >= iTimeleftNight) + iTimeleft = iTimeleftNight; + else + iTimeleft = iTimeleftMorning; + + int iHours = (iTimeleft / 60) % 24; + int iMinutes = (iTimeleft % 60); + + if(iHours) + Format(sTimeleft, sizeof(sTimeleft), "%d Hours %02d Minutes", iHours, iMinutes); + else + Format(sTimeleft, sizeof(sTimeleft), "%d Minutes", iMinutes); + + ReplyToCommand(client, "[SM] Happy Hour is currently not active. Timeleft: %s.", sTimeleft); } return Plugin_Handled; diff --git a/Hide/scripting/Hide.sp b/Hide/scripting/Hide.sp new file mode 100644 index 00000000..3be3bf82 --- /dev/null +++ b/Hide/scripting/Hide.sp @@ -0,0 +1,203 @@ +#include +#include +#include +#include + +/* BOOLS */ +bool g_bHideEnabled; +bool g_bHidePlayers[MAXPLAYERS+1][MAXPLAYERS+1]; + +/* INTEGERS */ +int g_iHideDistance[MAXPLAYERS+1]; + +/* CONVARS */ +ConVar g_hCVar_HideEnabled; +ConVar g_hCVar_HideMinimumDistance; +ConVar g_hCVar_HideMaximumDistance; +ConVar g_hCVar_HideDefaultDistance; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Plugin myinfo = +{ + name = "Hide Teammates", + author = "Neon", + description = "A plugin that can !hide teammates with individual distances", + version = "1.0.0", + url = "https://steamcommunity.com/id/n3ontm" +}; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + + g_hCVar_HideEnabled = CreateConVar("sm_hide_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0); + g_hCVar_HideMinimumDistance = CreateConVar("sm_hide_minimum_distance", "10", "", FCVAR_NONE, true, 1.0); + g_hCVar_HideMaximumDistance = CreateConVar("sm_hide_maximum_distance", "50000", "", FCVAR_NONE, true, 1.0); + g_hCVar_HideDefaultDistance = CreateConVar("sm_hide_default_distance", "10000", "", FCVAR_NONE, true, 1.0); + g_bHideEnabled = g_hCVar_HideEnabled.BoolValue; + g_hCVar_HideEnabled.AddChangeHook(OnConVarChanged); + + + RegAdminCmd("sm_hide", Command_Hide, ADMFLAG_RCON); + + for(int client = 1; client <= MaxClients; client++) + { + if(IsClientInGame(client)) + OnClientPutInServer(client); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnMapStart() +{ + CreateTimer(0.3, UpdateHide, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) +{ + g_bHideEnabled = convar.BoolValue; + + for(int client = 1; client <= MaxClients; client++) + { + for(int target = 1; target <= MaxClients; target++) + g_bHidePlayers[client][target] = false; + + if(IsClientInGame(client)) + { + if(g_bHideEnabled) + SDKHook(client, SDKHook_SetTransmit, Hook_SetTransmit); + else + SDKUnhook(client, SDKHook_SetTransmit, Hook_SetTransmit); + } + } + + if(g_bHideEnabled) + CPrintToChatAll("{cyan}[Hide] {white}has been allowed."); + else + CPrintToChatAll("{cyan}[Hide] {white}has been disabled."); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientPutInServer(int client) +{ + if(!g_bHideEnabled) + return; + + SDKHook(client, SDKHook_SetTransmit, Hook_SetTransmit); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientDisconnect(int client) +{ + g_iHideDistance[client] = 0; + for(int target = 1; target <= MaxClients; target++) + { + g_bHidePlayers[client][target] = false; + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Command_Hide(int client, int args) +{ + if(!g_bHideEnabled) + { + ReplyToCommand(client, "[Hide] is currently not allowed."); + return Plugin_Handled; + } + + int iDistance; + + if(args == 0) + { + if(g_iHideDistance[client]) + { + g_iHideDistance[client] = 0; + ReplyToCommand(client, "[Hide] is now disabled."); + return Plugin_Handled; + } + else + iDistance = g_hCVar_HideDefaultDistance.IntValue; + } + else + { + char sArgs[8]; + GetCmdArg(1, sArgs, sizeof(sArgs)); + iDistance = StringToInt(sArgs); + } + + if((iDistance == 0) || (iDistance < g_hCVar_HideMinimumDistance.IntValue) || (iDistance > g_hCVar_HideMaximumDistance.IntValue)) + { + ReplyToCommand(client, "[Hide] Wrong input! Allowed range: %d-%d", g_hCVar_HideMinimumDistance.IntValue, g_hCVar_HideMaximumDistance.IntValue); + return Plugin_Handled; + } + + g_iHideDistance[client] = iDistance; + ReplyToCommand(client, "[Hide] Humans within range %d are now hidden.", g_iHideDistance[client]); + return Plugin_Handled; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action UpdateHide(Handle timer) +{ + if(!g_bHideEnabled) + return Plugin_Continue; + + for(int client = 1; client <= MaxClients; client++) + { + if(!g_iHideDistance[client]) + continue; + + if(!IsClientInGame(client) || !IsPlayerAlive(client) || !ZR_IsClientHuman(client)) + continue; + + float fOriginClient[3]; + float fOriginTarget[3]; + + for(int target = 1; target <= MaxClients; target++) + { + if(target != client && IsClientInGame(target) && IsPlayerAlive(target) && ZR_IsClientHuman(target)) + { + GetClientAbsOrigin(target, fOriginTarget); + GetClientAbsOrigin(client, fOriginClient); + if(GetVectorDistance(fOriginTarget, fOriginClient, true) < float(g_iHideDistance[client])) + g_bHidePlayers[client][target] = true; + else + g_bHidePlayers[client][target] = false; + } + else + g_bHidePlayers[client][target] = false; + } + } + return Plugin_Continue; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Hook_SetTransmit(int target, int client) +{ + if(!g_bHideEnabled) + return Plugin_Continue; + + if(g_bHidePlayers[client][target]) + return Plugin_Handled; + + return Plugin_Continue; +} \ No newline at end of file diff --git a/ItemSpawn/scripting/ItemSpawn.sp b/ItemSpawn/scripting/ItemSpawn.sp index 8a605659..73512976 100644 --- a/ItemSpawn/scripting/ItemSpawn.sp +++ b/ItemSpawn/scripting/ItemSpawn.sp @@ -61,19 +61,19 @@ public void OnPluginStart() } if(GameConfGetOffset(hGameConf, "GetSlot") == -1) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("Couldn't get GetSlot offset from game config!"); return; } if(GameConfGetOffset(hGameConf, "BumpWeapon") == -1) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("Couldn't get BumpWeapon offset from game config!"); return; } if(GameConfGetOffset(hGameConf, "OnPickedUp") == -1) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("Couldn't get OnPickedUp offset from game config!"); return; } @@ -82,7 +82,7 @@ public void OnPluginStart() StartPrepSDKCall(SDKCall_Entity); if(!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "GetSlot")) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"GetSlot\" failed!"); return; } @@ -93,7 +93,7 @@ public void OnPluginStart() StartPrepSDKCall(SDKCall_Player); if(!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "BumpWeapon")) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"BumpWeapon\" failed!"); return; } @@ -105,7 +105,7 @@ public void OnPluginStart() StartPrepSDKCall(SDKCall_Entity); if(!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "OnPickedUp")) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"OnPickedUp\" failed!"); return; } diff --git a/MakoVote/scripting/MakoVote.sp b/MakoVote/scripting/MakoVote.sp index ebaf8f0e..e7a047d8 100644 --- a/MakoVote/scripting/MakoVote.sp +++ b/MakoVote/scripting/MakoVote.sp @@ -307,7 +307,7 @@ public int Handler_MakoVoteMenu(Handle menu, MenuAction action, int param1, int { case MenuAction_End: { - CloseHandle(menu); + delete menu; if (param1 != -1) { diff --git a/NoAdminTools/scripting/NoAdminTools.sp b/NoAdminTools/scripting/NoAdminTools.sp index 16cb0da6..9c92deb8 100644 --- a/NoAdminTools/scripting/NoAdminTools.sp +++ b/NoAdminTools/scripting/NoAdminTools.sp @@ -15,6 +15,7 @@ float g_fSelfExtendsDelay; bool g_bSelfExtends[MAXPLAYERS + 1] = { false, ...}; bool g_bSelfExtendsAllowed; +bool g_bActiveAdmin[MAXPLAYERS + 1] = { false, ...}; int g_iSelfExtends; ConVar g_cvarTimeLimit; @@ -24,7 +25,7 @@ public Plugin myinfo = name = "No Admin Tools", author = "Dogan", description = "Make it possible for the server to do several things when there is no active admin online", - version = "1.0.0", + version = "1.1.0", url = "" }; @@ -44,7 +45,7 @@ public void OnPluginStart() g_fSelfExtendsRatio = cvar.FloatValue; HookConVarChange((cvar = CreateConVar("sm_selfextend_delay", "60.0", "Time to pass until sm_selfextend can be used")), Cvar_SelfExtendsDelay); g_fSelfExtendsDelay = cvar.FloatValue; - CloseHandle(cvar); + delete cvar; g_cvarTimeLimit = FindConVar("mp_timelimit"); @@ -76,24 +77,29 @@ public void Cvar_SelfExtendsDelay(ConVar convar, const char[] oldValue, const ch g_fSelfExtendsDelay = convar.FloatValue; } -public bool ActiveAdminPresent() +public bool ActiveAdmin(int client) { - for(int i = 1; i <= MaxClients; i++) - { - if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && (GetClientIdleTime(i) < g_iAdminAFKTime)) - return true; - } - return false; + if(GetClientIdleTime(client) < g_iAdminAFKTime) + return true; + + return false; } public void OnClientDisconnect(int client) { g_bSelfExtends[client] = false; + g_bActiveAdmin[client] = false; + CheckRatio(); } -public void OnClientPutInServer(int client) +public void OnClientPostAdminCheck(int client) { + if(CheckCommandAccess(client, "", ADMFLAG_GENERIC)) + { + g_bActiveAdmin[client] = true; + } + CheckRatio(); } @@ -120,22 +126,68 @@ public Action Timer_DelaySelfExtend(Handle timer) public Action Command_DisplayActiveAdmins(int client, int args) { - if(ActiveAdminPresent()) - ReplyToCommand(client, "[SM] There are active Admins online."); + for(int i = 1; i <= MaxClients; i++) + if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && ActiveAdmin(i)) + g_bActiveAdmin[i] = true; + else if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && !ActiveAdmin(i)) + g_bActiveAdmin[i] = false; + + char aBuf[1024]; + char bBuf[1024]; + char aBuf2[MAX_NAME_LENGTH]; + + for(int i = 1; i <= MaxClients; i++) + { + if(IsValidClient(i)) + { + if(g_bActiveAdmin[i]) + { + GetClientName(i, aBuf2, sizeof(aBuf2)); + StrCat(aBuf, sizeof(aBuf), aBuf2); + StrCat(aBuf, sizeof(aBuf), ", "); + } + + if(CheckCommandAccess(i, "", ADMFLAG_GENERIC) && !g_bActiveAdmin[i]) + { + GetClientName(i, aBuf2, sizeof(aBuf2)); + StrCat(bBuf, sizeof(bBuf), aBuf2); + StrCat(bBuf, sizeof(bBuf), ", "); + } + } + } + + if(strlen(aBuf)) + { + aBuf[strlen(aBuf) - 2] = 0; + ReplyToCommand(client, "[SM] Active Admins online: %s", aBuf); + } else - ReplyToCommand(client, "[SM] There are no active Admins online."); + ReplyToCommand(client, "[SM] Active Admins online: none"); + + if(strlen(bBuf)) + { + bBuf[strlen(bBuf) - 2] = 0; + ReplyToCommand(client, "[SM] Inactive Admins online: %s", bBuf); + } + else + ReplyToCommand(client, "[SM] Inactive Admins online: none"); return Plugin_Handled; } public Action Command_SelfExtend(int client, int args) { + int iAdminActivity = 0; + for(int i = 1; i <= MaxClients; i++) + if(g_bActiveAdmin[i]) + iAdminActivity++; + if(GetExtendsLeft() > 0) { ReplyToCommand(client, "[SM] Not available because not all regular extends have been depleted."); return Plugin_Handled; } - if(ActiveAdminPresent()) + if(iAdminActivity > 0) { ReplyToCommand(client, "[SM] Not available because there is atleast one active Admin who can extend. Please ask the Admins."); return Plugin_Handled; diff --git a/RandomizeSpawns/scripting/RandomizeSpawns.sp b/RandomizeSpawns/scripting/RandomizeSpawns.sp index 844e22ae..10183bd5 100644 --- a/RandomizeSpawns/scripting/RandomizeSpawns.sp +++ b/RandomizeSpawns/scripting/RandomizeSpawns.sp @@ -33,14 +33,14 @@ public void OnPluginStart() int iOffset; if ((iOffset = GameConfGetOffset(hGameConf, "SelectSpawnPoint")) == -1) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("GameConfGetOffset(hGameConf, \"SelectSpawnPoint\") failed!"); return; } if ((hSelectSpawnPoint = DHookCreate(iOffset, HookType_Entity, ReturnType_CBaseEntity, ThisPointer_CBaseEntity, OnPlayerSelectSpawnPoint)) == INVALID_HANDLE) { - CloseHandle(hGameConf); + delete hGameConf; SetFailState("DHookCreate(iOffset, HookType_Entity, ReturnType_CBaseEntity, ThisPointer_CBaseEntity, OnPlayerSelectSpawnPoint) failed!"); return; } @@ -54,7 +54,7 @@ public void OnPluginStart() } } - CloseHandle(hGameConf); + delete hGameConf; } //---------------------------------------------------------------------------------------------------- diff --git a/StopSound/scripting/StopSound.sp b/StopSound/scripting/StopSound.sp index 4f7108d1..5d947c24 100644 --- a/StopSound/scripting/StopSound.sp +++ b/StopSound/scripting/StopSound.sp @@ -740,7 +740,7 @@ public void OnReloadEffect(DataPack pack) } } - CloseHandle(pack); + delete pack; Handle ReloadEffect = StartMessage("ReloadEffect", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS); if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) diff --git a/WebShortcuts/scripting/WebShortcuts.sp b/WebShortcuts/scripting/WebShortcuts.sp index 6273e218..497f5b3a 100644 --- a/WebShortcuts/scripting/WebShortcuts.sp +++ b/WebShortcuts/scripting/WebShortcuts.sp @@ -48,7 +48,7 @@ enum _:FieldCheckFlags #else Flag_MaxPlayers = (1<<16) #endif /* _steamtools_included */ -}; +}; #define IsTeamFortress2() (g_iGameMode & Game_TF2) #define IsLeftForDead() (g_iGameMode & Game_L4D) @@ -67,15 +67,15 @@ public OnPluginStart() g_hIndexArray = CreateArray(); /* We'll only use this for cleanup to prevent handle leaks and what not. Our friend below doesn't have iteration, so we have to do this... */ g_hFastLookupTrie = CreateTrie(); - + AddCommandListener(Client_Say, "say"); AddCommandListener(Client_Say, "say_team"); - + /* From Psychonic */ Duck_OnPluginStart(); - + new Handle:cvarVersion = CreateConVar("webshortcutsredux_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_PLUGIN|FCVAR_NOTIFY); - + /* On a reload, this will be set to the old version. Let's update it. */ SetConVarString(cvarVersion, PLUGIN_VERSION); } @@ -86,22 +86,22 @@ public Action:Client_Say(iClient, const String:sCommand[], argc) { return Plugin_Continue; /* Well. While we can probably have blank hooks, I doubt anyone wants this. Lets not waste cycles. Let the game deal with this. */ } - + decl String:sFirstArg[64]; /* If this is too small, let someone know. */ GetCmdArg(1, sFirstArg, sizeof(sFirstArg)); TrimString(sFirstArg); - + new Handle:hStoredTrie = INVALID_HANDLE; if (!GetTrieValue(g_hFastLookupTrie, sFirstArg, hStoredTrie) || hStoredTrie == INVALID_HANDLE) /* L -> R. Strings are R -> L, but that can change. */ { return Plugin_Continue; /* Didn't find anything. Bug out! */ } - + if (DealWithOurTrie(iClient, sFirstArg, hStoredTrie)) { return Plugin_Handled; /* We want other hooks to be called, I guess. We just don't want it to go to the game. */ } - + return Plugin_Continue; /* Well this is embarasing. We didn't actually hook this. Or atleast didn't intend to. */ } @@ -113,14 +113,14 @@ public bool:DealWithOurTrie(iClient, const String:sHookedString[], Handle:hStore LogError("Unable to find a Url for: \"%s\".", sHookedString); return false; } - + new iUrlBits; - + if (!GetTrieValue(hStoredTrie, "UrlBits", iUrlBits)) { iUrlBits = 0; /* That's fine, there are no replacements! Less work for us. */ } - + decl String:sTitle[256]; new iTitleBits; if (!GetTrieString(hStoredTrie, "Title", sTitle, sizeof(sTitle))) @@ -135,12 +135,12 @@ public bool:DealWithOurTrie(iClient, const String:sHookedString[], Handle:hStore iTitleBits = 0; /* That's fine, there are no replacements! Less work for us. */ } } - + Duck_DoReplacements(iClient, sUrl, iUrlBits, sTitle, iTitleBits); /* Arrays are passed by reference. Variables are copied. */ - + new bool:bBig; new bool:bNotSilent = true; - + GetTrieValue(hStoredTrie, "Silent", bNotSilent); if (GoLargeOrGoHome()) { @@ -152,15 +152,15 @@ public bool:DealWithOurTrie(iClient, const String:sHookedString[], Handle:hStore { new iMsgBits; GetTrieValue(hStoredTrie, "MsgBits", iMsgBits); - + if (iMsgBits != 0) { Duck_DoReplacements(iClient, sMessage, iMsgBits, sMessage, 0); /* Lame Hack for now */ } - + PrintToChatAll("%s", sMessage); } - + DisplayMOTDWithOptions(iClient, sTitle, sUrl, bBig, bNotSilent, MOTDPANEL_TYPE_URL); return true; } @@ -171,15 +171,15 @@ public ClearExistingData() for (new i = (GetArraySize(g_hIndexArray) - 1); i >= 0; i--) { hHandle = GetArrayCell(g_hIndexArray, i); - + if (hHandle == INVALID_HANDLE) { continue; } - - CloseHandle(hHandle); + + delete hHandle; } - + ClearArray(g_hIndexArray); ClearTrie(g_hFastLookupTrie); } @@ -187,14 +187,14 @@ public ClearExistingData() public OnConfigsExecuted() { ClearExistingData(); - + decl String:sPath[256]; BuildPath(Path_SM, sPath, sizeof(sPath), "configs/Webshortcuts.txt"); if (!FileExists(sPath)) { return; } - + ProcessFile(sPath); } @@ -202,10 +202,10 @@ public ProcessFile(const String:sPathToFile[]) { new Handle:hSMC = SMC_CreateParser(); SMC_SetReaders(hSMC, SMCNewSection, SMCReadKeyValues, SMCEndSection); - + new iLine; new SMCError:ReturnedError = SMC_ParseFile(hSMC, sPathToFile, iLine); /* Calls the below functions, then execution continues. */ - + if (ReturnedError != SMCError_Okay) { decl String:sError[256]; @@ -213,14 +213,14 @@ public ProcessFile(const String:sPathToFile[]) if (iLine > 0) { LogError("Could not parse file (Line: %d, File \"%s\"): %s.", iLine, sPathToFile, sError); - CloseHandle(hSMC); /* Sneaky Handles. */ + delete hSMC; /* Sneaky Handles. */ return; } - + LogError("Parser encountered error (File: \"%s\"): %s.", sPathToFile, sError); } - CloseHandle(hSMC); + delete hSMC; } public SMCResult:SMCNewSection(Handle:smc, const String:name[], bool:opt_quotes) @@ -229,9 +229,9 @@ public SMCResult:SMCNewSection(Handle:smc, const String:name[], bool:opt_quotes) { LogError("Invalid Quoting used with Section: %s.", name); } - + strcopy(g_sCurrentSection, sizeof(g_sCurrentSection), name); - + if (GetTrieValue(g_hFastLookupTrie, name, g_hCurrentTrie)) { return SMCParse_Continue; @@ -243,7 +243,7 @@ public SMCResult:SMCNewSection(Handle:smc, const String:name[], bool:opt_quotes) SetTrieValue(g_hFastLookupTrie, name, g_hCurrentTrie); SetTrieString(g_hCurrentTrie, "Name", name); } - + return SMCParse_Continue; } @@ -261,7 +261,7 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v { return SMCParse_Continue; } - + switch (key[0]) { case 'p','P': @@ -270,21 +270,21 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v { return SMCParse_Continue; } - + new iFindValue; iFindValue = FindValueInArray(g_hIndexArray, g_hCurrentTrie); - + if (iFindValue > -1) { RemoveFromArray(g_hIndexArray, iFindValue); } - + if (g_sCurrentSection[0] != '\0') { RemoveFromTrie(g_hFastLookupTrie, g_sCurrentSection); } - - CloseHandle(g_hCurrentTrie); /* We're about to invalidate below */ + + delete g_hCurrentTrie; /* We're about to invalidate below */ if (GetTrieValue(g_hFastLookupTrie, value, g_hCurrentTrie)) { @@ -297,81 +297,81 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v SetTrieValue(g_hFastLookupTrie, g_sCurrentSection, g_hCurrentTrie, true); SetTrieString(g_hCurrentTrie, "Name", g_sCurrentSection, true); } - + case 'u','U': { if (!StrEqual(key, "Url", false)) { return SMCParse_Continue; } - + SetTrieString(g_hCurrentTrie, "Url", value, true); - + new iBits; Duck_CalcBits(value, iBits); /* Passed by Ref */ SetTrieValue(g_hCurrentTrie, "UrlBits", iBits, true); } - + case 'T','t': { if (!StrEqual(key, "Title", false)) { return SMCParse_Continue; } - + SetTrieString(g_hCurrentTrie, "Title", value, true); - + new iBits; Duck_CalcBits(value, iBits); /* Passed by Ref */ SetTrieValue(g_hCurrentTrie, "TitleBits", iBits, true); } - + case 'b','B': { if (!GoLargeOrGoHome() || !StrEqual(key, "Big", false)) /* Maybe they don't know they can't use it? Oh well. Protect the silly. */ { return SMCParse_Continue; } - + SetTrieValue(g_hCurrentTrie, "Big", TranslateToBool(value), true); } - + case 'h','H': { if (!StrEqual(key, "Hook", false)) { return SMCParse_Continue; } - + SetTrieValue(g_hFastLookupTrie, value, g_hCurrentTrie, true); } - + case 's', 'S': { if (!StrEqual(key, "Silent", false)) { return SMCParse_Continue; } - + SetTrieValue(g_hCurrentTrie, "Silent", !TranslateToBool(value), true); } - + case 'M', 'm': { if (!StrEqual(key, "Msg", false)) { return SMCParse_Continue; } - + SetTrieString(g_hCurrentTrie, "Msg", value, true); - + new iBits; Duck_CalcBits(value, iBits); /* Passed by Ref */ - + SetTrieValue(g_hCurrentTrie, "MsgBits", iBits, true); } } - + return SMCParse_Continue; } @@ -389,13 +389,13 @@ public bool:TranslateToBool(const String:sSource[]) { return false; } - + case '1', 'y', 'Y', 't', 'T', 's', 'S': { return true; } } - + return false; /* Assume False */ } @@ -407,21 +407,21 @@ public DisplayMOTDWithOptions(iClient, const String:sTitle[], const String:sUrl[ { KvSetNum(hKv, "customsvr", 1); } - + KvSetNum(hKv, "type", iType); - + if (sTitle[0] != '\0') { KvSetString(hKv, "title", sTitle); } - + if (sUrl[0] != '\0') { KvSetString(hKv, "msg", sUrl); } - + ShowVGUIPanel(iClient, "info", hKv, bNotSilent); - CloseHandle(hKv); + delete hKv; } static stock bool:IsValidClient(iClient) @@ -455,7 +455,7 @@ if (StrContains(source, %1) != -1) { field |= %2; } #if defined _steamtools_included #define TOKEN_VACSTATUS "{VAC_STATUS}" #define TOKEN_SERVER_PUB_IP "{SERVER_PUB_IP}" -#define TOKEN_STEAM_CONNSTATUS "{STEAM_CONNSTATUS}" +#define TOKEN_STEAM_CONNSTATUS "{STEAM_CONNSTATUS}" new g_bSteamTools; #endif /* _steamtools_included */ @@ -485,7 +485,7 @@ public OnLibraryRemoved(const String:sLibrary[]) { return; } - + g_bSteamTools = false; } @@ -500,29 +500,29 @@ public Duck_OnPluginStart() g_iGameMode |= Game_TF2; g_iGameMode |= Big_MOTD; } - + /* On a reload, these will already be registered and could be set to non-default */ - + if (IsTeamFortress2()) { /* AddCommandListener(Duck_TF2OnClose, "closed_htmlpage"); */ - } - - LongIPToString(GetConVarInt(FindConVar("hostip")), g_szServerIp); + } + + LongIPToString(GetConVarInt(FindConVar("hostip")), g_szServerIp); GetConVarString(FindConVar("hostport"), g_szServerPort, sizeof(g_szServerPort)); - + new Handle:hostname = FindConVar("hostname"); decl String:szHostname[256]; GetConVarString(hostname, szHostname, sizeof(szHostname)); Duck_UrlEncodeString(g_szServerName, sizeof(g_szServerName), szHostname); HookConVarChange(hostname, OnCvarHostnameChange); - + decl String:szCustom[256]; new Handle:hCVARCustom = CreateConVar("WebShortcuts_Custom", "", "Custom String for this server."); GetConVarString(hCVARCustom, szCustom, sizeof(szCustom)); Duck_UrlEncodeString(g_szServerCustom, sizeof(g_szServerCustom), szCustom); HookConVarChange(hCVARCustom, OnCvarCustomChange); - + new iSDKVersion = GuessSDKVersion(); if (iSDKVersion == SOURCE_SDK_LEFT4DEAD || iSDKVersion == SOURCE_SDK_LEFT4DEAD2) { @@ -533,7 +533,7 @@ public Duck_OnPluginStart() Duck_UrlEncodeString(g_szL4DGameMode, sizeof(g_szL4DGameMode), szGamemode); HookConVarChange(hGameMode, OnCvarGamemodeChange); } - + Duck_UrlEncodeString(g_szGameDir, sizeof(g_szGameDir), sGameDir); } @@ -541,7 +541,7 @@ public OnMapStart() { decl String:sTempMap[sizeof(g_szCurrentMap)]; GetCurrentMap(sTempMap, sizeof(sTempMap)); - + Duck_UrlEncodeString(g_szCurrentMap, sizeof(g_szCurrentMap), sTempMap); } @@ -566,7 +566,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_STEAM_ID, ""); } } - + if (iUrlBits & Flag_User_ID || iTitleBits & Flag_User_ID) { decl String:sUserId[16]; @@ -576,7 +576,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 if (iUrlBits & Flag_User_ID) ReplaceString(sUrl, sizeof(sUrl), TOKEN_USER_ID, sUserId); } - + if (iUrlBits & Flag_Friend_ID || iTitleBits & Flag_Friend_ID) { decl String:sFriendId[64]; @@ -595,7 +595,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_FRIEND_ID, ""); } } - + if (iUrlBits & Flag_Name || iTitleBits & Flag_Name) { decl String:sName[MAX_NAME_LENGTH]; @@ -616,7 +616,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_NAME, ""); } } - + if (iUrlBits & Flag_IP || iTitleBits & Flag_IP) { decl String:sClientIp[32]; @@ -635,7 +635,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_IP, ""); } } - + if (iUrlBits & Flag_Language || iTitleBits & Flag_Language) { decl String:sLanguage[32]; @@ -656,7 +656,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_LANGUAGE, ""); } } - + if (iUrlBits & Flag_Rate || iTitleBits & Flag_Rate) { decl String:sRate[16]; @@ -678,27 +678,27 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_RATE, ""); } } - + if (iTitleBits & Flag_Server_IP) ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_IP, g_szServerIp); if (iUrlBits & Flag_Server_IP) ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_IP, g_szServerIp); - + if (iTitleBits & Flag_Server_Port) ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_PORT, g_szServerPort); if (iUrlBits & Flag_Server_Port) ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_PORT, g_szServerPort); - + if (iTitleBits & Flag_Server_Name) ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_NAME, g_szServerName); if (iUrlBits & Flag_Server_Name) - ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_NAME, g_szServerName); - + ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_NAME, g_szServerName); + if (iTitleBits & Flag_Server_Custom) ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_CUSTOM, g_szServerCustom); if (iUrlBits & Flag_Server_Custom) ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_CUSTOM, g_szServerCustom); - + if (IsLeftForDead() && ((iUrlBits & Flag_L4D_GameMode) || (iTitleBits & Flag_L4D_GameMode))) { if (iTitleBits & Flag_L4D_GameMode) @@ -706,12 +706,12 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 if (iUrlBits & Flag_L4D_GameMode) ReplaceString(sUrl, sizeof(sUrl), TOKEN_L4D_GAMEMODE, g_szL4DGameMode); } - + if (iTitleBits & Flag_Current_Map) ReplaceString(sTitle, sizeof(sTitle), TOKEN_CURRENT_MAP, g_szCurrentMap); if (iUrlBits & Flag_Current_Map) ReplaceString(sUrl, sizeof(sUrl), TOKEN_CURRENT_MAP, g_szCurrentMap); - + if (iUrlBits & Flag_Next_Map || iTitleBits & Flag_Next_Map) { decl String:szNextMap[PLATFORM_MAX_PATH]; @@ -730,12 +730,12 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_NEXT_MAP, ""); } } - + if (iTitleBits & Flag_GameDir) ReplaceString(sTitle, sizeof(sTitle), TOKEN_GAMEDIR, g_szGameDir); if (iUrlBits & Flag_GameDir) ReplaceString(sUrl, sizeof(sUrl), TOKEN_GAMEDIR, g_szGameDir); - + if (iUrlBits & Flag_CurPlayers || iTitleBits & Flag_CurPlayers) { decl String:sCurPlayers[10]; @@ -745,7 +745,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 if (iUrlBits & Flag_CurPlayers) ReplaceString(sUrl, sizeof(sUrl), TOKEN_CURPLAYERS, sCurPlayers); } - + if (iUrlBits & Flag_MaxPlayers || iTitleBits & Flag_MaxPlayers) { decl String:maxplayers[10]; @@ -755,8 +755,8 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 if (iUrlBits & Flag_MaxPlayers) ReplaceString(sUrl, sizeof(sUrl), TOKEN_MAXPLAYERS, maxplayers); } - -#if defined _steamtools_included + +#if defined _steamtools_included if (iUrlBits & Flag_VACStatus || iTitleBits & Flag_VACStatus) { if (g_bSteamTools && Steam_IsVACEnabled()) @@ -774,7 +774,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_VACSTATUS, "0"); } } - + if (iUrlBits & Flag_Server_Pub_IP || iTitleBits & Flag_Server_Pub_IP) { if (g_bSteamTools) @@ -783,7 +783,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 decl String:sIPString[16]; Steam_GetPublicIP(ip); FormatEx(sIPString, sizeof(sIPString), "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); - + if (iTitleBits & Flag_Server_Pub_IP) ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_PUB_IP, sIPString); if (iUrlBits & Flag_Server_Pub_IP) @@ -797,7 +797,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_PUB_IP, ""); } } - + if (iUrlBits & Flag_Steam_ConnStatus || iTitleBits & Flag_Steam_ConnStatus) { if (g_bSteamTools && Steam_IsConnected()) @@ -818,7 +818,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256 #endif /* _steamtools_included */ } -stock bool:GetClientFriendID(client, String:sFriendID[], size) +stock bool:GetClientFriendID(client, String:sFriendID[], size) { #if defined _steamtools_included Steam_GetCSteamIDForClient(client, sFriendID, size); @@ -829,22 +829,22 @@ stock bool:GetClientFriendID(client, String:sFriendID[], size) sFriendID[0] = '\0'; /* Sanitize incase the return isn't checked. */ return false; } - + TrimString(sSteamID); /* Just incase... */ - + if (StrEqual(sSteamID, "STEAM_ID_LAN", false)) { sFriendID[0] = '\0'; return false; } - + decl String:toks[3][16]; ExplodeString(sSteamID, ":", toks, sizeof(toks), sizeof(toks[])); - + new iServer = StringToInt(toks[1]); new iAuthID = StringToInt(toks[2]); new iFriendID = (iAuthID*2) + 60265728 + iServer; - + if (iFriendID >= 100000000) { decl String:temp[12], String:carry[12]; @@ -852,7 +852,7 @@ stock bool:GetClientFriendID(client, String:sFriendID[], size) FormatEx(carry, 2, "%s", temp); new icarry = StringToInt(carry[0]); new upper = 765611979 + icarry; - + FormatEx(temp, sizeof(temp), "%d", iFriendID); FormatEx(sFriendID, size, "%d%s", upper, temp[1]); } @@ -867,7 +867,7 @@ stock bool:GetClientFriendID(client, String:sFriendID[], size) Duck_CalcBits(const String:source[], &field) { field = 0; - + FIELD_CHECK(TOKEN_STEAM_ID, Flag_Steam_ID); FIELD_CHECK(TOKEN_USER_ID, Flag_User_ID); FIELD_CHECK(TOKEN_FRIEND_ID, Flag_Friend_ID); @@ -879,12 +879,12 @@ Duck_CalcBits(const String:source[], &field) FIELD_CHECK(TOKEN_SERVER_PORT, Flag_Server_Port); FIELD_CHECK(TOKEN_SERVER_NAME, Flag_Server_Name); FIELD_CHECK(TOKEN_SERVER_CUSTOM, Flag_Server_Custom); - + if (IsLeftForDead()) { FIELD_CHECK(TOKEN_L4D_GAMEMODE, Flag_L4D_GameMode); } - + FIELD_CHECK(TOKEN_CURRENT_MAP, Flag_Current_Map); FIELD_CHECK(TOKEN_NEXT_MAP, Flag_Next_Map); FIELD_CHECK(TOKEN_GAMEDIR, Flag_GameDir); @@ -909,7 +909,7 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[]) { new icnt = 0; new ocnt = 0; - + for(;;) { if (ocnt == size) @@ -917,14 +917,14 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[]) output[ocnt-1] = '\0'; return; } - + new c = input[icnt]; if (c == '\0') { output[ocnt] = '\0'; return; } - + // Use '+' instead of '%20'. // Still follows spec and takes up less of our limited buffer. if (c == ' ') @@ -934,7 +934,7 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[]) else if ((c < '0' && c != '-' && c != '.') || (c < 'A' && c > '9') || (c > 'Z' && c < 'a' && c != '_') || - (c > 'z' && c != '~')) + (c > 'z' && c != '~')) { output[ocnt++] = '%'; Format(output[ocnt], size-strlen(output[ocnt]), "%x", c); @@ -944,7 +944,7 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[]) { output[ocnt++] = c; } - + icnt++; } } diff --git a/advertisements/include/colorvariables.inc b/advertisements/include/colorvariables.inc index 6d709706..0af547cc 100644 --- a/advertisements/include/colorvariables.inc +++ b/advertisements/include/colorvariables.inc @@ -270,7 +270,7 @@ stock CAddVariable(String:sName[], String:sValue[], bool:bOnlySaveToConfig = fal new Handle:hKV = CreateKeyValues("colorvariables"); if (!FileToKeyValues(hKV, g_sConfig)) { - CloseHandle(hKV); + delete hKV; LogError("Cannot open file (for adding color variable) '%s' !", g_sConfig); return; } @@ -284,13 +284,13 @@ stock CAddVariable(String:sName[], String:sValue[], bool:bOnlySaveToConfig = fal PushArrayString(hRedirect, sName); SetTrieString(g_hColors, sName, sValue); SolveRedirects(g_hColors, hRedirect); - CloseHandle(hRedirect); + delete hRedirect; } } KvRewind(hKV); KeyValuesToFile(hKV, g_sConfig); - CloseHandle(hKV); + delete hKV; } } @@ -310,7 +310,7 @@ stock CLoadPluginConfig(const String:sPluginName[], bool:bAllowPrefix = true) new Handle:hRedirect = CreateArray(64); LoadConfigFile(g_hColors, sConfig, hRedirect, bAllowPrefix); SolveRedirects(g_hColors, hRedirect); - CloseHandle(hRedirect); + delete hRedirect; } } @@ -346,8 +346,8 @@ stock CLoadPluginVariables(const String:sPluginName[], const String:sVariables[] } SolveRedirects(g_hColors, hRedirect); - CloseHandle(hRedirect); - CloseHandle(hVariables); + delete hRedirect; + delete hVariables; } } @@ -571,8 +571,7 @@ stock bool:Init() } WriteFileLine(hConfig, "}"); - CloseHandle(hConfig); - hConfig = INVALID_HANDLE; + delete hConfig; } else { hConfig = OpenFile(g_sConfigGlobal, "r"); if (hConfig == INVALID_HANDLE) { @@ -582,7 +581,7 @@ stock bool:Init() new String:sVersionLine[64]; ReadFileLine(hConfig, sVersionLine, sizeof(sVersionLine)); - CloseHandle(hConfig); + delete hConfig; TrimString(sVersionLine); strcopy(sVersionLine, sizeof(sVersionLine), sVersionLine[FindCharInString(sVersionLine, ':') + 2]); @@ -591,7 +590,7 @@ stock bool:Init() new Handle:hKV = CreateKeyValues("colorvariables"); if (!FileToKeyValues(hKV, g_sConfigGlobal) || !KvGotoFirstSubKey(hKV, false)) { - CloseHandle(hKV); + delete hKV; LogError("Cannot read variables from file '%s' !", g_sConfigGlobal); return false; } @@ -629,8 +628,8 @@ stock bool:Init() WriteFileLine(hConfig, "}"); - CloseHandle(hConfig); - CloseHandle(hKV); + delete hConfig; + delete hKV; } } @@ -643,8 +642,7 @@ stock bool:Init() } WriteFileLine(hConfig, "\"colorvariables\"\n{\n}"); - CloseHandle(hConfig); - hConfig = INVALID_HANDLE; + delete hConfig; } for (new iClient = 1; iClient <= MaxClients; iClient++) { @@ -683,13 +681,13 @@ stock static LoadConfigFile(Handle:hTrie, String:sPath[], Handle:hRedirect, bool new Handle:hKV = CreateKeyValues("colorvariables"); if (!FileToKeyValues(hKV, sPath)) { - CloseHandle(hKV); + delete hKV; LogError("Cannot load color variables from file '%s' !", sPath); return; } if (!KvGotoFirstSubKey(hKV, false)) { - CloseHandle(hKV); + delete hKV; return; } @@ -723,7 +721,7 @@ stock static LoadConfigFile(Handle:hTrie, String:sPath[], Handle:hRedirect, bool SetTrieString(hTrie, sCode, sColor); } while (KvGotoNextKey(hKV, false)); - CloseHandle(hKV); + delete hKV; } stock static SolveRedirects(Handle:hTrie, Handle:hRedirect) diff --git a/includes/multicolors/morecolors.inc b/includes/multicolors/morecolors.inc index ecf74136..f88c0ea0 100644 --- a/includes/multicolors/morecolors.inc +++ b/includes/multicolors/morecolors.inc @@ -29,11 +29,11 @@ static Handle sm_show_activity = INVALID_HANDLE; /** * Prints a message to a specific client in the chat area. * Supports color tags. - * + * * @param client Client index. * @param message Message (formatting rules). * @noreturn - * + * * On error/Errors: If the client is not connected an error will be thrown. */ stock void MC_PrintToChat(int client, const char[] message, any ...) { @@ -55,7 +55,7 @@ stock void MC_PrintToChat(int client, const char[] message, any ...) { /** * Prints a message to all clients in the chat area. * Supports color tags. - * + * * @param client Client index. * @param message Message (formatting rules). * @noreturn @@ -79,12 +79,12 @@ stock void MC_PrintToChatAll(const char[] message, any ...) { /** * Prints a message to a specific client in the chat area. * Supports color tags and teamcolor tag. - * + * * @param client Client index. * @param author Author index whose color will be used for teamcolor tag. * @param message Message (formatting rules). * @noreturn - * + * * On error/Errors: If the client or author are not connected an error will be thrown */ stock void MC_PrintToChatEx(int client, int author, const char[] message, any ...) { @@ -116,7 +116,7 @@ stock void MC_PrintToChatEx(int client, int author, const char[] message, any .. * @param author Author index whose color will be used for teamcolor tag. * @param message Message (formatting rules). * @noreturn - * + * * On error/Errors: If the author is not connected an error will be thrown. */ stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) { @@ -143,7 +143,7 @@ stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) { /** * Sends a SayText2 usermessage - * + * * @param client Client to send usermessage to * @param message Message to send * @noreturn @@ -191,7 +191,7 @@ stock void MC_SendMessage(int client, const char[] message, int author = 0) { * MC_PrintToChatAll or MC_PrintToChatAllEx. It causes those functions * to skip the specified client when printing the message. * After printing the message, the client will no longer be skipped. - * + * * @param client Client index * @noreturn */ @@ -204,7 +204,7 @@ stock void MC_SkipNextClient(int client) { /** * Checks if the colors trie is initialized and initializes it if it's not (used internally) - * + * * @return No return */ stock void MC_CheckTrie() { @@ -221,7 +221,7 @@ stock void MC_CheckTrie() { * @param removeTags Optional boolean value to determine whether we're replacing tags with colors, or just removing tags, used by MC_RemoveTags * @param maxlen Optional value for max buffer length, used by MC_RemoveTags * @noreturn - * + * * On error/Errors: If the client index passed for author is invalid or not in game. */ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = false, int maxlen = MAX_BUFFER_LENGTH) { @@ -243,16 +243,16 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = } int cursor = 0; int value; - char tag[32], buff[32]; + char tag[32], buff[32]; char[] output = new char[maxlen]; - + strcopy(output, maxlen, buffer); // Since the string's size is going to be changing, output will hold the replaced string and we'll search buffer - + Handle regex = CompileRegex("{[a-zA-Z0-9]+}"); for(int i = 0; i < 1000; i++) { // The RegEx extension is quite flaky, so we have to loop here :/. This loop is supposed to be infinite and broken by return, but conditions have been added to be safe. if(MatchRegex(regex, buffer[cursor]) < 1) { - CloseHandle(regex); + delete regex; strcopy(buffer, maxlen, output); return; } @@ -262,11 +262,11 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = strcopy(buff, sizeof(buff), tag); ReplaceString(buff, sizeof(buff), "{", ""); ReplaceString(buff, sizeof(buff), "}", ""); - + if(!GetTrieValue(MC_Trie, buff, value)) { continue; } - + if(removeTags) { ReplaceString(output, maxlen, tag, "", false); } else { @@ -279,7 +279,7 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = /** * Gets a part of a string - * + * * @param input String to get the part from * @param output Buffer to write to * @param maxlen Max length of output buffer @@ -301,7 +301,7 @@ stock void CSubString(const char[] input, char[] output, int maxlen, int start, /** * Converts a string to lowercase - * + * * @param buffer String to convert * @noreturn */ @@ -334,7 +334,7 @@ stock bool MC_AddColor(const char[] name, int color) { /** * Removes color tags from a message - * + * * @param message Message to remove tags from * @param maxlen Maximum buffer length * @noreturn @@ -345,7 +345,7 @@ stock void MC_RemoveTags(char[] message, int maxlen) { /** * Replies to a command with colors - * + * * @param client Client to reply to * @param message Message (formatting rules) * @noreturn @@ -364,7 +364,7 @@ stock void MC_ReplyToCommand(int client, const char[] message, any ...) { /** * Replies to a command with colors - * + * * @param client Client to reply to * @param author Client to use for {teamcolor} * @param message Message (formatting rules) @@ -383,12 +383,12 @@ stock void MC_ReplyToCommandEx(int client, int author, const char[] message, any } /** - * Displays usage of an admin command to users depending on the - * setting of the sm_show_activity cvar. + * Displays usage of an admin command to users depending on the + * setting of the sm_show_activity 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, + * 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, * MC_ShowActivity2() is slightly more useful. * Supports color tags. * @@ -402,14 +402,14 @@ stock int MC_ShowActivity(int client, const char[] format, any ...) { if (sm_show_activity == INVALID_HANDLE) sm_show_activity = FindConVar("sm_show_activity"); - + char tag[] = "[SM] "; - + char szBuffer[MC_MAX_MESSAGE_LENGTH]; //char szCMessage[MC_MAX_MESSAGE_LENGTH]; int value = GetConVarInt(sm_show_activity); ReplySource replyto = GetCmdReplySource(); - + char name[MAX_NAME_LENGTH] = "Console"; char sign[MAX_NAME_LENGTH] = "ADMIN"; bool display_in_chat = false; @@ -417,7 +417,7 @@ stock int MC_ShowActivity(int client, const char[] format, any ...) { if (client < 0 || client > MaxClients || !IsClientConnected(client)) ThrowError("Client index %d is invalid", client); - + GetClientName(client, name, sizeof(name)); AdminId id = GetUserAdmin(client); if (id == INVALID_ADMIN_ID @@ -425,13 +425,13 @@ stock int MC_ShowActivity(int client, const char[] format, any ...) { sign = "PLAYER"; } - + /* Display the message to the client? */ if (replyto == SM_REPLY_TO_CONSOLE) { SetGlobalTransTarget(client); VFormat(szBuffer, sizeof(szBuffer), format, 3); - + MC_RemoveTags(szBuffer, sizeof(szBuffer)); PrintToConsole(client, "%s%s\n", tag, szBuffer); display_in_chat = true; @@ -441,16 +441,16 @@ stock int MC_ShowActivity(int client, const char[] format, any ...) { SetGlobalTransTarget(LANG_SERVER); VFormat(szBuffer, sizeof(szBuffer), format, 3); - + MC_RemoveTags(szBuffer, sizeof(szBuffer)); PrintToServer("%s%s\n", tag, szBuffer); } - + if (!value) { return 1; } - + MuCo_LoopClients(i) { if (i == 0 @@ -475,7 +475,7 @@ stock int MC_ShowActivity(int client, const char[] format, any ...) newsign = name; } VFormat(szBuffer, sizeof(szBuffer), format, 3); - + MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer); } } @@ -494,12 +494,12 @@ stock int MC_ShowActivity(int client, const char[] format, any ...) newsign = name; } VFormat(szBuffer, sizeof(szBuffer), format, 3); - + MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer); } } } - + return 1; } @@ -518,12 +518,12 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a { if (sm_show_activity == INVALID_HANDLE) sm_show_activity = FindConVar("sm_show_activity"); - + char szBuffer[MC_MAX_MESSAGE_LENGTH]; //char szCMessage[MC_MAX_MESSAGE_LENGTH]; int value = GetConVarInt(sm_show_activity); ReplySource replyto = GetCmdReplySource(); - + char name[MAX_NAME_LENGTH] = "Console"; char sign[MAX_NAME_LENGTH] = "ADMIN"; bool display_in_chat = false; @@ -531,7 +531,7 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a { if (client < 0 || client > MaxClients || !IsClientConnected(client)) ThrowError("Client index %d is invalid", client); - + GetClientName(client, name, sizeof(name)); AdminId id = GetUserAdmin(client); if (id == INVALID_ADMIN_ID @@ -539,13 +539,13 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a { sign = "PLAYER"; } - + /* Display the message to the client? */ if (replyto == SM_REPLY_TO_CONSOLE) { SetGlobalTransTarget(client); VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_RemoveTags(szBuffer, sizeof(szBuffer)); PrintToConsole(client, "%s%s\n", tag, szBuffer); display_in_chat = true; @@ -555,16 +555,16 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a { SetGlobalTransTarget(LANG_SERVER); VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_RemoveTags(szBuffer, sizeof(szBuffer)); PrintToServer("%s%s\n", tag, szBuffer); } - + if (!value) { return 1; } - + MuCo_LoopClients(i) { if (i == 0 @@ -589,7 +589,7 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a newsign = name; } VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer); } } @@ -608,18 +608,18 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a newsign = name; } VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer); } } } - + return 1; } /** * Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar. - * All users receive a message in their chat text, except for the originating client, + * 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. * @@ -634,19 +634,19 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an { if (sm_show_activity == INVALID_HANDLE) sm_show_activity = FindConVar("sm_show_activity"); - + char szBuffer[MC_MAX_MESSAGE_LENGTH]; //char szCMessage[MC_MAX_MESSAGE_LENGTH]; int value = GetConVarInt(sm_show_activity); // ReplySource replyto = GetCmdReplySource(); - + char name[MAX_NAME_LENGTH] = "Console"; char sign[MAX_NAME_LENGTH] = "ADMIN"; if (client != 0) { if (client < 0 || client > MaxClients || !IsClientConnected(client)) ThrowError("Client index %d is invalid", client); - + GetClientName(client, name, sizeof(name)); AdminId id = GetUserAdmin(client); if (id == INVALID_ADMIN_ID @@ -654,12 +654,12 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an { sign = "PLAYER"; } - + SetGlobalTransTarget(client); VFormat(szBuffer, sizeof(szBuffer), format, 4); - - /* We don't display directly to the console because the chat text - * simply gets added to the console, so we don't want it to print + + /* We don't display directly to the console because the chat text + * simply gets added to the console, so we don't want it to print * twice. */ MC_PrintToChatEx(client, client, "%s%s", tag, szBuffer); @@ -668,16 +668,16 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an { SetGlobalTransTarget(LANG_SERVER); VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_RemoveTags(szBuffer, sizeof(szBuffer)); PrintToServer("%s%s\n", tag, szBuffer); } - + if (!value) { return 1; } - + MuCo_LoopClients(i) { if (i == 0 @@ -702,7 +702,7 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an newsign = name; } VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer); } } @@ -721,18 +721,18 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an newsign = name; } VFormat(szBuffer, sizeof(szBuffer), format, 4); - + MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer); } } } - - return 1; + + return 1; } /** * Determines whether a color name exists - * + * * @param color The color name to check * @return True if the color exists, false otherwise */ diff --git a/includes/smjansson.inc b/includes/smjansson.inc index 1d7c9f8f..77494de0 100644 --- a/includes/smjansson.inc +++ b/includes/smjansson.inc @@ -290,7 +290,7 @@ native bool json_object_update_missing(JSONObject hObj, JSONObject hOther); * * // Do something with sKey and hValue * - * CloseHandle(hValue); + * delete hValue; * * hIterator = json_object_iter_next(hObj, hIterator); * } @@ -1575,7 +1575,7 @@ public JSONObject json_pack_object_(const char[] sFormat, int &iPos, Handle hPar if(this_char != 115) { LogError("Object keys must be strings at %d.", iPos); - CloseHandle(hObj); + delete hObj; return view_as(INVALID_HANDLE); } diff --git a/leader2/scripting/leader2.sp b/leader2/scripting/leader2.sp index 5c50fbce..e0cb7295 100644 --- a/leader2/scripting/leader2.sp +++ b/leader2/scripting/leader2.sp @@ -816,7 +816,7 @@ public int LeaderMenu_Handler(Handle menu, MenuAction action, int client, int po } else if(action == MenuAction_End) { - CloseHandle(menu); + delete menu; } } @@ -912,7 +912,7 @@ public int SpriteMenu_Handler(Handle menu, MenuAction action, int client, int po } else if(action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel && position == MenuCancel_ExitBack) { @@ -989,7 +989,7 @@ public int MarkerMenu_Handler(Handle menu, MenuAction action, int client, int po } else if(action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel && position == MenuCancel_ExitBack) { diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index 4fb97eb4..55daeb2d 100644 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -1192,7 +1192,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) AddMapItem(map); } - CloseHandle(randomizeList); + delete randomizeList; randomizeList = INVALID_HANDLE; } @@ -1233,7 +1233,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map"); } } - CloseHandle(inputlist); + delete inputlist; } int voteDuration = GetConVarInt(g_Cvar_VoteDuration); @@ -1482,7 +1482,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p if(g_NativeVotes) NativeVotes_Close(menu); else - CloseHandle(menu); + delete menu; } case MenuAction_Display: @@ -1748,7 +1748,7 @@ void CreateNextVote() } delete groupmap; - CloseHandle(tempMaps); + delete tempMaps; } bool CanVoteStart() diff --git a/sourcebans/scripting/sbchecker.sp b/sourcebans/scripting/sbchecker.sp index 41128a64..4a7b1713 100644 --- a/sourcebans/scripting/sbchecker.sp +++ b/sourcebans/scripting/sbchecker.sp @@ -179,7 +179,7 @@ public OnListBans(Handle:owner, Handle:hndl, const String:error[], any:pack) new client = GetClientOfUserId(clientuid); decl String:targetName[MAX_NAME_LENGTH]; ReadPackString(pack, targetName, sizeof(targetName)); - CloseHandle(pack); + delete pack; if (clientuid > 0 && client == 0) return; diff --git a/ze_boatescape6_remix_fix2/scripting/ze_boatescape6_remix_fix2.sp b/ze_boatescape6_remix_fix2/scripting/ze_boatescape6_remix_fix2.sp index e8b351bc..c2e86d2d 100644 --- a/ze_boatescape6_remix_fix2/scripting/ze_boatescape6_remix_fix2.sp +++ b/ze_boatescape6_remix_fix2/scripting/ze_boatescape6_remix_fix2.sp @@ -781,11 +781,7 @@ public Action Sparks(Handle timer) stock ClearTimer(&Handle:timer) { - if (timer != INVALID_HANDLE) - { - CloseHandle(timer); - timer = INVALID_HANDLE; - } + delete timer; } public Action SpawnSeagullRelay()