Raised This Month: $ Target: $400
 0% 

Menu help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tedaimlocks
Senior Member
Join Date: Jan 2024
Old 04-13-2024 , 09:01   Menu help
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <zp_buymenu>

#define PLUGIN "PVIP Shop"
#define VERSION "1.0"
#define AUTHOR "tedaimlocks"

#define PVIP_FLAG ADMIN_LEVEL_D

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /pvip""PVIPMenu")
}

public 
PVIPMenu(id) {
        if(!(
get_user_flags(id) & PVIP_FLAG))
        {
            return 
PLUGIN_HANDLED;
        }

    new 
title[198]
    new 
money zp_cs_get_user_money(id)

    
formatex(titlecharsmax(title), "\ySPK - Zombie Plague \r[CSO] \d | PVIP Shop^nMoney: %d"money)
    new 
menu menu_create(title"PVIPMenuHandler")
    
    
menu_additem(menu"100 Armor""1")
    
menu_additem(menu"100 Health""2")
    
menu_additem(menu"idk""3")
    
    
menu_setprop(menuMPROP_EXITNAME"Exit")
    
menu_display(idmenu)
}

public 
PVIPMenuHandler(idmenuitem) {
    switch(
item) {
        case 
0: {
            
PVIPMenuItemArmor(id)
        }
        case 
1: {
            
PVIPMenuItemHealth(id)
        }
        case 
2: {
            
PVIPMenuItemIdk(id)
        }
    }
}

public 
PVIPMenuItemArmor(id) {
    
set_hudmessage(25500, -1.0, -1.006.012.0)
        
show_hudmessage(id"Option 1 testinggggghg")
}

public 
PVIPMenuItemHealth(id) {
    new 
hp get_user_health(id)
        new 
ap get_user_armor(id)
        new 
money zp_cs_get_user_money(id)
        
client_print(idprint_chat"Health: %d | Armor: %d | Money: %d"hpapmoney)
}

public 
PVIPMenuItemIdk(id) {
        
user_silentkill(id)

I made this, it works perfectly fine but i get a warning when compiling it

pvipshop.sma(35) : warning 209: function "PVIPMenu" should return a value

Could anyone help?
tedaimlocks is offline
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 04-13-2024 , 09:38   Re: Menu help
Reply With Quote #2

..
Attached Files
File Type: sma Get Plugin or Get Source (PVIPMenu.sma - 57 views - 1.4 KB)
File Type: inc zp_buymenu.inc (513 Bytes, 41 views)
__________________
💻Know Our New Blog👄
🔗tube2downs.blogspot.com
WATCH_D0GS UNITED is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-13-2024 , 17:04   Re: Menu help
Reply With Quote #3

Quote:
Originally Posted by tedaimlocks View Post
I made this, it works perfectly fine but i get a warning when compiling it

pvipshop.sma(35) : warning 209: function "PVIPMenu" should return a value

Could anyone help?
This warning is saying that you a explicitly returning a value in some but not all possible cases of code execution. This exists because there is, generally, a very good chance that you are creating unknown behavior of your code. All possible executions of a function should have an explicit return value. So, in this case, you return a value in the if statement at the beginning of the function but if that if statement doesn't get executed i.e. the menu is created and displayed, then there is no explicit return value. To fix this, you should either add a "return PLUGIN_CONTINUE" or "return PLUGIN_HANDLED" at the end of the function depending on how you want the function to behave. For chat commands like this, PLUGIN_CONTINUE will allow the original chat command to be shown to other players like a normal chat message but PLUGIN_HANDLED will suppress this message (i.e. your function gets executed but nobody sees who used the command).


Quote:
Originally Posted by WATCH_D0GS UNITED View Post
..
This is Scripting Help, people are here to learn. Explain what is actually wrong. It's not really helpful if you just post a plugin without any explanation.
__________________
fysiks is offline
tedaimlocks
Senior Member
Join Date: Jan 2024
Old 04-13-2024 , 17:14   Re: Menu help
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
This warning is saying that you a explicitly returning a value in some but not all possible cases of code execution. This exists because there is, generally, a very good chance that you are creating unknown behavior of your code. All possible executions of a function should have an explicit return value. So, in this case, you return a value in the if statement at the beginning of the function but if that if statement doesn't get executed i.e. the menu is created and displayed, then there is no explicit return value. To fix this, you should either add a "return PLUGIN_CONTINUE" or "return PLUGIN_HANDLED" at the end of the function depending on how you want the function to behave. For chat commands like this, PLUGIN_CONTINUE will allow the original chat command to be shown to other players like a normal chat message but PLUGIN_HANDLED will suppress this message (i.e. your function gets executed but nobody sees who used the command).
Hi, thanks for the explanation, it has been fixed, i also figured out the returns when i saw the other guy's code

Last edited by tedaimlocks; 04-13-2024 at 17:14.
tedaimlocks is offline
Reply


Thread Tools
Display Modes

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