Raised This Month: $51 Target: $400
 12% 

2 different menus for CT & T on round start... possible ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xExperienced
Member
Join Date: Jun 2017
Location: USA
Old 09-09-2017 , 15:34   2 different menus for CT & T on round start... possible ?
Reply With Quote #1

I'm looking for a code which creates 2 different menus on round start for T & CT.

is it possible to create ? if yes please post the code

Code:
new menu = menu_create( "\r Select:", "menu_handler" );

new teamchk = get_user_team
	if teamchk = 1
	{
	menu_additem( menu, "\wFor T", "", 0 );
    menu_additem( menu, "\wFor T", "", 0 );
	}
	
	if teamchk = 2
	{
	menu_additem( menu, "\wFor CT", "", 0 );
    menu_additem( menu, "\wFor CT", "", 0 );
	}
I tried this but , dont know it will work or not. Please have a look .
xExperienced is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 09-09-2017 , 15:58   Re: 2 different menus for CT & T on round start... possible ?
Reply With Quote #2

Is it possible? Yes, it has been done in the past.

In your code, you are not providing the index for get_user_team. If this is for cs 1.6 then you may want to use cs_get_user_team(id). In addition to that try using a switch, instead of using if over and over.

PHP Code:
new CsTeams:Team get_user_team(id)

switch(
Team)
    case 
1//Terrorist
    
{
    
menu_additemmenu"\wFor T""");
    
menu_additemmenu"\wFor T""");
    }

    case 
2//CT
    
{
    
menu_additemmenu"\wFor CT""");
    
menu_additemmenu"\wFor CT""");
    }
    case 
3//Spectator
    
{
    
//User is spectataor
    

PHP Code:
new CsTeams:Team cs_get_user_team(id)

switch(
Team)
    case 
CS_TEAM_T:
    {
    
menu_additemmenu"\wFor T""");
    
menu_additemmenu"\wFor T""");
    }

    case 
CS_TEAM_CT:
    {
    
menu_additemmenu"\wFor CT""");
    
menu_additemmenu"\wFor CT""");
    }
    case 
CS_TEAM_SPECTATOR:
    {
    
//User is spectataor
    

__________________
Spirit_12 is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-10-2017 , 06:13   Re: 2 different menus for CT & T on round start... possible ?
Reply With Quote #3

I don't think there is matter between 2 ifs or a switch, maybe when ifs are much more, then switch is better case. I usually use up to 3 ifs before go for switch.

Last edited by KiLLeR.; 09-10-2017 at 06:14.
KiLLeR. is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 09-13-2017 , 14:22   Re: 2 different menus for CT & T on round start... possible ?
Reply With Quote #4

Quote:
Originally Posted by KiLLeR. View Post
I don't think there is matter between 2 ifs or a switch, maybe when ifs are much more, then switch is better case. I usually use up to 3 ifs before go for switch.
it does actually, be it almost insignificant, it probably matters in preframe or prethink
switch is a couple less cpu operations even with 2 cases vs an if&else if

though if spectators can not spawn on your server, you can probably get away with an if&else since it's on spawn, which would probably be better than a switch
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-13-2017 , 15:11   Re: 2 different menus for CT & T on round start... possible ?
Reply With Quote #5

Didnt you already opened a thread with the same purpose
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 03:16.


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