Thread: Item limit
View Single Post
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 01-20-2021 , 03:07   Re: Item limit
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
Use menu callbacks to disable menu items for the items that a player is not allowed to get. In the callback, you can check for anything that you want. In your example, it would be a check to see if the player is full on that item and return ITEM_DISABLED.

A little advice:
Instead of the "if else if else..." for the variable "key", use a switch. It will be more efficient and be easier to read/understand.

Also, this if else if doesn't account for the case where limit_firenade[id] is equal to 2. However, if you do the menu item disabling with the callbacks, you can basically remove that check anyways.

Code:
        if(limit_firenade[id] < 2)
        {
            give_item(id, "weapon_hegrenade")
            limit_firenade[id]++
        }
        else if(limit_firenade[id] > 2)
        {
            client_printcolored(id, "!g[=SG=] !nYou have reached the limit !t[2/2]")
        }
i think he can use a code such like this, i'm not use, i do not tested ever, but i think it will works

Code:
firename_limit[id] < max_limit ? give_item(id, "weapon_hegrenade") : return ITEM_DISABLED;
__________________
LondoN is offline