CSGO: Add 'zmarketname' to fix keyvalues case bug.

https://forums.alliedmods.net/showpost.php?p=2220583&postcount=5, for
explanation.
This commit is contained in:
zaCade 2018-07-30 14:50:58 +02:00
parent fa758698c6
commit 651dd9921a
2 changed files with 37 additions and 10 deletions

View File

@ -60,6 +60,7 @@ enum WeaponsData
WEAPONS_DATA_AMMOTYPE,
WEAPONS_DATA_AMMOPRICE,
WEAPONS_DATA_KNOCKBACK,
WEAPONS_DATA_ZMARKETNAME,
WEAPONS_DATA_ZMARKETPRICE,
WEAPONS_DATA_ZMARKETPURCHASEMAX,
WEAPONS_DATA_ZMARKETCOMMAND,
@ -256,6 +257,7 @@ WeaponsCacheData()
decl String:weaponentity[CONFIG_MAX_LENGTH];
decl String:weapontype[CONFIG_MAX_LENGTH];
decl String:ammotype[CONFIG_MAX_LENGTH];
decl String:zmarketname[CONFIG_MAX_LENGTH];
decl String:zmarketcommand[CONFIG_MAX_LENGTH];
// General
@ -275,6 +277,7 @@ WeaponsCacheData()
new Float:knockback = KvGetFloat(kvWeapons, "knockback", 1.0);
// ZMarket (module)
KvGetString(kvWeapons, "zmarketname", zmarketname, sizeof(zmarketname), "");
new zmarketprice = KvGetNum(kvWeapons, "zmarketprice", -1);
new zmarketpurchasemax = KvGetNum(kvWeapons, "zmarketpurchasemax", -1);
KvGetString(kvWeapons, "zmarketcommand", zmarketcommand, sizeof(zmarketcommand), "");
@ -290,12 +293,13 @@ WeaponsCacheData()
PushArrayString(arrayWeapon, ammotype); // Index: 6
PushArrayCell(arrayWeapon, ammoprice); // Index: 7
PushArrayCell(arrayWeapon, knockback); // Index: 8
PushArrayCell(arrayWeapon, zmarketprice); // Index: 9
PushArrayCell(arrayWeapon, zmarketpurchasemax); // Index: 10
PushArrayString(arrayWeapon, zmarketcommand); // Index: 11
PushArrayString(arrayWeapon, zmarketname); // Index: 9
PushArrayCell(arrayWeapon, zmarketprice); // Index: 10
PushArrayCell(arrayWeapon, zmarketpurchasemax); // Index: 11
PushArrayString(arrayWeapon, zmarketcommand); // Index: 12
// Initialize other stored weapon info here.
PushArrayCell(arrayWeapon, restrictdefault); // Index: 12
PushArrayCell(arrayWeapon, restrictdefault); // Index: 13
}
// We're done with this file now, so we can close it.
@ -326,7 +330,7 @@ WeaponsClientInit(client)
/**
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
* @param client The client index.
*/
WeaponsOnCookiesCached(client)
{
@ -617,6 +621,21 @@ stock Float:WeaponsGetKnockback(index)
return Float:GetArrayCell(arrayWeapon, _:WEAPONS_DATA_KNOCKBACK);
}
/**
* Gets the ZMarket name for the weapon.
* @param index The weapon index.
* @param weapon The string to return name in.
* @param maxlen The max length of the string.
*/
stock WeaponsGetZMarketName(index, String:weapon[], maxlen)
{
// Get array handle of weapon at given index.
new Handle:arrayWeapon = GetArrayCell(arrayWeapons, index);
// Get the ZMarket name of the weapon.
GetArrayString(arrayWeapon, _:WEAPONS_DATA_ZMARKETNAME, weapon, maxlen);
}
/**
* Gets the ZMarket price for the weapon.
* @param index The weapon index.

View File

@ -787,6 +787,7 @@ 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.
@ -807,6 +808,13 @@ ZMarketMenuTypeWeapons(client)
// 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);
@ -827,7 +835,7 @@ ZMarketMenuTypeWeapons(client)
itemprice = WeaponsGetAmmoPrice(weaponindex);
// Tell client they are buying ammo.
Format(typeweapondisplay, sizeof(typeweapondisplay), "%s %t", typeweapon, "Weapons menu zmarket types weapon ammo");
Format(typeweapondisplay, sizeof(typeweapondisplay), "%s %t", displayname, "Weapons menu zmarket types weapon ammo");
}
// If the itemprice is invalid, then set to known integer to be later replaced.
@ -842,10 +850,10 @@ ZMarketMenuTypeWeapons(client)
new bool:restricted = RestrictIsWeaponRestricted(weaponindex);
// If weapon is restricted then format "[]" around it.
strcopy(typeweapondisplay, sizeof(typeweapondisplay), typeweapon);
strcopy(typeweapondisplay, sizeof(typeweapondisplay), displayname);
if (restricted)
{
Format(typeweapondisplay, sizeof(typeweapondisplay), "[%s]", typeweapon);
Format(typeweapondisplay, sizeof(typeweapondisplay), "[%s]", displayname);
}
// DO PURCHASE MAX STUFF HERE.