AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   menu only for a User (https://forums.alliedmods.net/showthread.php?t=174766)

victorngl 12-25-2011 03:08

menu only for a User
 
I need this menu can be accessed only by the first user to type the command to open it.

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < cstrike >


#define PLUGIN "Vivo ou Morto JailBreak"
#define VERSION "1.0"
#define AUTHOR "Viictor #"

new szSoundM[] = { "sound/misc/morto.wav" 
new 
szSoundV[] = { "sound/misc/vivo.wav" 

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /brincadeiras""szFunny")
}

public 
plugin_precache()
{
    
precache_sound(szSoundM)
    
precache_sound(szSoundV)
}

public 
szFunny(id)
{
    new 
menu menu_create("\yVivo ou Morto!\r By Viictor#:""szMenu_Handled")
    
    
menu_additem(menu"\yVivo!""1"0)
    
menu_additem(menu"\yMorto!""2"0)
    
    
menu_setprop(menuMPROP_EXITMEXIT_NEVER)
    
    
menu_display(idmenu0)
}
public 
szMenu_Handled(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:{
            
server_cmd("amx_execall spk sound/misc/vivo.wav")
            
set_hudmessage(025500.480.3606.03.0)
            
show_hudmessage(0"VIVO!")
            
szFunny(id)
            
menu_destroy(menu)
            return 
PLUGIN_HANDLED
        
}
        case 
2:{
            
server_cmd("amx_execall spk sound/misc/morto.wav")
            
set_hudmessage(025500.480.3606.03.0)
            
show_hudmessage(0"MORTO!")
            
szFunny(id)
            
menu_destroy(menu)
            return 
PLUGIN_HANDLED
        
}
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED



Heartbeat 12-25-2011 04:13

Re: menu only for a User
 
i dont believe that is possible.. :(

fysiks 12-25-2011 04:13

Re: menu only for a User
 
Store the id of the first player in a global variable. Check in the command if the id of the person calling the command is the same as the person in the variable. Also, if the variable is equal to 0 then store the person's id. Quite simple actually.

victorngl 12-25-2011 04:18

Re: menu only for a User
 
something like that?

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < cstrike >


#define PLUGIN "Vivo ou Morto JailBreak"
#define VERSION "1.0"
#define AUTHOR "Viictor #"
new szName[32]
new 
szSoundM[] = { "sound/misc/morto.wav" 
new 
szSoundV[] = { "sound/misc/vivo.wav" 
new 
g_Player[33]


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /brincadeiras""szFunnyTask")
    
    
}

public 
szFunnyTaskid )
{
    
    
get_user_name(idszNamecharsmax(szName))
    
g_Player szName
    set_task
(0.1"szFunny"szName)
    
}
public 
plugin_precache()
{
    
precache_sound(szSoundM)
    
precache_sound(szSoundV)
}

public 
szFunny(id)
{
    
    if(
szName[id])
    {
        
        new 
menu menu_create("\yVivo ou Morto!\r By Viictor#:""szMenu_Handled")
        
        
menu_additem(menu"\yVivo!""1"0)
        
menu_additem(menu"\yMorto!""2"0)
        
        
menu_setprop(menuMPROP_EXITMEXIT_NEVER)
        
        
menu_display(idmenu0)
    }
    else
    {
        
client_print(idprint_chat"Outra pessoa ja esta usando o menu de brincadeiras")
    }
}
public 
szMenu_Handled(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:{
            
server_cmd("amx_execall spk sound/misc/vivo.wav")
            
set_hudmessage(025500.480.3606.03.0)
            
show_hudmessage(0"VIVO!")
            
szFunny(id)
            
menu_destroy(menu)
            return 
PLUGIN_HANDLED
        
}
        case 
2:{
            
server_cmd("amx_execall spk sound/misc/morto.wav")
            
set_hudmessage(025500.480.3606.03.0)
            
show_hudmessage(0"MORTO!")
            
szFunny(id)
            
menu_destroy(menu)
            return 
PLUGIN_HANDLED
        
}
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED



ConnorMcLeod 12-25-2011 08:08

Re: menu only for a User
 
PHP Code:

#include < amxmodx >

#define PLUGIN "Vivo ou Morto JailBreak"
#define VERSION "1.0"
#define AUTHOR "Viictor #"

new szSoundM[] = { "misc/morto.wav" }  // remove sound/ from path unless sound is located in cstrike/sound/sound/...
new szSoundV[] = { "misc/vivo.wav" 

new 
bool:g_bCmdHasBeenUsed

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /brincadeiras""ClCmd_FunnyTask")
}

public 
plugin_precache()
{
    
precache_sound(szSoundM)
    
precache_sound(szSoundV)
}

public 
ClCmd_FunnyTaskid )
{
    if( 
g_bCmdHasBeenUsed )
    {
        
client_print(idprint_chat"Outra pessoa ja esta usando o menu de brincadeiras")
        return 
PLUGIN_HANDLED
    
}

    
g_bCmdHasBeenUsed true

    
new menu menu_create("\yVivo ou Morto!\r By Viictor#:""hVivoMortoMenuHandled")

    
menu_additem(menu"\yVivo!")
    
menu_additem(menu"\yMorto!")

    
menu_setprop(menuMPROP_EXITMEXIT_NEVER)

    
menu_display(idmenu0)

    return 
PLUGIN_CONTINUE
}

public 
hVivoMortoMenuHandled(idmenuitem)
{
    switch( 
item // MENU_EXIT implied there, also MEXIT_NEVER is set so there is no exit option
    
{
        case 
0:
        {
            
client_cmd(0"spk %s"szSoundV)
            
set_hudmessage(025500.480.3606.03.0,_,_,-1)
            
show_hudmessage(0"VIVO!")
        }
        case 
1:
        {
            
client_cmd(0"spk %s"szSoundM)
            
set_hudmessage(025500.480.3606.03.0,_,_,-1)
            
show_hudmessage(0"MORTO!")
        }
    }

    
menu_destroy(menu)
    return 
PLUGIN_HANDLED



fysiks 12-25-2011 18:27

Re: menu only for a User
 
I was thinking he meant that the first person to use it can use it again and everybody else cannot use it at all. I guess the way he says it that it could be either way.

ConnorMcLeod 12-26-2011 00:45

Re: menu only for a User
 
Anyway, his code is so terrible that i would be better in request forum than in scripting help one.


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

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