Raised This Month: $32 Target: $400
 8% 

[TUT][ZP50]How to add limit to any Extra item


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 09-25-2013 , 10:52   [TUT][ZP50]How to add limit to any Extra item
Reply With Quote #1

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
PHP Code:
#define MyItem_Limit 10 // This is just an example , put any number u want instead of 10 as limit 

Step 2:-


Make a new variable to store how many times has the use bought our item
PHP Code:
new MyItemHasUser[33// Register a new variable 
Step 3:-

Find something like this : (It might differ from the function below, so jut make sure it has "zp_fw_items_select_pre")
PHP Code:
public zp_fw_items_select_pre(iditemidig//This function is called before a user has bought an extra item 
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:
PHP Code:
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...         
 
       

then in it add smthing like this:
PHP Code:
new text[32// Make a new buffer text to add
format(textcharsmax(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 menu 
After that to check the condition add this
PHP Code:
 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
            

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")
PHP Code:
public zp_fw_items_select_post(iditemidig// this is a function called after a use selects an extra item
{
         
blablabla...... // the rest of the code of the function


In that find
PHP Code:
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
       

then put this part of code in it
PHP Code:
       MyItemHasUser[id]++  // Increase the variable (purchase) by 1 
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
PHP Code:
public zp_fw_core_spawn_post(id)
{
       
MyItemHasUser[id] = 0  // To reset the variable at new spawn so that purchases become 0





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


Credits:-

Me
Blizzard_87 (Correcting me so that no one gets confused)
__________________
You will find everything u need :-

Last edited by Catastrophe; 09-30-2013 at 01:50.
Catastrophe is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 09-26-2013 , 07:06   Re: [TUT][ZP50]How to add limit to any Extra item
Reply With Quote #2

This is a very poorly written tutorial.

Your "step by step" instructions go into basically no detail whatsoever.
Your item limit has been defined as a string but should be an integer.
There is no consistency in your variable names - they completely change.
You have not said anything about linking MyRegisteredItem to the correct menu item.

How is anybody supposed to make sense of this? This tutorial looks like its targeted users who do not have scripting experience ... How are they supposed to pick up the pieces?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 09-26-2013 , 10:50   Re: [TUT][ZP50]How to add limit to any Extra item
Reply With Quote #3

It is actually targetted for ppl who do not have scripting experience..... if u wud look at any zp extra item code, u'd know what this tutorial is about..... no consistency in my variables ?? LOL.

My steps go in no detail ? WTF does the first line mean ?

MyRegisteredItem isnt a menu item its a pre-registered extra item for fucks sake, that is to check whether the forward is for that specific item or not...

My limit has been defined as a string ? I never knew anyone cud be so dumb/prurposely.annoying ....... (FFS "How much limit u want" this means a number that u want)

Its not about making sense out of anything, its about how can i atealst "help" in stopping those morons out there from asking for the same thing over and over again.....

So if u dont like it/ think its poorly written u better stfu ......

__________________
You will find everything u need :-

Last edited by Catastrophe; 09-26-2013 at 10:53.
Catastrophe is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 09-28-2013 , 00:04   Re: [TUT][ZP50]How to add limit to any Extra item
Reply With Quote #4

Quote:
Originally Posted by Catastrophe View Post
My limit has been defined as a string ? I never knew anyone cud be so dumb/prurposely.annoying ....... (FFS "How much limit u want" this means a number that u want)
you still dont get it...

Code:
#define MyItem_Limit "How much limit u want" // The limit that we want

the part in quotes "" means your defining a string...

to define a integer you just put the number without quotes...

Code:
#define MyItem_Limit 10 // The Limit Can Be What Ever Number You Want This Is Just Example

before you call someone dumb/purposely annoying you should try to understand there corrections.
__________________

Last edited by Blizzard_87; 09-28-2013 at 00:06.
Blizzard_87 is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 09-30-2013 , 01:48   Re: [TUT][ZP50]How to add limit to any Extra item
Reply With Quote #5

No, i always use "<>" or "" to show someone where to put the value..... but obviously if u dint understand that i shud use <> than "" so..... but i actually had no idea that u/anyone else wud take "How much u want" as a string since what i meant by that was actually <How much u want> ....

NVM, ill edit the first post so that no one gets confused

And i do think before calling ppl dumb/purposely annoying unless they assault me w/o properly explaining my mistakes...... unlike you thanks again
__________________
You will find everything u need :-

Last edited by Catastrophe; 09-30-2013 at 01:53.
Catastrophe is offline
Reply



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 15:26.


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