AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu error on compile. (https://forums.alliedmods.net/showthread.php?t=84074)

ianglowz 01-20-2009 04:38

Menu error on compile.
 
Help me in this.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "Stat Menu(Test Mod)"
#define VERSION "1.1"
#define AUTHOR "ianglowz"

new plugin_on
new speedprice,armorprice,healthprice

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /stat" "statmenu")
    
    
plugin_on register_cvar("sm_pluginon","1")
    
speedprice register_cvar("sm_speedprice","2000")
    
armorprice register_cvar("sm_armorprice","2000")
    
healthprice register_cvar("sm_healthprice","2500")
}

public 
statmenu(id)
{
    new 
money cs_get_user_money(id)

    if (
get_pcvar_num(plugin_on) == 1)

    new 
menu menu_create"Choose your stat""menu_handler")
    
    
menu_additem(menu"Speed""1"0)
    
menu_additem(menu"Armor""2"0)
    
menu_additem(menu"Health""3",0)
     
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idmenu0)
    
}

public 
menu_handler(idmenuitem)
{
    if (
item == MENU_EXIT)

    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
    
}

    new 
data[6], iName[64]
    new 
accesscallback
    
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)

    new 
key str_to_num(data)
    switch(
key)

     {
        case 
1:{
       if (
money >= get_pcvar_num(speedprice))    
       
client_print(idprint_chat"You have selected Speed Stats."
       
set_user_maxspeed(id 5)
       
menu_destroy(menu)
       return 
PLUGIN_HANDLED
        
}
        else
        {
         
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
    }
        case 
2:{
       if (
money >= get_pcvar_num(armorprice))
       
client_print(idprint_chat"You have selected Armor Stats")
       
set_user_armor(id,200)
       
menu_destroy(menu)
       return 
PLUGIN_HANDLED
        
}
        else
        {
         
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
    }    
        case 
3:{ 
       if (
money >= get_pcvar_num(healthprice))
       
client_print(idprint_chat"You have choose Health Stats")
       
set_user_health(id,200)
       
menu_destroy(menu)
       return 
PLUGIN_HANDLED
       
}
       else
        {
         
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
    }
}
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
 


But get error on compile.

Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Declaration of a local variable must appear in a compound block on line 32
Error: Undefined symbol "menu" on line 32
Error: Undefined symbol "menu" on line 34
Warning: Expression has no effect on line 34
Warning: Expression has no effect on line 34
Warning: Expression has no effect on line 34
Error: Expected token: ";", but found ")" on line 34
Error: Invalid expression, assumed zero on line 34
Error: Too many error messages on one line on line 34

Compilation aborted.
6 Errors.
Could not locate output file C:\Program Files\AMX Mod X\amxxstudio\Untitled.amx (compile failed).


One 01-20-2009 04:49

Re: Menu error on compile.
 
Hey,

PHP Code:

new menu 


ianglowz 01-20-2009 04:51

Re: Menu error on compile.
 
Any mistake at there?

PHP Code:

new menu menu_create"Choose your stat""menu_handler"


One 01-20-2009 04:55

Re: Menu error on compile.
 
Quote:

Originally Posted by ianglowz (Post 747044)
Any mistake at there?

PHP Code:

new menu menu_create"Choose your stat""menu_handler"


Hey,

lol i copied this & there wasnt the new menu= . lol :-?

ianglowz 01-20-2009 05:25

Re: Menu error on compile.
 
I don't get your mean.

Can you edit this code so the error will gone?

Sn!ff3r 01-20-2009 06:11

Re: Menu error on compile.
 
This plugin is completely incorrect.

ianglowz 01-20-2009 06:15

Re: Menu error on compile.
 
Why?Can you give the incorrect part?

xPaw 01-20-2009 08:03

Re: Menu error on compile.
 
rly this code is all incorrent :o
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN    "Stat Menu (Test Mod)"
#define VERSION    "1.1"
#define AUTHOR    "ianglowz"

new plugin_on;
new 
speedpricearmorpricehealthprice;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /stat" "statmenu");
    
    
plugin_on    register_cvar("sm_pluginon","1");
    
speedprice    register_cvar("sm_speedprice","2000");
    
armorprice    register_cvar("sm_armorprice","2000");
    
healthprice    register_cvar("sm_healthprice","2500");
}

public 
statmenuid ) {
    if( 
get_pcvar_num(plugin_on) == ) {
    
//    new money = cs_get_user_money(id);    // huh? do you really need this here?
        
        
new menu menu_create"Choose your stat""menu_handler");
    
        
menu_additem(menu"Speed""1"0);
        
menu_additem(menu"Armor""2"0);
        
menu_additem(menu"Health""3",0);
    
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0);
    }
}

public 
menu_handler(idmenuitem) {
    if (
item == MENU_EXIT) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64]
    new 
accesscallback
    
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)

    new 
key str_to_num(data)
    switch( 
key ) {
        case 
1: {    // you need to get money here
            
new money cs_get_user_money(id);
            
            if (
money >= get_pcvar_num(speedprice)) {
                
client_print(idprint_chat"You have selected Speed Stats."
                
set_user_maxspeed(id5.0)    // 5 ? speed is float
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED
            
} else {
                
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
            }
        }
    
    
// others try do your self ;)
        
case 2:{
               if (
money >= get_pcvar_num(armorprice))
               
client_print(idprint_chat"You have selected Armor Stats")
               
set_user_armor(id,200)
               
menu_destroy(menu)
               return 
PLUGIN_HANDLED
            
}
            else
            {
             
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
            }    
        case 
3:{ 
               if (
money >= get_pcvar_num(healthprice))
               
client_print(idprint_chat"You have choose Health Stats")
               
set_user_health(id,200)
               
menu_destroy(menu)
               return 
PLUGIN_HANDLED
               
}
               else
            {
             
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED


its specially not full fixed, you need to learn a bit too

ianglowz 01-20-2009 09:18

Re: Menu error on compile.
 
I just trying to do some advanced script(for me).Thanks for advice.

ianglowz 01-21-2009 03:43

Re: Menu error on compile.
 
So it will be like this?

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN    "Stat Menu (Test Mod)"
#define VERSION    "1.1"
#define AUTHOR    "ianglowz"

new plugin_on;
new 
speedpricearmorpricehealthprice;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /stat" "statmenu");
    
    
plugin_on    register_cvar("sm_pluginon","1");
    
speedprice    register_cvar("sm_speedprice","2000");
    
armorprice    register_cvar("sm_armorprice","2000");
    
healthprice    register_cvar("sm_healthprice","2500");
}

public 
statmenuid ) {
    if( 
get_pcvar_num(plugin_on) == ) {
        
        new 
menu menu_create"Choose your stat""menu_handler");
    
        
menu_additem(menu"Speed""1"0);
        
menu_additem(menu"Armor""2"0);
        
menu_additem(menu"Health""3",0);
    
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0);
    }
}

public 
menu_handler(idmenuitem) {
    if (
item == MENU_EXIT) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64]
    new 
accesscallback
    
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)

    new 
key str_to_num(data)
    switch( 
key ) {
        case 
1: {    
            new 
money cs_get_user_money(id);
            
            if (
money >= get_pcvar_num(speedprice)) {
                
client_print(idprint_chat"You have selected Speed Stats."
                
set_user_maxspeed(id5.0)    
            } else {
                
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
            }
        }
    
        case 
2:{
    new 
money cs_get_user_money(id);
        
               if (
money >= get_pcvar_num(armorprice))
           {
               
client_print(idprint_chat"You have selected Armor Stats")
               
set_user_armor(id,200)
           } else {
             
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
            }
}
        
        case 
3:{ 
    new 
money cs_get_user_money(id);
        
               if (
money >= get_pcvar_num(healthprice))
           {
               
client_print(idprint_chat"You have choose Health Stats")
               
set_user_health(id,200)
               }
               else
            {
             
client_print(id ,print_chat"You do not have enough money.WORK HARD!!")
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


But i get error also.

Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 64
Warning: Loose indentation on line 68
Warning: Loose indentation on line 76
Error: Only a single statement (or expression) can follow each "case" on line 86
Warning: Expression has no effect on line 86

1 Error.
Could not locate output file C:\Program Files\AMX Mod X\amxxstudio\Untitled.amx (compile failed).



All times are GMT -4. The time now is 01:46.

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