AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Warning with Compiler (https://forums.alliedmods.net/showthread.php?t=164482)

Mifuntm 08-12-2011 06:56

Warning with Compiler
 
Please check what is wrong wit code because i have warning when try compile.
Thanks!


Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Menu"
#define VERSION "1.0"
#define AUTHOR "Szymek"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_clcmd("say /menu", "menu");
    register_clcmd("say_team /menu", "menu");
}
public menu(id)
{
    new menu = menu_create("\yMenu DR", "menu_Handle");
    menu_additem(menu, "\wSlep");
    menu_additem(menu, "\wPunkty");
    menu_additem(menu, "\wRegulamin");
    menu_additem(menu, "\rCzapki");
    menu_additem(menu, "\wSzlaczek 1");
    menu_additem(menu, "\ySzlaczek 2");
    menu_additem(menu, "\ySzlaczek 3");
    menu_display(id, menu);
}
public menu_Handle(id,menu,item)
{
    if(item == MENU_EXIT)
{
    menu_destroy(menu);
    return PLUGIN_CONTINUE;
}
    menu_display(id, menu);
    switch(item)
        {
        case 0:
        {
            client_cmd(id,"say /drshop")
        }
        case 1:
        {
            client_cmd(id,"say /mypoints")
        }
        case 2:
        {
            client_cmd(id,"say /zasady")
        }
        case 3:
        {
            client_cmd(id,"say /hats")
        }
        case 4:
        {
            client_cmd(id,"say trail 10 red")
        }
        case 5:
        {
            client_cmd(id,"say trail 5 green")
        }
        case 6:
        {
            client_cmd(id,"say trail 5 yellow")
        }
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/


abdul-rehman 08-12-2011 07:18

Re: Warning with Compiler
 
You indentation is lose, which software do u use to make plugin ?

Korxu 08-12-2011 07:18

Re: Warning with Compiler
 
PHP Code:

#include <amxmodx>

#define PLUGIN "Menu"
#define VERSION "1.0"
#define AUTHOR "Szymek"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /menu""menu")
    
register_clcmd("say_team /menu""menu")
}

public 
menu(id)
{
    new 
menu menu_create("\yMenu DR""menu_Handle")
    
    
menu_additem(menu"\wSlep""1")
    
menu_additem(menu"\wPunkty""2")
    
menu_additem(menu"\wRegulamin""3")
    
menu_additem(menu"\rCzapki""4")
    
menu_additem(menu"\wSzlaczek 1""5")
    
menu_additem(menu"\ySzlaczek 2""6")
    
menu_additem(menu"\ySzlaczek 3""7")
    
    
menu_display(idmenu)
}

public 
menu_Handle(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_CONTINUE;
    }
    
    new 
data[6], name[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5name63callback)
    
    switch(
str_to_num(data))
    {
        case 
1:
            
client_cmd(id,"say /drshop")
        case 
2:
            
client_cmd(id,"say /mypoints")
        case 
3:
            
client_cmd(id,"say /zasady")
        case 
4:
            
client_cmd(id,"say /hats")
        case 
5:
            
client_cmd(id,"say trail 10 red")
        case 
6:
            
client_cmd(id,"say trail 5 green")
        case 
7:
            
client_cmd(id,"say trail 5 yellow")
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED


You forgot destroy the menu and return.

This will helps you ;).

@EDIT: Use [*PHP] and [*/PHP] (without *) to put codes.

Mifuntm 08-12-2011 16:20

Re: Warning with Compiler
 
Quote:

Originally Posted by Korxu (Post 1530906)
You forgot destroy the menu and return.

This will helps you ;).


The point is i dont want destroy menu after choosing one of options.
Every option will be opening MOTD window and closing menu should be only last option (0) Exit

abdul-rehman 08-12-2011 16:44

Re: Warning with Compiler
 
Quote:

Originally Posted by abdul-rehman (Post 1530905)
You indentation is lose, which IDE do u use to make plugin ?


Mifuntm 08-12-2011 18:11

Re: Warning with Compiler
 
Quote:

Originally Posted by abdul-rehman (Post 1530905)
You indentation is lose, which software do u use to make plugin ?


i'v found this in web

fysiks 08-13-2011 00:53

Re: Warning with Compiler
 
Quote:

Originally Posted by Mifuntm (Post 1531215)
The point is i dont want destroy menu after choosing one of options.

Always destroy a menu that you don't build as a global resource (hint: you are not building it as a global resource).

Mifuntm 08-13-2011 07:04

Re: Warning with Compiler
 
i dont get it!
This plugin have wrong code?

fysiks 08-13-2011 16:41

Re: Warning with Compiler
 
Quote:

Originally Posted by Mifuntm (Post 1531557)
i dont get it!
This plugin have wrong code?

If you want to keep showing the menu after the select an option other than exit then you need to do this at the end of menu_Hanled():

PHP Code:

    menu_destroy(menu)
    
menu(id)
    return 
PLUGIN_HANDLED 



All times are GMT -4. The time now is 03:28.

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