Raised This Month: $ Target: $400
 0% 

Multi jump menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 01-18-2014 , 09:10   Multi jump menu
Reply With Quote #1

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

CHE4TER is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-18-2014 , 17:14   Re: Multi jump menu
Reply With Quote #2

You should be able to do this:
Code:
isEnabled[id] = !isEnabled[id]
__________________
fysiks is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 01-19-2014 , 09:56   Re: Multi jump menu
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
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

CHE4TER is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-19-2014 , 10:19   Re: Multi jump menu
Reply With Quote #4

  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.
__________________
fysiks is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 01-25-2014 , 21:12   Re: Multi jump menu
Reply With Quote #5

I don't get it.. Anyone can do this?
CHE4TER is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-25-2014 , 23:11   Re: Multi jump menu
Reply With Quote #6

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.
__________________
fysiks is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 01-25-2014 , 23:45   Re: Multi jump menu
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
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..
CHE4TER is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-26-2014 , 00:38   Re: Multi jump menu
Reply With Quote #8

Quote:
Originally Posted by CHE4TER View Post
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
__________________
fysiks is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 01-27-2014 , 00:09   Re: Multi jump menu
Reply With Quote #9

damn it..
CHE4TER is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-27-2014 , 00:10   Re: Multi jump menu
Reply With Quote #10

Quote:
Originally Posted by CHE4TER View Post
damn it..
And what does that mean?
__________________
fysiks 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 10:10.


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