AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Menu Option Turn On Off (https://forums.alliedmods.net/showthread.php?t=306850)

polimpo4 04-16-2018 19:14

Menu Option Turn On Off
 
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

fysiks 04-16-2018 21:38

Re: Menu Option Turn On Off
 
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?

iceeedr 04-16-2018 21:45

Re: Menu Option Turn On Off
 
It's simple, use a global boolean on menu, true = do something, false = do other thing.

polimpo4 04-16-2018 23:16

Re: Menu Option Turn On Off
 
Quote:

Originally Posted by fysiks (Post 2588051)
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



Relaxing 04-17-2018 04:22

Re: Menu Option Turn On Off
 
Here's an example. Take a closer look.
Quote:

Originally Posted by Relaxing (Post 2566807)
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;             }         }     } }


polimpo4 04-17-2018 15:59

Re: Menu Option Turn On Off
 
Quote:

Originally Posted by Relaxing (Post 2588080)
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 04-17-2018 16:15

Re: Menu Option Turn On Off
 
Quote:

Originally Posted by Relaxing (Post 2588080)
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 04-17-2018 16:23

Re: Menu Option Turn On Off
 
Quote:

Originally Posted by Relaxing (Post 2588080)
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;
            }
        }
    }



Relaxing 04-18-2018 03:42

Re: Menu Option Turn On Off
 
Quote:

Originally Posted by polimpo4 (Post 2588173)
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.


All times are GMT -4. The time now is 04:33.

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