Raised This Month: $51 Target: $400
 12% 

Help Limit Extra ZP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hector
New Member
Join Date: Mar 2024
Old 03-25-2024 , 15:51   Help Limit Extra ZP
Reply With Quote #1

Hello, I would like to receive the help of someone who knows how to set extra item limits for ZP!
hector is offline
Tote
Senior Member
Join Date: Jul 2023
Old 03-26-2024 , 07:17   Re: Help Limit Extra ZP
Reply With Quote #2

Hi, you can do the following:

1. Make a global for limit for player: new g_iLimit[33];
2. Set g_iLimit[id] to 0 on client_disconnected & client_putinserver.
3. Now, when on selection case put g_iLimit[id]++ it will add +1 to limit for example if its for limit 1
4. Before selection case make a check like
if(g_iLimit[id] == 1) {
client_print(id,print_chat, "Oops seems like you've hit the limit!")
return PLUGIN_HANDLED ;
}
5. Done.

An example is given here.

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"

new g_iLimit[33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /menu", "menux")
	RegisterHam(Ham_Spawn, "player", "fw_Spawn", 1)
}

public client_putinserver(id) {
	g_iLimit[id] = 0
}
public client_disconnected(id) {
	g_iLimit[id] = 0
}
public fw_Spawn(id) {
	g_iLimit[id] = 0
}

public menux(id) {
	new menu = menu_create("example menu", "menu_handler")
	
	menu_additem(menu, "ITEM", "", 0)
	
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, menu, 0)
}

public menu_handler(id,menu,item) {
	if(item == MENU_EXIT) {
		menu_destroy(menu)
	}
	
	if(is_user_connected(id))
	{
		switch(item) {
			case 1: {
				if(g_iLimit[id] == 1) // if want limit 1 then == 1 if 2 == 2 and increase like this so on
				{
					client_print(id, print_chat, "Oops! Seems like you've hit the item limit!")
					return PLUGIN_HANDLED;
				}
				g_iLimit[id]++
                                // Here give the Item
				client_print(id, print_chat, "You've selected the item for %d time", g_iLimit[id])
			}
		}
	}
	return PLUGIN_HANDLED;
}

Last edited by Tote; 03-26-2024 at 07:19.
Tote 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 04:15.


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