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
} 