Raised This Month: $318 Target: $400
 79%   Almost there!

[BB] Addon: Ammo-Pack System v2.2 [API Shop, nVault Saving, AP Rewards and more!]


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
crnova
Senior Member
Join Date: Sep 2015
Old 02-23-2016 , 16:03   [BB] Addon: Ammo-Pack System v2.2 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #1

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
Code:
nvault
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"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.

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"500"DoubleHealth_Handler"//Add our shop item
}

//Handle our shop item
public 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"

// 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_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 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
  • Fixed bugs.


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.
Attached Files
File Type: inc bb_ammopacks.inc (1.0 KB, 810 views)
File Type: sma Get Plugin or Get Source (bb_ammopacks.sma - 2030 views - 12.0 KB)
__________________

Last edited by crnova; 04-02-2016 at 17:20.
crnova is offline
NyTe
Junior Member
Join Date: Nov 2015
Old 02-24-2016 , 12:58   Re: [BB] Addon: Ammo-Pack System v1.1 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #2

Great plugin, bb's slowly getting upgrades.
NyTe is offline
crnova
Senior Member
Join Date: Sep 2015
Old 02-24-2016 , 13:01   Re: [BB] Addon: Ammo-Pack System v1.1 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #3

Quote:
Originally Posted by NyTe View Post
Great plugin, bb's slowly getting upgrades.
Thanks for the feedback i'm working on more BB plugins
__________________
crnova is offline
MrMoHanD
Junior Member
Join Date: Mar 2016
Old 03-19-2016 , 13:06   Re: [BB] Addon: Ammo-Pack System v1.1 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #4

Great Scripting Bro,
you should add Team Parameter
bb_shop_item_add( "item name", "item coast", "item team", "item_Handler" )
Wainting For The Updates

Last edited by MrMoHanD; 03-19-2016 at 13:06.
MrMoHanD is offline
crnova
Senior Member
Join Date: Sep 2015
Old 03-20-2016 , 07:51   Re: [BB] Addon: Ammo-Pack System v1.1 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #5

Quote:
Originally Posted by MrMoHanD View Post
Great Scripting Bro,
you should add Team Parameter
bb_shop_item_add( "item name", "item coast", "item team", "item_Handler" )
Wainting For The Updates
Added
__________________
crnova is offline
MrMoHanD
Junior Member
Join Date: Mar 2016
Old 03-21-2016 , 15:58   Re: [BB] Addon: Ammo-Pack System v2.0 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #6

Great Man,
tested and works perfectly
please how to save ammo on Player Name not on SteamID
MrMoHanD is offline
MrMoHanD
Junior Member
Join Date: Mar 2016
Old 03-21-2016 , 17:09   Re: [BB] Addon: Ammo-Pack System v2.0 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #7

Bug: The New Connected Player Got the latest players ammo
Fix + Add : How to save ammo (SteamID, IP, Name)
Remove
PHP Code:
public client_authorized(id)
    
get_user_authididg_szAuthID[id], charsmax(g_szAuthID[])) 
Replace
PHP Code:
public client_putinserver(id)
{
    
load_ap(id)
    
set_task0.1"hud_info"id__"b")

by
PHP Code:
public client_connect(id){
    
load_ap(id)
}
public 
client_putinserver(id)
{
    
set_task0.1"hud_info"id__"b")

replace line 31 by
PHP Code:
new cvar_human_killed_rewardcvar_zombie_killed_rewardcvar_save_type 
before this line
PHP Code:
cvar_zombie_killed_reward register_cvar"ap_zombie_killed_reward""5"
add the following
PHP Code:
cvar_save_type register_cvar("ap_save_type","3"); // 1- SteamID 2-IP 3-Name 
and replace those 2 fuctions
PHP Code:
public save_ap(id)
public 
load_ap(id
by
PHP Code:
public save_ap(id)
{
    new 
szAP[7]
    new 
szKey[40]
    
get_auth(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
formatexszKeycharsmax(szKey), "%sAMMOPACK"g_szAuthID[id])
    
formatexszAPcharsmax(szAP), "%d"g_AP[id])
    
    
nvault_setg_VaultszKeyszAP)
}


public 
load_ap(id)
{
    new 
szAP[7]
    new 
szKey[40]
    
get_auth(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
formatexszKeycharsmax(szKey), "%sAMMOPACK"g_szAuthID[id])
    
formatexszAPcharsmax(szAP), "%d"g_AP[id])
    new 
iAP nvault_getg_VaultszKey)
    if(
iAP)
    {
        
g_AP[id] = iAP
        nvault_remove
g_VaultszKey)
    }

and finaly add stock at the end of file
PHP Code:
stock get_auth(id,data[],len)
    switch(
get_pcvar_num(cvar_save_type)) {
        case 
1get_user_authid(id,data,len);
        case 
2get_user_ip(id,data,len,1);
        case 
3get_user_name(id,data,len);

if i'm somewhere wrong please let me know.. and hope to see that on next updates

Last edited by MrMoHanD; 03-26-2016 at 18:40.
MrMoHanD is offline
crnova
Senior Member
Join Date: Sep 2015
Old 03-21-2016 , 17:54   Re: [BB] Addon: Ammo-Pack System v2.0 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #8

thanks, will be added in the update
__________________
crnova is offline
MrMoHanD
Junior Member
Join Date: Mar 2016
Old 03-21-2016 , 18:16   Re: [BB] Addon: Ammo-Pack System v2.0 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #9

Quote:
Originally Posted by crnova View Post
thanks, will be added in the update
great, and as a suggestion
you sould delete
PHP Code:
if(bb_is_prep_phase())
    {
        
client_print_colorid"You cannot use this command during ^3Prep-Phase^1.")
        
        return 
PLUGIN_HANDLED
    

because in prepare phase we should prepare our selves to zombies
MrMoHanD is offline
crnova
Senior Member
Join Date: Sep 2015
Old 03-25-2016 , 10:08   Re: [BB] Addon: Ammo-Pack System v2.0 [API Shop, nVault Saving, AP Rewards and more!]
Reply With Quote #10

Quote:
Originally Posted by MrMoHanD View Post
great, and as a suggestion
you sould delete
PHP Code:
if(bb_is_prep_phase())
    {
        
client_print_colorid"You cannot use this command during ^3Prep-Phase^1.")
        
        return 
PLUGIN_HANDLED
    

because in prepare phase we should prepare our selves to zombies
added
__________________
crnova is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:27.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode