Sunday, 20 March 2016

Plugin: [BB] Addon: Ammo-Pack System

Plugin: [BB] Addon: Ammo-Pack System
Author: crnova
Latest Version: 2.0
Date Updated: 20/03/2016


Description:


- This plugin adds in an Ammo-Pack system 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


size="5"][color=orange]Requirements:[/size][/size]


- Base Buildes

- Modules
Code:
#include <hamsandwich>
#include <nvault>
#include <fakemeta>
Api Tutorial:

- Alright so i'm gonna show you how to make your sub-plugin for the Ammo-Pack API Shop, first thing you should do is register the shop item you're about to add, now in example



PHP Code:
public plugin_init()
{
    
bb_shop_item_add"Double Health"500"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_healthidget_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.

the full sub-plugin is gonna look like this



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"501"DoubleHealth_Handler"//Add our shop item}//Handle our shop itempublic DoubleHealth_Handler(id)
{
    
set_user_healthidget_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"  
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_apIndexiAmount)  

Changelog


v1.0

  • Released

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 lots of bugs
  • Optimized Code


Credits:


MeRcyLeZZ for the idea.


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 '.

Download Link:


http://sh.st/TZqVT

No comments:

Post a Comment