Extended ZMarkets feature to include overwriting their current loadout with their current weapons, and viewing their custom loadout.
* Restructured ZMarkets menus.
This commit is contained in:
parent
424a852d3a
commit
ed752979b8
@ -532,6 +532,11 @@
|
|||||||
"en" "Weapon @green{1} @defaulthas a purchase limit of @green{2}@default. Wait until you respawn to try again."
|
"en" "Weapon @green{1} @defaulthas a purchase limit of @green{2}@default. Wait until you respawn to try again."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Weapons zmarket get current loadout"
|
||||||
|
{
|
||||||
|
"en" "Updated current loadout, use rebuy option to purchase these weapons again."
|
||||||
|
}
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
|
|
||||||
"Weapons command restrict syntax"
|
"Weapons command restrict syntax"
|
||||||
@ -597,22 +602,82 @@
|
|||||||
|
|
||||||
// Menu (ZMarket)
|
// Menu (ZMarket)
|
||||||
|
|
||||||
|
"Weapons menu zmarket main title"
|
||||||
|
{
|
||||||
|
"en" "ZMarket\nSelect an Option:"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket main get loadout"
|
||||||
|
{
|
||||||
|
"en" "Get Current Loadout"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket main view loadout"
|
||||||
|
{
|
||||||
|
"en" "View My Loadout"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket main rebuy"
|
||||||
|
{
|
||||||
|
"en" "Rebuy My Loadout"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket main auto-rebuy"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Auto-Rebuy: {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket main weapons list"
|
||||||
|
{
|
||||||
|
"en" "View Weapons List"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout title"
|
||||||
|
{
|
||||||
|
"en" "ZMarket\nMy Current Loadout:\nRebuy refers to these weapons"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout primary"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Primary: {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout secondary"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Secondary: {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout melee"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Melee: {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout projectile"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Projectile: {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout explosive"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Explosive: {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu zmarket loadout empty"
|
||||||
|
{
|
||||||
|
"en" "(None)"
|
||||||
|
}
|
||||||
|
|
||||||
"Weapons menu zmarket types title"
|
"Weapons menu zmarket types title"
|
||||||
{
|
{
|
||||||
"en" "ZMarket\nSelect Weapon Type:"
|
"en" "ZMarket\nSelect Weapon Type:"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Weapons menu zmarket types rebuy"
|
|
||||||
{
|
|
||||||
"en" "Rebuy (1 weapon per slot)"
|
|
||||||
}
|
|
||||||
|
|
||||||
"Weapons menu zmarket types auto-rebuy"
|
|
||||||
{
|
|
||||||
"#format" "{1:s}"
|
|
||||||
"en" "Auto-Rebuy: {1}\n "
|
|
||||||
}
|
|
||||||
|
|
||||||
"Weapons menu zmarket types weapon type title"
|
"Weapons menu zmarket types weapon type title"
|
||||||
{
|
{
|
||||||
"#format" "{1:s}"
|
"#format" "{1:s}"
|
||||||
|
@ -168,7 +168,7 @@ public MenuMainHandle(Handle:menu, MenuAction:action, client, slot)
|
|||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
// Send ZMarket menu.
|
// Send ZMarket menu.
|
||||||
resend = !ZMarketMenuTypes(client);
|
resend = !ZMarketMenuMain(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +371,32 @@ stock WeaponsNameToIndex(const String:weapon[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a weapon's classname and returns the display name in weapons config file.
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
stock WeaponsClassnameToDisplay(String:classname[], classnamemaxlen, String:display[], displaymaxlen)
|
||||||
|
{
|
||||||
|
// Strip off classnames' weapon prefix.
|
||||||
|
ReplaceString(classname, classnamemaxlen, "weapon_", "");
|
||||||
|
ReplaceString(classname, classnamemaxlen, "item_", "");
|
||||||
|
|
||||||
|
// Get the index of the weapon.
|
||||||
|
new weaponindex = WeaponsNameToIndex(classname);
|
||||||
|
|
||||||
|
// If weapon index is invalid, then return an empty string.
|
||||||
|
if (weaponindex == -1)
|
||||||
|
{
|
||||||
|
// Return an empty string.
|
||||||
|
strcopy(display, displaymaxlen, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the display name.
|
||||||
|
WeaponsGetName(weaponindex, display, displaymaxlen);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a weapon is valid. (E.G. listed in weapons.txt)
|
* Checks if a weapon is valid. (E.G. listed in weapons.txt)
|
||||||
* @param weapon The weapon name.
|
* @param weapon The weapon name.
|
||||||
|
@ -175,11 +175,12 @@ ZMarketGetPurchaseCount(client, const String:weapon[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends weapon type list to client.
|
* Sends main ZMarket menu to client.
|
||||||
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @return True if the menu was sent successfully, false if not.
|
* @return True if the menu was sent successfully, false if not.
|
||||||
*/
|
*/
|
||||||
bool:ZMarketMenuTypes(client)
|
bool:ZMarketMenuMain(client)
|
||||||
{
|
{
|
||||||
// If weapons module is disabled, then stop.
|
// If weapons module is disabled, then stop.
|
||||||
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
||||||
@ -199,6 +200,240 @@ bool:ZMarketMenuTypes(client)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create menu handle.
|
||||||
|
new Handle:menu_zmarket_main = CreateMenu(ZMarketMenuMainHandle);
|
||||||
|
|
||||||
|
// Set translation target as client.
|
||||||
|
SetGlobalTransTarget(client);
|
||||||
|
|
||||||
|
// Set menu title.
|
||||||
|
SetMenuTitle(menu_zmarket_main, "%t\n ", "Weapons menu zmarket main title");
|
||||||
|
|
||||||
|
// If rebuy is enabled, then add it to the menu.
|
||||||
|
new bool:zmarketrebuy = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY]);
|
||||||
|
new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]);
|
||||||
|
|
||||||
|
// Add "Get Current Loadout" option.
|
||||||
|
decl String:getloadout[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:viewloadout[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:rebuy[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:rebuyauto[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:weaponslist[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
|
// Get auto-rebuy setting.
|
||||||
|
decl String:rebuyautosetting[8];
|
||||||
|
ConfigBoolToSetting(g_bZMarketAutoRebuy[client], rebuyautosetting, sizeof(rebuyautosetting));
|
||||||
|
|
||||||
|
// Format menu options.
|
||||||
|
Format(getloadout, sizeof(getloadout), "%t", "Weapons menu zmarket main get loadout");
|
||||||
|
Format(viewloadout, sizeof(viewloadout), "%t", "Weapons menu zmarket main view loadout");
|
||||||
|
Format(rebuy, sizeof(rebuy), "%t", "Weapons menu zmarket main rebuy");
|
||||||
|
Format(rebuyauto, sizeof(rebuyauto), "%t", "Weapons menu zmarket main auto-rebuy", rebuyautosetting);
|
||||||
|
Format(weaponslist, sizeof(weaponslist), "%t", "Weapons menu zmarket main weapons list");
|
||||||
|
|
||||||
|
// Add formatted options to menu.
|
||||||
|
AddMenuItem(menu_zmarket_main, "Get Loadout", getloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
|
||||||
|
AddMenuItem(menu_zmarket_main, "View Loadout", viewloadout, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
|
||||||
|
AddMenuItem(menu_zmarket_main, "Rebuy", rebuy, MenuGetItemDraw(zmarketrebuy || zmarketrebuyauto));
|
||||||
|
AddMenuItem(menu_zmarket_main, "Auto-Rebuy", rebuyauto, MenuGetItemDraw(zmarketrebuyauto));
|
||||||
|
AddMenuItem(menu_zmarket_main, "Weapons List", weaponslist);
|
||||||
|
|
||||||
|
// Set exit back button.
|
||||||
|
SetMenuExitBackButton(menu_zmarket_main, true);
|
||||||
|
|
||||||
|
DisplayMenu(menu_zmarket_main, client, MENU_TIME_FOREVER);
|
||||||
|
|
||||||
|
// Menu sent successfully.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when client selects option in the main ZMarket menu, and handles it.
|
||||||
|
*
|
||||||
|
* @param menu_zmarket_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 ZMarketMenuMainHandle(Handle:menu_zmarket_main, MenuAction:action, client, slot)
|
||||||
|
{
|
||||||
|
// Client selected an option.
|
||||||
|
if (action == MenuAction_Select)
|
||||||
|
{
|
||||||
|
switch(slot)
|
||||||
|
{
|
||||||
|
// Get loadout.
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
// Gets a client's current loadout.
|
||||||
|
ZMarketGetCurrentLoadout(client);
|
||||||
|
|
||||||
|
// Resend menu.
|
||||||
|
ZMarketMenuMain(client);
|
||||||
|
}
|
||||||
|
// View loadout.
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
// Show a client their current loadout.
|
||||||
|
ZMarketMenuLoadout(client);
|
||||||
|
}
|
||||||
|
// Rebuy.
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
// Force client to rebuy weapons.
|
||||||
|
ZMarketRebuy(client);
|
||||||
|
|
||||||
|
// Resend menu.
|
||||||
|
ZMarketMenuMain(client);
|
||||||
|
}
|
||||||
|
// Auto-rebuy.
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
// Toggle rebuy.
|
||||||
|
g_bZMarketAutoRebuy[client] = !g_bZMarketAutoRebuy[client];
|
||||||
|
|
||||||
|
// Resend menu.
|
||||||
|
ZMarketMenuMain(client);
|
||||||
|
}
|
||||||
|
// Weapons list.
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
// Send the weapon types list.
|
||||||
|
ZMarketMenuTypes(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Client closed the menu.
|
||||||
|
if (action == MenuAction_Cancel)
|
||||||
|
{
|
||||||
|
// Client hit "Back" button.
|
||||||
|
if (slot == MenuCancel_ExitBack)
|
||||||
|
{
|
||||||
|
MenuMain(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Client hit "Exit" button.
|
||||||
|
else if (action == MenuAction_End)
|
||||||
|
{
|
||||||
|
CloseHandle(menu_zmarket_main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends list of weapons in a client's loadout to the client.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
bool:ZMarketMenuLoadout(client)
|
||||||
|
{
|
||||||
|
// Create menu handle.
|
||||||
|
new Handle:menu_zmarket_loadout = CreateMenu(ZMarketMenuLoadoutHandle);
|
||||||
|
|
||||||
|
// Set translation target as client.
|
||||||
|
SetGlobalTransTarget(client);
|
||||||
|
|
||||||
|
// Set menu title.
|
||||||
|
SetMenuTitle(menu_zmarket_loadout, "%t\n ", "Weapons menu zmarket loadout title");
|
||||||
|
|
||||||
|
decl String:primaryweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:secondaryweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:meleeweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:projectileweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:explosiveweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
|
// 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(g_strZMarketLastWeapon[client][Slot_Secondary], sizeof(g_strZMarketLastWeapon), secondaryweapon, sizeof(secondaryweapon));
|
||||||
|
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Melee], sizeof(g_strZMarketLastWeapon), meleeweapon, sizeof(meleeweapon));
|
||||||
|
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Projectile], sizeof(g_strZMarketLastWeapon), projectileweapon, sizeof(projectileweapon));
|
||||||
|
WeaponsClassnameToDisplay(g_strZMarketLastWeapon[client][Slot_Explosive], sizeof(g_strZMarketLastWeapon), explosiveweapon, sizeof(explosiveweapon));
|
||||||
|
|
||||||
|
// Get the empty translation.
|
||||||
|
decl String:empty[64];
|
||||||
|
Format(empty, sizeof(empty), "%t", "Weapons menu zmarket loadout empty");
|
||||||
|
|
||||||
|
// If the client doesn't have a weapon in this slot, then set the weapon to the empty translation.
|
||||||
|
if (!primaryweapon[0])
|
||||||
|
{
|
||||||
|
strcopy(primaryweapon, sizeof(primaryweapon), empty);
|
||||||
|
}
|
||||||
|
if (!secondaryweapon[0])
|
||||||
|
{
|
||||||
|
strcopy(secondaryweapon, sizeof(secondaryweapon), empty);
|
||||||
|
}
|
||||||
|
if (!meleeweapon[0])
|
||||||
|
{
|
||||||
|
strcopy(meleeweapon, sizeof(meleeweapon), empty);
|
||||||
|
}
|
||||||
|
if (!projectileweapon[0])
|
||||||
|
{
|
||||||
|
strcopy(projectileweapon, sizeof(projectileweapon), empty);
|
||||||
|
}
|
||||||
|
if (!explosiveweapon[0])
|
||||||
|
{
|
||||||
|
strcopy(explosiveweapon, sizeof(explosiveweapon), empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
decl String:primary[64];
|
||||||
|
decl String:secondary[64];
|
||||||
|
decl String:melee[64];
|
||||||
|
decl String:projectile[64];
|
||||||
|
decl String:explosive[64];
|
||||||
|
|
||||||
|
// Format all the lines of the menu.
|
||||||
|
Format(primary, sizeof(primary), "%t", "Weapons menu zmarket loadout primary", primaryweapon);
|
||||||
|
Format(secondary, sizeof(secondary), "%t", "Weapons menu zmarket loadout secondary", secondaryweapon);
|
||||||
|
Format(melee, sizeof(melee), "%t", "Weapons menu zmarket loadout melee", meleeweapon);
|
||||||
|
Format(projectile, sizeof(projectile), "%t", "Weapons menu zmarket loadout projectile", projectileweapon);
|
||||||
|
Format(explosive, sizeof(explosive), "%t", "Weapons menu zmarket loadout explosive", explosiveweapon);
|
||||||
|
|
||||||
|
// Add formatted options to menu.
|
||||||
|
AddMenuItem(menu_zmarket_loadout, primary, primary, ITEMDRAW_DISABLED);
|
||||||
|
AddMenuItem(menu_zmarket_loadout, secondary, secondary, ITEMDRAW_DISABLED);
|
||||||
|
AddMenuItem(menu_zmarket_loadout, melee, melee, ITEMDRAW_DISABLED);
|
||||||
|
AddMenuItem(menu_zmarket_loadout, projectile, projectile, ITEMDRAW_DISABLED);
|
||||||
|
AddMenuItem(menu_zmarket_loadout, explosive, explosive, ITEMDRAW_DISABLED);
|
||||||
|
|
||||||
|
// Set exit back button.
|
||||||
|
SetMenuExitBackButton(menu_zmarket_loadout, true);
|
||||||
|
|
||||||
|
// Send menu to client.
|
||||||
|
DisplayMenu(menu_zmarket_loadout, client, MENU_TIME_FOREVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow the user to press the "Back" button to go to main ZMarket menu.
|
||||||
|
*
|
||||||
|
* @param menu_zmarket_loadout 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 ZMarketMenuLoadoutHandle(Handle:menu_zmarket_loadout, MenuAction:action, client, slot)
|
||||||
|
{
|
||||||
|
// Client closed the menu.
|
||||||
|
if (action == MenuAction_Cancel)
|
||||||
|
{
|
||||||
|
// Client hit "Back" button.
|
||||||
|
if (slot == MenuCancel_ExitBack)
|
||||||
|
{
|
||||||
|
ZMarketMenuMain(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Client hit "Exit" button.
|
||||||
|
else if (action == MenuAction_End)
|
||||||
|
{
|
||||||
|
CloseHandle(menu_zmarket_loadout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends weapon type list to client.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
ZMarketMenuTypes(client)
|
||||||
|
{
|
||||||
// Create menu handle.
|
// Create menu handle.
|
||||||
new Handle:menu_zmarket_types = CreateMenu(ZMarketMenuTypesHandle);
|
new Handle:menu_zmarket_types = CreateMenu(ZMarketMenuTypesHandle);
|
||||||
|
|
||||||
@ -208,32 +443,6 @@ bool:ZMarketMenuTypes(client)
|
|||||||
// Set menu title.
|
// Set menu title.
|
||||||
SetMenuTitle(menu_zmarket_types, "%t\n ", "Weapons menu zmarket types title");
|
SetMenuTitle(menu_zmarket_types, "%t\n ", "Weapons menu zmarket types title");
|
||||||
|
|
||||||
// If rebuy is enabled, then add it to the menu.
|
|
||||||
new bool:zmarketrebuy = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY]);
|
|
||||||
new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]);
|
|
||||||
|
|
||||||
// If rebuy or auto-rebuy is enabled, then add it to the menu.
|
|
||||||
if (zmarketrebuy || zmarketrebuyauto)
|
|
||||||
{
|
|
||||||
// Add "Rebuy" option.
|
|
||||||
decl String:rebuy[WEAPONS_MAX_LENGTH];
|
|
||||||
Format(rebuy, sizeof(rebuy), "%t", "Weapons menu zmarket types rebuy");
|
|
||||||
AddMenuItem(menu_zmarket_types, "Rebuy", rebuy);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If auto-rebuy is enabled, then add it to the menu.
|
|
||||||
if (zmarketrebuyauto)
|
|
||||||
{
|
|
||||||
// Get current auto-rebuy setting.
|
|
||||||
decl String:rebuyautosetting[8];
|
|
||||||
ConfigBoolToSetting(g_bZMarketAutoRebuy[client], rebuyautosetting, sizeof(rebuyautosetting));
|
|
||||||
|
|
||||||
// Add "Auto-Rebuy" option.
|
|
||||||
decl String:rebuyauto[WEAPONS_MAX_LENGTH];
|
|
||||||
Format(rebuyauto, sizeof(rebuyauto), "%t", "Weapons menu zmarket types auto-rebuy", rebuyautosetting);
|
|
||||||
AddMenuItem(menu_zmarket_types, "Auto-Rebuy", rebuyauto);
|
|
||||||
}
|
|
||||||
|
|
||||||
decl String:typename[WEAPONS_MAX_LENGTH];
|
decl String:typename[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
// x = Array index.
|
// x = Array index.
|
||||||
@ -260,13 +469,11 @@ bool:ZMarketMenuTypes(client)
|
|||||||
SetMenuExitBackButton(menu_zmarket_types, true);
|
SetMenuExitBackButton(menu_zmarket_types, true);
|
||||||
|
|
||||||
DisplayMenu(menu_zmarket_types, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu_zmarket_types, client, MENU_TIME_FOREVER);
|
||||||
|
|
||||||
// Menu sent successfully.
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when client selects option in the weapons list menu, and handles it.
|
* Called when client selects option in the weapons list menu, and handles it.
|
||||||
|
*
|
||||||
* @param menu_zmarket_types Handle of the menu being used.
|
* @param menu_zmarket_types Handle of the menu being used.
|
||||||
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
@ -280,28 +487,6 @@ public ZMarketMenuTypesHandle(Handle:menu_zmarket_types, MenuAction:action, clie
|
|||||||
decl String:weapontype[WEAPONS_MAX_LENGTH];
|
decl String:weapontype[WEAPONS_MAX_LENGTH];
|
||||||
GetMenuItem(menu_zmarket_types, slot, weapontype, sizeof(weapontype));
|
GetMenuItem(menu_zmarket_types, slot, weapontype, sizeof(weapontype));
|
||||||
|
|
||||||
if (StrEqual(weapontype, "Rebuy"))
|
|
||||||
{
|
|
||||||
// Force client to rebuy weapons.
|
|
||||||
ZMarketRebuy(client);
|
|
||||||
|
|
||||||
// Resend menu.
|
|
||||||
ZMarketMenuTypes(client);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrEqual(weapontype, "Auto-Rebuy"))
|
|
||||||
{
|
|
||||||
// Toggle rebuy.
|
|
||||||
g_bZMarketAutoRebuy[client] = !g_bZMarketAutoRebuy[client];
|
|
||||||
|
|
||||||
// Resend menu.
|
|
||||||
ZMarketMenuTypes(client);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get weapon index.
|
// Get weapon index.
|
||||||
new weapontypeindex = RestrictTypeToIndex(weapontype);
|
new weapontypeindex = RestrictTypeToIndex(weapontype);
|
||||||
|
|
||||||
@ -326,7 +511,7 @@ public ZMarketMenuTypesHandle(Handle:menu_zmarket_types, MenuAction:action, clie
|
|||||||
// Client hit "Back" button.
|
// Client hit "Back" button.
|
||||||
if (slot == MenuCancel_ExitBack)
|
if (slot == MenuCancel_ExitBack)
|
||||||
{
|
{
|
||||||
MenuMain(client);
|
ZMarketMenuMain(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Client hit "Exit" button.
|
// Client hit "Exit" button.
|
||||||
@ -338,6 +523,7 @@ public ZMarketMenuTypesHandle(Handle:menu_zmarket_types, MenuAction:action, clie
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a list of weapons of a certain type in a menu to the client.
|
* Sends a list of weapons of a certain type in a menu to the client.
|
||||||
|
*
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
*/
|
*/
|
||||||
ZMarketMenuTypeWeapons(client)
|
ZMarketMenuTypeWeapons(client)
|
||||||
@ -455,6 +641,7 @@ ZMarketMenuTypeWeapons(client)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when client selects option in the weapon group menu, and handles it.
|
* Called when client selects option in the weapon group menu, and handles it.
|
||||||
|
*
|
||||||
* @param menu_zmarket_typeweapons Handle of the menu being used.
|
* @param menu_zmarket_typeweapons Handle of the menu being used.
|
||||||
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
@ -636,6 +823,59 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the client's current weapons and puts them in the rebuy cache.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @return True if the menu sent successfully, false if not.
|
||||||
|
*/
|
||||||
|
bool:ZMarketGetCurrentLoadout(client)
|
||||||
|
{
|
||||||
|
// If client is dead, then tell them they must be alive and stop.
|
||||||
|
if (!IsPlayerAlive(client))
|
||||||
|
{
|
||||||
|
TranslationPrintToChat(client, "Must be alive");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If client is a zombie, then tell them they must be human and stop.
|
||||||
|
if (!IsPlayerAlive(client))
|
||||||
|
{
|
||||||
|
TranslationPrintToChat(client, "Must be human");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all of client's current weapons.
|
||||||
|
new weapons[WeaponsSlot];
|
||||||
|
WeaponsGetClientWeapons(client, weapons);
|
||||||
|
|
||||||
|
decl String:weaponname[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
|
// x = Weapon slot.
|
||||||
|
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||||
|
{
|
||||||
|
// If slot is empty, then clear this slot in rebuy cache and stop.
|
||||||
|
if (weapons[x] == -1)
|
||||||
|
{
|
||||||
|
// Empty rebuy slot.
|
||||||
|
strcopy(g_strZMarketLastWeapon[client][x], sizeof(g_strZMarketLastWeapon), "");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the name of the weapon.
|
||||||
|
GetEdictClassname(weapons[x], weaponname, sizeof(weaponname));
|
||||||
|
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
|
||||||
|
|
||||||
|
// Copy the name to the rebuy cache.
|
||||||
|
strcopy(g_strZMarketLastWeapon[client][x], sizeof(g_strZMarketLastWeapon), weaponname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tell client their loadout has been updated.
|
||||||
|
TranslationPrintToChat(client, "Weapons zmarket get current loadout");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force a client to rebuy their weapons.
|
* Force a client to rebuy their weapons.
|
||||||
*
|
*
|
||||||
@ -687,7 +927,7 @@ public Action:ZMarketCommand(client, argc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send ZMarket menu.
|
// Send ZMarket menu.
|
||||||
ZMarketMenuTypes(client);
|
ZMarketMenuMain(client);
|
||||||
|
|
||||||
// This stops the "Unknown command" message in client's console.
|
// This stops the "Unknown command" message in client's console.
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
Loading…
Reference in New Issue
Block a user