AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu for Spectator (https://forums.alliedmods.net/showthread.php?t=107147)

RICHIERICH 10-23-2009 10:19

Menu for Spectator
 
how to built menu ?? when all players r in spec and admin say /selecteams

than menu is visible to admin for choosing players to specific teams

RICHIE RICH should go in
1. T
2. CT

so admin have to choose 1 or 2 & than that players goes to that specified team,,,,,:D :D :D

Hawk552 10-23-2009 11:40

Re: Menu for Spectator
 
Uncompiled, untested:

PHP Code:

#include <amxmodx>
#include <cstrike>

public plugin_init()
{
    
register_plugin"Spec Menu""1.0""Hawk552" )
    
    
// Add admin checking.
    
register_clcmd"amx_specmenu""CmdSpecMenu" )
}

public 
CmdSpecMenuid )
{
    new 
players[32], playersNumplayer
    get_players
playersplayersNum )
    
    for ( new 
iplayersNumi++ )
    {
        if ( 
cs_get_user_teamplayer players[i] ) == CS_TEAM_SPECTATOR )
        {
            static 
menuTitle[64], name[33], idStr[3]
            
get_user_nameplayername32 )
            
num_to_strplayeridStr)
            
            
formatexmenuTitle63"Which team should %s be on?"name )
            
            new 
menu menu_createmenuTitle"MenuHandle" )
            
menu_additemmenu"Terrorist"idStr )
            
menu_additemmenu"Counter-Terrorist" )
            
            
menu_displayidmenu )
            
            break
        }
    }
    
    return 
PLUGIN_HANDLED
}

public 
MenuHandleidmenuitem )
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroymenu )
        return 
PLUGIN_HANDLED
    
}
    
    static 
garbageidStr[3]
    
menu_item_getinfomenu0garbageidStr2__garbage )
    
menu_destroymenu )
    
    new 
player str_to_numidStr )
    
    new 
teamStr[2]
    
teamStr[0] = item '2' '1'
    
    
// In case they left before the menu option was chosen.
    
if ( is_user_connectedplayer ) )
    {
        
engclient_cmdplayer"jointeam"teamStr )
        
// Adjust this yourself later. It's not important for functionality.
        
engclient_cmdplayer"joinclass""1" )
        
        
// If they're still spectators.
        
if ( cs_get_user_teamplayer ) == CS_TEAM_SPECTATOR )
            
// Use a crappier method that always works.
            
cs_set_user_teamplayeritem CS_TEAM_CT CS_TEAM_T )
    }
    
    
CmdSpecMenuid )
    
    return 
PLUGIN_HANDLED


You'll need a ton of extra checks that I neglected to make it faster to write. I only added ones that I figured you would probably miss.

RICHIERICH 10-23-2009 14:56

Re: Menu for Spectator
 
thanks for the code +karma will check and tell the result..

RICHIERICH 10-23-2009 15:35

Re: Menu for Spectator
 
ERROR on line 19 Possible unintended assigment

Hawk552 10-23-2009 15:38

Re: Menu for Spectator
 
Quote:

Originally Posted by RICHIERICH (Post 970087)
ERROR on line 19 Possible unintended assigment

That's actually just a warning, and would have been caught if I had tried compiling it before posting it. The plugin will work anyway, but to fix it, change that line from:

PHP Code:

        if ( cs_get_user_teamplayer players[i] ) == CS_TEAM_SPECTATOR 

...to...

PHP Code:

        if ( cs_get_user_team( ( player players[i] ) ) == CS_TEAM_SPECTATOR 


izzle 10-23-2009 15:40

Re: Menu for Spectator
 
Quote:

Originally Posted by RICHIERICH (Post 970087)
ERROR on line 19 Possible unintended assigment

Quote:

Warning: Possibly unintended assignment on line 19
theres no errors

Hawk552 10-23-2009 15:47

Re: Menu for Spectator
 
What are you trying to merge?

RICHIERICH 10-23-2009 15:51

Re: Menu for Spectator
 
amx_spec - all players to spec
amx_specmenu - menu for selection

need to merge this 2 codes..

-----------------------------
ur code worked for me ...but when team selection is done and whn players spawn they get menu of selection models.can u handle that by showing that menu b4


Hawk552 10-23-2009 16:02

Re: Menu for Spectator
 
Quote:

Originally Posted by RICHIERICH (Post 970112)
amx_spec - all players to spec
amx_specmenu - menu for selection

need to merge this 2 codes..

-----------------------------



No. When you come to this forum, you should have a basic level of understanding. The people here will only guide you through more complex concepts.

Quote:

Originally Posted by RICHIERICH (Post 970112)
ur code worked for me ...but when team selection is done and whn players spawn they get menu of selection models.can u handle that by showing that menu b4

It shouldn't be doing that. Explain in more detail what is happening.

RICHIERICH 10-23-2009 16:05

Re: Menu for Spectator
 
Example
RICHEI RICH team join
1.T
2.CT

admin select option 2 than than RICHIE RICH moves CT....than he is spawn..After spawn MODEL MENU comes in between for choosing model for CT.....so i was telling that, that model menu should come b4 spwaning


All times are GMT -4. The time now is 17:43.

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