AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Formatex (https://forums.alliedmods.net/showthread.php?t=183778)

Napoleon_be 04-26-2012 14:30

Formatex
 
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?

.Dare Devil. 04-26-2012 14:45

Re: Formatex
 
Quote:

if ( on )
= off
else
= on
?

Napoleon_be 04-26-2012 15:00

Re: Formatex
 
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

.Dare Devil. 04-26-2012 15:08

Re: Formatex
 
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
         
}
     }



EpicMonkey 04-26-2012 17:14

Re: Formatex
 
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;



alan_el_more 04-26-2012 17:53

Re: Formatex
 
PHP Code:

new szItem[32]
formatex(szItemcharsmax(szItem), "GodMode [%s]"gGodmode[id] ? "ON" "OFF")
    
// Handler
gGodmode[id] = !gGodmode[id


K.K.Lv 04-26-2012 22:54

Re: Formatex
 
if you use the new menu system, use the callback function menu_makecallback and menu_item_setname with the given golbal var !


All times are GMT -4. The time now is 07:52.

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