AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Multi jump menu (https://forums.alliedmods.net/showthread.php?t=233645)

CHE4TER 01-18-2014 09:10

Multi jump menu
 
This plugin enables multi jump when you connect to the server..
What I need, is just make that function to the menu..
Like, you open the menu, you press 1, the jumps activates, you press again 1, the jumps disactivates..


PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define LEVEL_A        ADMIN_LEVEL_A

new jumpnum[33] = 0
new bool:dojump[33] = false

new isEnabled[64]
new 
status[64]

public 
plugin_init()
{
    
register_cvar("amx_maxjumps","1")
    
    
register_clcmd("say /jump""sayJump")
}

public 
client_putinserver(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_disconnect(id)
{

    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
sayJump(id) {
    
    
//isEnabled[32]
    
    
new menu menu_create("\rMenu""menu_handler")
    
formatex(status63"\wMulti Jump: %s^n"isEnabled[id] ? "\yON" "\dOFF")
    
menu_additem(menustatus"1")
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
menu_handler(idmenuitem) {

    switch(
item) {
        
        case 
0: {
            
// HOW?
        
}
    }
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
new nbut get_user_button(id)
    new 
obut get_user_oldbutton(id)
    if((
nbut IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut IN_JUMP))
    {
        if(
jumpnum[id] < get_cvar_num("amx_maxjumps"))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
PLUGIN_CONTINUE
        
}
    }
    if((
nbut IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
    {
        
jumpnum[id] = 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(dojump[id] == true)
    {
        new 
Float:velocity[3]    
        
entity_get_vector(id,EV_VEC_velocity,velocity)
        
velocity[2] = random_float(265.0,285.0)
        
entity_set_vector(id,EV_VEC_velocity,velocity)
        
dojump[id] = false
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE



fysiks 01-18-2014 17:14

Re: Multi jump menu
 
You should be able to do this:
Code:

isEnabled[id] = !isEnabled[id]

CHE4TER 01-19-2014 09:56

Re: Multi jump menu
 
Quote:

Originally Posted by fysiks (Post 2087830)
You should be able to do this:
Code:

isEnabled[id] = !isEnabled[id]

Like this, right?
PHP Code:

public sayJump(id) {
    
    
isEnabled[32] = !isEnabled[id]
    
    new 
menu menu_create("\rMenu""menu_handler")
    
formatex(status63"\wMulti Jump: %s^n"isEnabled[id] ? "\yON" "\dOFF")
    
menu_additem(menustatus"1")
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
menu_handler(idmenuitem) {

    switch(
item) {
        case 
0: {
            
// if user is not alive
            
if(!(is_user_alive(id))) {
            
client_print(idprint_chat"You must be alive")
            return 
PLUGIN_HANDLED
            
}
            
            
// make multi jump
        
}
    }
    return 
PLUGIN_CONTINUE



fysiks 01-19-2014 10:19

Re: Multi jump menu
 
  1. That is not what I said.
  2. The code I posted changes the enabled state. You said in your first post where you want that to happen so you need to put it there.

CHE4TER 01-25-2014 21:12

Re: Multi jump menu
 
I don't get it.. Anyone can do this?

fysiks 01-25-2014 23:11

Re: Multi jump menu
 
You want the enabled state to change when they select the menu options right? Therefore, you put the code that I have given you where it will get executed when the player chooses that option in the menu. You currently have it so that it will change every time you say /jump.

CHE4TER 01-25-2014 23:45

Re: Multi jump menu
 
Quote:

Originally Posted by fysiks (Post 2090987)
You want the enabled state to change when they select the menu options right? Therefore, you put the code that I have given you where it will get executed when the player chooses that option in the menu. You currently have it so that it will change every time you say /jump.

I want a menu that can enable/disable this multi jump...
Because client_PreThink/client_PostThink auto enable it..

fysiks 01-26-2014 00:38

Re: Multi jump menu
 
Quote:

Originally Posted by CHE4TER (Post 2090993)
I want a menu that can enable/disable this multi jump...
Because client_PreThink/client_PostThink auto enable it..

Ok, so do you have the menu part working?

Note: You shouldn't be doing an alive check in the menu part, it just doesn't make any sense.

After you get the menu part working correctly, you can add the isEnabled[id] to the multi-jump code. Which you can do by changing:

Code:

if(!is_user_alive(id)) return PLUGIN_CONTINUE
to this:

Code:

if(!is_user_alive(id) && !isEnabled[id]) return PLUGIN_CONTINUE

CHE4TER 01-27-2014 00:09

Re: Multi jump menu
 
damn it..

fysiks 01-27-2014 00:10

Re: Multi jump menu
 
Quote:

Originally Posted by CHE4TER (Post 2091390)
damn it..

And what does that mean?


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

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