remove trailing whitespaces from sourcecode
This commit is contained in:
@ -32,7 +32,7 @@ new g_iWeaponsCurType[MAXPLAYERS + 1];
|
||||
|
||||
/**
|
||||
* Sends main weapon menu to client.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
bool:WeaponsMenuMain(client)
|
||||
@ -43,42 +43,42 @@ bool:WeaponsMenuMain(client)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Create menu handle.
|
||||
new Handle:menu_weapons_main = CreateMenu(WeaponsMenuMainHandle);
|
||||
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
|
||||
decl String:title[MENU_LINE_TITLE_LENGTH];
|
||||
decl String:restrict[MENU_LINE_SMALL_LENGTH];
|
||||
decl String:zmarket[MENU_LINE_SMALL_LENGTH];
|
||||
|
||||
|
||||
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict main title");
|
||||
Format(restrict, sizeof(restrict), "%t", "Weapons menu restrict main restrict");
|
||||
Format(zmarket, sizeof(zmarket), "%t", "Weapons menu restrict main market");
|
||||
|
||||
|
||||
// Draw items, make unselectable if module is disabled.
|
||||
SetMenuTitle(menu_weapons_main, title);
|
||||
AddMenuItem(menu_weapons_main, "restrict", restrict, MenuGetItemDraw(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT])));
|
||||
AddMenuItem(menu_weapons_main, "zmarket", zmarket, MenuGetItemDraw(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET])));
|
||||
|
||||
|
||||
// Create a "Back" button to the weapons main menu.
|
||||
SetMenuExitBackButton(menu_weapons_main, true);
|
||||
|
||||
|
||||
// Send menu.
|
||||
DisplayMenu(menu_weapons_main, client, MENU_TIME_FOREVER);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when client selects option in the weapons main menu, and handles it.
|
||||
*
|
||||
*
|
||||
* @param menu_weapons_main Handle of the menu being used.
|
||||
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||
* @param client The client index.
|
||||
* @param slot The slot index selected (starting from 0).
|
||||
*/
|
||||
*/
|
||||
public WeaponsMenuMainHandle(Handle:menu_weapons_main, MenuAction:action, client, slot)
|
||||
{
|
||||
// Client selected an option.
|
||||
@ -117,58 +117,58 @@ public WeaponsMenuMainHandle(Handle:menu_weapons_main, MenuAction:action, client
|
||||
|
||||
/**
|
||||
* Sends weapon type list to client.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsMenuTypes(client)
|
||||
{
|
||||
// Create menu handle.
|
||||
new Handle:menu_weapons_types = CreateMenu(WeaponsMenuTypesHandle);
|
||||
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
|
||||
decl String:title[MENU_LINE_TITLE_LENGTH];
|
||||
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict types title");
|
||||
SetMenuTitle(menu_weapons_types, title);
|
||||
|
||||
|
||||
decl String:typename[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// x = Array index.
|
||||
new size = GetArraySize(arrayWeaponTypes);
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
// Get name of type.
|
||||
RestrictWeaponTypeGetName(x, typename, sizeof(typename));
|
||||
|
||||
|
||||
// Add item to menu.
|
||||
AddMenuItem(menu_weapons_types, typename, typename);
|
||||
}
|
||||
|
||||
|
||||
// If there are no weapons, add an "(Empty)" line.
|
||||
if (size == 0)
|
||||
{
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
|
||||
decl String:empty[MENU_LINE_SMALL_LENGTH];
|
||||
Format(empty, sizeof(empty), "%t", "Menu empty");
|
||||
|
||||
|
||||
AddMenuItem(menu_weapons_types, "empty", empty, ITEMDRAW_DISABLED);
|
||||
}
|
||||
|
||||
|
||||
// Set exit back button.
|
||||
SetMenuExitBackButton(menu_weapons_types, true);
|
||||
|
||||
|
||||
DisplayMenu(menu_weapons_types, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when client selects option in the weapons list menu, and handles it.
|
||||
*
|
||||
*
|
||||
* @param menu_weapons_types Handle of the menu being used.
|
||||
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||
* @param client The client index.
|
||||
* @param slot The slot index selected (starting from 0).
|
||||
*/
|
||||
*/
|
||||
public WeaponsMenuTypesHandle(Handle:menu_weapons_types, MenuAction:action, client, slot)
|
||||
{
|
||||
// Client selected an option.
|
||||
@ -176,7 +176,7 @@ public WeaponsMenuTypesHandle(Handle:menu_weapons_types, MenuAction:action, clie
|
||||
{
|
||||
// Menu slot index is = weapon type index.
|
||||
g_iWeaponsCurType[client] = slot;
|
||||
|
||||
|
||||
// Send weapons of the selected type in a menu to client.
|
||||
WeaponsMenuTypeWeapons(client);
|
||||
}
|
||||
@ -198,77 +198,77 @@ public WeaponsMenuTypesHandle(Handle:menu_weapons_types, MenuAction:action, clie
|
||||
|
||||
/**
|
||||
* Sends a list of weapons of a certain type in a menu to the client.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsMenuTypeWeapons(client)
|
||||
{
|
||||
// Create menu handle.
|
||||
new Handle:menu_weapons_typeweapons = CreateMenu(WeaponsMenuTypeWeaponsHandle);
|
||||
|
||||
|
||||
decl String:typename[WEAPONS_MAX_LENGTH];
|
||||
RestrictWeaponTypeGetName(g_iWeaponsCurType[client], typename, sizeof(typename));
|
||||
|
||||
|
||||
// Set translation language.
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
|
||||
decl String:title[MENU_LINE_TITLE_LENGTH];
|
||||
decl String:restrictall[MENU_LINE_REG_LENGTH];
|
||||
decl String:unrestrictall[MENU_LINE_REG_LENGTH];
|
||||
|
||||
|
||||
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict types weapon type title", typename);
|
||||
Format(restrictall, sizeof(restrictall), "%t", "Weapons menu restrict types restrict all", typename);
|
||||
Format(unrestrictall, sizeof(unrestrictall), "%t\n ", "Weapons menu restrict types unrestrict all", typename);
|
||||
|
||||
|
||||
// Draw items as selectable only if not all weapons within the type are restricted or unrestricted.
|
||||
SetMenuTitle(menu_weapons_typeweapons, title);
|
||||
AddMenuItem(menu_weapons_typeweapons, "restrictall", restrictall, MenuGetItemDraw(!RestrictIsTypeUniform(true, g_iWeaponsCurType[client])));
|
||||
AddMenuItem(menu_weapons_typeweapons, "unrestrictall", unrestrictall, MenuGetItemDraw(!RestrictIsTypeUniform(false, g_iWeaponsCurType[client])));
|
||||
|
||||
|
||||
decl String:typeweapon[MENU_LINE_SMALL_LENGTH];
|
||||
decl String:display[MENU_LINE_SMALL_LENGTH + 2]; // +2 to allow room for the [ ] if its restricted.
|
||||
|
||||
|
||||
// Get an array populated with all weapons of the given type.
|
||||
new Handle:arrayTypeWeapons;
|
||||
new count = RestrictGetTypeWeapons(g_iWeaponsCurType[client], arrayTypeWeapons);
|
||||
|
||||
|
||||
// x = Array index.
|
||||
for (new x = 0; x < count; x++)
|
||||
{
|
||||
// Get weapon index to check restricted status of.
|
||||
new weaponindex = GetArrayCell(arrayTypeWeapons, x);
|
||||
|
||||
|
||||
// Get name of weapon.
|
||||
WeaponsGetName(weaponindex, typeweapon, sizeof(typeweapon));
|
||||
strcopy(display, sizeof(display), typeweapon);
|
||||
|
||||
|
||||
if (RestrictIsWeaponRestricted(weaponindex))
|
||||
{
|
||||
Format(display, sizeof(display), "[%s]", typeweapon);
|
||||
}
|
||||
|
||||
|
||||
// Disable option if it isn't toggleable.
|
||||
AddMenuItem(menu_weapons_typeweapons, typeweapon, display, MenuGetItemDraw(WeaponsGetToggleable(weaponindex)));
|
||||
}
|
||||
|
||||
|
||||
// Destroy the array handle.
|
||||
CloseHandle(arrayTypeWeapons);
|
||||
|
||||
|
||||
// Set menu back button.
|
||||
SetMenuExitBackButton(menu_weapons_typeweapons, true);
|
||||
|
||||
|
||||
// Display menu to client.
|
||||
DisplayMenu(menu_weapons_typeweapons, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when client selects option in the weapon group menu, and handles it.
|
||||
*
|
||||
*
|
||||
* @param menu_weapons_typeweapons Handle of the menu being used.
|
||||
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||
* @param client The client index.
|
||||
* @param slot The slot index selected (starting from 0).
|
||||
*/
|
||||
*/
|
||||
public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:action, client, slot)
|
||||
{
|
||||
// Client selected an option.
|
||||
@ -277,14 +277,14 @@ public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:
|
||||
// Get name of current weapon type.
|
||||
decl String:typename[WEAPONS_MAX_LENGTH];
|
||||
RestrictWeaponTypeGetName(g_iWeaponsCurType[client], typename, sizeof(typename));
|
||||
|
||||
|
||||
new RestrictQuery:query;
|
||||
new bool:single;
|
||||
new bool:restrict;
|
||||
decl String:returntarget[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
switch(slot)
|
||||
{
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// Restrict all weapons of this type.
|
||||
@ -302,17 +302,17 @@ public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:
|
||||
// Get weappon name.
|
||||
decl String:typeweapon[MENU_LINE_REG_LENGTH];
|
||||
GetMenuItem(menu_weapons_typeweapons, slot, typeweapon, sizeof(typeweapon));
|
||||
|
||||
|
||||
// Get weapon index.
|
||||
new weaponindex = WeaponsNameToIndex(typeweapon);
|
||||
|
||||
|
||||
// If weapon index is -1, then something went very wrong.
|
||||
if (weaponindex == -1)
|
||||
{
|
||||
CloseHandle(menu_weapons_typeweapons);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If weapon isn't restricted, then restrict it.
|
||||
if (!RestrictIsWeaponRestricted(weaponindex))
|
||||
{
|
||||
@ -328,10 +328,10 @@ public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Print query response.
|
||||
RestrictPrintQueryResponse(client, query, single, restrict, returntarget);
|
||||
|
||||
|
||||
// Resend menu.
|
||||
WeaponsMenuTypeWeapons(client);
|
||||
}
|
||||
@ -353,45 +353,45 @@ public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:
|
||||
|
||||
/**
|
||||
* Sends ZMarket options menu to client.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsMenuZMarket(client)
|
||||
{
|
||||
// Create menu handle.
|
||||
new Handle:menu_weapons_market = CreateMenu(WeaponsMenuZMarketHandle);
|
||||
|
||||
|
||||
// Get "yes" or "no" settings from respective cvar.
|
||||
decl String:buyzonesetting[MENU_LINE_SMALL_LENGTH];
|
||||
ConfigBoolToSetting(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]), buyzonesetting, sizeof(buyzonesetting), true, client);
|
||||
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
|
||||
decl String:title[MENU_LINE_TITLE_LENGTH];
|
||||
decl String:buyzone[MENU_LINE_REG_LENGTH];
|
||||
|
||||
|
||||
// Add options to menu.
|
||||
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict zmarket title");
|
||||
Format(buyzone, sizeof(buyzone), "%t", "Weapons menu restrict zmarket buyzone", buyzonesetting);
|
||||
|
||||
|
||||
SetMenuTitle(menu_weapons_market, title);
|
||||
AddMenuItem(menu_weapons_market, "buyzone", buyzone);
|
||||
|
||||
|
||||
// Create a "Back" button to the weapons main menu.
|
||||
SetMenuExitBackButton(menu_weapons_market, true);
|
||||
|
||||
|
||||
// Send menu
|
||||
DisplayMenu(menu_weapons_market, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when client selects option in the weapons main menu, and handles it.
|
||||
*
|
||||
*
|
||||
* @param menu_weapons_market Handle of the menu being used.
|
||||
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||
* @param client The client index.
|
||||
* @param slot The slot index selected (starting from 0).
|
||||
*/
|
||||
*/
|
||||
public WeaponsMenuZMarketHandle(Handle:menu_weapons_market, MenuAction:action, client, slot)
|
||||
{
|
||||
// Client selected an option.
|
||||
@ -407,7 +407,7 @@ public WeaponsMenuZMarketHandle(Handle:menu_weapons_market, MenuAction:action, c
|
||||
SetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE], !zmarketbuyzone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Resend menu.
|
||||
WeaponsMenuZMarket(client);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ RestrictInit()
|
||||
|
||||
/**
|
||||
* Auto-create a list of types loaded by weapons module.
|
||||
*/
|
||||
*/
|
||||
RestrictLoad()
|
||||
{
|
||||
// If array exists, then destroy it.
|
||||
@ -85,31 +85,31 @@ RestrictLoad()
|
||||
{
|
||||
CloseHandle(arrayWeaponTypes);
|
||||
}
|
||||
|
||||
|
||||
// Initialize array.
|
||||
arrayWeaponTypes = CreateArray(WEAPONS_MAX_LENGTH);
|
||||
|
||||
|
||||
decl String:weapontype[WEAPONS_MAX_LENGTH];
|
||||
new String:weapontypes[WEAPONS_RESTRICT_MAX_TYPES][WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// x = Array index.
|
||||
new size = GetArraySize(arrayWeapons);
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
WeaponsGetType(x, weapontype, sizeof(weapontype));
|
||||
|
||||
|
||||
ExplodeString(weapontype, ",", weapontypes, sizeof(weapontypes), sizeof(weapontypes[]));
|
||||
for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++)
|
||||
{
|
||||
// Cut off whitespace.
|
||||
TrimString(weapontypes[y]);
|
||||
|
||||
|
||||
// If we've reached the end of the weapon's types, then stop.
|
||||
if (!weapontypes[y][0])
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// If the weapon type isn't in the main array, then push it in.
|
||||
if (FindStringInArray(arrayWeaponTypes, weapontypes[y]) == -1)
|
||||
{
|
||||
@ -132,7 +132,7 @@ RestrictOnCommandsCreate()
|
||||
|
||||
/**
|
||||
* Client is joining the server.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
RestrictClientInit(client)
|
||||
@ -140,20 +140,20 @@ RestrictClientInit(client)
|
||||
// Hook "Weapon_CanUse" on client.
|
||||
#if defined USE_SDKHOOKS
|
||||
SDKHook(client, SDKHook_WeaponCanUse, RestrictCanUse);
|
||||
|
||||
|
||||
// Set dummy value so it think it's hooked.
|
||||
g_iCanUseHookID[client] = 1;
|
||||
#else
|
||||
g_iCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
|
||||
#endif
|
||||
|
||||
|
||||
// Reset block weapons flag.
|
||||
g_bRestrictBlockWeapon[client] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unhook Weapon_CanUse function on a client.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
RestrictOnClientDisconnect(client)
|
||||
@ -166,14 +166,14 @@ RestrictOnClientDisconnect(client)
|
||||
#else
|
||||
ZRTools_UnhookWeapon_CanUse(g_iCanUseHookID[client]);
|
||||
#endif
|
||||
|
||||
|
||||
g_iCanUseHookID[client] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client is spawning into the game.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
RestrictOnClientSpawn(client)
|
||||
@ -187,14 +187,14 @@ RestrictOnClientSpawn(client)
|
||||
ZRTools_UnhookWeapon_CanUse(g_iCanUseHookID[client]);
|
||||
g_iCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
|
||||
#endif
|
||||
|
||||
|
||||
// H4x. Unfortunately I can't disable this flag early enough for CS:S to give start USP/Glock.
|
||||
// So I have to give BOOTLEG weapons. (Sorry Valve)
|
||||
if (g_bRestrictBlockWeapon[client])
|
||||
{
|
||||
// Reset block weapons flag.
|
||||
g_bRestrictBlockWeapon[client] = false;
|
||||
|
||||
|
||||
if (ZRIsClientOnTeam(client, CS_TEAM_T))
|
||||
{
|
||||
GivePlayerItem(client, WEAPONS_SPAWN_T_WEAPON);
|
||||
@ -216,7 +216,7 @@ RestrictOnRoundEnd()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// x = Client index.
|
||||
for (new x = 1; x <= MaxClients; x++)
|
||||
{
|
||||
@ -225,13 +225,13 @@ RestrictOnRoundEnd()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// If client is a human, then stop.
|
||||
if (InfectIsClientHuman(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Enable block weapon flag.
|
||||
g_bRestrictBlockWeapon[x] = true;
|
||||
}
|
||||
@ -240,7 +240,7 @@ RestrictOnRoundEnd()
|
||||
/**
|
||||
* Command callback function for the "buy" command
|
||||
* Used to block use of this command under certain conditions.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param argc Argument count.
|
||||
*/
|
||||
@ -251,52 +251,52 @@ public Action:RestrictBuyCommand(client, argc)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
|
||||
// If the client isn't in a buyzone, then stop.
|
||||
if (!WeaponsIsClientInBuyZone(client))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
|
||||
// If player is a zombie, then block command.
|
||||
if (InfectIsClientInfected(client))
|
||||
{
|
||||
TranslationPrintToChat(client, "Zombie cant use weapon");
|
||||
|
||||
|
||||
// Block command
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
decl String:weapon[WEAPONS_MAX_LENGTH];
|
||||
GetCmdArg(1, weapon, sizeof(weapon));
|
||||
|
||||
|
||||
// If the weapon is restricted, then prevent pickup.
|
||||
decl String:weaponname[WEAPONS_MAX_LENGTH];
|
||||
new weaponindex = WeaponsEntityToDisplay(weapon, weaponname, sizeof(weaponname), true);
|
||||
|
||||
|
||||
// If weapon isn't configged, then allow pickup.
|
||||
if (weaponindex == -1)
|
||||
{
|
||||
// Allow command.
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
|
||||
// If weapon is restricted, then stop.
|
||||
if (RestrictIsWeaponRestricted(weaponindex))
|
||||
{
|
||||
TranslationPrintToChat(client, "Weapon is restricted", weaponname);
|
||||
|
||||
|
||||
// Block command.
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// Allow command.
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts (or unrestricts) a given weapon or weapon type.
|
||||
*
|
||||
*
|
||||
* @param restrict True to restrict, false to unrestrict.
|
||||
* @param target Weapon or weapon type to restrict/unrestrict.
|
||||
* @param single True if a single weapon is being restricted, false if weapon type.
|
||||
@ -308,41 +308,41 @@ RestrictQuery:RestrictWeapon(bool:restrict, const String:target[], &bool:single
|
||||
{
|
||||
// Copy 'target' to 'returntarget' to be possibly changed later.
|
||||
strcopy(returntarget, maxlen, target);
|
||||
|
||||
|
||||
// Find index of the given weapon type.
|
||||
new typeindex = RestrictTypeToIndex(returntarget);
|
||||
|
||||
|
||||
// Single weapon.
|
||||
if (typeindex == -1)
|
||||
{
|
||||
single = true;
|
||||
|
||||
|
||||
new weaponindex = WeaponsNameToIndex(returntarget);
|
||||
|
||||
|
||||
// If weapon index is invalid, then return invalid.
|
||||
if (weaponindex == -1)
|
||||
{
|
||||
return Query_Invalid;
|
||||
}
|
||||
|
||||
|
||||
// Return proper weapon name.
|
||||
WeaponsGetName(weaponindex, returntarget, maxlen);
|
||||
|
||||
|
||||
// If weapon is untoggleable, then return locked.
|
||||
if (!WeaponsGetToggleable(weaponindex))
|
||||
{
|
||||
return Query_Locked;
|
||||
}
|
||||
|
||||
|
||||
// If weapon restriction is redundant then return stopped.
|
||||
if (RestrictIsWeaponRestricted(weaponindex) == restrict)
|
||||
{
|
||||
return Query_Stopped;
|
||||
}
|
||||
|
||||
|
||||
// Set weapon's restricted state.
|
||||
RestrictSetWeaponRestricted(weaponindex, false, restrict);
|
||||
|
||||
|
||||
// Successfully restricted weapon.
|
||||
return Query_Successful;
|
||||
}
|
||||
@ -350,35 +350,35 @@ RestrictQuery:RestrictWeapon(bool:restrict, const String:target[], &bool:single
|
||||
else
|
||||
{
|
||||
single = false;
|
||||
|
||||
|
||||
// Get all weapons in the given type.
|
||||
new Handle:arrayTypeWeapons;
|
||||
new count = RestrictGetTypeWeapons(typeindex, arrayTypeWeapons);
|
||||
|
||||
|
||||
// Return proper weapon name.
|
||||
RestrictWeaponTypeGetName(typeindex, returntarget, maxlen);
|
||||
|
||||
|
||||
// If weapon restriction is redundant then return stopped.
|
||||
if (RestrictIsTypeUniform(restrict, typeindex))
|
||||
{
|
||||
return Query_Stopped;
|
||||
}
|
||||
|
||||
|
||||
for (new x = 0; x < count; x++)
|
||||
{
|
||||
// Get weapon index.
|
||||
new weaponindex = GetArrayCell(arrayTypeWeapons, x);
|
||||
|
||||
|
||||
// If weapon is untoggleable, then stop.
|
||||
if (!WeaponsGetToggleable(weaponindex))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Set weapon's restricted state.
|
||||
RestrictSetWeaponRestricted(weaponindex, false, restrict);
|
||||
}
|
||||
|
||||
|
||||
// Successfully restricted weapon type.
|
||||
return Query_Successful;
|
||||
}
|
||||
@ -464,20 +464,20 @@ RestrictPrintQueryResponse(client, RestrictQuery:query, bool:single, bool:restri
|
||||
stock RestrictTypeToIndex(const String:type[])
|
||||
{
|
||||
decl String:typename[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// x = Array index.
|
||||
new size = GetArraySize(arrayWeaponTypes);
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
RestrictWeaponTypeGetName(x, typename, sizeof(typename));
|
||||
|
||||
|
||||
// If types match, then return index.
|
||||
if (StrEqual(type, typename, false))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Type doesn't exist.
|
||||
return -1;
|
||||
}
|
||||
@ -496,7 +496,7 @@ stock RestrictWeaponTypeGetName(index, String:weapontype[], maxlen)
|
||||
|
||||
/**
|
||||
* Returns an array containing all weapon indexes matching the given type.
|
||||
*
|
||||
*
|
||||
* @param index The weapon type index.
|
||||
* @param arrayTypeWeapons A handle to store array containing matching weapons.
|
||||
* Don't forget to close this!
|
||||
@ -505,33 +505,33 @@ stock RestrictGetTypeWeapons(index, &Handle:arrayTypeWeapons)
|
||||
{
|
||||
// Create array to hold weapons of the given type.
|
||||
arrayTypeWeapons = CreateArray();
|
||||
|
||||
|
||||
// Get name of the weapon type at given index.
|
||||
decl String:typename[WEAPONS_MAX_LENGTH];
|
||||
RestrictWeaponTypeGetName(index, typename, sizeof(typename));
|
||||
|
||||
|
||||
new count;
|
||||
decl String:weapontype[WEAPONS_MAX_LENGTH];
|
||||
new String:weapontypes[WEAPONS_RESTRICT_MAX_TYPES][WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// x = Array index.
|
||||
new size = GetArraySize(arrayWeapons);
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
WeaponsGetType(x, weapontype, sizeof(weapontype));
|
||||
|
||||
|
||||
ExplodeString(weapontype, ",", weapontypes, sizeof(weapontypes), sizeof(weapontypes[]));
|
||||
for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++)
|
||||
{
|
||||
// Cut off whitespace.
|
||||
TrimString(weapontypes[y]);
|
||||
|
||||
|
||||
// If we've reached the end of the weapon's types, then stop.
|
||||
if (!weapontypes[y][0])
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// If types match, then add weapon to array.
|
||||
if (StrEqual(typename, weapontypes[y], false))
|
||||
{
|
||||
@ -540,14 +540,14 @@ stock RestrictGetTypeWeapons(index, &Handle:arrayTypeWeapons)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return number of weapons of the given type.
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the restricted status on a weapon.
|
||||
*
|
||||
*
|
||||
* @param index The weapon index.
|
||||
* @param toggle If true, the value is toggled, otherwise 'restrict' param is used.
|
||||
* @param restrict (Only if 'toggle' is 'false') Restricted status of the weapon.
|
||||
@ -556,7 +556,7 @@ stock RestrictSetWeaponRestricted(index, bool:toggle, bool:restrict = false)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Set restricted status.
|
||||
new bool:value = toggle ? !RestrictIsWeaponRestricted(index) : restrict;
|
||||
SetArrayCell(arrayWeapon, _:WEAPONS_DATA_RESTRICTED, value);
|
||||
@ -564,7 +564,7 @@ stock RestrictSetWeaponRestricted(index, bool:toggle, bool:restrict = false)
|
||||
|
||||
/**
|
||||
* Gets the restricted status on a weapon.
|
||||
*
|
||||
*
|
||||
* @param index The weapon index.
|
||||
* @return True if weapon is restricted, false if not.
|
||||
*/
|
||||
@ -572,14 +572,14 @@ stock bool:RestrictIsWeaponRestricted(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return restricted status.
|
||||
return bool:GetArrayCell(arrayWeapon, _:WEAPONS_DATA_RESTRICTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if all weapons of a type are restricted.
|
||||
*
|
||||
*
|
||||
* @param restricted True to check if all weapons of given type are restricted.
|
||||
* @param index The weapon type index.
|
||||
* @return True if all weapons of the given type are restricted or not, false if not.
|
||||
@ -588,20 +588,20 @@ stock bool:RestrictIsTypeUniform(bool:restricted, index)
|
||||
{
|
||||
new Handle:arrayTypeWeapons;
|
||||
new count = RestrictGetTypeWeapons(index, arrayTypeWeapons);
|
||||
|
||||
|
||||
// x = array index
|
||||
for (new x = 0; x < count; x++)
|
||||
{
|
||||
// Get weapon index to check restricted status of.
|
||||
new weaponindex = GetArrayCell(arrayTypeWeapons, x);
|
||||
|
||||
|
||||
// If weapon is toggleable and it's not uniform with the given status, then return false.
|
||||
if (WeaponsGetToggleable(weaponindex) && RestrictIsWeaponRestricted(weaponindex) != restricted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// All weapons are restricted, so return true.
|
||||
return true;
|
||||
}
|
||||
@ -621,59 +621,59 @@ public ZRTools_Action:RestrictCanUse(client, weapon)
|
||||
{
|
||||
new String:weaponentity[WEAPONS_MAX_LENGTH];
|
||||
GetEdictClassname(weapon, weaponentity, sizeof(weaponentity));
|
||||
|
||||
|
||||
// If weapon is a knife, then allow pickup.
|
||||
if (StrEqual(weaponentity, "weapon_knife"))
|
||||
{
|
||||
return ACTION_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
// If the player is a zombie, then prevent pickup.
|
||||
if (InfectIsClientInfected(client))
|
||||
{
|
||||
return ACTION_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
// If client is flagged for not picking up weapons, then stop.
|
||||
if (g_bRestrictBlockWeapon[client])
|
||||
{
|
||||
return ACTION_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
// If weapons module is disabled, then stop.
|
||||
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
||||
if (!weapons)
|
||||
{
|
||||
return ACTION_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
// If restrict module is disabled, then stop.
|
||||
new bool:restrict = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT]);
|
||||
if (!restrict)
|
||||
{
|
||||
return ACTION_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
// If the weapon is restricted, then prevent pickup.
|
||||
decl String:weaponname[WEAPONS_MAX_LENGTH];
|
||||
new weaponindex = WeaponsEntityToDisplay(weaponentity, weaponname, sizeof(weaponname));
|
||||
|
||||
|
||||
// If weapon isn't configged, then allow pickup.
|
||||
if (weaponindex == -1)
|
||||
{
|
||||
// Allow pickup.
|
||||
return ACTION_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
// If weapon is restricted, then stop.
|
||||
if (RestrictIsWeaponRestricted(weaponindex))
|
||||
{
|
||||
return ACTION_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
// Forward event to weapons module.
|
||||
WeaponsOnItemPickup(client, weapon);
|
||||
|
||||
|
||||
// Allow pickup.
|
||||
return ACTION_CONTINUE;
|
||||
}
|
||||
@ -685,7 +685,7 @@ public ZRTools_Action:RestrictCanUse(client, weapon)
|
||||
/**
|
||||
* Command callback (zr_restrict)
|
||||
* Restricts a weapon or group
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param argc Argument count.
|
||||
*/
|
||||
@ -697,7 +697,7 @@ public Action:RestrictCommand(client, argc)
|
||||
TranslationReplyToCommand(client, "No access to command");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// If weapons module is disabled, then stop.
|
||||
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
||||
if (!weapons)
|
||||
@ -706,7 +706,7 @@ public Action:RestrictCommand(client, argc)
|
||||
TranslationReplyToCommand(client, "Feature is disabled");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// If restrict module is disabled, then stop.
|
||||
new bool:restrict = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT]);
|
||||
if (!restrict)
|
||||
@ -715,38 +715,38 @@ public Action:RestrictCommand(client, argc)
|
||||
TranslationReplyToCommand(client, "Feature is disabled");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// If not enough arguments given, then stop.
|
||||
if (argc < 1)
|
||||
{
|
||||
TranslationReplyToCommand(client, "Weapons command restrict syntax");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
decl String:target[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
new args = GetCmdArgs();
|
||||
for (new x = 1; x <= args; x++)
|
||||
{
|
||||
// Get target to restrict.
|
||||
GetCmdArg(x, target, sizeof(target));
|
||||
|
||||
|
||||
// Query restrict on this target, and get a result back.
|
||||
new bool:single;
|
||||
decl String:returntarget[WEAPONS_MAX_LENGTH];
|
||||
new RestrictQuery:query = RestrictWeapon(true, target, single, returntarget, sizeof(returntarget));
|
||||
|
||||
|
||||
// Print response to client(s).
|
||||
RestrictPrintQueryResponse(client, query, single, true, returntarget);
|
||||
}
|
||||
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Command callback (zr_unrestrict)
|
||||
* Unrestricts a weapon or group
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param argc Argument count.
|
||||
*/
|
||||
@ -758,7 +758,7 @@ public Action:UnrestrictCommand(client, argc)
|
||||
TranslationReplyToCommand(client, "No access to command");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// If weapons module is disabled, then stop.
|
||||
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
||||
if (!weapons)
|
||||
@ -767,7 +767,7 @@ public Action:UnrestrictCommand(client, argc)
|
||||
TranslationReplyToCommand(client, "Feature is disabled");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// If restrict module is disabled, then stop.
|
||||
new bool:restrict = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT]);
|
||||
if (!restrict)
|
||||
@ -776,31 +776,31 @@ public Action:UnrestrictCommand(client, argc)
|
||||
TranslationReplyToCommand(client, "Feature is disabled");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// If not enough arguments given, then stop.
|
||||
if (argc < 1)
|
||||
{
|
||||
TranslationReplyToCommand(client, "Weapons command unrestrict syntax");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
// arg1 = weapon being restricted
|
||||
decl String:target[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
new args = GetCmdArgs();
|
||||
for (new x = 1; x <= args; x++)
|
||||
{
|
||||
// Get target to restrict.
|
||||
GetCmdArg(x, target, sizeof(target));
|
||||
|
||||
|
||||
// Query unrestrict on this target, and get a result back.
|
||||
new bool:single;
|
||||
decl String:returntarget[WEAPONS_MAX_LENGTH];
|
||||
new RestrictQuery:query = RestrictWeapon(false, target, single, returntarget, sizeof(returntarget));
|
||||
|
||||
|
||||
// Print response to client(s).
|
||||
RestrictPrintQueryResponse(client, query, single, false, returntarget);
|
||||
}
|
||||
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Zombie:Reloaded
|
||||
*
|
||||
* File: weaponalpha.inc
|
||||
* Type: Core
|
||||
* Type: Core
|
||||
* Description: Weapon alpha functions, and alpha updating on drop/pickup.
|
||||
*
|
||||
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
||||
@ -37,7 +37,7 @@ new g_iWeaponDropHookID[MAXPLAYERS + 1] = {-1, ...};
|
||||
|
||||
/**
|
||||
* Client is joining the server.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponAlphaClientInit(client)
|
||||
@ -46,7 +46,7 @@ WeaponAlphaClientInit(client)
|
||||
// Hook "Weapon_Drop" on client.
|
||||
#if defined USE_SDKHOOKS
|
||||
SDKHook(client, SDKHook_WeaponDrop, WeaponAlphaDrop);
|
||||
|
||||
|
||||
// Set dummy value so it think it's hooked.
|
||||
g_iWeaponDropHookID[client] = 1;
|
||||
#else
|
||||
@ -56,7 +56,7 @@ WeaponAlphaClientInit(client)
|
||||
|
||||
/**
|
||||
* Client is leaving the server.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponAlphaOnClientDisconnect(client)
|
||||
@ -70,16 +70,16 @@ WeaponAlphaOnClientDisconnect(client)
|
||||
#else
|
||||
ZRTools_UnhookWeapon_Drop(g_iWeaponDropHookID[client]);
|
||||
#endif
|
||||
|
||||
|
||||
g_iWeaponDropHookID[client] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client has just picked up a weapon.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weapon The weapon index.
|
||||
* @param weapon The weapon index.
|
||||
*/
|
||||
WeaponAlphaOnItemPickupPost(client, weapon)
|
||||
{
|
||||
@ -93,10 +93,10 @@ WeaponAlphaOnItemPickupPost(client, weapon)
|
||||
// (entity 666/info_particle_system)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get client's current alpha.
|
||||
new alpha = ToolsGetEntityAlpha(client);
|
||||
|
||||
|
||||
// Set new alpha on weapons.
|
||||
WeaponAlphaApplyWeaponAlpha(weapon, alpha);
|
||||
}
|
||||
@ -104,7 +104,7 @@ WeaponAlphaOnItemPickupPost(client, weapon)
|
||||
/**
|
||||
* Callback function for Weapon_Drop.
|
||||
* Called when a client drops their weapon.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weapon The weapon index.
|
||||
*/
|
||||
@ -120,14 +120,14 @@ public ZRTools_Action:WeaponAlphaDrop(client, weapon)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Set new alpha on weapons.
|
||||
WeaponAlphaApplyWeaponAlpha(weapon, WEAPONALPHA_DEFAULT_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* A client's alpha has been changed by the plugin.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponAlphaOnClientAlphaChanged(client, alpha)
|
||||
@ -139,7 +139,7 @@ WeaponAlphaOnClientAlphaChanged(client, alpha)
|
||||
|
||||
/**
|
||||
* Set's the alpha on a client's weapons.
|
||||
*
|
||||
*
|
||||
* @param entity If client index is given, alpha will be set on all their weapons.
|
||||
* If a non-client index is given, alpha will be set on given entity.
|
||||
* @param alpha The alpha to set the weapons to.
|
||||
@ -151,18 +151,18 @@ WeaponAlphaApplyWeaponAlpha(entity, alpha)
|
||||
{
|
||||
// Turn rendermode on, on the weapon.
|
||||
SetEntityRenderMode(entity, RENDER_TRANSALPHA);
|
||||
|
||||
|
||||
// Set alpha value on the weapon.
|
||||
SetEntityRenderColor(entity, _, _, _, alpha);
|
||||
|
||||
|
||||
// Entity alpha has been set, so stop.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get client's list of weapons.
|
||||
new weapons[WeaponsSlot];
|
||||
WeaponsGetClientWeapons(entity, weapons);
|
||||
|
||||
|
||||
// Loop through array slots and set alpha.
|
||||
// x = weapon slot.
|
||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||
@ -172,10 +172,10 @@ WeaponAlphaApplyWeaponAlpha(entity, alpha)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Turn rendermode on, on the weapon.
|
||||
SetEntityRenderMode(weapons[x], RENDER_TRANSALPHA);
|
||||
|
||||
|
||||
// Set alpha value on the weapon.
|
||||
SetEntityRenderColor(weapons[x], _, _, _, alpha);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Zombie:Reloaded
|
||||
*
|
||||
* File: weaponammo.inc
|
||||
* Type: Core
|
||||
* Type: Core
|
||||
* Description: API for all weaponammo-related functions.
|
||||
*
|
||||
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
||||
@ -90,14 +90,14 @@ WeaponAmmoOnOffsetsFound()
|
||||
{
|
||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CBaseCombatWeapon::m_iClip1\" was not found.");
|
||||
}
|
||||
|
||||
|
||||
// If offset "m_iClip2" can't be found, then stop the plugin.
|
||||
g_iToolsClip2 = FindSendPropInfo("CBaseCombatWeapon", "m_iClip2");
|
||||
if (g_iToolsClip2 == -1)
|
||||
{
|
||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CBaseCombatWeapon::m_iClip2\" was not found.");
|
||||
}
|
||||
|
||||
|
||||
// If offset "m_iAmmo" can't be found, then stop the plugin.
|
||||
g_iToolsAmmo = FindSendPropInfo("CBasePlayer", "m_iAmmo");
|
||||
if (g_iToolsAmmo == -1)
|
||||
@ -108,7 +108,7 @@ WeaponAmmoOnOffsetsFound()
|
||||
|
||||
/**
|
||||
* Set clip/reserve ammo on a weapon.
|
||||
*
|
||||
*
|
||||
* @param weapon The weapon index.
|
||||
* @param clip True sets clip ammo, false sets reserve.
|
||||
* @param value The amount of ammo to set to.
|
||||
@ -118,23 +118,23 @@ stock WeaponAmmoSetAmmo(weapon, bool:clip, value, bool:add = false)
|
||||
{
|
||||
// Set variable to offset we are changing.
|
||||
new ammooffset = clip ? g_iToolsClip1 : g_iToolsClip2;
|
||||
|
||||
|
||||
// Initialize variable (value is 0)
|
||||
new ammovalue;
|
||||
|
||||
|
||||
// If we are adding, then update variable with current ammo value.
|
||||
if (add)
|
||||
{
|
||||
ammovalue = WeaponAmmoGetAmmo(weapon, clip);
|
||||
}
|
||||
|
||||
|
||||
// Return ammo offset value.
|
||||
SetEntData(weapon, ammooffset, ammovalue + value, _, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get clip/reserve ammo on a weapon.
|
||||
*
|
||||
*
|
||||
* @param weapon The weapon index.
|
||||
* @param clip True gets clip ammo, false gets reserve.
|
||||
*/
|
||||
@ -142,36 +142,36 @@ stock WeaponAmmoGetAmmo(weapon, bool:clip)
|
||||
{
|
||||
// Set variable to offset we are changing.
|
||||
new ammooffset = clip ? g_iToolsClip1 : g_iToolsClip2;
|
||||
|
||||
|
||||
// Return ammo offset value.
|
||||
return GetEntData(weapon, ammooffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the count of any grenade-type a client has.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param slot The type of
|
||||
* @param value The amount of ammo to set to.
|
||||
* @param add (Optional) If true, the value is added to the grenades' current ammo count.
|
||||
* @param add (Optional) If true, the value is added to the grenades' current ammo count.
|
||||
*/
|
||||
stock WeaponAmmoSetGrenadeCount(client, WeaponAmmoGrenadeType:type, value, bool:add)
|
||||
{
|
||||
// Initialize variable (value is 0)
|
||||
new ammovalue;
|
||||
|
||||
|
||||
// If we are adding, then update variable with current ammo value.
|
||||
if (add)
|
||||
{
|
||||
ammovalue = WeaponAmmoGetGrenadeCount(client, type);
|
||||
}
|
||||
|
||||
|
||||
SetEntData(client, g_iToolsAmmo + (_:type * 4), ammovalue + value, _, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the count of any grenade-type a client has.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param slot The type of
|
||||
*/
|
||||
@ -182,7 +182,7 @@ stock WeaponAmmoGetGrenadeCount(client, WeaponAmmoGrenadeType:type)
|
||||
|
||||
/**
|
||||
* Takes a weapon entity and returns an entry in enum WeaponAmmoGrenadeType.
|
||||
*
|
||||
*
|
||||
* @param weaponentity The weapon entity to find entry for.
|
||||
* @return An entry in WeaponAmmoGrenadeType.
|
||||
*/
|
||||
@ -200,15 +200,15 @@ stock WeaponAmmoGrenadeType:WeaponAmmoEntityToGrenadeType(const String:weaponent
|
||||
{
|
||||
return GrenadeType_Smokegrenade;
|
||||
}
|
||||
|
||||
|
||||
return GrenadeType_Invalid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max amount of this type of grenades the client is allowed to carry.
|
||||
*
|
||||
*
|
||||
* @param weaponentity The weapon entity to get the limit for.
|
||||
* @return The grenade limit, -1 if an unhandled grenade entity was given.
|
||||
* @return The grenade limit, -1 if an unhandled grenade entity was given.
|
||||
*/
|
||||
stock WeaponAmmoGetGrenadeLimit(WeaponAmmoGrenadeType:grenadetype)
|
||||
{
|
||||
@ -218,7 +218,7 @@ stock WeaponAmmoGrenadeType:WeaponAmmoEntityToGrenadeType(const String:weaponent
|
||||
{
|
||||
// Attempt to find a cvar provided by an outside plugin.
|
||||
new Handle:gplimit = FindConVar(GRENADE_PACK_CVAR_LIMIT);
|
||||
|
||||
|
||||
// If Grenade Pack is loaded and the cvar was found, then get the value of the outside cvar, if not return CS:S default.
|
||||
return (g_bGrenadePack && gplimit != INVALID_HANDLE) ? GetConVarInt(gplimit) : WEAPONAMMO_HEGRENADE_LIMIT;
|
||||
}
|
||||
@ -231,7 +231,7 @@ stock WeaponAmmoGrenadeType:WeaponAmmoEntityToGrenadeType(const String:weaponent
|
||||
return WEAPONAMMO_SMOKEGRENADE_LIMIT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -243,25 +243,25 @@ stock bool:ZMarketIsGPLoaded()
|
||||
new Handle:hPlugins = GetPluginIterator();
|
||||
new Handle:hPlugin;
|
||||
decl String:strPlugin[PLATFORM_MAX_PATH];
|
||||
|
||||
|
||||
while (MorePlugins(hPlugins))
|
||||
{
|
||||
// Read the next plugin.
|
||||
hPlugin = ReadPlugin(hPlugins);
|
||||
|
||||
|
||||
GetPluginFilename(hPlugin, strPlugin, sizeof(strPlugin));
|
||||
if (!StrEqual(strPlugin, GRENADE_PACK_FILENAME, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Plugin was found, now return true only if it is running.
|
||||
return (GetPluginStatus(hPlugin) == Plugin_Running);
|
||||
}
|
||||
|
||||
|
||||
// Done iterating, close handle.
|
||||
CloseHandle(hPlugins);
|
||||
|
||||
|
||||
// Plugin wasn't found.
|
||||
return false;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* Zombie:Reloaded
|
||||
*
|
||||
* File: weapons.inc
|
||||
* Type: Core
|
||||
* Type: Core
|
||||
* Description: API for all weapon-related functions.
|
||||
*
|
||||
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
||||
@ -126,14 +126,14 @@ WeaponsOnOffsetsFound()
|
||||
{
|
||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CBasePlayer::m_hActiveWeapon\" was not found.");
|
||||
}
|
||||
|
||||
|
||||
// If offset "m_bInBuyZone" can't be found, then stop the plugin.
|
||||
g_iToolsInBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone");
|
||||
if (g_iToolsInBuyZone == -1)
|
||||
{
|
||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CCSPlayer::m_bInBuyZone\" was not found.");
|
||||
}
|
||||
|
||||
|
||||
// Forward event to sub-modules
|
||||
WeaponAmmoOnOffsetsFound();
|
||||
}
|
||||
@ -164,54 +164,54 @@ WeaponsLoad()
|
||||
{
|
||||
// Register config file.
|
||||
ConfigRegisterConfig(File_Weapons, Structure_Keyvalue, CONFIG_FILE_ALIAS_WEAPONS);
|
||||
|
||||
|
||||
// If module is disabled, then stop.
|
||||
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
||||
if (!weapons)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get weapons config path.
|
||||
decl String:pathweapons[PLATFORM_MAX_PATH];
|
||||
new bool:exists = ConfigGetCvarFilePath(CVAR_CONFIG_PATH_WEAPONS, pathweapons);
|
||||
|
||||
|
||||
// If file doesn't exist, then log and stop.
|
||||
if (!exists)
|
||||
{
|
||||
// Log failure.
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Weapons, "Config Validation", "Missing weapons config file: %s", pathweapons);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Set the path to the config file.
|
||||
ConfigSetConfigPath(File_Weapons, pathweapons);
|
||||
|
||||
|
||||
// Load config from file and create array structure.
|
||||
new bool:success = ConfigLoadConfig(File_Weapons, arrayWeapons);
|
||||
|
||||
|
||||
// Unexpected error, stop plugin.
|
||||
if (!success)
|
||||
{
|
||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Config Validation", "Unexpected error encountered loading: %s", pathweapons);
|
||||
}
|
||||
|
||||
|
||||
// Validate weapons config.
|
||||
new size = GetArraySize(arrayWeapons);
|
||||
if (!size)
|
||||
{
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Weapons, "Config Validation", "No usable data found in weapons config file: %s", pathweapons);
|
||||
}
|
||||
|
||||
|
||||
// Now copy data to array structure.
|
||||
WeaponsCacheData();
|
||||
|
||||
|
||||
// Set config data.
|
||||
ConfigSetConfigLoaded(File_Weapons, true);
|
||||
ConfigSetConfigReloadFunc(File_Weapons, GetFunctionByName(GetMyHandle(), "WeaponsOnConfigReload"));
|
||||
ConfigSetConfigHandle(File_Weapons, arrayWeapons);
|
||||
|
||||
|
||||
// Forward event to sub-modules
|
||||
RestrictLoad();
|
||||
}
|
||||
@ -225,17 +225,17 @@ WeaponsCacheData()
|
||||
// Get config's file path.
|
||||
decl String:pathweapons[PLATFORM_MAX_PATH];
|
||||
ConfigGetConfigPath(File_Weapons, pathweapons, sizeof(pathweapons));
|
||||
|
||||
|
||||
new Handle:kvWeapons;
|
||||
new bool:success = ConfigOpenConfigFile(File_Weapons, kvWeapons);
|
||||
|
||||
|
||||
if (!success)
|
||||
{
|
||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Config Validation", "Unexpected error caching data from weapons config file: %s", pathweapons);
|
||||
}
|
||||
|
||||
|
||||
decl String:weaponname[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// x = array index
|
||||
new size = GetArraySize(arrayWeapons);
|
||||
for (new x = 0; x < size; x++)
|
||||
@ -247,35 +247,35 @@ WeaponsCacheData()
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Weapons, "Config Validation", "Couldn't cache weapon data for: %s (check weapons config)", weaponname);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Get config data.
|
||||
|
||||
|
||||
decl String:weaponentity[CONFIG_MAX_LENGTH];
|
||||
decl String:weapontype[CONFIG_MAX_LENGTH];
|
||||
decl String:ammotype[CONFIG_MAX_LENGTH];
|
||||
|
||||
|
||||
// General
|
||||
KvGetString(kvWeapons, "weaponentity", weaponentity, sizeof(weaponentity));
|
||||
KvGetString(kvWeapons, "weapontype", weapontype, sizeof(weapontype));
|
||||
new WeaponsSlot:weaponslot = WeaponsSlot:KvGetNum(kvWeapons, "weaponslot", -1);
|
||||
|
||||
|
||||
// Restrict (core)
|
||||
new bool:restrictdefault = ConfigKvGetStringBool(kvWeapons, "restrictdefault", "no");
|
||||
new bool:toggleable = ConfigKvGetStringBool(kvWeapons, "toggleable", "yes");
|
||||
|
||||
|
||||
// Weapon Ammo (core)
|
||||
KvGetString(kvWeapons, "ammotype", ammotype, sizeof(ammotype));
|
||||
new ammoprice = KvGetNum(kvWeapons, "ammoprice", -1);
|
||||
|
||||
|
||||
// Knockback (module)
|
||||
new Float:knockback = KvGetFloat(kvWeapons, "knockback", 1.0);
|
||||
|
||||
|
||||
// ZMarket (module)
|
||||
new zmarketprice = KvGetNum(kvWeapons, "zmarketprice", -1);
|
||||
new zmarketpurchasemax = KvGetNum(kvWeapons, "zmarketpurchasemax", 0);
|
||||
|
||||
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, x);
|
||||
|
||||
|
||||
// Push data into array.
|
||||
PushArrayString(arrayWeapon, weaponentity); // Index: 1
|
||||
PushArrayString(arrayWeapon, weapontype); // Index: 2
|
||||
@ -287,11 +287,11 @@ WeaponsCacheData()
|
||||
PushArrayCell(arrayWeapon, knockback); // Index: 8
|
||||
PushArrayCell(arrayWeapon, zmarketprice); // Index: 9
|
||||
PushArrayCell(arrayWeapon, zmarketpurchasemax); // Index: 10
|
||||
|
||||
|
||||
// Initialize other stored weapon info here.
|
||||
PushArrayCell(arrayWeapon, restrictdefault); // Index: 11
|
||||
}
|
||||
|
||||
|
||||
// We're done with this file now, so we can close it.
|
||||
CloseHandle(kvWeapons);
|
||||
}
|
||||
@ -304,11 +304,11 @@ public WeaponsOnConfigReload()
|
||||
// Reload weapons config.
|
||||
WeaponsLoad();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Client is joining the server.
|
||||
*
|
||||
* @param client The client index.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsClientInit(client)
|
||||
{
|
||||
@ -320,7 +320,7 @@ WeaponsClientInit(client)
|
||||
|
||||
/**
|
||||
* Called once a client's saved cookies have been loaded from the database.
|
||||
*
|
||||
*
|
||||
* @param client Client index.
|
||||
*/
|
||||
WeaponsOnCookiesCached(client)
|
||||
@ -331,7 +331,7 @@ WeaponsOnCookiesCached(client)
|
||||
|
||||
/**
|
||||
* Client is leaving the server.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsOnClientDisconnect(client)
|
||||
@ -344,7 +344,7 @@ WeaponsOnClientDisconnect(client)
|
||||
|
||||
/**
|
||||
* Client is spawning into the game.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsOnClientSpawn(client)
|
||||
@ -355,14 +355,14 @@ WeaponsOnClientSpawn(client)
|
||||
|
||||
/**
|
||||
* Client is spawning into the game. *Post
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
WeaponsOnClientSpawnPost(client)
|
||||
{
|
||||
// Refresh all weapons on clients to cleanup any rendering errors.
|
||||
WeaponsRefreshAllClientWeapons(client);
|
||||
|
||||
|
||||
// Forward event to sub-modules.
|
||||
ZMarketOnClientSpawnPost(client);
|
||||
}
|
||||
@ -378,28 +378,28 @@ WeaponsOnRoundEnd()
|
||||
|
||||
/**
|
||||
* 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, TIMER_DATA_HNDL_CLOSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client picks up an item. *Post
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weapon The weapon index.
|
||||
*/
|
||||
@ -409,19 +409,19 @@ public Action:WeaponsOnItemPickupPost(Handle:timer, Handle:eventinfo)
|
||||
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);
|
||||
}
|
||||
@ -432,53 +432,53 @@ public Action:WeaponsOnItemPickupPost(Handle:timer, Handle:eventinfo)
|
||||
|
||||
/**
|
||||
* Clear cache for a given weapon.
|
||||
*
|
||||
*
|
||||
* @param index The weapon index.
|
||||
*/
|
||||
stock WeaponsClearCache(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:hWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Clear array.
|
||||
ClearArray(hWeapon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the index at which the weapon's name is at.
|
||||
*
|
||||
*
|
||||
* @param weapon The weapon name.
|
||||
* @return The array index containing the given weapon name.
|
||||
*/
|
||||
stock WeaponsNameToIndex(const String:weapon[])
|
||||
{
|
||||
decl String:weaponname[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// x = Array index.
|
||||
new size = GetArraySize(arrayWeapons);
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
WeaponsGetName(x, weaponname, sizeof(weaponname));
|
||||
|
||||
|
||||
// If names match, then return index.
|
||||
if (StrEqual(weapon, weaponname, false))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Name doesn't exist.
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a weapon's entity name and returns the display name in weapons config file.
|
||||
*
|
||||
*
|
||||
* @param entityname The entity to find the display of.
|
||||
* @param display Buffer to store display name in.
|
||||
* @param displaymaxlen The max length of the display name.
|
||||
* @param noprefix If this is true, the entity name will be compared without the weapon_/item_ prefix.
|
||||
* @return The index of the weapon found.
|
||||
* @return The index of the weapon found.
|
||||
*/
|
||||
stock WeaponsEntityToDisplay(const String:entityname[], String:display[], displaymaxlen, noprefix = false)
|
||||
{
|
||||
@ -487,38 +487,38 @@ stock WeaponsEntityToDisplay(const String:entityname[], String:display[], displa
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
decl String:weaponentity[WEAPONS_MAX_LENGTH];
|
||||
|
||||
|
||||
// Initialize string to null.
|
||||
strcopy(display, sizeof(displaymaxlen), "");
|
||||
|
||||
|
||||
// x = Array index.
|
||||
new size = GetArraySize(arrayWeapons);
|
||||
for (new x = 0; x < size; x++)
|
||||
{
|
||||
// If entity names don't match, then stop.
|
||||
WeaponsGetEntity(x, weaponentity, sizeof(weaponentity));
|
||||
|
||||
|
||||
// If noprefix is true, then strip the weapon_/item_ prefix.
|
||||
if (noprefix)
|
||||
{
|
||||
ReplaceString(weaponentity, sizeof(weaponentity), "weapon_", "");
|
||||
ReplaceString(weaponentity, sizeof(weaponentity), "item_", "");
|
||||
}
|
||||
|
||||
|
||||
if (!StrEqual(entityname, weaponentity, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// The entity names match, so return display.
|
||||
WeaponsGetName(x, display, displaymaxlen);
|
||||
|
||||
|
||||
// Return the weapon index.
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
// Nothing was found.
|
||||
return -1;
|
||||
}
|
||||
@ -543,7 +543,7 @@ stock WeaponsGetName(index, String:weapon[], maxlen)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Get weapon name.
|
||||
GetArrayString(arrayWeapon, _:WEAPONS_DATA_NAME, weapon, maxlen);
|
||||
}
|
||||
@ -558,7 +558,7 @@ stock WeaponsGetEntity(index, String:type[], maxlen)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Get weapon type.
|
||||
GetArrayString(arrayWeapon, _:WEAPONS_DATA_ENTITY, type, maxlen);
|
||||
}
|
||||
@ -573,7 +573,7 @@ stock WeaponsGetType(index, String:type[], maxlen)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Get weapon type.
|
||||
GetArrayString(arrayWeapon, _:WEAPONS_DATA_TYPE, type, maxlen);
|
||||
}
|
||||
@ -587,7 +587,7 @@ stock WeaponsSlot:WeaponsGetSlot(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return default restriction status.
|
||||
return WeaponsSlot:GetArrayCell(arrayWeapon, _:WEAPONS_DATA_SLOT);
|
||||
}
|
||||
@ -601,7 +601,7 @@ stock bool:WeaponsGetRestrictDefault(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return default restriction status.
|
||||
return bool:GetArrayCell(arrayWeapon, _:WEAPONS_DATA_RESTRICTDEFAULT);
|
||||
}
|
||||
@ -615,7 +615,7 @@ stock bool:WeaponsGetToggleable(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return if weapon is toggleable.
|
||||
return bool:GetArrayCell(arrayWeapon, _:WEAPONS_DATA_TOGGLEABLE);
|
||||
}
|
||||
@ -630,7 +630,7 @@ stock WeaponsGetAmmoType(index, String:ammotype[], maxlen)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Get ammo type of the weapon.
|
||||
GetArrayString(arrayWeapon, _:WEAPONS_DATA_AMMOTYPE, ammotype, maxlen);
|
||||
}
|
||||
@ -644,7 +644,7 @@ stock WeaponsGetAmmoPrice(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return ammo price of the weapon.
|
||||
return GetArrayCell(arrayWeapon, _:WEAPONS_DATA_AMMOPRICE);
|
||||
}
|
||||
@ -658,7 +658,7 @@ stock Float:WeaponsGetKnockback(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return knockback multiplier of the weapon.
|
||||
return Float:GetArrayCell(arrayWeapon, _:WEAPONS_DATA_KNOCKBACK);
|
||||
}
|
||||
@ -672,7 +672,7 @@ stock WeaponsGetZMarketPrice(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return the ZMarket price of the weapon.
|
||||
return GetArrayCell(arrayWeapon, _:WEAPONS_DATA_ZMARKETPRICE);
|
||||
}
|
||||
@ -686,7 +686,7 @@ stock WeaponsGetZMarketPurchaseMax(index)
|
||||
{
|
||||
// Get array handle of weapon at given index.
|
||||
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
|
||||
|
||||
|
||||
// Return the ZMarket price of the weapon.
|
||||
return GetArrayCell(arrayWeapon, _:WEAPONS_DATA_ZMARKETPURCHASEMAX);
|
||||
}
|
||||
@ -697,7 +697,7 @@ stock WeaponsGetZMarketPurchaseMax(index)
|
||||
|
||||
/**
|
||||
* Checks if a client has a specific weapon.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weapon The weapon classname.
|
||||
*/
|
||||
@ -706,9 +706,9 @@ stock bool:WeaponsClientHasWeapon(client, const String:weapon[])
|
||||
// Get all of client's current weapons.
|
||||
new weapons[WeaponsSlot];
|
||||
WeaponsGetClientWeapons(client, weapons);
|
||||
|
||||
|
||||
decl String:classname[64];
|
||||
|
||||
|
||||
// x = slot index
|
||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||
{
|
||||
@ -717,7 +717,7 @@ stock bool:WeaponsClientHasWeapon(client, const String:weapon[])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// If the weapon's classname matches, then return true.
|
||||
GetEdictClassname(weapons[x], classname, sizeof(classname));
|
||||
if (StrEqual(weapon, classname, false))
|
||||
@ -725,16 +725,16 @@ stock bool:WeaponsClientHasWeapon(client, const String:weapon[])
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array that contains all client's weapon indexes.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weapons The weapon index array.
|
||||
* -1 if no weapon in slot.
|
||||
* -1 if no weapon in slot.
|
||||
*/
|
||||
stock WeaponsGetClientWeapons(client, weapons[WeaponsSlot])
|
||||
{
|
||||
@ -747,10 +747,10 @@ stock WeaponsGetClientWeapons(client, weapons[WeaponsSlot])
|
||||
|
||||
/**
|
||||
* Returns weapon index of the client's deployed weapon.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @return The weapon index of the deployed weapon.
|
||||
* -1 if no weapon is deployed.
|
||||
* -1 if no weapon is deployed.
|
||||
*/
|
||||
stock WeaponsGetDeployedWeaponIndex(client)
|
||||
{
|
||||
@ -769,16 +769,16 @@ stock WeaponsSlot:WeaponsGetDeployedWeaponSlot(client)
|
||||
// Get all client's weapon indexes.
|
||||
new weapons[WeaponsSlot];
|
||||
WeaponsGetClientWeapons(client, weapons);
|
||||
|
||||
|
||||
// Get client's deployed weapon.
|
||||
new deployedweapon = WeaponsGetDeployedWeaponIndex(client);
|
||||
|
||||
|
||||
// If client has no deployed weapon, then stop.
|
||||
if (deployedweapon == -1)
|
||||
{
|
||||
return Type_Invalid;
|
||||
}
|
||||
|
||||
|
||||
// x = weapon slot.
|
||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||
{
|
||||
@ -787,13 +787,13 @@ stock WeaponsSlot:WeaponsGetDeployedWeaponSlot(client)
|
||||
return WeaponsSlot:x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Type_Invalid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces player to drop weapon index. (Simplified wrapper)
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weapon The weapon index to force client to drop.
|
||||
*/
|
||||
@ -805,9 +805,9 @@ stock WeaponsForceClientDrop(client, weapon)
|
||||
|
||||
/**
|
||||
* Used to explicitly remove projectile weapons from a client.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weaponsdrop True to force drop on all weapons, false to strip.
|
||||
* @param weaponsdrop True to force drop on all weapons, false to strip.
|
||||
*/
|
||||
stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop)
|
||||
{
|
||||
@ -826,7 +826,7 @@ stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop)
|
||||
RemovePlayerItem(client, grenade);
|
||||
AcceptEntityInput(grenade, "Kill");
|
||||
}
|
||||
|
||||
|
||||
// Find next grenade.
|
||||
grenade = GetPlayerWeaponSlot(client, _:Slot_Projectile);
|
||||
}
|
||||
@ -834,24 +834,24 @@ stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop)
|
||||
|
||||
/**
|
||||
* Refresh a weapon by taking it and giving it back.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param slot The weapon slot to refresh. (see enum WeaponsSlot)
|
||||
*/
|
||||
stock WeaponsRefreshClientWeapon(client, WeaponsSlot:slot)
|
||||
{
|
||||
new weaponindex = GetPlayerWeaponSlot(client, _:slot);
|
||||
|
||||
|
||||
// If weapon is invalid, then stop.
|
||||
if (weaponindex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get the classname of the weapon to re-give.
|
||||
decl String:entityname[WEAPONS_MAX_LENGTH];
|
||||
GetEdictClassname(weaponindex, entityname, sizeof(entityname));
|
||||
|
||||
|
||||
// Refresh weapon.
|
||||
RemovePlayerItem(client, weaponindex);
|
||||
AcceptEntityInput(weaponindex, "Kill");
|
||||
@ -860,7 +860,7 @@ stock WeaponsRefreshClientWeapon(client, WeaponsSlot:slot)
|
||||
|
||||
/**
|
||||
* Remove all weapons, except knife, on a client, with options.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param weaponsdrop True to force drop on all weapons, false to strip.
|
||||
*/
|
||||
@ -869,7 +869,7 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
|
||||
// Get a list of all client's weapon indexes.
|
||||
new weapons[WeaponsSlot];
|
||||
WeaponsGetClientWeapons(client, weapons);
|
||||
|
||||
|
||||
// Loop through array slots and force drop.
|
||||
// x = weapon slot.
|
||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||
@ -879,7 +879,7 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// If this is the knife slot, then strip it and stop.
|
||||
if (WeaponsSlot:x == Slot_Melee)
|
||||
{
|
||||
@ -888,7 +888,7 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
|
||||
AcceptEntityInput(weapons[x], "Kill");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (weaponsdrop)
|
||||
{
|
||||
// Force client to drop weapon.
|
||||
@ -901,17 +901,17 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
|
||||
AcceptEntityInput(weapons[x], "Kill");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove left-over projectiles.
|
||||
WeaponsRemoveClientGrenades(client, weaponsdrop);
|
||||
|
||||
|
||||
// Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning)
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh a weapon by taking it and giving it back.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
stock WeaponsRefreshAllClientWeapons(client)
|
||||
@ -919,7 +919,7 @@ stock WeaponsRefreshAllClientWeapons(client)
|
||||
// Get a list of all client's weapon indexes.
|
||||
new weapons[WeaponsSlot];
|
||||
WeaponsGetClientWeapons(client, weapons);
|
||||
|
||||
|
||||
// Loop through array slots and force drop.
|
||||
// x = weapon slot.
|
||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||
@ -929,14 +929,14 @@ stock WeaponsRefreshAllClientWeapons(client)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
WeaponsRefreshClientWeapon(client, WeaponsSlot:x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a client is in a buyzone.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
stock bool:WeaponsIsClientInBuyZone(client)
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user