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

Solved Menu Option Turn On Off


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 19:14   Menu Option Turn On Off
Reply With Quote #1

I Need One Option Key Like I Already Made (2) For Activate And The Same Key To Deactivate The Function Like Godmode If I Press 2 It Turns On And If I Press 2 Again It Turns Off How I Can Make It With Speed?!?!? I Made A New Plugin To Make It Short And Easy to Understand (debug)

The Code
PHP Code:
/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <amxmisc> 
#include <fun> 

#define PLUGIN "teste speed menu" 
#define VERSION "1.0" 
#define AUTHOR "_|Polimpo4|_" 

#define ADMIN_ACESS ADMIN_KICK    // 

#define Keysmenu_1 (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) //Keys: 1234567890 

// Tag Do Clan 
new const g_Client[] = "[PlayMeNow]"

public 
plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
     
    
register_dictionary"speedmenu.txt"); 
     
    
register_cvar("write_log_file","1"); 
     
    
register_concmd("speedmenu""ShowSpeedMenu"ADMIN_ACESS"Open Admin Menu #1"
     
    
register_menucmd(register_menuid("menu_1"), Keysmenu_1"Pressedmenu_1"
     
    
// Add your code here... 


public 
ShowSpeedMenu(id) { 
    if (
get_user_flags(id) & ADMIN_ACESS
    { 
        
show_menu(idKeysmenu_1"\rPMN Menu #1^n^n\r1. \wMax Speed^n^n\r2. Sair", -1"menu_1"// Display menu 
     
        
return PLUGIN_CONTINUE 
    

    else 
    { 
        
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"MSGM_ACESSO"); 
         
        return 
PLUGIN_HANDLED
    } 
     
    return 
PLUGIN_CONTINUE 


public 
Pressedmenu_1(idkey) { 

    new 
team[32], User[32]; 
    
get_user_team(id,team,32); 
    
get_user_name(id,User,32); 
     
    switch (
key) { 
        case 
0: { // 1 
         
                
for(new i=1;i<=32;i++) 
                { 
                    if(
is_user_connected(i) && is_user_alive(i) ) 
                    { 
                        new 
name[32]; 
                        
get_user_name(id,name,31); 
                        new 
triggeroption something to trigger
                         
                        if(
triggeroption == 0
                        { 
                            
set_user_maxspeed(id,900.0); // Max speed: 500 
                            
triggeroption 1
                            
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"SPEED_RUN_MSG"
                             
                            if(
get_cvar_num("write_log_file") == 1
                                
log_amx("%s use a Admin Cheats: Max SPEED (500)"User); 
                        } 
                        else 
                        { 
                            
triggeroption0
                            
set_user_maxspeed(id,320.0); // Normal speed: 320 
                            
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"SPEED_NOT_RUN_MSG"
                            return 
PLUGIN_HANDLED
                        } 
                    } 
                    else 
                    { 
                        
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"DIED_MSG"
                        return 
PLUGIN_HANDLED
                    } 
                     
                    
client_cmd(id"speedmenu"
                } 
            } 
        case 
1: { // 2 
            
return PLUGIN_HANDLED
        } 
    } 
    return 
PLUGIN_HANDLED 

To Make It Working You Need Change That Keywords:

something to trigger » i used get_user_godmode(id);
triggeroption » i used ghost

Last edited by polimpo4; 04-17-2018 at 16:28. Reason: Easy To Explain
polimpo4 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-16-2018 , 21:38   Re: Menu Option Turn On Off
Reply With Quote #2

And what exactly do you think speed will contain after this?

Code:
new speed = set_user_maxspeed(id,320.0);
It has no return value.

Have you tried get_user_maxspeed() and then checking that value accordingly?
__________________

Last edited by fysiks; 04-16-2018 at 21:38.
fysiks is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-16-2018 , 21:45   Re: Menu Option Turn On Off
Reply With Quote #3

It's simple, use a global boolean on menu, true = do something, false = do other thing.
iceeedr is offline
Send a message via Skype™ to iceeedr
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 23:16   Re: Menu Option Turn On Off
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
And what exactly do you think speed will contain after this?

Code:
new speed = set_user_maxspeed(id,320.0);
It has no return value.

Have you tried get_user_maxspeed() and then checking that value accordingly?
I Create All New Plugin Just To Be Easy To Understand What I Want...

I Need To Click 2 And Activate And When I Press 2 Again Deactivate. I Made It But Only Works If You Change That Keywords:

something to trigger » i used get_user_godmode(id);
triggeroption » i used ghost


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "teste speed menu"
#define VERSION "1.0"
#define AUTHOR "_|Polimpo4|_"

#define ADMIN_ACESS ADMIN_KICK    //

#define Keysmenu_1 (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) //Keys: 1234567890

// Tag Do Clan
new const g_Client[] = "[PlayMeNow]";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_dictionary"adminmenu.txt");
    
    
register_cvar("write_log_file","1");
    
    
register_concmd("speedmenu""ShowSpeedMenu"ADMIN_ACESS"Open Admin Menu #1")
    
    
register_menucmd(register_menuid("menu_1"), Keysmenu_1"Pressedmenu_1")
    
    
// Add your code here...
}

public 
ShowSpeedMenu(id) {
    if (
get_user_flags(id) & ADMIN_ACESS)
    {
        
show_menu(idKeysmenu_1"\rPMN Menu #1^n^n\r1. \wMax Speed^n^n\r2. Sair", -1"menu_1"// Display menu
    
        
return PLUGIN_CONTINUE
    
}
    else
    {
        
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"MSGM_ACESSO");
        
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE
}

public 
Pressedmenu_1(idkey) {

    new 
team[32], User[32];
    
get_user_team(id,team,32);
    
get_user_name(id,User,32);
    
    switch (
key) {
        case 
0: { // 1
        
                
for(new i=1;i<=32;i++)
                {
                    if(
is_user_connected(i) && is_user_alive(i) )
                    {
                        new 
name[32];
                        
get_user_name(id,name,31);
                        new 
triggeroption something to trigger;
                        
                        if(
triggeroption == 0)
                        {
                            
set_user_maxspeed(id,900.0); // Max speed: 500
                            
triggeroption 1;
                            
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"SPEED_RUN_MSG")
                            
                            if(
get_cvar_num("write_log_file") == 1)
                                
log_amx("%s use a Admin Cheats: Max SPEED (500)"User);
                        }
                        else
                        {
                            
triggeroption0;
                            
set_user_maxspeed(id,320.0); // Normal speed: 320
                            
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"SPEED_NOT_RUN_MSG")
                            return 
PLUGIN_HANDLED;
                        }
                    }
                    else
                    {
                        
client_print(idprint_chat"%s %L",g_ClientLANG_PLAYER,"DIED_MSG")
                        return 
PLUGIN_HANDLED;
                    }
                    
                    
client_cmd(id"speedmenu")
                }
            }
        case 
1: { // 2
            
return PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED

polimpo4 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-17-2018 , 04:22   Re: Menu Option Turn On Off
Reply With Quote #5

Here's an example. Take a closer look.
Quote:
Originally Posted by Relaxing View Post
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define GRAVITY 0.5 #define SPEED 800.0 new bool: gravity[33]; new bool: speed[33]; public plugin_init()     register_clcmd("say /vip", "clcmd_vip"); public clcmd_vip(id, level, cid){     if(is_user_alive(id)) continue;     new menu = menu_create("VIP Menu", "handler");     new formatex_gravity[20], formatex_speed[20];     formatex(formatex_gravity, charsmax(formatex_gravity), "Gravity [%s]", gravity[id] ? "ON" : "\rOFF\w");     formatex(formatex_speed, charsmax(formatex_speed), "Speed [%s]", speed[id] ? "ON" : "\rOFF\w");     menu_additem(menu, formatex_gravity);     menu_additem(menu, formatex_speed);     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);     menu_display(id, menu); } public handler(id, menu, item){     switch(item){         case MENU_EXIT: menu_destroy(menu);         case 0: {             if(gravity[id]){                 set_user_gravity(id, 1.0)                 gravity[id] = false;             }             else {                 set_user_gravity(id, GRAVITY);                 gravity[id] = true;             }         }                 case 1: {             if(speed[id]){                 set_user_maxspeed(id, 400.0)                 speed[id] = false;             }             else {                 set_user_maxspeed(id, SPEED);                 speed[id] = true;             }         }     } }
__________________

Last edited by Relaxing; 04-17-2018 at 04:25.
Relaxing is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-17-2018 , 15:59   Re: Menu Option Turn On Off
Reply With Quote #6

Quote:
Originally Posted by Relaxing View Post
Here's an example. Take a closer look.
register_clcmd("say /vip", "clcmd_vip")
: error 021: symbol already defined: "register_clcmd"

if(is_user_alive(id)) continue;
: error 024: "break" or "continue" is out of context
polimpo4 is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-17-2018 , 16:15   Re: Menu Option Turn On Off
Reply With Quote #7

Quote:
Originally Posted by Relaxing View Post
Here's an example. Take a closer look.
I Fixed Syntax Of Your Code But... One Little Thing Speed Dont Work At All ;) Same Problem As Me ;)
polimpo4 is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-17-2018 , 16:23   Re: Menu Option Turn On Off
Reply With Quote #8

Quote:
Originally Posted by Relaxing View Post
Here's an example. Take a closer look.
I Already Fixed Evrything ;) Thanks Your TOP ;)

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

#define GRAVITY 0.5
#define NORMALSPEED 320.0
#define MAXSPEED 900.0

new boolgravity[33];
new 
boolspeed[33];

public 
plugin_init()

    
register_clcmd("say /vip""clcmd_vip");

public 
clcmd_vip(idlevelcid){
    if(
is_user_alive(id)){
    new 
menu menu_create("VIP Menu""handler");

    new 
formatex_gravity[20], formatex_speed[20];
    
formatex(formatex_gravitycharsmax(formatex_gravity), "Gravity [%s]"gravity[id] ? "ON" "\rOFF\w");

    
formatex(formatex_speedcharsmax(formatex_speed), "Speed [%s]"speed[id] ? "ON" "\rOFF\w");

    
menu_additem(menuformatex_gravity);
    
menu_additem(menuformatex_speed);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu);
   }
}

public 
handler(idmenuitem){
    switch(
item){
        case 
MENU_EXITmenu_destroy(menu);

        case 
0: {
            if(
gravity[id]){
                
set_user_gravity(id1.0)
                
gravity[id] = false;
            }

            else {
                
set_user_gravity(idGRAVITY);
                
gravity[id] = true;
            }
        }
        
        case 
1: {
            if(
speed[id]){
                
set_user_maxspeed(idNORMALSPEED)
                
speed[id] = false;
            }

            else {
                
set_user_maxspeed(idMAXSPEED);
                
speed[id] = true;
            }
        }
    }


Last edited by polimpo4; 04-17-2018 at 16:23.
polimpo4 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-18-2018 , 03:42   Re: Menu Option Turn On Off
Reply With Quote #9

Quote:
Originally Posted by polimpo4 View Post
register_clcmd("say /vip", "clcmd_vip")
: error 021: symbol already defined: "register_clcmd"

if(is_user_alive(id)) continue;
: error 024: "break" or "continue" is out of context
Typically the vvorst errors ive ever sean.
__________________
Relaxing 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 07:17.


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