Finished client cookies (remembers settings, yaay) zsettings still to come.
Changed steamidcache.inc to LF newline format. Hopefully permanently fixed the weapon rendering problem.
This commit is contained in:
parent
6426bf169c
commit
2e178d2ab6
@ -31,6 +31,8 @@
|
|||||||
CookiesInit()
|
CookiesInit()
|
||||||
{
|
{
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
|
ClassOnCookiesCreate();
|
||||||
|
WeaponsOnCookiesCreate();
|
||||||
ZHPOnCookiesCreate();
|
ZHPOnCookiesCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc
|
|||||||
public Action:EventRoundStartPost(Handle:timer, any:index)
|
public Action:EventRoundStartPost(Handle:timer, any:index)
|
||||||
{
|
{
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
WeaponsOnRoundStartPost();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,7 +138,6 @@ public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcas
|
|||||||
new reason = GetEventInt(event, "reason");
|
new reason = GetEventInt(event, "reason");
|
||||||
|
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
WeaponsOnRoundEnd();
|
|
||||||
RoundEndOnRoundEnd(reason);
|
RoundEndOnRoundEnd(reason);
|
||||||
InfectOnRoundEnd();
|
InfectOnRoundEnd();
|
||||||
SEffectsOnRoundEnd();
|
SEffectsOnRoundEnd();
|
||||||
@ -224,6 +222,7 @@ public Action:EventPlayerSpawnPost(Handle:timer, any:index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
|
WeaponsOnClientSpawnPost(index);
|
||||||
SpawnProtectOnClientSpawnPost(index);
|
SpawnProtectOnClientSpawnPost(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +236,11 @@ OverlaysChannel:OverlaysClientFindChannel(client)
|
|||||||
*
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param channel The channel to change state of.
|
* @param channel The channel to change state of.
|
||||||
* @param toggle Set to true to toggle state, false to use value param.
|
* @param update (Optional) Update the overlay when this function is called.
|
||||||
|
* @param toggle (Optional) Set to true to toggle state, false to use value param.
|
||||||
* @param value (Optional) New value of the state, only used if toggle is false.
|
* @param value (Optional) New value of the state, only used if toggle is false.
|
||||||
|
* @param reset (Optional) Clears the overlay from client's screen.
|
||||||
|
* @return The overlay's new state.
|
||||||
*/
|
*/
|
||||||
bool:OverlaysClientSetChannelState(client, OverlaysChannel:channel, bool:update = false, bool:toggle = true, bool:value = false, bool:reset = false)
|
bool:OverlaysClientSetChannelState(client, OverlaysChannel:channel, bool:update = false, bool:toggle = true, bool:value = false, bool:reset = false)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,24 @@
|
|||||||
* ------------------------------------
|
* ------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create class-related cookies here.
|
||||||
|
*/
|
||||||
|
ClassOnCookiesCreate()
|
||||||
|
{
|
||||||
|
// Forward event to sub-modules.
|
||||||
|
ClassOverlayOnCookiesCreate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when all modules are done loading.
|
||||||
|
*/
|
||||||
|
ClassOnModulesLoaded()
|
||||||
|
{
|
||||||
|
// Set default classes on all player slots.
|
||||||
|
ClassClientSetDefaultIndexes();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a client connects to the server (OnClientPutInServer).
|
* Called when a client connects to the server (OnClientPutInServer).
|
||||||
*/
|
*/
|
||||||
@ -35,15 +53,6 @@ ClassClientInit(client)
|
|||||||
ClassOverlayClientInit(client);
|
ClassOverlayClientInit(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when all modules are done loading.
|
|
||||||
*/
|
|
||||||
ClassOnModulesLoaded()
|
|
||||||
{
|
|
||||||
// Set default classes on all player slots.
|
|
||||||
ClassClientSetDefaultIndexes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called a client disconnects.
|
* Called a client disconnects.
|
||||||
*/
|
*/
|
||||||
|
@ -33,26 +33,16 @@
|
|||||||
/**
|
/**
|
||||||
* @endsection
|
* @endsection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Array to store default class overlay enable flag.
|
|
||||||
*/
|
|
||||||
new bool:h_bClassOverlay[MAXPLAYERS + 1];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* Name of the cookie for toggle state the class overlay.
|
||||||
*
|
|
||||||
* @param client The client index.
|
|
||||||
*/
|
*/
|
||||||
ClassOverlayClientInit(client)
|
#define CLASSOVERLAY_COOKIE_ENABLED "zr_overlay"
|
||||||
{
|
|
||||||
// Get overlay toggle cvar values.
|
/**
|
||||||
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
* Cookie handle for the toggle state of an overlay.
|
||||||
new bool:overlaydefault = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_DEFAULT]);
|
*/
|
||||||
|
new Handle:g_hOverlayEnabledCookie = INVALID_HANDLE;
|
||||||
// Apply default value if toggle is enabled, default to true if toggle is disabled.
|
|
||||||
h_bClassOverlay[client] = overlaytoggle ? overlaydefault : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook commands related to overlay here.
|
* Hook commands related to overlay here.
|
||||||
@ -78,6 +68,43 @@ ClassOverlayOnCommandsHook()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create class overlay-related cookies here.
|
||||||
|
*/
|
||||||
|
ClassOverlayOnCookiesCreate()
|
||||||
|
{
|
||||||
|
// If cookie doesn't already exist, then create it.
|
||||||
|
g_hOverlayEnabledCookie = FindClientCookie(CLASSOVERLAY_COOKIE_ENABLED);
|
||||||
|
if (g_hOverlayEnabledCookie == INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
g_hOverlayEnabledCookie = RegClientCookie(CLASSOVERLAY_COOKIE_ENABLED, "The toggle state of the class overlay.", CookieAccess_Public);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client is joining the server.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
ClassOverlayClientInit(client)
|
||||||
|
{
|
||||||
|
// Get overlay toggle cvar values.
|
||||||
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
||||||
|
new bool:overlaydefault = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_DEFAULT]);
|
||||||
|
|
||||||
|
// Get ZHP enabled cookie value.
|
||||||
|
decl String:overlayenabled[8];
|
||||||
|
GetClientCookie(client, g_hOverlayEnabledCookie, overlayenabled, sizeof(overlayenabled));
|
||||||
|
|
||||||
|
// If the cookie is empty, then set the default value.
|
||||||
|
if (!overlayenabled[0])
|
||||||
|
{
|
||||||
|
// Set cookie to default value from cvar.
|
||||||
|
new bool:overlayvalue = overlaytoggle ? overlaydefault : true;
|
||||||
|
CookiesSetClientCookieBool(client, g_hOverlayEnabledCookie, overlayvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is spawning into the game.
|
* Client is spawning into the game.
|
||||||
*
|
*
|
||||||
@ -152,7 +179,7 @@ ClassOverlayInitialize(client, const String:overlay[])
|
|||||||
|
|
||||||
// Display class overlays.
|
// Display class overlays.
|
||||||
OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay);
|
OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay);
|
||||||
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, h_bClassOverlay[client]);
|
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,6 +198,7 @@ public Action:ClassOverlayEnableCommand(client, argc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle current overlay channel, and retrieve new value.
|
// Toggle current overlay channel, retrieve new value, and update cookie.
|
||||||
h_bClassOverlay[client] = OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, true);
|
new bool:overlayenabled = OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, true);
|
||||||
|
CookiesSetClientCookieBool(client, g_hOverlayEnabledCookie, overlayenabled);
|
||||||
}
|
}
|
||||||
|
@ -1,96 +1,96 @@
|
|||||||
/*
|
/*
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*
|
*
|
||||||
* Zombie:Reloaded
|
* Zombie:Reloaded
|
||||||
*
|
*
|
||||||
* File: steamidcache.inc
|
* File: steamidcache.inc
|
||||||
* Type: Core
|
* Type: Core
|
||||||
* Description: A SteamID caching API.
|
* Description: A SteamID caching API.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum length of a SteamID
|
* The maximum length of a SteamID
|
||||||
*/
|
*/
|
||||||
#define STEAMIDCACHE_MAX_LENGTH 16
|
#define STEAMIDCACHE_MAX_LENGTH 16
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a steamid cache.
|
* Creates a steamid cache.
|
||||||
*
|
*
|
||||||
* @return Handle to SteamID cache.
|
* @return Handle to SteamID cache.
|
||||||
*/
|
*/
|
||||||
stock Handle:SteamidCacheCreate()
|
stock Handle:SteamidCacheCreate()
|
||||||
{
|
{
|
||||||
// Return steamid cache handle.
|
// Return steamid cache handle.
|
||||||
return CreateArray(STEAMIDCACHE_MAX_LENGTH);
|
return CreateArray(STEAMIDCACHE_MAX_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add client serial number to the SteamID cache.
|
* Add client serial number to the SteamID cache.
|
||||||
*
|
*
|
||||||
* @param steamidcache The SteamID cache to add client to.
|
* @param steamidcache The SteamID cache to add client to.
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @return True if the client was added successfully, false if the client already exists.
|
* @return True if the client was added successfully, false if the client already exists.
|
||||||
*/
|
*/
|
||||||
stock bool:SteamidCacheAddClient(Handle:steamidcache, client)
|
stock bool:SteamidCacheAddClient(Handle:steamidcache, client)
|
||||||
{
|
{
|
||||||
// Check if client is in the cache.
|
// Check if client is in the cache.
|
||||||
if (SteamidCacheClientExists(steamidcache, client))
|
if (SteamidCacheClientExists(steamidcache, client))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get client's SteamID.
|
// Get client's SteamID.
|
||||||
decl String:steamid[STEAMIDCACHE_MAX_LENGTH];
|
decl String:steamid[STEAMIDCACHE_MAX_LENGTH];
|
||||||
GetClientAuthString(client, steamid, sizeof(steamid));
|
GetClientAuthString(client, steamid, sizeof(steamid));
|
||||||
|
|
||||||
// Push SteamID into the SteamID cache.
|
// Push SteamID into the SteamID cache.
|
||||||
PushArrayString(steamidcache, steamid);
|
PushArrayString(steamidcache, steamid);
|
||||||
|
|
||||||
// Client added successfully.
|
// Client added successfully.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a client is in the SteamID cache.
|
* Check if a client is in the SteamID cache.
|
||||||
*
|
*
|
||||||
* @param steamidcache The SteamID cache to check in.
|
* @param steamidcache The SteamID cache to check in.
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @return True if the client exists, false otherwise.
|
* @return True if the client exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
stock bool:SteamidCacheClientExists(Handle:steamidcache, client)
|
stock bool:SteamidCacheClientExists(Handle:steamidcache, client)
|
||||||
{
|
{
|
||||||
// Get client's SteamID.
|
// Get client's SteamID.
|
||||||
decl String:steamid[STEAMIDCACHE_MAX_LENGTH];
|
decl String:steamid[STEAMIDCACHE_MAX_LENGTH];
|
||||||
GetClientAuthString(client, steamid, sizeof(steamid));
|
GetClientAuthString(client, steamid, sizeof(steamid));
|
||||||
|
|
||||||
// Return true if client was found, false otherwise.
|
// Return true if client was found, false otherwise.
|
||||||
return (FindStringInArray(steamidcache, steamid) != -1);
|
return (FindStringInArray(steamidcache, steamid) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset SteamID cache.
|
* Reset SteamID cache.
|
||||||
*
|
*
|
||||||
* @param steamidcache The SteamID cache to reset.
|
* @param steamidcache The SteamID cache to reset.
|
||||||
*/
|
*/
|
||||||
stock SteamidCacheReset(Handle:steamidcache)
|
stock SteamidCacheReset(Handle:steamidcache)
|
||||||
{
|
{
|
||||||
// Clear array.
|
// Clear array.
|
||||||
ClearArray(steamidcache);
|
ClearArray(steamidcache);
|
||||||
}
|
}
|
||||||
|
@ -581,8 +581,8 @@ public ZRTools_Action:RestrictCanUse(client, weapon)
|
|||||||
return ZRTools_Handled;
|
return ZRTools_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward event to modules. (item pickup)
|
// Forward event to weapons module.
|
||||||
WeaponAlphaOnItemPickup(client, weapon);
|
WeaponsOnItemPickup(client, weapon);
|
||||||
|
|
||||||
// Allow pickup.
|
// Allow pickup.
|
||||||
return ZRTools_Continue;
|
return ZRTools_Continue;
|
||||||
|
@ -35,11 +35,6 @@
|
|||||||
*/
|
*/
|
||||||
new g_iWeaponDropHookID[MAXPLAYERS + 1] = {-1, ...};
|
new g_iWeaponDropHookID[MAXPLAYERS + 1] = {-1, ...};
|
||||||
|
|
||||||
/**
|
|
||||||
* Global variable that stops render mode modifying
|
|
||||||
*/
|
|
||||||
new bool:g_bWeaponAlpha;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* Client is joining the server.
|
||||||
*
|
*
|
||||||
@ -66,40 +61,14 @@ WeaponAlphaOnClientDisconnect(client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The round is starting.
|
|
||||||
*/
|
|
||||||
WeaponAlphaOnRoundStartPost()
|
|
||||||
{
|
|
||||||
// Allow weapon render mode to be modified.
|
|
||||||
g_bWeaponAlpha = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The round is ending.
|
|
||||||
*
|
|
||||||
* @param reason Reason the round has ended.
|
|
||||||
*/
|
|
||||||
WeaponAlphaOnRoundEnd()
|
|
||||||
{
|
|
||||||
// Disallow weapon render mode to be modified.
|
|
||||||
g_bWeaponAlpha = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client has just picked up a weapon.
|
* Client has just picked up a weapon.
|
||||||
*
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param weapon The weapon index.
|
* @param weapon The weapon index.
|
||||||
*/
|
*/
|
||||||
WeaponAlphaOnItemPickup(client, weapon)
|
WeaponAlphaOnItemPickupPost(client, weapon)
|
||||||
{
|
{
|
||||||
// If weapon alpha updating is disabled, then stop.
|
|
||||||
if (!g_bWeaponAlpha)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get client's current alpha.
|
// Get client's current alpha.
|
||||||
new alpha = ToolsGetEntityAlpha(client);
|
new alpha = ToolsGetEntityAlpha(client);
|
||||||
|
|
||||||
@ -116,12 +85,6 @@ WeaponAlphaOnItemPickup(client, weapon)
|
|||||||
*/
|
*/
|
||||||
public ZRTools_Action:WeaponAlphaDrop(client, weapon)
|
public ZRTools_Action:WeaponAlphaDrop(client, weapon)
|
||||||
{
|
{
|
||||||
// If weapon alpha updating is disabled, then stop.
|
|
||||||
if (!g_bWeaponAlpha)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If weapon isn't a valid entity, then stop.
|
// If weapon isn't a valid entity, then stop.
|
||||||
if (weapon < MaxClients)
|
if (weapon < MaxClients)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,15 @@ WeaponsOnCommandsCreate()
|
|||||||
ZMarketOnCommandsCreate();
|
ZMarketOnCommandsCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create weapon-related cookies here.
|
||||||
|
*/
|
||||||
|
WeaponsOnCookiesCreate()
|
||||||
|
{
|
||||||
|
// Forward event to sub-modules.
|
||||||
|
ZMarketOnCookiesCreate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads weapon data from file.
|
* Loads weapon data from file.
|
||||||
*/
|
*/
|
||||||
@ -303,27 +312,67 @@ WeaponsOnClientSpawn(client)
|
|||||||
{
|
{
|
||||||
// Forward event to sub-modules.
|
// Forward event to sub-modules.
|
||||||
RestrictOnClientSpawn(client);
|
RestrictOnClientSpawn(client);
|
||||||
ZMarketOnClientSpawn(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The round is starting.
|
* Client is spawning into the game. *Post
|
||||||
*/
|
|
||||||
WeaponsOnRoundStartPost()
|
|
||||||
{
|
|
||||||
// Forward event to sub-modules
|
|
||||||
WeaponAlphaOnRoundStartPost();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The round is ending.
|
|
||||||
*
|
*
|
||||||
* @param reason Reason the round has ended.
|
* @param client The client index.
|
||||||
*/
|
*/
|
||||||
WeaponsOnRoundEnd()
|
WeaponsOnClientSpawnPost(client)
|
||||||
{
|
{
|
||||||
// Forward event to sub-modules
|
// Forward event to sub-modules.
|
||||||
WeaponAlphaOnRoundEnd();
|
ZMarketOnClientSpawnPost(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a client picks up an item.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param weapon The weapon index.
|
||||||
|
*/
|
||||||
|
WeaponsOnItemPickup(client, weapon)
|
||||||
|
{
|
||||||
|
// Forward event to sub-modules.
|
||||||
|
|
||||||
|
// Fire post OnItemPickup event.
|
||||||
|
|
||||||
|
// Fill datapack with event information.
|
||||||
|
new Handle:eventinfo = CreateDataPack();
|
||||||
|
WritePackCell(eventinfo, client);
|
||||||
|
WritePackCell(eventinfo, weapon);
|
||||||
|
|
||||||
|
// Create post delay timer.
|
||||||
|
CreateTimer(0.0, WeaponsOnItemPickupPost, eventinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a client picks up an item. *Post
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param weapon The weapon index.
|
||||||
|
*/
|
||||||
|
public Action:WeaponsOnItemPickupPost(Handle:timer, Handle:eventinfo)
|
||||||
|
{
|
||||||
|
// Get event info.
|
||||||
|
ResetPack(eventinfo);
|
||||||
|
new client = ReadPackCell(eventinfo);
|
||||||
|
new weapon = ReadPackCell(eventinfo);
|
||||||
|
|
||||||
|
// If client isn't in the game anymore, then stop.
|
||||||
|
if (!IsClientInGame(client))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the weapon entity isn't valid anymore, then stop.
|
||||||
|
if (!IsValidEdict(weapon))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forward event to sub-modules.
|
||||||
|
WeaponAlphaOnItemPickupPost(client, weapon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,15 @@
|
|||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @section Name of the cookies for ZMarket rebuy/auto-rebuy data.
|
||||||
|
*/
|
||||||
|
#define ZMARKET_COOKIE_AUTOREBUY "zr_zmarket_autorebuy"
|
||||||
|
#define ZMARKET_COOKIE_REBUY "zr_zmarket_rebuy"
|
||||||
|
/**
|
||||||
|
* @endsection
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variable to store buyzone offset value.
|
* Variable to store buyzone offset value.
|
||||||
*/
|
*/
|
||||||
@ -41,14 +50,9 @@ new g_iZMarketCurType[MAXPLAYERS + 1];
|
|||||||
new Handle:g_hZMarketPurchaseCount[MAXPLAYERS + 1];
|
new Handle:g_hZMarketPurchaseCount[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array to store a weapon of each type last purchased from ZMarket.
|
* Cookie handle for auti-rebuy.
|
||||||
*/
|
*/
|
||||||
new String:g_strZMarketLastWeapon[MAXPLAYERS + 1][WeaponsSlot][WEAPONS_MAX_LENGTH];
|
new Handle:g_hZMarketAutoRebuyCookie = INVALID_HANDLE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Array to store clients' auto-rebuy setting.
|
|
||||||
*/
|
|
||||||
new bool:g_bZMarketAutoRebuy[MAXPLAYERS + 1];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create commands specific to ZMarket.
|
* Create commands specific to ZMarket.
|
||||||
@ -59,6 +63,30 @@ ZMarketOnCommandsCreate()
|
|||||||
RegConsoleCmd(SAYHOOKS_KEYWORD_ZMARKET, ZMarketCommand, "Opens custom buymenu.");
|
RegConsoleCmd(SAYHOOKS_KEYWORD_ZMARKET, ZMarketCommand, "Opens custom buymenu.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZMarketOnCookiesCreate()
|
||||||
|
{
|
||||||
|
// If auto-rebuy cookie doesn't already exist, then create all ZMarket cookies.
|
||||||
|
g_hZMarketAutoRebuyCookie = FindClientCookie(ZMARKET_COOKIE_AUTOREBUY);
|
||||||
|
if (g_hZMarketAutoRebuyCookie == INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Public);
|
||||||
|
|
||||||
|
decl String:rebuycookiename[32];
|
||||||
|
decl String:rebuycookiedesc[64];
|
||||||
|
|
||||||
|
// x = Weapon slot.
|
||||||
|
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||||
|
{
|
||||||
|
// Format cookie name and description.
|
||||||
|
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_Public);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find ZMarket-specific offsets here.
|
* Find ZMarket-specific offsets here.
|
||||||
*/
|
*/
|
||||||
@ -89,7 +117,15 @@ ZMarketClientInit(client)
|
|||||||
g_hZMarketPurchaseCount[client] = CreateTrie();
|
g_hZMarketPurchaseCount[client] = CreateTrie();
|
||||||
|
|
||||||
// Initialize auto-rebuy data.
|
// Initialize auto-rebuy data.
|
||||||
g_bZMarketAutoRebuy[client] = false;
|
decl String:zmarketautorebuy[8];
|
||||||
|
GetClientCookie(client, g_hZMarketAutoRebuyCookie, zmarketautorebuy, sizeof(zmarketautorebuy));
|
||||||
|
|
||||||
|
// If the cookie is empty, then set the default value.
|
||||||
|
if (!zmarketautorebuy[0])
|
||||||
|
{
|
||||||
|
// Set cookie to false.
|
||||||
|
CookiesSetClientCookieBool(client, g_hZMarketAutoRebuyCookie, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,13 +150,19 @@ ZMarketOnClientDisconnect(client)
|
|||||||
*
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
*/
|
*/
|
||||||
ZMarketOnClientSpawn(client)
|
ZMarketOnClientSpawnPost(client)
|
||||||
{
|
{
|
||||||
// Reset purchase counts for client.
|
// Reset purchase counts for client.
|
||||||
ZMarketResetPurchaseCount(client);
|
ZMarketResetPurchaseCount(client);
|
||||||
|
|
||||||
|
// If client hasn't spawned into the game yet, then stop.
|
||||||
|
if (!IsPlayerAlive(client))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If auto-rebuy is enabled, then force client to rebuy weapons.
|
// If auto-rebuy is enabled, then force client to rebuy weapons.
|
||||||
if (g_bZMarketAutoRebuy[client])
|
if (CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie))
|
||||||
{
|
{
|
||||||
ZMarketRebuy(client, true);
|
ZMarketRebuy(client, true);
|
||||||
}
|
}
|
||||||
@ -222,7 +264,7 @@ bool:ZMarketMenuMain(client)
|
|||||||
|
|
||||||
// Get auto-rebuy setting.
|
// Get auto-rebuy setting.
|
||||||
decl String:rebuyautosetting[8];
|
decl String:rebuyautosetting[8];
|
||||||
ConfigBoolToSetting(g_bZMarketAutoRebuy[client], rebuyautosetting, sizeof(rebuyautosetting));
|
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), rebuyautosetting, sizeof(rebuyautosetting));
|
||||||
|
|
||||||
// Format menu options.
|
// Format menu options.
|
||||||
Format(getloadout, sizeof(getloadout), "%t", "Weapons menu zmarket main get loadout");
|
Format(getloadout, sizeof(getloadout), "%t", "Weapons menu zmarket main get loadout");
|
||||||
@ -290,7 +332,8 @@ public ZMarketMenuMainHandle(Handle:menu_zmarket_main, MenuAction:action, client
|
|||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
// Toggle rebuy.
|
// Toggle rebuy.
|
||||||
g_bZMarketAutoRebuy[client] = !g_bZMarketAutoRebuy[client];
|
new bool:autorebuyenabled = CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie);
|
||||||
|
CookiesSetClientCookieBool(client, g_hZMarketAutoRebuyCookie, !autorebuyenabled);
|
||||||
|
|
||||||
// Resend menu.
|
// Resend menu.
|
||||||
ZMarketMenuMain(client);
|
ZMarketMenuMain(client);
|
||||||
@ -341,12 +384,16 @@ bool:ZMarketMenuLoadout(client)
|
|||||||
decl String:projectileweapon[WEAPONS_MAX_LENGTH];
|
decl String:projectileweapon[WEAPONS_MAX_LENGTH];
|
||||||
decl String:explosiveweapon[WEAPONS_MAX_LENGTH];
|
decl String:explosiveweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
|
// Transfer cookie values into an array.
|
||||||
|
new String:rebuyweapons[WeaponsSlot][WEAPONS_MAX_LENGTH];
|
||||||
|
ZMarketCookiesToArray(client, rebuyweapons, WEAPONS_SLOTS_MAX, sizeof(rebuyweapons[]));
|
||||||
|
|
||||||
// Return the display name for all the client's weapon classname's.
|
// Return the display name for all the client's weapon classname's.
|
||||||
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Primary], sizeof(g_strZMarketLastWeapon), primaryweapon, sizeof(primaryweapon));
|
WeaponsClassnameToDisplay(rebuyweapons[Slot_Primary], sizeof(rebuyweapons[]), primaryweapon, sizeof(primaryweapon));
|
||||||
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Secondary], sizeof(g_strZMarketLastWeapon), secondaryweapon, sizeof(secondaryweapon));
|
WeaponsClassnameToDisplay(rebuyweapons[Slot_Secondary], sizeof(rebuyweapons[]), secondaryweapon, sizeof(secondaryweapon));
|
||||||
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Melee], sizeof(g_strZMarketLastWeapon), meleeweapon, sizeof(meleeweapon));
|
WeaponsClassnameToDisplay(rebuyweapons[Slot_Melee], sizeof(rebuyweapons[]), meleeweapon, sizeof(meleeweapon));
|
||||||
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Projectile], sizeof(g_strZMarketLastWeapon), projectileweapon, sizeof(projectileweapon));
|
WeaponsClassnameToDisplay(rebuyweapons[Slot_Projectile], sizeof(rebuyweapons[]), projectileweapon, sizeof(projectileweapon));
|
||||||
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Explosive], sizeof(g_strZMarketLastWeapon), explosiveweapon, sizeof(explosiveweapon));
|
WeaponsClassnameToDisplay(rebuyweapons[Slot_Explosive], sizeof(rebuyweapons[]), explosiveweapon, sizeof(explosiveweapon));
|
||||||
|
|
||||||
// Get the empty translation.
|
// Get the empty translation.
|
||||||
decl String:empty[64];
|
decl String:empty[64];
|
||||||
@ -685,7 +732,7 @@ public ZMarketMenuTypeWeaponsHandle(Handle:menu_zmarket_typeweapons, MenuAction:
|
|||||||
* Equip a weapon on a client.
|
* Equip a weapon on a client.
|
||||||
*
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param weapon The weapon to equip (must be in weapons config file)
|
* @param weapon The weapon to equip. (must be in weapons config file)
|
||||||
* @param rebuy (Optional) If client is rebuying, ammo will be ignored.
|
* @param rebuy (Optional) If client is rebuying, ammo will be ignored.
|
||||||
*/
|
*/
|
||||||
stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
|
stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
|
||||||
@ -792,8 +839,8 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
|
|||||||
// Give client the weapon.
|
// Give client the weapon.
|
||||||
GivePlayerItem(client, weaponentity);
|
GivePlayerItem(client, weaponentity);
|
||||||
|
|
||||||
// Copy weapon to array for this slot.
|
// Update cookie with new weapon.
|
||||||
strcopy(g_strZMarketLastWeapon[client][slot], sizeof(g_strZMarketLastWeapon), weapon);
|
ZMarketSetRebuyCookie(client, slot, weapon);
|
||||||
|
|
||||||
// Add 1 to the client's purchase count.
|
// Add 1 to the client's purchase count.
|
||||||
ZMarketSetPurchaseCount(client, weapon, 1, true);
|
ZMarketSetPurchaseCount(client, weapon, 1, true);
|
||||||
@ -858,7 +905,7 @@ bool:ZMarketGetCurrentLoadout(client)
|
|||||||
if (weapons[x] == -1)
|
if (weapons[x] == -1)
|
||||||
{
|
{
|
||||||
// Empty rebuy slot.
|
// Empty rebuy slot.
|
||||||
strcopy(g_strZMarketLastWeapon[client][x], sizeof(g_strZMarketLastWeapon), "");
|
ZMarketSetRebuyCookie(client, WeaponsSlot:x, "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +914,7 @@ bool:ZMarketGetCurrentLoadout(client)
|
|||||||
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
|
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
|
||||||
|
|
||||||
// Copy the name to the rebuy cache.
|
// Copy the name to the rebuy cache.
|
||||||
strcopy(g_strZMarketLastWeapon[client][x], sizeof(g_strZMarketLastWeapon), weaponname);
|
ZMarketSetRebuyCookie(client, WeaponsSlot:x, weaponname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell client their loadout has been updated.
|
// Tell client their loadout has been updated.
|
||||||
@ -876,12 +923,80 @@ bool:ZMarketGetCurrentLoadout(client)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfer array values to rebuy cookies.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param rebuyweapons The string array to copy results from.
|
||||||
|
* @param maxweapons The max amount of weapons in the array.
|
||||||
|
* @param maxlen The max length of each cookie result.
|
||||||
|
*/
|
||||||
|
stock ZMarketArrayToCookies(client, String:rebuyweapons[WeaponsSlot][], maxweapons, maxlen)
|
||||||
|
{
|
||||||
|
decl String:rebuycookiename[32];
|
||||||
|
new Handle:rebuycookie;
|
||||||
|
|
||||||
|
// x = Weapon slot.
|
||||||
|
for (new x = 0; x < maxweapons; x++)
|
||||||
|
{
|
||||||
|
// Format cookie name.
|
||||||
|
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
|
||||||
|
|
||||||
|
// Find cookie handle, and retrieve its value.
|
||||||
|
rebuycookie = FindClientCookie(rebuycookiename);
|
||||||
|
SetClientCookie(client, rebuycookie, rebuyweapons[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfer rebuy cookies to an array for easier access.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param rebuyweapons The string array to copy results to
|
||||||
|
* @param maxweapons The max amount of weapons in the array.
|
||||||
|
* @param maxlen The max length of each cookie result.
|
||||||
|
*/
|
||||||
|
stock ZMarketCookiesToArray(client, String:rebuyweapons[WeaponsSlot][], maxweapons, maxlen)
|
||||||
|
{
|
||||||
|
decl String:rebuycookiename[32];
|
||||||
|
new Handle:rebuycookie;
|
||||||
|
|
||||||
|
// x = Weapon slot.
|
||||||
|
for (new x = 0; x < maxweapons; x++)
|
||||||
|
{
|
||||||
|
// Format cookie name.
|
||||||
|
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
|
||||||
|
|
||||||
|
// Find cookie handle, and retrieve its value.
|
||||||
|
rebuycookie = FindClientCookie(rebuycookiename);
|
||||||
|
GetClientCookie(client, rebuycookie, rebuyweapons[x], maxlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a weapon slot cookie given the slot and value.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param slot The weapon slot to set value to.
|
||||||
|
* @param value The value (weaponname) of the slot.
|
||||||
|
*/
|
||||||
|
stock ZMarketSetRebuyCookie(client, WeaponsSlot:slot, const String:value[])
|
||||||
|
{
|
||||||
|
// Format cookie name.
|
||||||
|
decl String:rebuycookiename[32];
|
||||||
|
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, _:slot);
|
||||||
|
|
||||||
|
// Find cookie handle, and retrieve its value.
|
||||||
|
new Handle:rebuycookie = FindClientCookie(rebuycookiename);
|
||||||
|
SetClientCookie(client, rebuycookie, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force a client to rebuy their weapons.
|
* Force a client to rebuy their weapons.
|
||||||
*
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
*/
|
*/
|
||||||
ZMarketRebuy(client, bool:rebuy = false)
|
ZMarketRebuy(client, bool:autorebuy = false)
|
||||||
{
|
{
|
||||||
// If client is a zombie, then stop.
|
// If client is a zombie, then stop.
|
||||||
if (InfectIsClientInfected(client))
|
if (InfectIsClientInfected(client))
|
||||||
@ -891,23 +1006,24 @@ ZMarketRebuy(client, bool:rebuy = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]);
|
new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]);
|
||||||
if (!rebuy && zmarketbuyzone && !ZMarketIsClientInBuyZone(client))
|
if (!autorebuy && zmarketbuyzone && !ZMarketIsClientInBuyZone(client))
|
||||||
{
|
{
|
||||||
TranslationPrintToChat(client, "Weapons zmarket buyzone");
|
TranslationPrintToChat(client, "Weapons zmarket buyzone");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transfer cookie values into an array.
|
||||||
|
new String:rebuyweapons[WeaponsSlot][WEAPONS_MAX_LENGTH];
|
||||||
|
ZMarketCookiesToArray(client, rebuyweapons, WEAPONS_SLOTS_MAX, sizeof(rebuyweapons[]));
|
||||||
|
|
||||||
// x = Weapon slot.
|
// x = Weapon slot.
|
||||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||||
{
|
{
|
||||||
new bool:equipped = ZMarketEquip(client, g_strZMarketLastWeapon[client][x], true);
|
ZMarketEquip(client, rebuyweapons[x], true);
|
||||||
|
|
||||||
// Remove weapon from last weapons.
|
|
||||||
if (!equipped)
|
|
||||||
{
|
|
||||||
strcopy(g_strZMarketLastWeapon[client][x], sizeof(g_strZMarketLastWeapon), "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy values back to cookies.
|
||||||
|
ZMarketArrayToCookies(client, rebuyweapons, WEAPONS_SLOTS_MAX, sizeof(rebuyweapons));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ ZHPOnCookiesCreate()
|
|||||||
g_hZHPEnabledCookie = FindClientCookie(ZHP_COOKIE_ENABLED);
|
g_hZHPEnabledCookie = FindClientCookie(ZHP_COOKIE_ENABLED);
|
||||||
if (g_hZHPEnabledCookie == INVALID_HANDLE)
|
if (g_hZHPEnabledCookie == INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
g_hZHPEnabledCookie = RegClientCookie(ZHP_COOKIE_ENABLED, "The toggle state of ZHP", CookieAccess_Public);
|
g_hZHPEnabledCookie = RegClientCookie(ZHP_COOKIE_ENABLED, "The toggle state of ZHP.", CookieAccess_Public);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,12 +191,15 @@ bool:ZHPToggle(client)
|
|||||||
// Get the cookie value.
|
// Get the cookie value.
|
||||||
new bool:zhpstate = CookiesGetClientCookieBool(client, g_hZHPEnabledCookie);
|
new bool:zhpstate = CookiesGetClientCookieBool(client, g_hZHPEnabledCookie);
|
||||||
|
|
||||||
// If ZHP is enabled, then tell client it's being disabled.
|
// Toggle the value.
|
||||||
|
CookiesSetClientCookieBool(client, g_hZHPEnabledCookie, !zhpstate);
|
||||||
|
|
||||||
|
// If ZHP was enabled, then tell client it has been disabled.
|
||||||
if (zhpstate)
|
if (zhpstate)
|
||||||
{
|
{
|
||||||
TranslationPrintToChat(client, "ZHP disable");
|
TranslationPrintToChat(client, "ZHP disable");
|
||||||
}
|
}
|
||||||
// If ZHP is disabled, then tell client it's being enabled.
|
// If ZHP was disabled, then tell client it has been enabled.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TranslationPrintToChat(client, "ZHP enable");
|
TranslationPrintToChat(client, "ZHP enable");
|
||||||
@ -205,9 +208,6 @@ bool:ZHPToggle(client)
|
|||||||
ZHPUpdateHUD(client);
|
ZHPUpdateHUD(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle the value.
|
|
||||||
CookiesSetClientCookieBool(client, g_hZHPEnabledCookie, !zhpstate);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user