Raised This Month: $ Target: $400
 0% 

Menu Model Help [ Fixed ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Baws
Veteran Member
Join Date: Oct 2012
Old 09-10-2013 , 23:20   Menu Model Help [ Fixed ]
Reply With Quote #1

I just want to see your methods so i can inform my self and learn every single one as i'm new to coding. What i'm talking about? Well, i want to use a new method for menu model. Like when i press a number it will give me the model. Well here is my method.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define MAXPLAYERS 32

#define MODNAME "^x01 [^x04 GenderCheck^x01 ]"

new SayText;

enum Color
{
    
NORMAL 1,
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

public 
plugin_init() 
{
    
register_plugin("GenderChecker""1.1""Baws")
    
    
register_cvar("amx_gender""1")
    
    
register_menucmd(register_menuid("menu"), 1023"menu_handler")
    
    
SayText get_user_msgid("SayText");
}

public 
plugin_precache()
{
   
precache_model("cstrike/models/player/f_arctic/f_arctic.mdl")
   
precache_model("cstrike/models/player/f_guerilla/f_guerilla.mdl")
   
precache_model("cstrike/models/player/f_leet/f_leet.mdl")
   
precache_model("cstrike/models/player/f_terror/f_terror.mdl")
}

public 
ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...) 
{
    static 
SayText;

    if(!
SayText)
        
SayText get_user_msgid("SayText");

    static 
message[256];

    switch(
type)
    {
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        case 
TEAM_COLOR// Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist).
        
{
            
message[0] = 0x03;
        }
        default: 
// Yellow.
        
{

            
message[0] = 0x01;
        }
    }

    
vformat(message[1], 251msg4);

    
message[192] = '^0';

    if(
id)
    {
        if(
is_user_connected(id))
        {
            
message_begin(MSG_ONESayText, {000}, id);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    } else {
        static 
players[32]; new countindex;
        
get_players(playerscount);

        for(new 
0counti++)
        {
            
index players[i];

            
message_begin(MSG_ONESayText, {000}, index);
            
write_byte(index);
            
write_string(message);
            
message_end();

        }
    }
}

public 
client_putinserver(id
{
    if(
get_cvar_num("amx_gender") != 1)
        return 
PLUGIN_HANDLED
    
    set_task
(1.0"GenderMenu"id)
        
    return 
PLUGIN_HANDLED


public 
GenderMenu(id)
{
   new 
menu menu_create"\yGender Checker: \rAre you a Guy or a Girl?""menu_handler" )

   
menu_additemmenu"\wI'm a Guy!""");
   
menu_additemmenu"\wI'm a Girl!""");
   
   
menu_displayidmenu);
}

public 
menu_handler(idmenuitem
{
    new 
szName[64];
    
get_user_name(idszNamecharsmax(szName))
    
    new 
message[132]
    
    
    switch(
item
    {
        case 
0:
        {
            
format(messagecharsmax(message), "%s Ladies! Mr. ^x04%s^x01 is coming.. but he's on the moon and he's walking!"MODNAMEszName)
        }
        case 
1:
        {
            
format(messagecharsmax(message), "%s Guys! Ms. ^x04%s^x01 is coming.. but she's in the kitchen and she's on her way!"MODNAMEszName)
            
ShowGirlMenu(id)
        }
        case 
MENU_EXIT:
        {
            
format(messagecharsmax(message), "%s Ladies & Gentlemen ^x04%s^x01 is an Alien!"MODNAMEszName)
        }
    }
    
    for (new 
i=0i<get_maxplayers(); i++) 
    {
        if(
is_user_connected(i)) 
        {
            
ColorChat(idGREENmessage);
            
message_begin(MSG_ONESayText_i);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED
}

ShowGirlMenu(id)
{
   new 
menu menu_create"\yGC: \rGirls Model Menu!""ShowGirlMenu_handler" )

   
menu_additemmenu"\wGirl Arctic""");
   
menu_additemmenu"\wGirl Guerilla""");
   
menu_additemmenu"\wGirl Leet""");
   
menu_additemmenu"\wGirl Terror""");
   
menu_additemmenu"\wReset model""");
   
   
menu_displayidmenu);
}

public 
ShowGirlMenu_handler(idmenuitem)
{        
    switch( 
item )
    {
        case 
0
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_arctic")
            
ShowGirlMenu(id)
        }
        case 
1
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_guerilla")
            
ShowGirlMenu(id)
        }
        case 
2
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_leet")
            
ShowGirlMenu(id)
        }       
        case 
3
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_terror")
            
ShowGirlMenu(id)
        }       
        case 
4
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"sas")
            
ShowGirlMenu(id)
        }   
        case 
9ColorChatidGREEN"%s Menu Exited."MODNAME)
        } 
        
    
menu_destroymenu );
    return 
PLUGIN_HANDLED

But people say it leads to crashes or bad svc errors. I think Connor have some TUT or helping but didn't help me actually didn't show me, menu = model. Thank you in advance! Appreciate your support!
__________________
Like my clean plugins and work?

Last edited by Baws; 09-15-2013 at 23:32.
Baws is offline
Old 09-11-2013, 00:46
dark_style
This message has been deleted by dark_style.
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-11-2013 , 01:12   Re: Menu Model Help
Reply With Quote #2

- You shouldn't include the cstrike folder into the path.
- You never check if the user is alive before you set him a new model.
- Using format/formatex for such thing is completely useless, use client_print() instead.
- Read how the old menu style works - > http://wiki.amxmodx.org/Advanced_Scr...Mod_X%29#Menus , tho I suggest you to use the new amxx menu style.
__________________



dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-11-2013 , 01:19   Re: Menu Model Help
Reply With Quote #3

Showing a menu at this time will overwrite default team menus, and gonna messup the game because critical properties won't be set on players.

What you should do is let players choose a team, then, overwrite the default appearance text menu (let the game think default menu has been shown to player).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 09-11-2013 , 18:26   Re: Menu Model Help
Reply With Quote #4

Quote:
Originally Posted by dark_style View Post
- You shouldn't include the cstrike folder into the path.
- You never check if the user is alive before you set him a new model.
- Using format/formatex for such thing is completely useless, use client_print() instead.
- Read how the old menu style works - > http://wiki.amxmodx.org/Advanced_Scr...Mod_X%29#Menus , tho I suggest you to use the new amxx menu style.
- Why?
- I fixed it in the code below, check it out andtell me if it's good please
- I used format because i want the message to be shown to everyone, not just myself and i.
- Yeah thanks. I used the old menu but it doesn't sound good but is it better than the new menu system?

Quote:
Originally Posted by ConnorMcLeod View Post
Showing a menu at this time will overwrite default team menus, and gonna messup the game because critical properties won't be set on players.




What you should do is let players choose a team, then, overwrite the default appearance text menu (let the game think default menu has been shown to player).
Like i changed the time from the task is it good? or i need to code something so it will only comes when player has chosen the team?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define MAXPLAYERS 32

#define MODNAME "^x01 [^x04 GenderCheck^x01 ]"

new SayText;

enum Color
{
    
NORMAL 1,
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

public 
plugin_init() 
{
    
register_plugin("GenderChecker""1.1""Baws")
    
    
register_cvar("amx_gender""1")
    
    
register_menucmd(register_menuid("menu"), 1023"menu_handler")
    
    
SayText get_user_msgid("SayText");
}

public 
plugin_precache()
{
   
precache_model("cstrike/models/player/f_arctic/f_arctic.mdl")
   
precache_model("cstrike/models/player/f_guerilla/f_guerilla.mdl")
   
precache_model("cstrike/models/player/f_leet/f_leet.mdl")
   
precache_model("cstrike/models/player/f_terror/f_terror.mdl")
}

public 
ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...) 
{
    static 
SayText;

    if(!
SayText)
        
SayText get_user_msgid("SayText");

    static 
message[256];

    switch(
type)
    {
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        case 
TEAM_COLOR// Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist).
        
{
            
message[0] = 0x03;
        }
        default: 
// Yellow.
        
{

            
message[0] = 0x01;
        }
    }

    
vformat(message[1], 251msg4);

    
message[192] = '^0';

    if(
id)
    {
        if(
is_user_connected(id))
        {
            
message_begin(MSG_ONESayText, {000}, id);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    } else {
        static 
players[32]; new countindex;
        
get_players(playerscount);

        for(new 
0counti++)
        {
            
index players[i];

            
message_begin(MSG_ONESayText, {000}, index);
            
write_byte(index);
            
write_string(message);
            
message_end();

        }
    }
}

public 
client_putinserver(id
{
    if(
get_cvar_num("amx_gender") != 1)
        return 
PLUGIN_HANDLED
    
    set_task
(1.0"GenderMenu"id//Connor so here i put the "1.0" to "2.0" ? 
        
    
return PLUGIN_HANDLED


public 
GenderMenu(id)
{
   new 
menu menu_create"\yGender Checker: \rAre you a Guy or a Girl?""menu_handler" )

   
menu_additemmenu"\wI'm a Guy!""");
   
menu_additemmenu"\wI'm a Girl!""");
   
   
menu_displayidmenu);
}

public 
menu_handler(idmenuitem
{
    new 
szName[64];
    
get_user_name(idszNamecharsmax(szName))
    
    new 
message[132]
    
    if(
is_user_alive(id)) //here changes if user is alive
    
    
switch(item
    {
        case 
0:
        {
            
format(messagecharsmax(message), "%s Ladies! Mr. ^x04%s^x01 is coming.. but he's on the moon and he's walking!"MODNAMEszName)
        }
        case 
1:
        {
            
format(messagecharsmax(message), "%s Guys! Ms. ^x04%s^x01 is coming.. but she's in the kitchen and she's on her way!"MODNAMEszName)
            
ShowGirlMenu(id)
        }
        case 
MENU_EXIT:
        {
            
format(messagecharsmax(message), "%s Ladies & Gentlemen ^x04%s^x01 is an Alien!"MODNAMEszName)
        }
    }
    
    for (new 
i=0i<get_maxplayers(); i++) 
    {
        if(
is_user_connected(i)) 
        {
            
ColorChat(idGREENmessage);
            
message_begin(MSG_ONESayText_i);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED
}

ShowGirlMenu(id)
{
   new 
menu menu_create"\yGC: \rGirls Model Menu!""ShowGirlMenu_handler" )

   
menu_additemmenu"\wGirl Arctic""");
   
menu_additemmenu"\wGirl Guerilla""");
   
menu_additemmenu"\wGirl Leet""");
   
menu_additemmenu"\wGirl Terror""");
   
menu_additemmenu"\wReset model""");
   
   
menu_displayidmenu);
}

public 
ShowGirlMenu_handler(idmenuitem)
{        
    if(
is_user_alive(id)) //if the user is alive his model will change
    
    
switch( item )
    {
        case 
0
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_arctic")
            
ShowGirlMenu(id)
        }
        case 
1
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_guerilla")
            
ShowGirlMenu(id)
        }
        case 
2
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_leet")
            
ShowGirlMenu(id)
        }       
        case 
3
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_terror")
            
ShowGirlMenu(id)
        }       
        case 
4
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"sas")
            
ShowGirlMenu(id)
        }   
        case 
9ColorChatidGREEN"%s Menu Exited."MODNAME)
        } 
        
    
menu_destroymenu );
    return 
PLUGIN_HANDLED

__________________
Like my clean plugins and work?

Last edited by Baws; 09-11-2013 at 18:27.
Baws is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-12-2013 , 01:10   Re: Menu Model Help
Reply With Quote #5

Quote:
- Why?
- I fixed it in the code below, check it out andtell me if it's good please
- I used format because i want the message to be shown to everyone, not just myself and i.
- Yeah thanks. I used the old menu but it doesn't sound good but is it better than the new menu system?
- Because it isn't needed.
- Your checks are wrong, they will throw an error if you don't put {} or simply if( !is_user_alive( id ) ) return PLUGIN_HANDLED.
- Use client_print() with index 0, it will print the message to everyone in the server.
- I can't really say this because I have never used the old menu style since I am scripting. You can find more info in new amxx menu style tutorial by Emp`, check out the comments.

- Always use pcvars.
- I would use Connor's colorchat.
__________________




Last edited by dark_style; 09-12-2013 at 01:49.
dark_style is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 09-12-2013 , 16:54   Re: Menu Model Help
Reply With Quote #6

Quote:
Originally Posted by dark_style View Post
- Because it isn't needed.
- Your checks are wrong, they will throw an error if you don't put {} or simply if( !is_user_alive( id ) ) return PLUGIN_HANDLED.
- Use client_print() with index 0, it will print the message to everyone in the server.
- I can't really say this because I have never used the old menu style since I am scripting. You can find more info in new amxx menu style tutorial by Emp`, check out the comments.

- Always use pcvars.
- I would use Connor's colorchat.
- When i removed cs from reset_model or other it said error so it's needed? or i'm doing the code wrong?
- I added the {} now it's good?
- Um i said something in the ColorChat //... i used ColorChat(0,... see the question in the code please
- I use his method, or the new menu method. It's easy and fun!

- Now the code has pcvar
- the question is in the same ColorChat //....


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define MAXPLAYERS 32

#define MODNAME "^x01 [^x04 GenderCheck^x01 ]"

new pcvargender

new SayText;

enum Color
{
    
NORMAL 1,
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

public 
plugin_init() 
{
    
register_plugin("GenderChecker""1.1""Baws")
    
    
pcvargender register_cvar("amx_gender""1"//added pcvar 
    
    
register_menucmd(register_menuid("menu"), 1023"menu_handler")
    
    
SayText get_user_msgid("SayText");
}

public 
plugin_precache()
{
   
precache_model("cstrike/models/player/f_arctic/f_arctic.mdl")
   
precache_model("cstrike/models/player/f_guerilla/f_guerilla.mdl")
   
precache_model("cstrike/models/player/f_leet/f_leet.mdl")
   
precache_model("cstrike/models/player/f_terror/f_terror.mdl")
}

public 
ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...) //Connor color chat is better but i don't want to use a plugin to make this plugin use colorchat, i want coding you know or i just #include <colorchat> and its good with ColorChat()?
{
    static 
SayText;

    if(!
SayText)
        
SayText get_user_msgid("SayText");

    static 
message[256];

    switch(
type)
    {
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        case 
TEAM_COLOR// Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist).
        
{
            
message[0] = 0x03;
        }
        default: 
// Yellow.
        
{

            
message[0] = 0x01;
        }
    }

    
vformat(message[1], 251msg4);

    
message[192] = '^0';

    if(
id)
    {
        if(
is_user_connected(id))
        {
            
message_begin(MSG_ONESayText, {000}, id);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    } else {
        static 
players[32]; new countindex;
        
get_players(playerscount);

        for(new 
0counti++)
        {
            
index players[i];

            
message_begin(MSG_ONESayText, {000}, index);
            
write_byte(index);
            
write_string(message);
            
message_end();

        }
    }
}

public 
client_putinserver(id
{
    if(
get_pcvar_num(pcvargender))
        return 
PLUGIN_HANDLED
    
    set_task
(1.0"GenderMenu"id//Connor so here i put the "1.0" to "2.0" ? 
        
    
return PLUGIN_HANDLED


public 
GenderMenu(id)
{
   new 
menu menu_create"\yGender Checker: \rAre you a Guy or a Girl?""menu_handler" )

   
menu_additemmenu"\wI'm a Guy!""");
   
menu_additemmenu"\wI'm a Girl!""");
   
   
menu_displayidmenu);
}

public 
menu_handler(idmenuitem
{
    new 
szName[64];
    
get_user_name(idszNamecharsmax(szName))
    
    new 
message[132]
    
    if(
is_user_alive(id)) //here changes if user is alive *ADDED {}*
    
{
        
    switch(
item
    {
        case 
0:
        {
            
ColorChat(0GREENmessage"%s Ladies! Mr. ^x04%s^x01 is coming.. but he's on the moon and he's walking!"MODNAMEszName//Good? 
        
}
        case 
1:
        {
            
ColorChat(0GREENmessage"%s Guys! Ms. ^x04%s^x01 is coming.. but she's in the kitchen and she's on her way!"MODNAMEszName//Good?
            
ShowGirlMenu(id)
        }
        case 
MENU_EXIT:
        {
            
ColorChat(0GREENmessage"%s Ladies & Gentlemen ^x04%s^x01 is an Alien!"MODNAMEszName//Good?
        
}
    }
    }
    
    for (new 
i=0i<get_maxplayers(); i++) 
    {
        if(
is_user_connected(i)) 
        {
            
ColorChat(idGREENmessage);
            
message_begin(MSG_ONESayText_i);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED
}

ShowGirlMenu(id)
{
   new 
menu menu_create"\yGC: \rGirls Model Menu!""ShowGirlMenu_handler" )

   
menu_additemmenu"\wGirl Arctic""");
   
menu_additemmenu"\wGirl Guerilla""");
   
menu_additemmenu"\wGirl Leet""");
   
menu_additemmenu"\wGirl Terror""");
   
menu_additemmenu"\wReset model""");
   
   
menu_displayidmenu);
}

public 
ShowGirlMenu_handler(idmenuitem)
{        
    if(
is_user_alive(id)) //if the user is alive his model will change *ADDED {}*
    
{
        
    switch( 
item )
    {
        case 
0
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_arctic")
            
ShowGirlMenu(id)
        }
        case 
1
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_guerilla")
            
ShowGirlMenu(id)
        }
        case 
2
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_leet")
            
ShowGirlMenu(id)
        }       
        case 
3
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"f_terror")
            
ShowGirlMenu(id)
        }       
        case 
4
        {
            
cs_reset_user_model(id)
            
cs_set_user_model(id"sas")
            
ShowGirlMenu(id)
        }   
        case 
9ColorChatidGREEN"%s Menu Exited."MODNAME)
        }
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED

__________________
Like my clean plugins and work?
Baws is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-13-2013 , 01:15   Re: Menu Model Help
Reply With Quote #7

- Who told you to remove cs_* from the natives? What I have been saying is to remove the cstrike folder from the path of precaching models, it isn't needed.

- You should indent your code better, it may throw indent warrnings.

-
Quote:
Originally Posted by ConnorMcLeod
If you prefer to use a stock version that doesn't need an extra plugin to work, follow the following link :> Here <
- Your menu code won't work. You should take a look to Emp`'s tutorial.
__________________



dark_style is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 09-14-2013 , 14:23   Re: Menu Model Help
Reply With Quote #8

Quote:
Originally Posted by dark_style View Post
- Who told you to remove cs_* from the natives? What I have been saying is to remove the cstrike folder from the path of precaching models, it isn't needed.

- You should indent your code better, it may throw indent warrnings.

-

- Your menu code won't work. You should take a look to Emp`'s tutorial.

- Removed
- I guess it's good now?
- Now i'm using Connor's Client_print_color
- Now is it good?

- I got a question, how to do like when a player has chosen a team the menu comes? Like connor said up there. Please thank you dark!

Is this good? i re-did all the code.
Attached Files
File Type: sma Get Plugin or Get Source (GenderCheckerREDONE.sma - 573 views - 9.4 KB)
__________________
Like my clean plugins and work?

Last edited by Baws; 09-14-2013 at 14:25.
Baws is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-14-2013 , 14:28   Re: Menu Model Help
Reply With Quote #9

I suggest you to read this tutorial: https://forums.alliedmods.net/showthread.php?t=85274
__________________



dark_style is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 09-14-2013 , 14:30   Re: Menu Model Help
Reply With Quote #10

Quote:
Originally Posted by dark_style View Post
I suggest you to read this tutorial: https://forums.alliedmods.net/showthread.php?t=85274
I read it before long time ago and it's for better coding like with spaces and such.
__________________
Like my clean plugins and work?
Baws is offline
Reply


Thread Tools
Display Modes

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 19:03.


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