diff --git a/src/zr/playerclasses/classevents.inc b/src/zr/playerclasses/classevents.inc index 9788419..1c68d98 100644 --- a/src/zr/playerclasses/classevents.inc +++ b/src/zr/playerclasses/classevents.inc @@ -25,6 +25,20 @@ ClassOnCookiesCreate() // Forward event to sub-modules. ClassOverlayOnCookiesCreate(); + // Close cookie handles if they already exist. + if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] != INVALID_HANDLE) + { + CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS]); + } + if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] != INVALID_HANDLE) + { + CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES]); + } + if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] != INVALID_HANDLE) + { + CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS]); + } + // Create class index cookies. g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] = RegClientCookie("zr_humanclass", "The last human class selected.", CookieAccess_Protected); g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] = RegClientCookie("zr_zombieclass", "The last zombie class selected.", CookieAccess_Protected); diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index 687eaed..b470d1c 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -76,6 +76,12 @@ ClassOverlayOnCommandsHook() */ ClassOverlayOnCookiesCreate() { + // Close cookie handle if it already exist. + if (g_hOverlayEnabledCookie != INVALID_HANDLE) + { + CloseHandle(g_hOverlayEnabledCookie); + } + // Create overlay cookie. g_hOverlayEnabledCookie = RegClientCookie(CLASSOVERLAY_COOKIE_ENABLED, "The toggle state of the class overlay.", CookieAccess_Protected); } diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index 237fc72..f3c64d3 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -54,6 +54,11 @@ new Handle:g_hZMarketPurchaseCount[MAXPLAYERS + 1]; */ new Handle:g_hZMarketAutoRebuyCookie = INVALID_HANDLE; +/** + * Cookie handle array for weapon loadouts. + */ +new Handle:g_hZMarketLoadoutCookie[WEAPONS_SLOTS_MAX + 1]; + /** * Create commands specific to ZMarket. */ @@ -65,7 +70,13 @@ ZMarketOnCommandsCreate() ZMarketOnCookiesCreate() { - // Create all cookies. + // Close auto-rebuy cookie handle if it already exist. + if (g_hZMarketAutoRebuyCookie != INVALID_HANDLE) + { + CloseHandle(g_hZMarketAutoRebuyCookie); + } + + // Create auto-rebuy cookie. g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Protected); decl String:rebuycookiename[32]; @@ -78,8 +89,14 @@ ZMarketOnCookiesCreate() Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x); Format(rebuycookiedesc, sizeof(rebuycookiedesc), "Current loadout weapon for slot %d", x); - // Register client cookie. - RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected); + // Close loadout cookie handle if it already exist. + if (g_hZMarketLoadoutCookie[x] != INVALID_HANDLE) + { + CloseHandle(g_hZMarketLoadoutCookie[x]); + } + + // Create loadout cookie. + g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected); } } diff --git a/src/zr/zhp.inc b/src/zr/zhp.inc index a8c96f0..5847c1e 100644 --- a/src/zr/zhp.inc +++ b/src/zr/zhp.inc @@ -54,6 +54,12 @@ ZHPOnCommandsCreate() */ ZHPOnCookiesCreate() { + // Close cookie handle if it already exist. + if (g_hZHPEnabledCookie != INVALID_HANDLE) + { + CloseHandle(g_hZHPEnabledCookie); + } + // Create ZHP cookie. g_hZHPEnabledCookie = RegClientCookie(ZHP_COOKIE_ENABLED, "The toggle state of ZHP.", CookieAccess_Protected); }