AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   i need some script... (https://forums.alliedmods.net/showthread.php?t=129159)

EpicFail. 06-09-2010 15:22

i need some script...
 
1 Attachment(s)
someone can give me the script in the pic
the script for Your cash:
the for helpers..

GXLZPGX 06-09-2010 16:22

Re: i need some script...
 
Quote:

Originally Posted by EpicFail. (Post 1204370)
someone can give me the script in the pic
the script for Your cash:
the for helpers..

Ugh, he's talking about the HNS Shop I'm working on. Here:

PHP Code:

public menuiPlayer )
{
    new 
szShop[64]
    
formatexszShopcharsmaxszShop ), "Hide'N'Seek Shop^n\rYour cash: \y$%d"cs_get_user_moneyiPlayer ) );
    
    new 
menu menu_createszShop"shop_handler" );
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
menu_displayiPlayermenu);



EpicFail. 06-10-2010 05:55

Re: i need some script...
 
i have 1 problem in the menu it no show the money i have this show me "$%d" how i can fix this...

infek 06-10-2010 23:23

Re: i need some script...
 
PHP Code:

"Hide'N'Seek Shop^n\rYour cash: \y$%d"cs_get_user_moneyid ) ); 

make sure you have cs_get_user_money it returns the call on %d

fysiks 06-10-2010 23:44

Re: i need some script...
 
Quote:

Originally Posted by EpicFail. (Post 1204823)
i have 1 problem in the menu it no show the money i have this show me "$%d" how i can fix this...

Show your code.

EpicFail. 06-11-2010 02:18

Re: i need some script...
 
Here my Code...
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <chatcolor>

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

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

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

#define MAX_CLIENTS 32

// other pcvars
new plugin_on

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


// cost pcvars
new Antifrostcost;

new 
userantifrost[33];

new 
allowantifrost;

native add_user_immuneid )
native remove_user_immuneid )

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");
       
        
    
Antifrostcost register_cvar"antifrost_cost""1" );
       
       
    
allowantifrost register_cvar"allowantifrost""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(0DontChange"^3[Lw. Shop] ^1Click ^4'N' ^1To Open  The ^3Shop.");
    
    
client_print_color(0DontChange"^3[Lw. Shop] ^1This server is running ^3Hide-N-Seek ^4Shop, ^1say ^4/shop ^1or press ^4'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("\r[\wLw.\r]\r Hide'\wN\r'Seek Shop^n\rYour Cash: \r%d$""hideNseek_handler"cs_get_user_moneyid ) ); 
    
        new 
grav[60];
    
        
formatex(gravsizeof(grav) - 1"\wAnti-Frost\r - \r%d$"get_pcvar_num(Antifrostcost)); 
        
menu_additem(iMenugrav"1"0); 
       
        
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
        
menu_display(idiMenu);
    } 
   
    else
    {
        
client_print_coloridDontChange"^3[HnS Shop] ^1Shop is currently closed.");
    }
    return 
PLUGIN_HANDLED
}


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_color0DontChange"^4[Hide'n'Seek Shop] ^1You need to be alive!");
                return 
PLUGIN_HANDLED;
            }
            if(
userantifrost[id] > 0) {
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1You already own this item!");
                return 
PLUGIN_HANDLED;
            }
            if(
get_pcvar_num(allowantifrost) == 0) {
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1This item is disabled.");
                return 
PLUGIN_HANDLED;
            }
    
            new 
money fm_get_user_money(id);
            new 
cost get_pcvar_num(Antifrostcost);
    
            if(
money cost || money == cost) {
                
fm_get_user_money(idmoney cost);
                
userantifrost[id]++;
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1You purchased ^3Anti-Frost.");
            } else {  
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1You need more ^4money ^1to buy this!");
            } 
            
        }
    }
    return 
PLUGIN_HANDLED;


^.^

GXLZPGX 06-11-2010 02:41

Re: i need some script...
 
Use this:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <chatcolor>

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

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

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

#define MAX_CLIENTS 32

// other pcvars
new plugin_on

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


// cost pcvars
new Antifrostcost;

new 
userantifrost[33];

new 
allowantifrost;

native add_user_immuneid )
native remove_user_immuneid )

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

public 
Event_Deathmsg()
{
    new 
victim read_data(2)
    
    
userantifrost[victim]    = 0;
}
    
public 
hideNseek(id)
{
    if(
get_pcvar_num(plugin_on) == 1)
    {
        new 
szShop[64], szGrav[60];
        
formatexszShopcharsmaxszShop ), "\r[\wLw.\r]\r Hide'\wN\r'Seek Shop^n\rYour Cash: \r%d$"cs_get_user_moneyid ) );
        
formatexszGravsizeof(szGrav) - 1"\wAnti-Frost\r - \r%d$"get_pcvar_num(Antifrostcost)); 
        
        new 
iMenu menu_createszShop"shop_handler" );
        
menu_additem(iMenuszGrav"1"0); 
       
        
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
        
menu_display(idiMenu);
    } 
   
    else
    {
        
client_print_coloridDontChange"^3[HnS Shop] ^1Shop is currently closed.");
    }
    return 
PLUGIN_HANDLED
}


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_color0DontChange"^4[Hide'n'Seek Shop] ^1You need to be alive!");
                return 
PLUGIN_HANDLED;
            }
            if(
userantifrost[id] > 0) {
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1You already own this item!");
                return 
PLUGIN_HANDLED;
            }
            if(
get_pcvar_num(allowantifrost) == 0) {
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1This item is disabled.");
                return 
PLUGIN_HANDLED;
            }
    
            new 
money fm_get_user_money(id);
            new 
cost get_pcvar_num(Antifrostcost);
    
            if(
money cost || money == cost) {
                
fm_get_user_money(idmoney cost);
                
userantifrost[id]++;
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1You purchased ^3Anti-Frost.");
            } else {  
                
client_print_color0DontChange"^4[Hide'n'Seek Shop] ^1You need more ^4money ^1to buy this!");
            } 
            
        }
    }
    return 
PLUGIN_HANDLED;



infek 06-11-2010 20:02

Re: i need some script...
 
or he could always do this
\r$\r%d

fysiks 06-11-2010 20:10

Re: i need some script...
 
Quote:

Originally Posted by infek (Post 1206234)
or he could always do this
\r$\r%d

You obviously don't understand what caused the problem.

GXLZPGX 06-11-2010 20:34

Re: i need some script...
 
Quote:

Originally Posted by infek (Post 1206234)
or he could always do this
\r$\r%d

His problem was you cannot use special items like %d or %s in a menu such as what he used. You have to create a new format that allows you to retrieve cvars and such.


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

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