-------------------------------------------------- Info:
I will make this as simple as i can from the start to finish.
Makeing extra item for zombies that will give them evolution in type of more HP and so on.
Nothing to complicated step by step. --------------------------------------------------
-------------------------------------------------- 1. Start (Setting Autor Plugin Name And Version) --------------------------------------------------
Spoiler
PHP Code:
#include < amxmodx >
#define _PLUGIN "[ZP] TUT Extra item with limit" #define _VERSION "1.0" #define _AUTHOR "H.RED.ZONE"
public plugin_init() { register_plugin(_PLUGIN, _VERSION, _AUTHOR) }
-------------------------------------------------- 2. Item Setting up (Adding item to the zp 5.0 Menu) --------------------------------------------------
#define _PLUGIN "[ZP] TUT Extra item with limit" #define _VERSION "1.0" #define _AUTHOR "H.RED.ZONE"
// Add define for item cost and its name. #define _COST 50 #define _NAME "Zombie Evolutio"
// Used to store 1 item ID new _gItemID
public plugin_init() { register_plugin(_PLUGIN, _VERSION, _AUTHOR)
// We use defines its same as setting instead _COST = 50 // zp_items_register is used to add item to menu so you register it. _gItemID = zp_items_register(_NAME, _COST) }
-------------------------------------------------- NOTE:
Now you will have an error in that code that item id is not used.
So lets use it in zp forwards. --------------------------------------------------
-------------------------------------------------- 3. ZP Forwards. --------------------------------------------------
We have 2 forwards that we use in item so lets start with First one.
I. "zp_fw_items_select_post" Lets add it.
#define _PLUGIN "[ZP] TUT Extra item with limit" #define _VERSION "1.0" #define _AUTHOR "H.RED.ZONE"
// Add define for item cost and its name.
#define _COST 50 #define _NAME "Zombie Evolutio"
// Used to store 1 item ID
new _gItemID
public plugin_init() { register_plugin(_PLUGIN, _VERSION, _AUTHOR)
// We use defines its same as setting instead _COST = 50 // zp_items_register is used to add item to menu so you register it. _gItemID = zp_items_register(_NAME, _COST) }
// Event when item is taken from extra item menu. // We have now "id" and "_itemid"
public zp_fw_items_select_post(id, _itemid, ignorecost) {
// We add IF Our item is _gItemID if (_itemid == _gItemID) {
// And if user is alive that is our ID = Players ID. if(is_user_alive(id)) {
// Now we set what happens when you get item. } } }
-------------------------------------------------- 4. Adding who has item. --------------------------------------------------
Adding second part this is a part that can set what player can buy item and limit to item same as who can take item and so on
II. "zp_fw_items_select_pre"
#define _PLUGIN "[ZP] TUT Extra item with limit" #define _VERSION "1.0" #define _AUTHOR "H.RED.ZONE"
// Add define for item cost and its name.
#define _COST 50 #define _NAME "Zombie Evolutio"
// Used to store 1 item ID
new _gItemID
public plugin_init() { register_plugin(_PLUGIN, _VERSION, _AUTHOR)
// We use defines its same as setting instead _COST = 50 // zp_items_register is used to add item to menu so you register it.
_gItemID = zp_items_register(_NAME, _COST) }
// Event when item is taken from extra item menu. // We have now "id" and "_itemid"
public zp_fw_items_select_post(id, _itemid, ignorecost) {
// We add IF Our item is _gItemID if (_itemid == _gItemID) {
// And if user is alive that is our ID = Players ID. if(is_user_alive(id)) {
// Now we set what happens when you get item. } } }
// Set who can have item.
public zp_fw_items_select_pre(id, itemid) {
// We add IF Our item is _gItemID if (itemid == _gItemID) {
// If user is zombie (id) of a pleyer if (zp_core_is_zombie(id)) {
// Return item is available. return ZP_ITEM_AVAILABLE; }
// Else if he is not zombie it will be returned. return ZP_ITEM_DONT_SHOW }
// And this needs to be available always because its for other item // it is not our item. return ZP_ITEM_AVAILABLE; }
-------------------------------------------------- 5. Adding Limit to item. -------------------------------------------------- Info: Limit is added to item in "zp_fw_items_select_pre"
So now i will show you.
The first one is for single player so it will not limit for whole team.
I. Single Player Limit.
Spoiler
PHP Code:
// We add this
// Added limit for 1 player not whole team. new _gLimit[33]
// Find MaxPlayers On Server new g_MaxPlayers
// In public plugin_init() // We add. g_MaxPlayers = get_maxplayers()
// That will be used to loop every player. // So we can remove limit when round is ended.
// We add this when item is used. _gLimit[id]++
// Later we use this to remove in new round. _gLimit[plr] = 0
// And finally we will add this. // in our pre so we limit to number 2 It can be used 2 times // After that it will return iten NOT AVAILABLE
// So we have. // ZP_ITEM_AVAILABLE // You can buy it. // ZP_ITEM_NOT_AVAILABLE // It will be in the list but it will be closed. // ZP_ITEM_DONT_SHOW // It won't show in the list.
static text[32]
formatex ( text , charsmax ( text ) , "[%d/%d]" , _gLimit[id] , 2 ) // Number 2 is our limit.
// Thanks to zp items we have this. zp_items_menu_text_add ( text )
// If limit is 2 or more. if ( _gLimit[id] >= 2 )
// Not available return ZP_ITEM_NOT_AVAILABLE;
II. For Whole Team
Spoiler
PHP Code:
// We add this
// Added limit for whole team not 1 player. new _gLimit
// We add this when item is used. _gLimit++
// Later we use this to remove in new round. _gLimit = 0
// And finally we will add this. // in our pre so we limit to number 2 It can be used 2 times // After that it will return iten NOT AVAILABLE
// So we have. // ZP_ITEM_AVAILABLE // You can buy it. // ZP_ITEM_NOT_AVAILABLE // It will be in the list but it will be closed. // ZP_ITEM_DONT_SHOW // It won't show in the list.
static text[32]
formatex ( text , charsmax ( text ) , "[%d/%d]" , _gLimit , 2 ) // Number 2 is our limit.
// Thanks to zp items we have this. zp_items_menu_text_add ( text )
// If limit is 2 or more. if ( _gLimit >= 2 )
// Not available return ZP_ITEM_NOT_AVAILABLE;
//So we don't need loop and we don't need players id.
Full code for evolution item.
1 Player.
Spoiler
PHP Code:
#include < amxmodx >
// Add to set health.
#include < fun >
// Adding includes you dont need all if you want to meke item more advance use them. // If survivor has item and nemesis and soo on... #include <zp50_items> #include <zp50_class_survivor> #include <zp50_class_nemesis>
#define _PLUGIN "[ZP] TUT Extra item with limit" #define _VERSION "1.0" #define _AUTHOR "H.RED.ZONE"
// Add define for item cost and its name.
#define _COST 50 #define _NAME "Zombie Evolutio"
// Used to store 1 item ID
new _gItemID
// Added limit for 1 player not whole team. new _gLimit[33]
// Get max players. new g_MaxPlayers
public plugin_init() { register_plugin(_PLUGIN, _VERSION, _AUTHOR)
// We use defines its same as setting instead _COST = 50 // zp_items_register is used to add item to menu so you register it.
// Get Max Players. g_MaxPlayers = get_maxplayers() }
// Event when item is taken from extra item menu. // We have now "id" and "_itemid"
public zp_fw_items_select_post(id, _itemid, ignorecost) {
// We add IF Our item is _gItemID if (_itemid == _gItemID) {
// And if user is alive that is our ID = Players ID. if(is_user_alive(id)) {
// +1 :) _gLimit[id]++
// Set double hp. set_user_health(id, get_user_health(id) * 2)
// Now we set what happens when you get item. } } }
// Set who can have item.
public zp_fw_items_select_pre(id, itemid) {
// We add IF Our item is _gItemID if (itemid == _gItemID) {
// If user is zombie (id) of a pleyer if (zp_core_is_zombie(id)) {
// Return item is available. return ZP_ITEM_AVAILABLE; }
// Our code for limit "2" static text[32] formatex ( text , charsmax ( text ) , "[%d/%d]" , _gLimit[id] , 2 ) zp_items_menu_text_add ( text )
// You can use this with cvar instead of number 2 // Like in my Gas Mask code. if ( _gLimit[id] >= 2 ) return ZP_ITEM_NOT_AVAILABLE;
// Else if he is not zombie it will be returned. return ZP_ITEM_DONT_SHOW }
// And this needs to be available always because its for other item // it is not our item. return ZP_ITEM_AVAILABLE; }
// We add an event. public NewRound() {
// Loop. for ( new plr; plr <= g_MaxPlayers; plr++) {
// Set back to 0 on round end. _gLimit[plr] = 0 } }
Whole Team.
Spoiler
PHP Code:
#include < amxmodx >
// Add to set health.
#include < fun >
// Adding includes you dont need all if you want to meke item more advance use them. // If survivor has item and nemesis and soo on... #include <zp50_items> #include <zp50_class_survivor> #include <zp50_class_nemesis>
#define _PLUGIN "[ZP] TUT Extra item with limit" #define _VERSION "1.0" #define _AUTHOR "H.RED.ZONE"
// Add define for item cost and its name.
#define _COST 50 #define _NAME "Zombie Evolutio"
// Used to store 1 item ID
new _gItemID
// Added limit for whole team. new _gLimit
public plugin_init() { register_plugin(_PLUGIN, _VERSION, _AUTHOR)
// We use defines its same as setting instead _COST = 50 // zp_items_register is used to add item to menu so you register it.