Raised This Month: $ Target: $400
 0% 

I have a little problem in my code..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicFail.
Senior Member
Join Date: May 2010
Old 05-30-2010 , 05:24   I have a little problem in my code..
Reply With Quote #1

look i make shop for hns (only for check the Anti-Frost)
and this wont work..

Here my code:
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" );
    
register_clcmd("nightvision","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] ^x01Click^x03 'N' To Open The^x04 Shop.");
    
    
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

But when I buy in the shop "antifrost"
nothing happens it does not give me "antifrost"
The colorchat also does not work

Can anyone help me fix this?
Sorry for my bad English.
EpicFail. is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 05-30-2010 , 05:41   Re: I have a little problem in my code..
Reply With Quote #2

did you place the color chat include in the includes directory? If your using the web compiler, it wont work.
Styles is offline
Send a message via AIM to Styles
EpicFail.
Senior Member
Join Date: May 2010
Old 05-30-2010 , 05:51   Re: I have a little problem in my code..
Reply With Quote #3

i can compil it
but it still no work
and i put colorchat.ini in includes..
EpicFail. is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-30-2010 , 06:19   Re: I have a little problem in my code..
Reply With Quote #4

why doubles?
http://forums.alliedmods.net/showthread.php?t=127822
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
EpicFail.
Senior Member
Join Date: May 2010
Old 05-30-2010 , 06:32   Re: I have a little problem in my code..
Reply With Quote #5

It's not the same
Each cluster is another question ...
EpicFail. is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-30-2010 , 06:39   Re: I have a little problem in my code..
Reply With Quote #6

Looks like the same code to me
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
EpicFail.
Senior Member
Join Date: May 2010
Old 05-30-2010 , 06:43   Re: I have a little problem in my code..
Reply With Quote #7

this a same code but the question other...

if you can help i will be happy
EpicFail. is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-31-2010 , 02:06   Re: I have a little problem in my code..
Reply With Quote #8

Your topic title must be descriptive.
Fix it before posting again.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 05-31-2010 , 10:41   Re: I have a little problem in my code..
Reply With Quote #9

PHP Code:
public advert() 
{
    
    
ColorChat(0GREEN"^x04[ULT-Serv] ^x01Click^x03 'N' To Open  The^x04 Shop.");
    
    
ColorChat(0GREEN"^x04[ULT-Serv] ^x01This Server Running ^x04[Hns  Shop]^x01 To Open The Shop Type^x03 /hnsshop^x01 or^x03 /shop");

Well, if you are using this ColorChat plugin it should look like this:

PHP Code:
public advert() 
{
    
    
client_print_color(0GREEN"^4[ULT-Serv] ^1Click ^3'N' ^1To Open  The ^4Shop.");
    
    
client_print_color(0GREEN"^4[ULT-Serv] ^1This Server Running  ^4[Hns Shop] ^1To Open The Shop Type ^3/hnsshop ^1or ^3/shop");

And...
PHP Code:
       if(!is_user_alive(id)) 
            {
                
client_print_color(idGREEN"^4[HnS Shop] ^1You need to be alive!");
                return 
PLUGIN_HANDLED;
            }
            
            if(
userantifrost[id] > 0
            {
                
client_print_color(idGREEN"^4[HnS Shop] ^1You already own this item!");
                return 
PLUGIN_HANDLED;
            }
            
            if(
get_pcvar_num(allowantifrost) == 0) {
                
client_print_color(idGREEN"^4[HnS Shop] ^1This item is disabled.");
                return 
PLUGIN_HANDLED

But if you don't say which ColorChat plugin or "Native" you are trying to use, no one can help.

Last edited by RedRobster; 05-31-2010 at 10:58.
RedRobster is offline
EpicFail.
Senior Member
Join Date: May 2010
Old 05-31-2010 , 11:38   Re: I have a little problem in my code..
Reply With Quote #10

look here i change the code like you say me..
PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <chatcolor>

#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" );
    
register_clcmd("nightvision","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() 
{
    
    
client_print_color(0GREEN"^4[Lw. Shop] ^1Click ^3'N' ^1To Open  The ^4Shop.");
    
    
client_print_color(0GREEN"^4[Lw. Shop] ^1This server is running ^4Hide-N-Seek ^3Shop, say /shop or press ^3'N'");
}  

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)) 
            {
                
client_print_color(idGREEN"^4[HnS Shop] ^1You need to be alive!");
                return 
PLUGIN_HANDLED;
            }
            
            if(
userantifrost[id] > 0
            {
                
client_print_color(idGREEN"^4[HnS Shop] ^1You already own this item!");
                return 
PLUGIN_HANDLED;
            }
            
            if(
get_pcvar_num(allowantifrost) == 0) {
                
client_print_color(idGREEN"^4[HnS Shop] ^1This item is disabled.");
                return 
PLUGIN_HANDLED;  
            else
            {
                new 
iMoney cs_get_user_money(id);
                new 
iPrice get_pcvar_num(iAntifrost);
            
                if(
iMoney iPrice)
                {
                    
client_print_color0GREEN"^4[HnS Shop] ^1You need more money to buy this!" );
                }
            
                if(
iMoney >= iPrice)
                {
                    
cs_set_user_money(idiMoney iPrice)
                    
userantifrost[id]++;
                    
client_print_color0GREEN"^4[HnS Shop] ^1you purchased antifrost");
                }
            }
        }
    }
    return 
PLUGIN_HANDLED

this give me a erros when i try compil it
PHP Code:
/home/groups/amxmodx/tmp3/php7uUZRC.sma(4) : fatal error 100cannot read from file"chatcolor" 
and i don't use webcompiler...

and when i try compil it without include <chatcolor>
it give this errors...
PHP Code:
/home/groups/amxmodx/tmp3/phpuU1JgU.sma(98) : error 017undefined symbol "client_print_color"
/home/groups/amxmodx/tmp3/phpuU1JgU.sma(98) : warning 215expression has no effect
/home/groups/amxmodx/tmp3/phpuU1JgU.sma(98) : error 001expected token";"but found ")"
/home/groups/amxmodx/tmp3/phpuU1JgU.sma(98) : error 029invalid expressionassumed zero
/home/groups/amxmodx/tmp3/phpuU1JgU.sma(98) : fatal error 107too many error messages on one line 
Line 98:
PHP Code:
    client_print_color(0GREEN"^4[Lw. Shop] ^1Click ^3'N' ^1To Open  The ^4Shop."); 
can you compil it for me or just fix it ^^ ?
EpicFail. is offline
Reply



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 05:22.


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