hi again. when i buy a melee weapon while on secondary slot, all is well. however, when i buy a melee weapon in any other slot (e.g. primary, grenade, medkit), it gives me the "failed to buy" error but i still get melee weapon. also no points are deducted from wallet. anyone else have this issue? thanks.
EDIT: i have found the problem. the shop seems to conflict with this plugin. if you turn off auto-switch on secondary pickup and buy a melee weapon, it will throw you the refund message but still give you the weapon. any possible way to fix this?
hi again. when i buy a melee weapon while on secondary slot, all is well. however, when i buy a melee weapon in any other slot (e.g. primary, grenade, medkit), it gives me the "failed to buy" error but i still get melee weapon. also no points are deducted from wallet. anyone else have this issue? thanks.
EDIT: i have found the problem. the shop seems to conflict with this plugin. if you turn off auto-switch on secondary pickup and buy a melee weapon, it will throw you the refund message but still give you the weapon. any possible way to fix this?
It is because some map may not have the melee, so there is a checking for buying melee.
SourceMod error session started
Exception reported: Client 7 is not in game
Blaming: l4d2_shop.smx
Call stack trace:
ThrowError
Line 700, \scripting\include\pan0s.inc::CPrintToChat
Line 1418, l4d2_shop.sp::KillClient
Line 2939, l4d2_shop.sp::HandleMenuSuicide
Error log file session closed.
- Added airstrike and extinguisher(Thanks VYRNACH_GAMING for adding this)
- Added more shop on checking.
- Moved some global variables to shop_cv.inc
- Simplified adding a new item. Adding cost convar is not necessary now as you will set the price in shop_cv.inc
- Rename ConVar in .cfg (you may need to delete old l4d2_shop.cfg to get the latest one)
- Fixed Transfer Point title
v4.2 (16 March 2022)
- Fixed memory leak
v4.1 (15 March 2022)
- Added gnome and cola bottles (Thanks NoroHime)
v4.0 (15 March 2022)
- Fixed Client index is invalid
- Supported Native function.
v3.0 (15 March 2022)
- Fixed round reset bug.
- Fixed survivors can buy infected shop item by command.
- Added ConVar to set points after resetting points.
v2.9 (25 Feb 2022)
- Tank and Witch limit bug, reported by laurauwu.
v2.8 (27 July 2021)
- Fixed SI id that doesn't match and the number of them do not reset, reported by ryxzxz
- Fixed the cheat command exploit by Crasher_3637
v2.7 (23 May 2021)
- Fixed Shop Commands does not show in the Admin menu sometime.
v2.6 (4 May 2021)
- Fixed !buy heal command
v2.52 (3 May 2021)
- Changed MaxClients to MAXPLAYERS
- Supported 18+ players' server.
- Fixed sql update statement for SF.
v2.4 (1 May 2021)
- Cleared the hard-coded print text.
- Flxed when player left, SF doesn't not clear.
- Removed cost limitation
v2.3 (30 April 2021)
- Added the checking for Infected Shop (cvar_infected_buy_respawn_on in .cfg)
- Simplified shortcut variables
- Changed the Points Transfer menu title
v2.2 (30 April 2021):
- Changed MaxClients from 20 to 18 to fix Client index 19 is invalid.
- Added !buy <item> command (Shortcut item names provided by: Elite Biker)
- Added disabling option for SF (just set the cost of it to -1)
- Added disabling specified shop
- Added transferring message to all players
- Fixed Infected Shop bug.
- Added cfg cvar_shop_infected_respawn to decide Where player respawn after buying infected
Features:
Native functions call
Save functions (Using SQLite Database, no need to setup anything)
Type !buy <item> in the game to buy an item by command.
type !admin and find 'Shop Commands' to open the shop admin menu.
type !rb or !repeatbuy to repeatedly buy.
type !kill to suicide.
Edit an item cost in the cfg to -1 to disable the item.
You can copy others plugin functions to make your own special functions.
When will save points?
To avoid making the server lag, I just added two triggers for it.
Round end
Player disconnected
Native functions:
Spoiler
PHP Code:
/**
* Gets the version of Shop
* @param buffer string buffer
* @return current version of rank system in form of a float
*/
native int Shop_GetVersion(char[] buffer);
/**
* Get client points
*
* @param client client index
* @return client points
*/
native int Shop_GetPoints(int client);
/**
* Buy item
*
* @param client client index
* @param buffer item name
* @param price item price
* @param team team (default: survivor)
* @return true if buying item is successful
*/
native bool Shop_BuyItem(int client, char[] buffer, int price, int team = 2);
/**
* Upgrade Weapon
*
* @param client client index
* @param buffer item name
* @param price item price
* @return true if buying item is successful
*/
native bool Shop_UpgradeWeapon(int client, char[] buffer, int price);
/**
* Upgrade Weapon
*
* @param client client index
* @param index SF index
* @param price SF price
* @param isPermanent is Permanent
* @return true if buying is successful
*/
native bool Shop_BuySF(int client, int index, int price, bool isPermanent);
/**
* Check is sf on
*
* @param client client index
* @param index SF index
* @return true if sf is on
*/
native bool Shop_IsSFOn(int client, int index);
/**
* Get SF Index by function no.
*
* @param functionNo functionNo (string)
* @return index of functionNo
*/
native int Shop_GetFunctionIndex(char[] functionNo);
/**
* Check is sf on
*
* @param client client index
* @param index SF index
* @param isPermanent isPermanent (default: false)
* @return true if sf is on
*/
native bool Shop_GetClientSFOn(int client, int index, bool isPermanent = false);
/**
* Get Eanbled Ammo Color Index
*
* @param client client index
* @return -1 if not found
*/
native int Shop_GetEanbledAmmoColorIndex(int client);
/**
* Buy function (reduce points)
*
* @param client client index
* @param item item name
* @param price item price
* @param bPrint print purchase is successful?
* @return true if reduciing point is successful
*/
native bool Shop_Checkout(const int client, const char[] item, const int price, bool bPrint = true);
/**
* Check Shop is off
*
* @param client client index
* @param shopId shopId (refer to shop_cv)
* @return true if shop is off
*/
native bool Shop_IsShopOff(int client, int shopId);
/**
* Call an agent to help you buy somethings
*
* @param client client index
* @param shopId shopId (refer to shop_cv)
* @param itemId itemId (refer to shop_cv)
* @return 0
*/
native int Shop_CallAgent(int client, int shopId, int itemId);
/**
* Set SF (round) on/off
*
* @param client client index
* @param sfId sf id
* @param bOn itemId (refer to shop_cv)
* @return 0
*/
native int Shop_SetSFOn(int client, int sfId, bool bOn = true);
/**
* Set first sfid on and set second sfid to false
*
* @param client client index
* @param sfIds sfIds
* @param bSave Will save to DB?
* @return 0
*/
native int Shop_SetSFOffWhenSFOn(int client, int[] sfIds, bool bSave = false);
/**
* Add points to client
*
* @param client client index
* @param points amouint of points
* @param bSave Will save to DB?
* @return 0
*/
native int Shop_AddPoints(int client, int points, bool bSave = false);
/**
* Reduce points to client
*
* @param client client index
* @param point sfIds
* @param bSave Will save to DB?
* @return 0
*/
native int Shop_ReducePoints(int client, int points, bool bSave = false);
/**
* Set client points
*
* @param client client index
* @param point sfIds
* @param bSave Will save to DB?
* @return 0
*/
native int Shop_SetPoints(int client, int points, bool bSave = false);
////
//
/**
* Registers a module for points system
*
* @param modulename String that contains the module to be registered's name
* @return false if successful true if already registered, true should never happen.
*/
native bool Shop_RegisterModule(const char[] modulename);
/**
* Unregisters a module for points system
*
* @param modulename String that contains the module to be unregistered's name
* @return none
*/
native void Shop_UnregisterModule(const char[] modulename);
/**
* Called when Points System is loaded
*
* @return none
*/
forward void OnShopLoaded();
/**
* Called when Points System is unloaded
*
* @return none
*/
forward void OnShopUnloaded();
ConVars:
PHP Code:
// This file was auto-generated by SourceMod (v1.11.0.6825)
// ConVars for plugin "l4d2_shop.smx"
// Will notify all players when a player buy an item? 0=OFF, 1=On
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
shop_buy_notify_all_on "1"
// Shop is on for coop mode? 0=OFF, 1=On
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
shop_coop_on "1"
// How many points buying an adrenaline costs. -1=Disabled
// -
// Default: "43"
shop_cost_adrenaline "43"
// How many points calling an airstrike (crosshair) costs. -1=Disa
// -
// Default: "88"
shop_cost_airstrike_on_crosshair "88"
// How many points calling an airstrike (positin) costs. -1=Disabl
// -
// Default: "88"
shop_cost_airstrike_on_position "88"
// How many points refilling ammo costs. -1=Disabled
// -
// Default: "12"
shop_cost_ammo "12"
// How many points buying a auto shotgun costs. -1=Disabled
// -
// Default: "30"
shop_cost_autoshotgun "30"
// How many points buying a baseball bat costs. -1=Disabled
// -
// Default: "9"
shop_cost_baseball_bat "9"
// How many points buying a chainsaw costs. -1=Disabled
// -
// Default: "16"
shop_cost_chainsaw "16"
// How many points buying a cola bottles costs. -1=Disabled
// -
// Default: "68"
shop_cost_cola_bottles "68"
// How many points buying a cricket bat costs. -1=Disabled
// -
// Default: "9"
shop_cost_cricket_bat "9"
// How many points buying a crowbar costs. -1=Disabled
// -
// Default: "9"
shop_cost_crowbar "9"
// How many points buying a defibrillator costs. -1=Disabled
// -
// Default: "50"
shop_cost_defibrillator "50"
// How many points buying an electric guitar costs. -1=Disabled
// -
// Default: "9"
shop_cost_electric_guitar "9"
// How many points upgrading explosive ammo costs. -1=Disabled
// -
// Default: "12"
shop_cost_explosive_ammo "12"
// How many points buying a extinguisher costs. -1=Disabled
// -
// Default: "40"
shop_cost_extinguisher "40"
// How many points buying a fireaxe costs. -1=Disabled
// -
// Default: "9"
shop_cost_fireaxe "9"
// How many points buying a firework crate costs. -1=Disabled
// -
// Default: "18"
shop_cost_fireworkcrate "18"
// How many points buying a first_aid_kit costs. -1=Disabled
// -
// Default: "88"
shop_cost_first_aid_kit "88"
// How many points buying a flamethrower costs. -1=Disabled
// -
// Default: "-1"
shop_cost_flamethrower "-1"
// How many points buying a frying pan costs. -1=Disabled
// -
// Default: "9"
shop_cost_frying_pan "9"
// How many points buying a gas can costs. -1=Disabled
// -
// Default: "18"
shop_cost_gascan "18"
// How many points buying a gnome costs. -1=Disabled
// -
// Default: "68"
shop_cost_gnome "68"
// How many points buying a golf club costs. -1=Disabled
// -
// Default: "9"
shop_cost_golfclub "9"
// How many points buying a grenade launcher costs. -1=Disabled
// -
// Default: "38"
shop_cost_grenade_launcher "38"
// How many points buying a hunting rifle costs. -1=Disabled
// -
// Default: "25"
shop_cost_hunting_rifle "25"
// How many points upgrading incendiary ammo costs. -1=Disabled
// -
// Default: "12"
shop_cost_incendiary_ammo "12"
// How many points becoming a boomer costs. -1=Disabled
// -
// Default: "10"
shop_cost_infected_boomer "10"
// How many points becoming a charger costs. -1=Disabled
// -
// Default: "7"
shop_cost_infected_charger "7"
// How many points becoming a mega mob costs. -1=Disabled
// -
// Default: "23"
shop_cost_infected_director_force_panic_event "23"
// How many points heal costs. -1=Disabled
// -
// Default: "10"
shop_cost_infected_health "10"
// How many points becoming a hunter costs. -1=Disabled
// -
// Default: "5"
shop_cost_infected_hunter "5"
// How many points becoming a jockey costs. -1=Disabled
// -
// Default: "7"
shop_cost_infected_jockey "7"
// How many points suicide costs. -1=Disabled
// -
// Default: "4"
shop_cost_infected_kill "4"
// How many points generating a mini-event/mob costs. -1=Disabled
// -
// Default: "18"
shop_cost_infected_mob "18"
// How many points becoming a smoker costs. -1=Disabled
// -
// Default: "7"
shop_cost_infected_smoker "7"
// How many points becoming a spitter costs. -1=Disabled
// -
// Default: "7"
shop_cost_infected_spitter "7"
// How many points becoming a tank costs. -1=Disabled
// -
// Default: "50"
shop_cost_infected_tank "50"
// How many points generating a witch costs. -1=Disabled
// -
// Default: "30"
shop_cost_infected_witch "30"
// How many points buying a katana costs. -1=Disabled
// -
// Default: "9"
shop_cost_katana "9"
// How many points buying a knife costs. -1=Disabled
// -
// Default: "5"
shop_cost_knife "5"
// How many points upgrading laser sight costs. -1=Disabled
// -
// Default: "10"
shop_cost_laser_sight "10"
// How many points buying a 3 lethal ammo costs. -1=Disabled
// -
// Default: "60"
shop_cost_lethal_ammo_3 "60"
// How many points buying a fireaxe costs. -1=Disabled
// -
// Default: "9"
shop_cost_machete "9"
// How many points buying a molotov costs. -1=Disabled
// -
// Default: "28"
shop_cost_molotov "28"
// How many points buying a oxygen tank costs. -1=Disabled
// -
// Default: "18"
shop_cost_oxygentank "18"
// How many points buying a pain pills costs. -1=Disabled
// -
// Default: "43"
shop_cost_pain_pills "43"
// How many points buying a pipe bomb costs. -1=Disabled
// -
// Default: "28"
shop_cost_pipe_bomb "28"
// How many points buying a pistol costs. -1=Disabled
// -
// Default: "5"
shop_cost_pistol "5"
// How many points buying a pistol magnum costs. -1=Disabled
// -
// Default: "13"
shop_cost_pistol_magnum "13"
// How many points buying a pitchfork costs. -1=Disabled
// -
// Default: "9"
shop_cost_pitchfork "9"
// How many points buying a SMG costs. -1=Disabled
// -
// Default: "300"
shop_cost_premanent_AUTO_BHOP "300"
// How many points buying a green laser tag costs. -1=Disabled
// -
// Default: "4000"
shop_cost_premanent_BLUE_AMMO "4000"
// How many points buying a green laser tag costs. -1=Disabled
// -
// Default: "6000"
shop_cost_premanent_GOLD_AMMO "6000"
// How many points buying a gary laser tag costs. -1=Disabled
// -
// Default: "1000"
shop_cost_premanent_GRAY_AMMO "1000"
// How many points buying a green laser tag costs. -1=Disabled
// -
// Default: "3000"
shop_cost_premanent_GREEN_AMMO "3000"
// How many points buying a qing gong costs. -1=Disabled
// -
// Default: "300"
shop_cost_premanent_QING_GONG "300"
// How many points buying a red laser tag costs. -1=Disabled
// -
// Default: "9999"
shop_cost_premanent_RED_AMMO "9999"
// How many points buying a propane tank costs. -1=Disabled
// -
// Default: "18"
shop_cost_propanetank "18"
// How many points buying a pumpshotgun costs. -1=Disabled
// -
// Default: "13"
shop_cost_pumpshotgun "13"
// How many points buying a rifle costs. -1=Disabled
// -
// Default: "30"
shop_cost_rifle "30"
// How many points buying an AK47 rifle costs. -1=Disabled
// -
// Default: "30"
shop_cost_rifle_ak47 "30"
// How many points buying a desert rifle costs. -1=Disabled
// -
// Default: "30"
shop_cost_rifle_desert "30"
// How many points buying a heavy gun M60 costs. -1=Disabled
// -
// Default: "160"
shop_cost_rifle_m60 "160"
// How many points buying a SG552 rifle costs. -1=Disabled
// -
// Default: "30"
shop_cost_rifle_sg552 "30"
// How many points buying a shotgun chrome costs. -1=Disabled
// -
// Default: "13"
shop_cost_shotgun_chrome "13"
// How many points buying a shotgun_spas costs. -1=Disabled
// -
// Default: "30"
shop_cost_shotgun_spas "30"
// How many points buying a shovel costs. -1=Disabled
// -
// Default: "9"
shop_cost_shovel "9"
// How many points buying a SMG costs. -1=Disabled
// -
// Default: "13"
shop_cost_smg "13"
// How many points buying a MP5 SMG costs. -1=Disabled
// -
// Default: "13"
shop_cost_smg_mp5 "13"
// How many points buying a Silenced SMG costs. -1=Disabled
// -
// Default: "13"
shop_cost_smg_silenced "13"
// How many points buying an AWP costs. -1=Disabled
// -
// Default: "50"
shop_cost_sniper_awp "50"
// How many points buying a sniper military costs. -1=Disabled
// -
// Default: "25"
shop_cost_sniper_military "25"
// How many points buying a scout costs. -1=Disabled
// -
// Default: "40"
shop_cost_sniper_scout "40"
// How many points buying a tonfa costs. -1=Disabled
// -
// Default: "9"
shop_cost_tonfa "9"
// How many points buying a SMG costs. -1=Disabled
// -
// Default: "30"
shop_cost_trial_AUTO_BHOP "30"
// How many points buying a green laser tag costs. -1=Disabled
// -
// Default: "400"
shop_cost_trial_BLUE_AMMO "400"
// How many points buying a green laser tag costs. -1=Disabled
// -
// Default: "600"
shop_cost_trial_GOLD_AMMO "600"
// How many points buying a gary laser tag costs. -1=Disabled
// -
// Default: "200"
shop_cost_trial_GRAY_AMMO "200"
// How many points buying a green laser tag costs. -1=Disabled
// -
// Default: "300"
shop_cost_trial_GREEN_AMMO "300"
// How many points buying a qing gong costs. -1=Disabled
// -
// Default: "30"
shop_cost_trial_QING_GONG "30"
// How many points buying a red laser tag costs. -1=Disabled
// -
// Default: "999"
shop_cost_trial_RED_AMMO "999"
// How many points buying an explosive upgrade pack costs. -1=Dis
// -
// Default: "18"
shop_cost_upgradepack_explosive "18"
// How many points buying an incendiary upgrade pack costs. -1=Di
// -
// Default: "18"
shop_cost_upgradepack_incendiary "18"
// How many points buying a vomitjar costs. -1=Disabled
// -
// Default: "28"
shop_cost_vomitjar "28"
// Will server save points? 0=OFF, 1=On
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
shop_db_on "1"
// How many points rewarded to player who used defibrillator 0=Disabled
// -
// Default: "5"
// Minimum: "0.000000"
shop_earn_defibrillate "5"
// How many points for healing someone. 0=Disabled
// -
// Default: "5"
// Minimum: "0.000000"
shop_earn_heal "5"
// How many points for killing a certain number of infected. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_earn_infected "1"
// How many killed infected does it take to earn points? Headshot and minigun kills can be used to rank up extra kills. 0=Disabled
// -
// Default: "10"
// Minimum: "0.000000"
shop_earn_infected_num "10"
// How many points for protecting someone. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_earn_protect "1"
// How many points rewarded to player who rescued the dead client. 0=Disabled
// -
// Default: "2"
// Minimum: "0.000000"
shop_earn_rescued "2"
// How many points for reviving someone. 0=Disabled
// -
// Default: "2"
// Minimum: "0.000000"
shop_earn_revive "2"
// How many points for reviving someone who is in ledge hang/ 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_earn_revive_ledge_hang "1"
// How many points for killing a special infected. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_earn_special "1"
// How many points you get for burning a tank. 0=Disabled
// -
// Default: "3"
// Minimum: "0.000000"
shop_earn_tank_burn "3"
// How many additional points you get for killing a tank. 0=Disabled
// -
// Default: "2"
// Minimum: "0.000000"
shop_earn_tank_killed "2"
// How many points you get for killing a witch. 0=Disabled
// -
// Default: "10"
// Minimum: "0.000000"
shop_earn_witch "10"
// How many extra points you get for killing a witch in one shot. 0=Disabled
// -
// Default: "10"
// Minimum: "0.000000"
shop_earn_witch_in_one_shot "10"
// Only dead infected can buy respawn? 0=OFF, 1=On
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
shop_infected_buy_respawn_on "1"
// How many points you get [as a charger] after impact on survivor, for 1 pummel damage. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_infected_earn_charge "1"
// How many points you get [as a charger] when hitting nearby survivors. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_infected_earn_charge_collateral "1"
// How many points you get [as a smoker] when you pull a survivor. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_infected_earn_grab "1"
// How many points infected get for hurting survivors a number of times. 0=Disabled
// -
// Default: "2"
// Minimum: "0.000000"
shop_infected_earn_hurt "2"
// How many points you get for incapacitating a survivor 0=Disabled
// -
// Default: "5"
// Minimum: "0.000000"
shop_infected_earn_incapacitate "5"
// How many points you get when jumping on a survivor. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_infected_earn_jockey_ride "1"
// How many points you get [as a hunter] when you pounce a survivor. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_infected_earn_pounce "1"
// How many points you get for killing a survivor 0=Disabled
// -
// Default: "10"
// Minimum: "0.000000"
shop_infected_earn_survivor "10"
// How many points you get [as a boomer] when you vomit/explode on a survivor. 0=Disabled
// -
// Default: "1"
// Minimum: "0.000000"
shop_infected_earn_vomit "1"
public void OnShopUnloaded()
{
g_isShopLoaded = false;
}
// ====================================================================================================
...
Step 4: Add checking to main code block.
You need to find which function is main on the plugin.
Refer to functions in shop_fn.inc to help you do what you want.)
PHP Code:
public ...
{
if(!Shop_IsSFOn(client, QING_GONG)) return Plugin_Continue; // may return only;
}
Step 5: compile l4d2_shop.sp , all sf sources l4d2_shop_XXXX.sp, and your SF source.
Last step: (Thanks kazya3 for reminding)
Add translation text (l4d2_weapons.phrases.txt):
PHP Code:
"MY_NEW_SF"
{
"en" "MY NEW SF"
}
Ways to add a new Item:
Spoiler
Step 1.
Add the command into the (Find which shop you want to put it into) (find them in shop_cv.inc)
e.g.
}
//<---------- Add an else if(){} here , refer to above. IndexOf(item, 32, "airstrike", 9) != -1 means the item name that has "airstrike", -1 = don't have
else CheatCommand(client, "give", item);