AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Menu won't display but the adv message displays (https://forums.alliedmods.net/showthread.php?t=193222)

f0rhead 08-17-2012 14:08

Menu won't display but the adv message displays
 
Hey, I'm using this code wich is below but I only get the advertise message to display, when I type ex. /cash nothing displays.

So my request is to anyone to fix the plugin so the effects and the menu displays.

Alright here's the code:

PHP Code:

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

new const PLUGIN[] = "Jaiilbreak Shop"
new const VERISON[] = "0.1"
new const AUTHOR[] = "Unkown"

new const g_szPrefix[] = "^4[Jailbreakshop]:^3";

new 
pCash[33]

new 
g_pEnableShop
new g_pEnableGamble

new const Shop_ItemNamesTerro[6][] = {
   
"He Grenade",
   
"Flash Grenade",
   
"Smoke Grenade",
   
"Deagle",
   
"TMP",
   
"Shield" 
}
new const 
Shop_ItemPricesTerro[6] = {
    
900,
    
700,
    
700,
    
3500,
    
2500,
    
1500
}
public 
plugin_init() 
{
    
register_plugin(PLUGINVERISONAUTHOR)
    
register_clcmd("say /jbshop""JailBreakShop")
    
register_clcmd("say /shop""JailBreakShop")
    
register_clcmd("say_team /jbshop""JailBreakShop")
    
register_clcmd("say_team /shop""JailBreakShop")
    
    
register_clcmd("say /gamble""gamble")
    
register_clcmd("say /rtd""gamble")
    
register_clcmd("say_team /gamble""gamble")
    
register_clcmd("say_team /rtd""gamble")
    
    
register_clcmd("say /cash""Handler_ShowPlayerCash")
    
    
RegisterHam(Ham_Killed"player""Ham_PlayerKilled");
    
    
g_pEnableShop register_cvar("jb_shop""1")
    
g_pEnableGamble register_cvar("jb_gamble""1")
}

public 
JailBreakShop(id)
{
    if(!
get_pcvar_num(g_pEnableShop))
    {
        return 
PLUGIN_HANDLED
    
}
    if(
cs_get_user_team(id)==CS_TEAM_T && is_user_alive(id))
    {
        new 
ShopMenu menu_create("\rJailBreak \yShop \wMenu:""shop_handler")
        
        new 
szTemp[500], Key[6]; 
        
        for(new 
08i++) {
            
formatex(szTempcharsmax(szTemp), "%s%s\d [\y$%i\d]", (pCash[id] >= Shop_ItemPricesTerro[i]) ? "\r" "\d"Shop_ItemNamesTerro[i], Shop_ItemPricesTerro[i])
            
num_to_str(iKeycharsmax(Key))
            
menu_additem(ShopMenuszTempKey)
        }
        
menu_setprop(ShopMenuMPROP_EXITMEXIT_ALL)
        
menu_display(idShopMenu0)
    }
    return 
PLUGIN_CONTINUE
}
public 
shop_handler(idShopMenuitem) {
    if(
item != MENU_EXIT) {
        new 
key MenuKey(ShopMenuitem)
        
        if(
Shop_ItemPricesTerro[key] > pCash[id]) {
            
ColorChat(idGREY"%s You don't got enough money for^x03 %s^x01."g_szPrefixShop_ItemNamesTerro[key])
            
JailBreakShop(id)
        }
        else {
            switch(
key)
            {
                case 
0:
                {
                    
give_item(id"weapon_deagle")
                }
                case 
1:
                {
                    
set_user_gravity(id0.7)
                }
                case 
2:
                {
                    
set_user_maxspeed(id320.0)
                }
                case 
3:
                {
                    
set_user_health(id100)
                }
                case 
4:
                {
                    
set_user_footsteps(id1)
                }
                case 
5:
                {
                    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0);
                    
set_task(60.0"RemoveInvis"id)
                }
                case 
6:
                {
                    
give_item(id"weapon_usp")
                    
give_item(id"weapon_flashbang")
                    
give_item(id"weapon_hegrenade")
                    
set_user_health(id80)
                    
set_user_armor(id100)
                }
                case 
7:
                {
                    if(!
get_pcvar_num(g_pEnableGamble))
                    {
                        return 
PLUGIN_HANDLED
                    
}
                    if(
pCash[id] > 200)
                    {
                        new 
Playernum random_num(1100)
                        new 
Servernum random_num(25100)
                        if(
Playernum Servernum)
                        {
                            new 
szName[32]; get_user_name(idszNamecharsmax(szName))
                            
pCash[id] += 200
                            ColorChat
(idTEAM_COLOR"%s You've won^x04 200$^x01 versus the server! %i vs %i"g_szPrefixPlayernumServernum)
                        }
                        else if(
Servernum Playernum)
                        {
                            new 
szName[32]; get_user_name(idszNamecharsmax(szName))
                            
pCash[id] -= 200
                            ColorChat
(idTEAM_COLOR"%s You've lost^x04 200$^x01 versus the server! %i vs %i"g_szPrefixServernumPlayernum)
                        }
                    }
                    else if(
pCash[id] < 200)
                    {
                        
ColorChat(idTEAM_COLOR"%s You need more JB cash to roll the dice!"g_szPrefix)
                    }
                        
                }
            }
            if(
Shop_ItemPricesTerro[key]) {
                
pCash[id] -= Shop_ItemPricesTerro[key]
                
ColorChat(idGREY"%s You bought item^x03 %s^x01 for^x03 %i$^x01."g_szPrefixShop_ItemNamesTerro[key], Shop_ItemPricesTerro[key])
            }
        }
    }    
    return 
PLUGIN_CONTINUE
}

public 
client_putinserver(id)
{
    
set_task(10.0"ShowMessage"id)
    
set_task(20.0"ShowInfo"id)
}

public 
ShowMessage(id)
{
    if(
is_user_connected(id))
    {
        new 
szName[32]; get_user_name(idszNamecharsmax(szName))
        
ColorChat(idTEAM_COLOR"%s Welcome to the server, ^x04[%s]^x01!"g_szPrefixszName)
    }
}




public 
Ham_PlayerKilled(idiAttacker)
{
    if(
is_user_alive(iAttacker) && get_user_team(id) != get_user_team(iAttacker))
    {
        
pCash[iAttacker] += 150
    
}
}

public 
Handler_ShowPlayerCash(id)  

    
client_print(idprint_chat"You got %i cash."pCash[id]) 
}  
stock MenuKey(menuitem) {
    new 
iAccessszNum], hCallback
    menu_item_getinfo
menuitemiAccessszNumcharsmaxszNum ), __hCallback )
    
    return 
str_to_numszNum )



matsi 08-17-2012 14:10

Re: Menu won't display but the adv message displays
 
Just remove iAttacker. :roll:

pokemonmaster 08-17-2012 14:52

Re: Menu won't display but the adv message displays
 
Quote:

Originally Posted by matsi (Post 1774257)
Just remove iAttacker. :roll:

He means
Edit this:
PHP Code:

public Handler_ShowPlayerCash(idiAttacker
{
    
client_print(idprint_chat"You got %i cash."pCash[iAttacker])


To this:
PHP Code:

public Handler_ShowPlayerCash(id
{
    
client_print(idprint_chat"You got %i cash."pCash[id])



f0rhead 08-17-2012 15:46

Re: Menu won't display but the adv message displays
 
Quote:

Originally Posted by pokemonmaster (Post 1774302)
He means
Edit this:
PHP Code:

public Handler_ShowPlayerCash(idiAttacker
{
    
client_print(idprint_chat"You got %i cash."pCash[iAttacker])


To this:
PHP Code:

public Handler_ShowPlayerCash(id
{
    
client_print(idprint_chat"You got %i cash."pCash[id])



I replaced that line but still it does not work :/

matsi 08-17-2012 16:17

Re: Menu won't display but the adv message displays
 
First problem is that your cvar register should be above the commands you register. If its below your commands you will have error with Invalid CVAR pointer.

So change your plugin_init:
Code:
public plugin_init() {     register_plugin(PLUGIN, VERISON, AUTHOR)         g_pEnableShop = register_cvar("jb_shop", "1") // New position     g_pEnableGamble = register_cvar("jb_gamble", "1") // New position         register_clcmd("say /jbshop", "JailBreakShop")     register_clcmd("say /shop", "JailBreakShop")     register_clcmd("say_team /jbshop", "JailBreakShop")     register_clcmd("say_team /shop", "JailBreakShop")         register_clcmd("say /gamble", "gamble")     register_clcmd("say /rtd", "gamble")     register_clcmd("say_team /gamble", "gamble")     register_clcmd("say_team /rtd", "gamble")         register_clcmd("say /cash", "Handler_ShowPlayerCash")         RegisterHam(Ham_Killed, "player", "Ham_PlayerKilled");            // Old position            // Old position }
Second problem is this:
Code:
set_task(20.0, "ShowInfo", id)
Remove it because there is no "ShowInfo" function, it gives you runtime errors.

f0rhead 08-17-2012 16:42

Re: Menu won't display but the adv message displays
 
Quote:

Originally Posted by matsi (Post 1774375)
First problem is that your cvar register should be above the commands you register. If its below your commands you will have error with Invalid CVAR pointer.

So change your plugin_init:
Code:
public plugin_init() {     register_plugin(PLUGIN, VERISON, AUTHOR)         g_pEnableShop = register_cvar("jb_shop", "1") // New position     g_pEnableGamble = register_cvar("jb_gamble", "1") // New position         register_clcmd("say /jbshop", "JailBreakShop")     register_clcmd("say /shop", "JailBreakShop")     register_clcmd("say_team /jbshop", "JailBreakShop")     register_clcmd("say_team /shop", "JailBreakShop")         register_clcmd("say /gamble", "gamble")     register_clcmd("say /rtd", "gamble")     register_clcmd("say_team /gamble", "gamble")     register_clcmd("say_team /rtd", "gamble")         register_clcmd("say /cash", "Handler_ShowPlayerCash")         RegisterHam(Ham_Killed, "player", "Ham_PlayerKilled");            // Old position            // Old position }
Second problem is this:
Code:
set_task(20.0, "ShowInfo", id)
Remove it because there is no "ShowInfo" function, it gives you runtime errors.

I appreicate the help, The Cvars is listed and shows in console now but when I write a command nothing displays!

ex. /cash and nothing happens.

matsi 08-17-2012 16:50

Re: Menu won't display but the adv message displays
 
Quote:

Originally Posted by f0rhead (Post 1774396)
I appreicate the help, The Cvars is listed and shows in console now but when I write a command nothing displays!

ex. /cash and nothing happens.

Ehh.... Remove these AGAIN because there is no "gamble" function:
Code:
register_clcmd("say /gamble", "gamble") register_clcmd("say /rtd", "gamble") register_clcmd("say_team /gamble", "gamble") register_clcmd("say_team /rtd", "gamble")

f0rhead 08-17-2012 17:56

Re: Menu won't display but the adv message displays
 
Works!


All times are GMT -4. The time now is 13:43.

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