Raised This Month: $ Target: $400
 0% 

Help with Code ..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicFail.
Senior Member
Join Date: May 2010
Old 08-23-2010 , 19:32   Help with Code ..
Reply With Quote #1

How i can fix this ?

here my code:
PHP Code:
menu_additemhmenu"1""%s25 Health \r- %s\W%d\Y$"is_user_aliveid ) ? "\w" "\d", ( iMoney >= HEALTH25_COST ) ? "\w" "\d"HEALTH25_COST ); 
Here the Error:
PHP Code:
ErrorArgument type mismatch (argument 4on line 441 
Some one help please
EpicFail. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-23-2010 , 20:00   Re: Help with Code ..
Reply With Quote #2

You can't format with menu_additem(). Youhave to format with format() then put that into menu_additem().
__________________
fysiks is offline
rubee
Senior Member
Join Date: Oct 2009
Location: party rocking
Old 08-23-2010 , 20:09   Re: Help with Code ..
Reply With Quote #3

try this

Code:
new option[30] formatex(option, charsmax(option), "%s25 Health \r- %s\w%d\y$", is_user_alive( id ) ? "\w" : "\d", ( iMoney >= HEALTH25_COST ) ? "\w" : "\d", HEALTH25_COST ); menu_additem(hmenu, option, "1", 0)
__________________


rubee is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 08-24-2010 , 01:18   Re: Help with Code ..
Reply With Quote #4

Quote:
Originally Posted by rubee View Post
try this

Code:
new option[30] formatex(option, charsmax(option), "%s25 Health \r- %s\w%d\y$", is_user_alive( id ) ? "\w" : "\d", ( iMoney >= HEALTH25_COST ) ? "\w" : "\d", HEALTH25_COST ); menu_additem(hmenu, option, "1", 0)
Next time, let him try it first. Otherwise he doesnt learn anything.
__________________
Hi.
Kreation is offline
EpicFail.
Senior Member
Join Date: May 2010
Old 08-24-2010 , 20:12   Re: Help with Code ..
Reply With Quote #5

Quote:
Originally Posted by rubee View Post
try this

Code:
new option[30] formatex(option, charsmax(option), "%s25 Health \r- %s\w%d\y$", is_user_alive( id ) ? "\w" : "\d", ( iMoney >= HEALTH25_COST ) ? "\w" : "\d", HEALTH25_COST );
menu_additem(hmenu, option, "1", 0)


Hm.. this work but !
if i buy one item of menu with 7 Numbers
i cant buy nothing again from this ..
how i can fix it ?

Sorry for bad English
EpicFail. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-24-2010 , 20:14   Re: Help with Code ..
Reply With Quote #6

Quote:
Originally Posted by EpicFail. View Post
Hm.. this work but !
if i buy one item of menu with 7 Numbers
i cant buy nothing again from this ..
how i can fix it ?

Sorry for bad English
Re-show the menu in the handling function. Directly before return PLUGIN_HANDLED but after menu_destroy (if the menu is not global).
__________________
fysiks is offline
EpicFail.
Senior Member
Join Date: May 2010
Old 08-24-2010 , 20:16   Re: Help with Code ..
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Re-show the menu in the handling function. Directly before return PLUGIN_HANDLED but after menu_destroy (if the menu is not global).

Hm ..
Like this ? Code:
PHP Code:
new menuname[64]
    
formatexmenuname63"\r[\wjG`\r] \wHns Shop^nHealth Menu^nYour Cash: %d\y$"cs_get_user_moneyid ) );
    new 
hmenu menu_createmenuname"health_handler" );
    
    new 
iMoney cs_get_user_moneyid )
    
    new 
Health25[30]
    
formatexHealth25charsmax(Health25), "25 Health \r- %s\W%d\Y$", ( iMoney >= HEALTH25_COST ) ? "\w" "\d"HEALTH25_COST );
    
menu_additem(hmenuHealth25"1"0);
     
    new 
Health50[30]
    
formatex(Health50charsmax(Health50), "50 Health \r- %s\W%d\Y$", ( iMoney >= HEALTH50_COST ) ? "\w" "\d"HEALTH50_COST );
         
menu_additem(hmenuHealth50"2"0);
    
    
menu_setprophmenuMPROP_EXITMEXIT_ALL );
    
menu_setprophmenuMPROP_EXITNAME"\wBack" );
    
    
menu_displayidhmenu);
    
    return 
PLUGIN_CONTINUE
EpicFail. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-24-2010 , 20:19   Re: Help with Code ..
Reply With Quote #8

Quote:
Originally Posted by EpicFail. View Post
Hm ..
Like this ? Code:
PHP Code:
new menuname[64]
    
formatexmenuname63"\r[\wjG`\r] \wHns Shop^nHealth Menu^nYour Cash: %d\y$"cs_get_user_moneyid ) );
    new 
hmenu menu_createmenuname"health_handler" );
    
    new 
iMoney cs_get_user_moneyid )
    
    new 
Health25[30]
    
formatexHealth25charsmax(Health25), "25 Health \r- %s\W%d\Y$", ( iMoney >= HEALTH25_COST ) ? "\w" "\d"HEALTH25_COST );
    
menu_additem(hmenuHealth25"1"0);
     
    new 
Health50[30]
    
formatex(Health50charsmax(Health50), "50 Health \r- %s\W%d\Y$", ( iMoney >= HEALTH50_COST ) ? "\w" "\d"HEALTH50_COST );
         
menu_additem(hmenuHealth50"2"0);
    
    
menu_setprophmenuMPROP_EXITMEXIT_ALL );
    
menu_setprophmenuMPROP_EXITNAME"\wBack" );
    
    
menu_displayidhmenu);
    
    return 
PLUGIN_CONTINUE
That is the menu function. I'm talking about "health_handler". It should look something like:

PHP Code:
public health_handler(idmenuitem)
{
    
// code to handle exit
    // code to hanlde selected options
    
    
menu_destroy(menu)
    
show_menu_function(id// This is the function that creates the menu an shows it.  The one you just posted.
    
return PLUGIN_HANDLED

__________________
fysiks is offline
EpicFail.
Senior Member
Join Date: May 2010
Old 08-24-2010 , 20:23   Re: Help with Code ..
Reply With Quote #9

This maybe ?

PHP Code:
public health_handleridhmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroyhmenu );
        
CmdMainMenuid );
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfohmenuitemaccessdata5iName63callback );
    
    new 
picked str_to_numdata );
    new 
iMoney cs_get_user_moneyid );
    
    switch( 
picked )
    {
             case 
1:
        {
            if( 
iMoney >= HEALTH25_COST )
            {
                if( 
is_user_aliveid ) )
                {
                    if( !
g_bHas25HP[id] )
                    {
                        
cs_set_user_moneyidiMoney HEALTH25_COST );
                    
                        new 
health get_user_healthid ) + 25;
                        
set_user_healthidhealth );
                        
g_bHas25HP[id] = true;
                    
                        
client_cmdid"spk items/medshot4" );
                    }
                    else
                    {
                        
ChatColor0"%s You already bought this item!"CLAN_TAG );
                        return 
PLUGIN_HANDLED;
                    }
                }
                else
                {
                    
ChatColor0"%s You must be alive to use the shop!"CLAN_TAG );
                    return 
PLUGIN_HANDLED;
                }
            }
            else
            {
                
ChatColor0"%s You don't have enough money for this!"CLAN_TAG );
                return 
PLUGIN_HANDLED;
            }
        }
        case 
2:
        {
            if( 
iMoney >= HEALTH50_COST )
            {
                if( 
is_user_aliveid ) )
                {
                    if( !
g_bHas25HP[id] )
                    {
                        
cs_set_user_moneyidiMoney HEALTH50_COST );
                    
                        new 
health get_user_healthid ) + 50;
                        
set_user_healthidhealth );
                        
g_bHas25HP[id] = true;
                    
                        
client_cmdid"spk items/medshot4" );
                    }
                    else
                    {
                        
ChatColor0"%s You already bought this item!"CLAN_TAG );
                        return 
PLUGIN_HANDLED;
                    }
                }
                else
                {
                    
ChatColor0"%s You must be alive to use the shop!"CLAN_TAG );
                    return 
PLUGIN_HANDLED;
                }
            }
            else
            {
                
ChatColor0"%s You don't have enough money for this!"CLAN_TAG );
                return 
PLUGIN_HANDLED;
            }
        }

         }        
    
    
menu_destroyhmenu );
    
CmdMainMenuid );
    return 
PLUGIN_HANDLED;

EpicFail. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-24-2010 , 21:30   Re: Help with Code ..
Reply With Quote #10

Quote:
Originally Posted by EpicFail. View Post
This maybe ?
Don't put it in the exit part. If you do that then you can never close the menu (unless it's a submenu). So, remove that and it should work.
__________________
fysiks 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 21:50.


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