AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invalid Statement (https://forums.alliedmods.net/showthread.php?t=106223)

DoviuX 10-12-2009 13:32

Invalid Statement
 
Whats wrong with this 111 Line:

PHP Code:

        case 2

The error:

Code:

(111) : warning 217: loose indentation
(111) : error 014: invalid statement; not in switch
(111) : warning 215: expression has no effect
(111) : error 001: expected token: ";", but found ":"
(111) : error 029: invalid expression, assumed zero
(111) : fatal error 107: too many error messages on one line


SnoW 10-12-2009 13:33

Re: Invalid Statement
 
The thing that it isn't inside a switch.

DoviuX 10-12-2009 13:43

Re: Invalid Statement
 
What can be wrong ?

PHP Code:

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

#define PLUGIN "SURF SHOP"
#define VERSION "1.0"
#define AUTHOR "DoviuX"

/*================================================================================
 [Customization]
=================================================================================*/
new const gHealth[] = "SurfShop/Health.wav"
new const gArmor[] = "SurfShop/Armor.wav"
new const gGun[] = "SurfShop/Gun.wav"
new const gNoMoney[] = "SurfShop/NoMoney.wav"

/*================================================================================
 [New Variables]
=================================================================================*/

new health
new armor
new randomgun
new BoostHealth

/*================================================================================
 [Init and Precache]
=================================================================================*/

public plugin_init()
{
      
register_pluginPLUGINVERSIONAUTHOR );

        
register_logevent"logevent_round_start"2"1=Round_Start" );

      
register_clcmd("say /shop""SurfShop")
      
register_clcmd("say_team /shop""SurfShop")

    
BoostHealth register_cvar("amx_boost_health""145");
    
      
health register_cvar("price_healthbooster""3500")
      
armor register_cvar("price_armor""2000")
      
randomgun register_cvar("price_gun""16000")

      
register_dictionary("surf_shop.txt");
}

/*================================================================================
 [Plugin Start]
=================================================================================*/

public plugin_precache()
{    
    
precache_sound("gHealth")
    
precache_sound("gArmor")
    
precache_sound("gGun")
    
precache_sound("gNoMoney")
}

public 
SurfShop(id)
{
    new 
menu menu_create("\ySurf Shop!""menu_handler")
    
    
menu_additem(menu"Health Booster""1"0)
    
menu_additem(menu"Armor""2"0)
    
menu_additem(menu"Random Gun""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
(menuitemaccessdata5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1
        {
            new 
Cost get_pcvar_num(health);
            new 
Money cs_get_user_money(id);
            
            if (
Money Cost)
            {
                
client_print(idprint_chat"%L"LANG_PLAYER"NO_MONEY"Cost);
                
client_cmd0"spk %s"gNoMoney);
                return 
PLUGIN_HANDLED;
            } 
            else 
            {

                
set_user_health(idget_user_health(id) + get_pcvar_num(health));
                
client_print(idprint_chat"%L"LANG_PLAYER"HEALTH");
                        
client_cmd0"spk %s"gHealth);    
                
                
Money -= Cost;
    
                
cs_set_user_money(idMoney);
            }

        case 
2
        {
            new 
Cost get_pcvar_num(armor);
            new 
Money cs_get_user_money(id);
            
            if (
Money Cost)
            {
                
client_print(idprint_chat"%L"LANG_PLAYER"NO_MONEY"Cost);
                
client_cmd0"spk %s"gNoMoney);
                return 
PLUGIN_HANDLED
            

            else 
            {
                
set_user_armor(id100)
                
client_print(idprint_chat"%L"LANG_PLAYER"ARMOR");
                        
client_cmd0"spk %s"gARMOR);
    
                
Money -= Cost;
    
                
cs_set_user_money(idMoney);
                
            }

        case 
3
        {
            new 
Cost get_pcvar_num(randomgun);
            new 
Money cs_get_user_money(id);
            
            if (
Money Cost)
            {
                
client_print(idprint_chat"%L"LANG_PLAYER"NO_MONEY"Cost);
                
client_cmd0"spk %s"gNoMoney);
                return 
PLUGIN_HANDLED
            

            else 
            {
                    
strip_user_weapons(id)
                    
give_item(idPrimary[random_num(0sizeof Primary 1)])
                    
give_item(idSecondary[random_num(0sizeof Secondary 1)])
                    
give_item(idGrenades[random_num(0sizeof Grenades 1)])
                    
give_item(idweapon_knife)
                
client_print(idprint_chat"%L"LANG_PLAYER"RANDOMGUN");
                        
client_cmd0"spk %s"gGun);
    
                
Money -= Cost;
    
                
cs_set_user_money(idMoney);    
                
            }
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED;
}

public 
logevent_round_start(id
{
            
set_hudmessage(25510001.00.3312.05.0);
            
show_hudmessage0"SurfShop maded by TBagT !" );



SnoW 10-12-2009 13:44

Re: Invalid Statement
 
You don't close the case 1 so the parser thinks case 2 isn't inside the switch but comes after it.

DoviuX 10-12-2009 13:49

Re: Invalid Statement
 
Thx i get it now :D

alan_el_more 10-13-2009 10:54

Re: Invalid Statement
 
PHP Code:

public plugin_precache() 
{     
    
precache_sound("gHealth"
    
precache_sound("gArmor"
    
precache_sound("gGun"
    
precache_sound("gNoMoney"


:arrow:

PHP Code:

public plugin_precache() 
{     
    
precache_sound(gHealth
    
precache_sound(gArmor
    
precache_sound(gGun
    
precache_sound(gNoMoney




All times are GMT -4. The time now is 22:39.

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