Plugin: [BB] Addon: Ammo-Pack System
Author: crnova
Latest Version: 2.2
Date Updated: 27/03/2016
Description:
- This plugin adds in an API Shop with the Ammo-Pack currency similar to that one of
Zombie Plague Mod.
Features:
- API Shop.
- Hud Info.
- nVault saving.
- Ammo-Pack rewards for both humans & zombies.
- Ammo-Pack as price.
Shop items:
-
https://forums.alliedmods.net/showthread.php?p=2396454
Screenshots:
- None at the moment......
Requirements:
-
Base Builder
- Modules
Api Tutorial:
- Alright so i'm gonna show you how to make your shop item for the Ammo-Pack API Shop, first thing you should do is register the shop item you're about to add:
PHP Code:
public plugin_init()
{
bb_shop_item_add( "Double Health", 50, 0, "DoubleHealth_Handler")
}
The first parameter is the name of the shop item that's gonna show up in the shop menu, the second parameter is the price for the item, the third parameter is for which team is the item gonna show up to
0 = All
1 = Zombie
2 = Human
and the last parameter is the item handler,
Example for item Handler:
PHP Code:
public DoubleHealth_Handler(id)
{
set_user_health( id, get_user_health(id) * 2)
}
Basically what the item will do, is double the purchaser's health, in example before we bought the item, our health was 2000, after we bought the item it's 4000.
full version:
PHP Code:
#include <amxmisc> //No need to include amxmodx, because when amxmisc is included, amxmodx is included too
#include <fun> // the include that's gonna handle our "set_user_health" function
#include <bb_ammopacks> // required for our bb_shop_item_add function
//Initialize our sub-plugin
public plugin_init()
{
bb_shop_item_add( "Double Health", 50, 0, "DoubleHealth_Handler") //Add our shop item
}
//Handle our shop item
public DoubleHealth_Handler(id)
{
set_user_health( id, get_user_health(id) * 2) //the function that's gonna double the purchaser's health.
}
Cvars, Commands and Natives:
Cvars:
PHP Code:
// Ammopack reward for the zombie that killed the human.
// default = "25"
ap_human_killed_reward "25"
// Ammopack reward for the human that killed the zombie.
// default = "5"
ap_zombie_killed_reward "5"
// 1 for steamid, 2 for IP, 3 for name.
// default = "1"
ap_save_type "1"
Commands:
Code:
"say /donate <name> <amount>" // Donates your money to <name>.
"say /shop" // Opens our shop menu
"amx_give_ap <name> <amount>" // Gives our target Ammo-pack, accessible only by immunity admins!
"amx_remove_ap <name> <amount>" //Takes ammo-pack from our target, accessible only by immunity admins!
Natives:
PHP Code:
/*
* @param szName Item Name
* @param iCost Item Cost
* @param iTeam Item Team 0 = All, 1 = Zombie, 2 = Human
* @param szHandler Item Function Handler
*/
native bb_shop_item_add( const szName[], const iCost, const iTeam, const szHandler[])
/*
* @param Index player index
* @return returns player index ammo pack
*/
native bb_get_user_ap(Index)
/*
* @param Index player index
* @param iAmount player index
*/
native bb_set_user_ap( Index, iAmount)
Changelog
v1.0
v1.1
- Added bb_set_user_ap native
v2.0
- Added a third param for bb_shop_item_add native, (iTeam).
- Added /donate command, Usage : say /donate "Name" "Amount".
- Fixed bugs.
- Optimized Code.
v2.1
- Fixed bugs.
- Added an fcvar to detect servers using this plugin.
- Added ap_save_type cvar as requested by MrMoHanD.
- Optimized Code.
v2.2
Credits:
-
MeRcyLeZZ for the idea.
-
MrMoHanD for the "get_auth( index, data, len)" function.
Installation:
- "bb_ammopacks.inc" file will go in 'addons\amxmodx\scripting\includes' folder.
- "bb_ammopacks.amxx" will go in 'addons\amxmodx\plugins' folder.
- Open "plugins.ini" from 'addons\amxmodx\configs' folder, and add the line 'bb_ammopacks.amxx' without the '.
Downloads are down below.