AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   i need help with fix my code... (https://forums.alliedmods.net/showthread.php?t=127822)

EpicFail. 05-25-2010 09:25

i need help with fix my code...
 
Look i tried to do shop
But it's not open for me the menu when I write server / shop
My code right
Can anyone see what the problem?, And tell me
Thanks
Sorry for my bad English

here my plugin..
PHP Code:

#include <amxmodx>
#include <fun>
#include <cstrike>
#include <colorchat>

#define PLUGIN "HnS Shop"
#define VERSION "1.9"
#define AUTHOR "olafur164 and Hawk and Drekes"


#define get_user_money(%1)    get_pdata_int( %1, 115 )

#define MAX_CLIENTS 32

native add_user_immune(id)
native remove_user_immune(id

// other pcvars
new plugin_on

// cfg
new cfg[] = "\addons\amxmodx\configs\hnsshopv1.9.cfg"


// cost pcvars
new iAntifrost;

new 
userantifrost[33];

new 
allowantifrost;


public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_cvar("hnsshop_version"VERSIONFCVAR_SERVER);
    
set_cvar_string("hnsshop_version"VERSION);
   
       
register_event("DeathMsg""Event_Deathmsg""a")
    
    
plugin_on register_cvar"shop_on""1");
   
    
    
iAntifrost register_cvar"antifrost_cost""1" );
   
   
    
allowantifrost          register_cvar"alloantifrost""1" );
    
   
    
register_clcmd"say /shop""hideNseek" );
    
register_clcmd"say shop""hideNseek" );
    
register_clcmd"say_team /shop""hideNseek" );
    
register_clcmd"say_team shop""hideNseek" );
   
    
set_task100.0"advert",_,_,_"b" ); 
}



public 
plugin_cfg() 
{
    if (!
file_exists(cfg))
    {
        
write_file(cfg"// other cfg");
        
write_file(cfg"shop_on 1");
        
write_file(cfg"");
        
write_file(cfg"");
        
write_file(cfg"// Cost cvars");
        
write_file(cfg"antifrost_cost 1");
        
        
write_file(cfg"// Allow cvars");
        
write_file(cfg"allowantifrost 1");
        
        
write_file(cfg"echo Hns Shop CFG succesfully loaded");

        
console_print(0"%s file not found. creating new ..."cfg);
    }
    
    else
    {
        
server_cmd("exec %s"cfg);
    }
}

public 
client_connect(id
{
    
userantifrost[id]    = 0;
}

public 
client_disconnect(id
{
    
userantifrost[id]    = 0;


public 
advert() 
{

    
ColorChat(0GREEN"^x04[ULT-Serv] ^x01This Server Running ^x04[Hns Shop]^x01 To Open The Shop Type^x03 /hnsshop^x01 or^x03 /shop");
}

public 
Event_Deathmsg()
{
    new 
victim read_data(2)
    
    
userantifrost[victim]    = 0;
}
    

public 
hideNseek(id)
{
    
    if(
get_pcvar_num(plugin_on) == 1)
    {
    
        new 
iMenu menu_create"\yH\wn\rS \yS\wh\ro\yp""hideNseek_handler" );
   


        new 
grav[60];

        
formatex(gravsizeof(grav) - 1"\yantifrost\w - \r%d$"get_pcvar_num(iAntifrost)); 
        
menu_additem(iMenugrav"1"0); 
   
        
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
        
menu_display(idiMenu);
   
    } 
   
    else
    {
        
client_printidprint_chat"[HnS Shop] Shop is currently closed.");
    }
}


public 
hideNseek_handler(idiMenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroyiMenu );
        return 
PLUGIN_HANDLED;
    }
   
    new 
data[6], iName[32];
    new 
accesscallback;
   
    
menu_item_getinfo(iMenuitemaccessdata,5iName31callback);
   
    new 
key str_to_num(data);
   
    switch(
key)
    {
           
        case 
1:
        {
            if(!
is_user_alive(id)) 
            {
                
ColorChat(idGREEN"[HnS Shop]^x01 You need to be alive!");
                return 
PLUGIN_HANDLED;
            }
            
            if(
userantifrost[id] > 0
            {
                
ColorChat(idGREEN"^x04[HnS Shop]^x01 You already own this item!");
                return 
PLUGIN_HANDLED;
            }
            
            if(
get_pcvar_num(allowantifrost) == 0) {
                
ColorChat(idGREEN"[HnS Shop]^x01 This item is disabled.");
                return 
PLUGIN_HANDLED;
            }
            
            else
            {
                new 
iMoney cs_get_user_money(id);
                new 
iPrice get_pcvar_num(iAntifrost);
            
                if(
iMoney iPrice)
                {
                    
ColorChat(idGREEN"[HnS Shop]^x01 You need more^x04 money^x01 to buy this!" );
                }
            
                if(
iMoney >= iPrice)
                {
                    
cs_set_user_money(idiMoney iPrice)
                    
userantifrost[id]++;
                    
ColorChat(idGREEN"[HnS Shop]^x01 you purchased^x03 antifrost");
                }
            }
        }
    }
    return 
PLUGIN_HANDLED



drekes 05-25-2010 18:34

Re: i need help with fix my code...
 
Are you planning to add more items? Cause a switch statement for 1 case is useless

Exolent[jNr] 05-25-2010 18:37

Re: i need help with fix my code...
 
Post your full code. It's obvious you deleted some before posting it.

EpicFail. 05-26-2010 01:46

Re: i need help with fix my code...
 
@ Drekes I do not want to add more case
Because I want to check the Anti-Frost that he was working

@ Exolent[jNr] Not, like I said I just want to check if the Anti-Frost work...

and this the FULL code.

Sorry for my bad English...

Exolent[jNr] 05-26-2010 01:51

Re: i need help with fix my code...
 
Your code is fine.
There has to be something else causing it to go wrong.

1. Make sure "shop_on" cvar is set to "1".
2. Check ./addons/amxmodx/logs/errorYYYYMMDD.log file for any errors that have occurred.

EpicFail. 05-26-2010 01:58

Re: i need help with fix my code...
 
Okay i check the cvar
but i don't have errors log

Edit:
i try to do amx_cvar shop_on "1"
and this say me
[AMXX] Unknown cvar: shop_on

FlyingHorse 05-26-2010 08:28

Re: i need help with fix my code...
 
Ur code? all u changed is adding ^x04 and stuff? ...

EpicFail. 05-28-2010 06:02

Re: i need help with fix my code...
 
it still my code!

@Exolent[jNr]
i don't have Errors log and cvar on...
and it still wont work

unnyquee 05-28-2010 07:27

Re: i need help with fix my code...
 
Make sure you wrote the plugin name correctly in 'plugins.ini' and you put the plugin file in addons/amxmodx/plugins :).

EpicFail. 05-28-2010 13:03

Re: i need help with fix my code...
 
There in the plugins.ini the name of my plugin
And the folder addons / amxmodx / plugins the plugin my... :(


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

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