AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help Limit Extra ZP (https://forums.alliedmods.net/showthread.php?t=346982)

hector 03-25-2024 15:51

Help Limit Extra ZP
 
Hello, I would like to receive the help of someone who knows how to set extra item limits for ZP!

Tote 03-26-2024 07:17

Re: Help Limit Extra ZP
 
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;
}



All times are GMT -4. The time now is 17:05.

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