Raised This Month: $ Target: $400
 0% 

Menu for Spectator


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-23-2009 , 11:40   Re: Menu for Spectator
Reply With Quote #2

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.
__________________

Last edited by Hawk552; 10-23-2009 at 12:00.
Hawk552 is offline
Send a message via AIM to Hawk552
 



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 17:43.


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