Raised This Month: $ Target: $400
 0% 

Formatex


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-26-2012 , 14:30   Formatex
Reply With Quote #1

Example:

Menu.

1. Godmode [ON] \ [OFF]

My question is, how do you do it in formatex if a player presses 1, it sets to ON or OFF. How to do it in the handler aswell?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-26-2012 , 14:45   Re: Formatex
Reply With Quote #2

Quote:
if ( on )
= off
else
= on
?
.Dare Devil. is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-26-2012 , 15:00   Re: Formatex
Reply With Quote #3

can you give me an example? also, on the handler. if he presses 1 and its on, it turnes on, but if it's off, it turns off aswell
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-26-2012 , 15:08   Re: Formatex
Reply With Quote #4

in old menu style ofcourse

PHP Code:
new onoff 0


public menuhandle(idkey)
{
    switch (
key)
    {
        case 
0// this is the key 1
        
{
            
// when player press the key 1 and thing is on, then it will be off, and if it off then 
            // it will be on
            
if (onoff)
                
onoff 0
            
else
                
onoff 1
         
}
     }


Last edited by .Dare Devil.; 04-26-2012 at 15:10.
.Dare Devil. is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-26-2012 , 17:14   Re: Formatex
Reply With Quote #5

like this?

PHP Code:
#include <amxmodx>

#define PLUGIN    "Test"
#define AUTHOR    "Epic"
#define VERSION    "1.0"

new onoff 0

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /menu""Menu")
}

public 
Menu(id)
{
    new 
menu menu_create("Choose an Option:""Menu_Handler")
    if(!
onoff)
    {
        
menu_additem(menu"Godmode \d[ON/\wOFF]""1"0);
    }
    else if(
onoff)
    {
        
menu_additem(menu"Godmode [ON\d/OFF]""1"0);
    }
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

public 
Menu_Handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1
        {
            if(!
onoff)
            {
                
onoff 1
            
}
            else if(
onoff)
            {
                
onoff 0
            
}
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Last edited by EpicMonkey; 04-26-2012 at 17:15.
EpicMonkey is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 04-26-2012 , 17:53   Re: Formatex
Reply With Quote #6

PHP Code:
new szItem[32]
formatex(szItemcharsmax(szItem), "GodMode [%s]"gGodmode[id] ? "ON" "OFF")
    
// Handler
gGodmode[id] = !gGodmode[id
__________________
alan_el_more is offline
Old 04-26-2012, 21:21
rak
This message has been deleted by rak. Reason: :O nice..
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 04-26-2012 , 22:54   Re: Formatex
Reply With Quote #7

if you use the new menu system, use the callback function menu_makecallback and menu_item_setname with the given golbal var !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
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 07:52.


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