Raised This Month: $51 Target: $400
 12% 

Help with menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asdfdsdf
AlliedModders Donor
Join Date: Aug 2010
Location: Belgium
Old 09-08-2011 , 10:54   Help with menu
Reply With Quote #1

need help with my menu im creating a menu for my knifeserver the problem is when i trie to purchase the machete it just says you just purchased a katana the katana works when i purchase but not the machete what did i do wrong here is the code

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
#include <engine>

#define PLUGIN "Shop"
#define VERSION "1.0"
#define AUTHOR "Prete"

#define MEXIT_ALL 1

new bool:g_bHasBoughtKatana[33]
new 
bool:g_bHasBoughtMachete[33]

new 
g_ShopMenu;

new 
VIEW_Katana[]    = "models/katana.mdl"
new PLAYER_Katana[]  = "models/katana.mdl"
new VIEW_Machete[]  = "models/machete.mdl"
new PLAYER_Machete[] = "models/machete.mdl"
new WORLD_MODEL[]        = "models/w_knife.mdl"
new OLDWORLD_MODEL[]        = "models/w_knife.mdl"

public plugin_precache()
{
    
precache_model(VIEW_Katana)
    
precache_model(PLAYER_Katana)
    
precache_model(VIEW_Machete)
    
precache_model(PLAYER_Machete)
}


public 
plugin_init() 
{    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event ("CurWeapon""Event_CurWeapon""b""1=1""2=29")
    
    
register_forward(FM_SetModel"fw_SetModel")
    
    
register_clcmd "say /jbshop","ShopMenu")
    
register_clcmd ("say_team /jbshop""ShopMenu")
    
    
register_cvar("amx_jail_menu""1");
}


public 
Event_CurWeapon(id)

    
/* Niet nodig door "2=29" filter in register_event()
    new weaponID = read_data(2)
    if(weaponID != CSW_KNIFE)
    return PLUGIN_CONTINUE
    */
    
    
if( g_bHasBoughtKatana[id] == true )
    {
        
entity_set_string(idEV_SZ_viewmodelVIEW_Katana);
        
entity_set_string(idEV_SZ_viewmodelPLAYER_Katana);
        return 
PLUGIN_CONTINUE;
    }

    if( 
g_bHasBoughtMachete[id] == true )
    {
        
        
entity_set_string(idEV_SZ_viewmodelVIEW_Machete);
        
entity_set_string(idEV_SZ_viewmodelPLAYER_Machete);
        return 
PLUGIN_CONTINUE;
    }
    
    return 
PLUGIN_CONTINUE;
    
}  
public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity))
        return 
FMRES_IGNORED
    
    
if(!equali(modelOLDWORLD_MODEL))
        return 
FMRES_IGNORED
    
    
new className[33]
    
entity_get_string(entityEV_SZ_classnameclassName32)
    
    if(
equal(className"weaponbox") || equal(className,
    
"armoury_entity") || equal(className"grenade"))
    {
        if(
entity_set_model(entityWORLD_MODEL) )
        return 
FMRES_SUPERCEDE
    
}
    
    return 
FMRES_IGNORED
}
public 
ShopMenu(id)
{
    
    
menu_create("ShopMenu""ShopMenu_Handler" );
    
menu_additem (g_ShopMenu"Katana""1"0)
    
menu_additem (g_ShopMenu"Machete""1"0)
    
menu_setprop (g_ShopMenuMPROP_EXITMEXIT_ALL);
    
    
menu_display(idg_ShopMenu0);
    
    return 
PLUGIN_HANDLED;
}
   
public 
ShopMenu_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:
        {
            
g_bHasBoughtKatana[id] = true
            client_print
(idprint_chat"You just purchased a katana knife!");
        }
        case 
2:
        {
            
g_bHasBoughtMachete[id] = true
            client_print
(idprint_chat"You just purchased a Machete!");
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

asdfdsdf is offline
liinuus
Senior Member
Join Date: Apr 2010
Old 09-08-2011 , 11:18   Re: Help with menu
Reply With Quote #2

change
menu_additem (g_ShopMenu, "Machete", "1", 0)
to
menu_additem (g_ShopMenu, "Machete", "2", 0)
liinuus is offline
asdfdsdf
AlliedModders Donor
Join Date: Aug 2010
Location: Belgium
Old 09-08-2011 , 13:08   Re: Help with menu
Reply With Quote #3

thx it works now
asdfdsdf 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 14:11.


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