ZMarket: Rework display name system, it applies to all menus now.

This commit is contained in:
zaCade 2019-03-09 13:44:42 +01:00
parent 96c640b58d
commit 10461e8ba4
3 changed files with 22 additions and 17 deletions

View File

@ -239,7 +239,7 @@ WeaponsMenuTypeWeapons(client)
new weaponindex = GetArrayCell(arrayTypeWeapons, x);
// Get name of weapon.
WeaponsGetName(weaponindex, typeweapon, sizeof(typeweapon));
WeaponsGetName(weaponindex, typeweapon, sizeof(typeweapon), true);
strcopy(display, sizeof(display), typeweapon);
if (RestrictIsWeaponRestricted(weaponindex))

View File

@ -471,7 +471,7 @@ stock WeaponsEntityToDisplay(const String:entityname[], String:display[], displa
}
// The entity names match, so return display.
WeaponsGetName(x, display, displaymaxlen);
WeaponsGetName(x, display, displaymaxlen, true);
// Return the weapon index.
return x;
@ -497,13 +497,26 @@ stock bool:WeaponsIsWeaponValid(const String:weapon[])
* @param weapon The string to return name in.
* @param maxlen The max length of the string.
*/
stock WeaponsGetName(index, String:weapon[], maxlen)
stock WeaponsGetName(index, String:weapon[], maxlen, bool zmarket = false)
{
// Get array handle of weapon at given index.
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
new String:weaponName[WEAPONS_MAX_LENGTH];
new String:marketName[WEAPONS_MAX_LENGTH];
// Get weapon name.
GetArrayString(arrayWeapon, _:WEAPONS_DATA_NAME, weapon, maxlen);
GetArrayString(arrayWeapon, _:WEAPONS_DATA_NAME, weaponName, maxlen);
// Get weapon zmarket name.
if (zmarket)
GetArrayString(arrayWeapon, _:WEAPONS_DATA_ZMARKETNAME, marketName, maxlen);
// Are we in zmarket, and is our name valid?
if (zmarket && strlen(marketName))
strcopy(weapon, maxlen, marketName);
else
strcopy(weapon, maxlen, weaponName);
}
/**

View File

@ -610,7 +610,7 @@ ZMarketMenuLoadoutWeapons(client, WeaponsSlot:slot)
if(wslot != slot)
continue;
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname));
WeaponsGetName(weaponindex, weaponname, sizeof(weaponname), true);
// Get restricted status on the weapon.
new bool:restricted = RestrictIsWeaponRestricted(weaponindex);
@ -787,7 +787,6 @@ ZMarketMenuTypeWeapons(client)
decl String:typeweapon[WEAPONS_MAX_LENGTH];
decl String:typeweapondisplay[MENU_LINE_REG_LENGTH];
decl String:typeweaponentity[WEAPONS_MAX_LENGTH];
decl String:displayname[MENU_LINE_REG_LENGTH];
decl String:display[MENU_LINE_BIG_LENGTH];
// Get an array populated with all weapons of the given type.
@ -803,18 +802,11 @@ ZMarketMenuTypeWeapons(client)
new weaponindex = GetArrayCell(arrayTypeWeapons, x);
// Get name of weapon.
WeaponsGetName(weaponindex, typeweapon, sizeof(typeweapon));
WeaponsGetName(weaponindex, typeweapon, sizeof(typeweapon), true);
// Get entity name of weapon.
WeaponsGetEntity(weaponindex, typeweaponentity, sizeof(typeweaponentity));
// Get display name of weapon.
WeaponsGetZMarketName(weaponindex, displayname, sizeof(displayname));
// Use display name if set, use name otherwise.
if (!strlen(displayname))
strcopy(displayname, sizeof(displayname), typeweapon);
// Check if client is buying the weapon or ammo for it, and get the price of the item.
new bool:hasweapon = WeaponsClientHasWeapon(client, typeweaponentity);
@ -835,7 +827,7 @@ ZMarketMenuTypeWeapons(client)
itemprice = WeaponsGetAmmoPrice(weaponindex);
// Tell client they are buying ammo.
Format(typeweapondisplay, sizeof(typeweapondisplay), "%s %t", displayname, "Weapons menu zmarket types weapon ammo");
Format(typeweapondisplay, sizeof(typeweapondisplay), "%s %t", typeweapon, "Weapons menu zmarket types weapon ammo");
}
// If the itemprice is invalid, then set to known integer to be later replaced.
@ -850,10 +842,10 @@ ZMarketMenuTypeWeapons(client)
new bool:restricted = RestrictIsWeaponRestricted(weaponindex);
// If weapon is restricted then format "[]" around it.
strcopy(typeweapondisplay, sizeof(typeweapondisplay), displayname);
strcopy(typeweapondisplay, sizeof(typeweapondisplay), typeweapon);
if (restricted)
{
Format(typeweapondisplay, sizeof(typeweapondisplay), "[%s]", displayname);
Format(typeweapondisplay, sizeof(typeweapondisplay), "[%s]", typeweapon);
}
// DO PURCHASE MAX STUFF HERE.