[TUT][ZP50]How to add limit to any Extra item
Posted: Mon Sep 28, 2026 12:23 pm
So this tutorial is about how to add limit to any extra item in ZP50, since i saw a lot of "limiting" requests.......
So First of all,
Step 1 :-
Add a define on how much limit u want for that item
Step 2:-
Make a new variable to store how many times has the use bought our item
Step 3:-
Find something like this : (It might differ from the function below, so jut make sure it has "zp_fw_items_select_pre")
And there check if the user has bought the item within the limit and show how much more he can buy beside the name of the item in the menu
Using smthing like this
First find this:
then in it add smthing like this:
After that to check the condition add this
So now we are done with the checking and restricting part....
Step 4:-
Find this: (Again it can differ just make sure it has "zp_fw_items_select_post")
In that find
then put this part of code in it
So this will increase the variable by 1 per purchase
Step 5:-
To finally reset variables on every new spawn (new round or after becoming zombie) add this anywhere in the code
NOTE:- Here "MyRegisteredItem", "MyItemHasUser" etc are variables so dont stick to them, in the real code they might be named different so try to find similarities between this and the code u wanna edit......... that will help u understand
So First of all,
Step 1 :-
Add a define on how much limit u want for that item
Code: Select all
#define MyItem_Limit 10 // This is just an example , put any number u want instead of 10 as limit Make a new variable to store how many times has the use bought our item
Code: Select all
new MyItemHasUser[33] // Register a new variable Find something like this : (It might differ from the function below, so jut make sure it has "zp_fw_items_select_pre")
Code: Select all
public zp_fw_items_select_pre(id, itemid, ig) //This function is called before a user has bought an extra item Using smthing like this
First find this:
Code: Select all
if(itemid == MyRegisteredItem) // This checks whether it is our item or not
{
blablablab............. // rest of the code that restricts the item for zombies/human/neme/surv etc...
} Code: Select all
new text[32] // Make a new buffer text to add
format(text, charsmax(text), "[%d/%d]", g_flare[id],FLARE_LIMIT) // Format it to what we want
zp_items_menu_text_add(text) // add the text after the items name in the menuCode: Select all
if(MyItemHasUser[id] >= MyItem_Limit) // check whether the users purchase are greater than / equal to the limit
{
return ZP_ITEM_NOT_AVAILABLE // this "return" is used to not let the use purchase the item if his purchase has reached the limit
}Step 4:-
Find this: (Again it can differ just make sure it has "zp_fw_items_select_post")
Code: Select all
public zp_fw_items_select_post(id, itemid, ig) // this is a function called after a use selects an extra item
{
blablabla...... // the rest of the code of the function
} Code: Select all
if(itemid == MyRegisteredItem) // This part of the code checks whether it is our item or not
{
blablab.......... // the rest of the code in this function
} Code: Select all
MyItemHasUser[id]++ // Increase the variable (purchase) by 1Step 5:-
To finally reset variables on every new spawn (new round or after becoming zombie) add this anywhere in the code
Code: Select all
public zp_fw_core_spawn_post(id)
{
MyItemHasUser[id] = 0 // To reset the variable at new spawn so that purchases become 0
}