Raised This Month: $ Target: $400
 0% 

Edit this plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-25-2024 , 05:21   Edit this plugin
Reply With Quote #1

I use this plugin for my 35hp server but I don't know why all people with ADMIN_IMMUNITY can select any knife whether they have the required level or not. How can I solve this?



PHP Code:
public KnifeSkinsMenu(id) { 
    
    new 
szItem[256], szAlien[50], szEllium[50], szDark[50], szTransparent[50], szGenuine[50], szHunt[50], szShadow[50], szSlaughterer[50], szKatana[50], szAssasins[50],
    
szLightsaber[50], szWolverine[50], szProton[50];
    
    new 
level iLevel[id] > iLevel[id] : 1;
    
    new 
xp level StartedLevel;
    
    if( 
iLevel[id] > )
    {
        
xp +=  ( xp );
    }
    
    
formatex(szItemcharsmax(szItem), "\w[ \r%s \w] \yKnife Skins Menu \rv%s^n\yYour Level: \r%d \w- \yYour XP: \r%d\w/\r%d\w.^n\yPage:\r"g_VAULTNAMEVERSION,iLevel[id],iXp[id], xp);
    
formatex(szAliencharsmax(szAlien),"%s"iLevel[id] >= "\wAlien Knife [\yUNLOCKED\w]" "\d???? ????? [\rLEVEL 1 REQUIRE\d]");
    
formatex(szElliumcharsmax(szEllium),"%s"iLevel[id] >= "\wEllium Knife [\yUNLOCKED\w]" "\d?????? ?????? [\rLEVEL 2 REQUIRE\d]");
    
formatex(szDarkcharsmax(szDark),"%s"iLevel[id] >= "\wDark Dagger [\yUNLOCKED\w]" "\d???? ?????? [\rLEVEL 3 REQUIRE\d]");
    
formatex(szTransparentcharsmax(szTransparent),"%s"iLevel[id] >= "\wTransparent Knife [\yUNLOCKED\w]" "\d??????????? ????? [\rLEVEL 4 REQUIRE\d]");
    
formatex(szGenuinecharsmax(szGenuine),"%s"iLevel[id] >= "\wGenuine Dagger [\yUNLOCKED\w]" "\d??????? ?????? [\rLEVEL 5 REQUIRE\d]");
    
formatex(szHuntcharsmax(szHunt),"%s"iLevel[id] >= "\wHunt Blade [\yUNLOCKED\w]" "\d???? ????? [\rLEVEL 6 REQUIRE\d]");
    
formatex(szShadowcharsmax(szShadow),"%s"iLevel[id] >= "\wShadow Blade [\yUNLOCKED\w]" "\d?????? ????? [\rLEVEL 7 REQUIRE\d]");
    
formatex(szSlaughterercharsmax(szSlaughterer),"%s"iLevel[id] >= "\wSlaughterer Axe [\yUNLOCKED\w]" "\d??????????? ??? [\rLEVEL 8 REQUIRE\d]");
    
formatex(szKatanacharsmax(szKatana),"%s"iLevel[id] >= "\wGolden Katana [\yUNLOCKED\w]" "\d?????? ?????? [\rLEVEL 9 REQUIRE\d]");
    
formatex(szAssasinscharsmax(szAssasins),"%s"iLevel[id] >= 10 "\wAssasin's Blade [\yUNLOCKED\w]" "\d???????? ????? [\rLEVEL 10 REQUIRE\d]");
    
formatex(szLightsabercharsmax(szLightsaber),"%s"iLevel[id] >= 11 "\wLightsaber [\yUNLOCKED\w]" "\d?????????? [\rLEVEL 11 REQUIRE\d]");
    
formatex(szWolverinecharsmax(szWolverine),"%s"iLevel[id] >= 12 "\wBloody Wolverine Claws [\yUNLOCKED\w]" "\d?????? ????????? ????? [\rLEVEL 12 REQUIRE\d]");
    
formatex(szProtoncharsmax(szProton),"%s"iLevel[id] >= 13 "\wProton Axe [\yUNLOCKED\w]" "\d?????? ??? [\rLEVEL 13 REQUIRE\d]");
    
    new 
menu menu_createszItem"KnifeSkinsMenu_Handler" ); 
    
menu_additem(menu"\wNormal Knife [\yUNLOCKED\w]""");
    
menu_additem(menuszAlien""iLevel[id] >= 1);
    
menu_additem(menuszEllium""iLevel[id] >= 1);
    
menu_additem(menuszDark""iLevel[id] >= 1);
    
menu_additem(menuszTransparent""iLevel[id] >= 1);
    
menu_additem(menuszGenuine""iLevel[id] >= 1);
    
menu_additem(menuszHunt""iLevel[id] >= 1);
    
menu_additem(menuszShadow""iLevel[id] >= 1);
    
menu_additem(menuszSlaughterer""iLevel[id] >= 1);
    
menu_additem(menuszKatana""iLevel[id] >= 1);
    
menu_additem(menuszAssasins""iLevel[id] >= 10 1);
    
menu_additem(menuszLightsaber""iLevel[id] >= 11 1);
    
menu_additem(menuszWolverine""iLevel[id] >= 12 1);
    
menu_additem(menuszProton""iLevel[id] >= 13 1);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL );
    
menu_display(idmenu);
    
    return 
PLUGIN_HANDLED;


Last edited by JuanitoAlimana; 04-25-2024 at 05:21.
JuanitoAlimana is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 04-25-2024 , 19:34   Re: Edit this plugin
Reply With Quote #2

PHP Code:
#include <amxmodx>

new _menu_items[][] =
{
    
"\wAlien Knife [\yUNLOCKED\w]",
    
"\wEllium Knife [\yUNLOCKED\w]",
    
"\wDark Dagger [\yUNLOCKED\w]",
    
"\wTransparent Knife [\yUNLOCKED\w]",
    
"\wGenuine Dagger [\yUNLOCKED\w]",
    
"\wHunt Blade [\yUNLOCKED\w]",
    
"\wShadow Blade [\yUNLOCKED\w]",
    
"\wSlaughterer Axe [\yUNLOCKED\w]",
    
"\wGolden Katana [\yUNLOCKED\w]",
    
"\wAssasin's Blade [\yUNLOCKED\w]",
    
"\wLightsaber [\yUNLOCKED\w]",
    
"\wBloody Wolverine Claws [\yUNLOCKED\w]",
    
"\wProton Axe [\yUNLOCKED\w]"
}

public 
KnifeSkinsMenu(id)
{
    new 
szItem[256], xp max(1iLevel[id]) * StartedLevel
    
    
if(iLevel[id])
        
xp += ( xp )
    
    
formatex(szItemcharsmax(szItem), "\w[ \r%s \w] \yKnife Skins Menu \rv%s^n\yYour Level: \r%d \w- \yYour XP: \r%d\w/\r%d\w.^n\yPage:\r"g_VAULTNAMEVERSION,iLevel[id],iXp[id], xp);
    
    new 
menu menu_createszItem"KnifeSkinsMenu_Handler" ); 
    
menu_additem(menu"\wNormal Knife [\yUNLOCKED\w]");
    
    for (new 
0sizeof(_menu_items); i++)
        
menu_additem(menuiLevel[id] >= _menu_items[i] : fmt("\d???? ????? [\rLEVEL %d REQUIRE\d]"1))
    
    
menu_display(idmenu0)

__________________
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-26-2024 , 00:22   Re: Edit this plugin
Reply With Quote #3

The problem is that you're misunderstanding how the "paccess" parameter in menu_additem() works. A value of 1 for this parameter allows anybody with immunity to access that item. The values that are intended to be used in this parameter are found in amxconst.inc here. You can see that the admin immunity flag (ADMIN_IMMUNITY) is a value of 1.

To do what you want, you're actually looking for callbacks. Callbacks are used to determine if you want an item enabled or disabled when this menu is shown to the player. So, in this case, you want "paccess" to always be zero and then create your callback:

PHP Code:
public showMyMenu(id)
{
    new 
menu menu_create()
    new 
cbLevelCheck menu_makecallback("cbLevelCheck")

    
menu_additem(menu"Name(1)""Info"0cbLevelCheck)
    .
    .
    .
    
menu_additem(menu"Name(n)""Info"0cbLevelCheck)
    
menu_display(idmenu0)
}

public 
cbLevelCheck(idmenuitem)
{
    
// Use any logic here to determine if the item should be enabled or disabled
    
if( iLevel[id] >= item )
    {
        return 
ITEM_ENABLED
    
}

    return 
ITEM_DISABLED

You can take a look at the New Menus Tutorial to learn more neat features.

P.S. You need to make your title descriptive (it's a rule here) so that people can have a general idea of what your post is about without having to read the entire post.

Quote:
Originally Posted by bigdaddy424 View Post
PHP Code:
#include <amxmodx>

new _menu_items[][] =
{
    
"\wAlien Knife [\yUNLOCKED\w]",
    
"\wEllium Knife [\yUNLOCKED\w]",
    
"\wDark Dagger [\yUNLOCKED\w]",
    
"\wTransparent Knife [\yUNLOCKED\w]",
    
"\wGenuine Dagger [\yUNLOCKED\w]",
    
"\wHunt Blade [\yUNLOCKED\w]",
    
"\wShadow Blade [\yUNLOCKED\w]",
    
"\wSlaughterer Axe [\yUNLOCKED\w]",
    
"\wGolden Katana [\yUNLOCKED\w]",
    
"\wAssasin's Blade [\yUNLOCKED\w]",
    
"\wLightsaber [\yUNLOCKED\w]",
    
"\wBloody Wolverine Claws [\yUNLOCKED\w]",
    
"\wProton Axe [\yUNLOCKED\w]"
}

public 
KnifeSkinsMenu(id)
{
    new 
szItem[256], xp max(1iLevel[id]) * StartedLevel
    
    
if(iLevel[id])
        
xp += ( xp )
    
    
formatex(szItemcharsmax(szItem), "\w[ \r%s \w] \yKnife Skins Menu \rv%s^n\yYour Level: \r%d \w- \yYour XP: \r%d\w/\r%d\w.^n\yPage:\r"g_VAULTNAMEVERSION,iLevel[id],iXp[id], xp);
    
    new 
menu menu_createszItem"KnifeSkinsMenu_Handler" ); 
    
menu_additem(menu"\wNormal Knife [\yUNLOCKED\w]");
    
    for (new 
0sizeof(_menu_items); i++)
        
menu_additem(menuiLevel[id] >= _menu_items[i] : fmt("\d???? ????? [\rLEVEL %d REQUIRE\d]"1))
    
    
menu_display(idmenu0)

I think you should probably do some testing first (e.g. learn how the menu_additem() function works). Also, you didn't even attempt to answer his question. At least explain that nothing you're posting has anything to do with the actual question.

Also, "if( iLevel[id] > 0 )" and "if(iLevel[id])" are two very different functionality.
__________________

Last edited by fysiks; 04-26-2024 at 00:30.
fysiks is online now
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-26-2024 , 03:50   Re: Edit this plugin
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
The problem is that you're misunderstanding how the "paccess" parameter in menu_additem() works. A value of 1 for this parameter allows anybody with immunity to access that item. The values that are intended to be used in this parameter are found in amxconst.inc here. You can see that the admin immunity flag (ADMIN_IMMUNITY) is a value of 1.

To do what you want, you're actually looking for callbacks. Callbacks are used to determine if you want an item enabled or disabled when this menu is shown to the player. So, in this case, you want "paccess" to always be zero and then create your callback:

PHP Code:
public showMyMenu(id)
{
    new 
menu menu_create()
    new 
cbLevelCheck menu_makecallback("cbLevelCheck")

    
menu_additem(menu"Name(1)""Info"0cbLevelCheck)
    .
    .
    .
    
menu_additem(menu"Name(n)""Info"0cbLevelCheck)
    
menu_display(idmenu0)
}

public 
cbLevelCheck(idmenuitem)
{
    
// Use any logic here to determine if the item should be enabled or disabled
    
if( iLevel[id] >= item )
    {
        return 
ITEM_ENABLED
    
}

    return 
ITEM_DISABLED

You can take a look at the New Menus Tutorial to learn more neat features.

P.S. You need to make your title descriptive (it's a rule here) so that people can have a general idea of what your post is about without having to read the entire post.



I think you should probably do some testing first (e.g. learn how the menu_additem() function works). Also, you didn't even attempt to answer his question. At least explain that nothing you're posting has anything to do with the actual question.

Also, "if( iLevel[id] > 0 )" and "if(iLevel[id])" are two very different functionality.
I will try to do it that way. Also, I promise to be more descriptive the next time. Thank you very much for the help!
JuanitoAlimana 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 22:47.


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