AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A problem with menu. (https://forums.alliedmods.net/showthread.php?t=129696)

obiwan 06-15-2010 19:05

A problem with menu.
 
Hello guys,

I want to make a menu, but i have got some problems.

I want to make menu that turn on/off a VIP model.
Part of the code is
Code:

public resetModel(id, level, cid) {
        if (get_user_flags(id) & ADMIN_USER) {
                new CsTeams:userTeam = cs_get_user_team(id)
                if (userTeam == CS_TEAM_T) {
                        cs_set_user_model(id, "vip_t")
                }
                else if(userTeam == CS_TEAM_CT) {
                        cs_set_user_model(id, "vip_ct")
                }
                else {
                        cs_reset_user_model(id)
                }
        }

        return PLUGIN_CONTINUE
}

I would like to make menu for that which going to look like this :
Code:

1. VIP Model [ON]
and when you are going to press number 1 its going to change to
Code:

1. VIP Model [OFF]
and this code is going to 'turn off' for a player and he will have default model again. (ofcourse when he will press 1 he will have VIP model again).

I am new to scripting, so please help me! :-)

Alucard^ 06-15-2010 20:50

Re: A problem with menu.
 
First you have to look at here:

http://forums.alliedmods.net/showthread.php?t=46364

obiwan 06-16-2010 02:02

Re: A problem with menu.
 
Quote:

Originally Posted by Alucard^ (Post 1210005)

Oh, thanks.
I just don't know how to make that if i press 1 in menu it wont disappear and change its name from
Code:

1.xxxx [ON]
to
Code:

1.xxxx [OFF]
i have deleted all
HTML Code:

menu_destroy(menu);
but it still doesnt want to not disappear

fysiks 06-16-2010 02:09

Re: A problem with menu.
 
If you don't the menu to disappear when you select option 1 then you just need to call the menu again when option 1 is selected.

obiwan 06-16-2010 10:29

Re: A problem with menu.
 
Okay, now i have another idea how to make this menu :
I want to make menu with cvars like this :

Code:

1. mp_friendlyfire 1
and when you going to click 1 its going to change to
Code:

1. mp_friendlyfire 0
i made it like this :
PHP Code:

 new call1

 
public plugin_init()
 {
    
//..stuff
    
call1 menu_makecallback("example_callback1")
 }

 public 
Menu(id)
 {

    new 
menu menu_create("\rCvar menu :""menu_handler");

    
menu_additem(menu"\wmp_friendlyfire""1"ADMIN_IMMUNITYcall1);
    
menu_additem(menu"\wI'm Selection #2""2"ADMIN_IMMUNITY);
    
menu_additem(menu"\wI'm Secret Selection #3""3"ADMIN_IMMUNITY);

    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
 }

// stuff

public example_callback1(idmenuitem)
{
    new 
callreturn
  
if(get_cvar_string("mp_friendlyfire" == 1){
      
callreturn ON
}
else {
    
callreturn OFF
}

    return 
callreturn


but i keep getting error
Code:

Error: Array must be indexed (variable "-unknown-") on line 97
line 97 is in this public
PHP Code:

public example_callback1(idmenuitem)
{
    new 
callreturn
  
if(get_cvar_string("mp_friendlyfire" == 1){
      
callreturn ON
}
else {
    
callreturn OFF
}

    return 
callreturn



fysiks 06-16-2010 13:10

Re: A problem with menu.
 
PHP Code:

if( get_cvar_num("mp_friendlyfire") ) 

I don't understand why you are using a callback. Do you want the line in the menu disabled? Also, ON and OFF are have no meaning.

obiwan 06-16-2010 13:56

Re: A problem with menu.
 
Quote:

Originally Posted by fysiks (Post 1210601)
PHP Code:

if( get_cvar_num("mp_friendlyfire") ) 

I don't understand why you are using a callback. Do you want the line in the menu disabled? Also, ON and OFF are have no meaning.

I dont know how to check players value and then make it to change cvar from 0 to 1 and from 1 to 0 if he press a button 1 in menu

I just want to make something like this and i dont know how :

http://i46.tinypic.com/1fwxnm.png
and after click
http://i46.tinypic.com/xljmyx.png

fysiks 06-16-2010 15:18

Re: A problem with menu.
 
Quote:

Originally Posted by obiwan (Post 1210662)
I dont know how to check players value and then make it to change cvar from 0 to 1 and from 1 to 0 if he press a button 1 in menu

PHP Code:

public Menu(id)
{
    
// ...
    
new szTemp[32]
    
formatex(szTempcharsmax(szTemp), "mp_friendlyfire %d"get_cvar_num("mp_friendlyfire"))
    
menu_additem(menuszTemp"1"ADMIN_IMMUNITY)
    
// ...
}
// menu handler
{
    
// ...
        
case 1:
        {
            
set_cvar_num("mp_friendlyfire"get_cvar_num("mp_friendlyfire") ? 1)
        }
    
// ...
    
menu_destroy(menu)
    
Menu(id)




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

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