Raised This Month: $ Target: $400
 0% 

A problem with menu.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
obiwan
Junior Member
Join Date: Sep 2008
Old 06-15-2010 , 19:05   A problem with menu.
Reply With Quote #1

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! :-)
obiwan is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-15-2010 , 20:50   Re: A problem with menu.
Reply With Quote #2

First you have to look at here:

http://forums.alliedmods.net/showthread.php?t=46364
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
obiwan
Junior Member
Join Date: Sep 2008
Old 06-16-2010 , 02:02   Re: A problem with menu.
Reply With Quote #3

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

Last edited by obiwan; 06-16-2010 at 02:07.
obiwan is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 02:09   Re: A problem with menu.
Reply With Quote #4

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.
__________________
fysiks is offline
Old 06-16-2010, 02:32
obiwan
This message has been deleted by obiwan. Reason: re
obiwan
Junior Member
Join Date: Sep 2008
Old 06-16-2010 , 10:29   Re: A problem with menu.
Reply With Quote #6

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

obiwan is offline
Old 06-16-2010, 11:17
drekes
This message has been deleted by drekes. Reason: nvm
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 13:10   Re: A problem with menu.
Reply With Quote #8

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.
__________________
fysiks is offline
obiwan
Junior Member
Join Date: Sep 2008
Old 06-16-2010 , 13:56   Re: A problem with menu.
Reply With Quote #9

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


and after click

Last edited by obiwan; 06-16-2010 at 14:01.
obiwan is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 15:18   Re: A problem with menu.
Reply With Quote #10

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

__________________
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 14:46.


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