Raised This Month: $ Target: $400
 0% 

[req] humans_join_team + spec


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-05-2010 , 01:13   Re: [req] humans_join_team + spec
Reply With Quote #21

If it's for csdm, try this, just use /spec command to spectate, and regular chooseteam command to choose back a team.

PHP Code:
/*    Formatright © 2009, ConnorMcLeod

    DeathMatch ChooseTeam is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DeathMatch ChooseTeam; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"

#define MAX_PLAYERS 32

#define OFFSET_CAN_CHOOSETEAM 125
const CANT_CHOOSETEAM 1<<8
#define AllowPlayerChooseTeam(%1)    set_pdata_int(%1, OFFSET_CAN_CHOOSETEAM, get_pdata_int(%1, OFFSET_CAN_CHOOSETEAM) & ~CANT_CHOOSETEAM)

#define m_fGameHUDInitialized 349

new g_pCvarChangeTeamDelay

new Float:g_fNextGameTimeChooseTeam[MAX_PLAYERS+1]

new 
gmsgTextMsg

new g_bPutInSpec[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin("DeathMatch ChooseTeam"VERSION"ConnorMcLeod")

    
g_pCvarChangeTeamDelay register_cvar("csdm_changeteam_minspawns""30")

    
register_clcmd("chooseteam""ClientCommand_ChooseTeam")
    
register_clcmd("say /spec""ClientCommand_GoSpec")

    
gmsgTextMsg get_user_msgid("TextMsg")

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)

//    register_event("ShowMenu", "Event_ShowMenu_TeamSelectSpect", "b", "1=51", "2=-1", "3=0", "4=#Team_Select_Spect")
//    register_event("VGUIMenu", "Event_VGUIMenu_TeamSelectSpect", "b", "1=2", "2=51"/*, "3=-1", "4=0"*/)
}

/*message_begin(MSG_ONE, get_user_msgid("ShowMenu"), {0,0,0}, 1)
write_short(51)
write_char(-1)
write_byte(0)
write_string("#Team_Select_Spect")
message_end()*/
/*message_begin(MSG_ONE, get_user_msgid("VGUIMenu"), {0,0,0}, 1)
write_byte(2)
write_short(51)
write_char(-1)
write_byte(0)
write_string(" ")
message_end()*/

public Player_Spawn_Postid )
{
    if( 
is_user_alive(id) )
    {
        
set_pdata_int(id5091)
    }
}

public 
client_putinserver(id)
{
    
g_bPutInSpec[id] = false

    
// not really fine
    
g_fNextGameTimeChooseTeam[id] = get_gametime() + get_pcvar_float(g_pCvarChangeTeamDelay)
}

public 
ClientCommand_GoSpec(id)
{
    new 
Float:fGameTime get_gametime()
    new 
Float:fTimeLeft g_fNextGameTimeChooseTeam[id] - fGameTime
    
if( fTimeLeft <= 0.0 )
    {
        
g_bPutInSpec[id] = true
        
new bVGUI = (get_pdata_int(id510) & (1<<0))
        
set_msg_block(gmsgTextMsgBLOCK_ONCE// attempt to block %playername% connected in players console
        
dllfunc(DLLFunc_ClientPutInServerid)
        
set_pdata_int(idm_fGameHUDInitialized1)
        
set_pev(idpev_viewmodel0)
        
engclient_cmd(idbVGUI "jointeam 6" "menuselect 6")
        new const 
szCommand[] = "slot6"
        
set_task(0.1"Task_DelayedCommand"idszCommandcharsmax(szCommand))
        
g_fNextGameTimeChooseTeam[id] = fGameTime get_pcvar_float(g_pCvarChangeTeamDelay)
    }
    else
    {
        
client_print(idprint_center"You can spec in %.0f seconds"fTimeLeft)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

/*public Event_ShowMenu_TeamSelectSpect(id)
{
    if( g_bPutInSpec[id] )
    {
        client_cmd(id, "menuselect 6")
        new szCommand[] = "slot6"
        set_task(0.1, "Task_DelayedCommand", id, szCommand, 12)
        g_bPutInSpec[id] = false
    }
}

public Event_VGUIMenu_TeamSelectSpect(id)
{
    if( g_bPutInSpec[id] )
    {
        client_cmd(id, "jointeam 6")
        new szCommand[] = "slot6"
        set_task(0.1, "Task_DelayedCommand", id, szCommand, 12)
        g_bPutInSpec[id] = false
    }
}*/

public Task_DelayedCommand(const szCommand[], const id)
{
    if( 
is_user_connected(id) )
    {
        
client_cmd(idszCommand)
    }
}

public 
ClientCommand_ChooseTeamid )
{
    new 
Float:fGameTime get_gametime()
    new 
Float:fTimeLeft g_fNextGameTimeChooseTeam[id] - fGameTime
    
if( fTimeLeft <= 0.0 )
    {
        
AllowPlayerChooseTeam(id)
        
g_fNextGameTimeChooseTeam[id] = fGameTime get_pcvar_float(g_pCvarChangeTeamDelay)
    }
    else
    {
        
client_print(idprint_center"You can choose a team in %.0f seconds"fTimeLeft)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
slpknt
Senior Member
Join Date: Dec 2007
Location: Russia
Old 05-05-2010 , 10:16   Re: [req] humans_join_team + spec
Reply With Quote #22

ConnorMcLeod, I have just tested it. Maybe I'm doing something wrong, but:
1. It doesn't disable the fadetoblack.
2. I cannot join the game after spectating. My nickname in TAB menu joins, but I do not respawn.
3. Quite often it says something like "wait 25 sec".

PS: drekes' version works good, but I need something to disable the fadetoblack for spectating admins.
__________________
play hard go pr0
dmg / slipknot!
slpknt is offline
Send a message via ICQ to slpknt
slpknt
Senior Member
Join Date: Dec 2007
Location: Russia
Old 05-11-2010 , 15:08   Re: [req] humans_join_team + spec
Reply With Quote #23

ConnorMcLeod, thank you for your reply!
drekes, the final version of the plugin I'm using:
PHP Code:
#include <amxmodx>
#include <fakemeta_util>
#include <cstrike>
#include <hamsandwich>

#define ACCESS ADMIN_IMMUNITY

new CsTeams:team[33]



public 
plugin_init()
{
    
register_plugin("Change to spec""1.0""Exolent")
    
    
register_clcmd("say /spec""cmd_spec")
    
register_clcmd("say /play""cmd_unspec")
    
register_clcmd("say_team /spec""cmd_spec")
    
register_clcmd("say_team /play""cmd_unspec")
}

public 
cmd_spec(id)
{
    if(!
get_user_flags(id) && ACCESS)
        return 
PLUGIN_HANDLED
        
    
if(!team[id]) 
    {
        if(
is_user_alive(id))
        {
            
client_cmd(id"kill")
            
cs_set_user_deaths(idcs_get_user_deaths(id) - 1)
            
fm_set_user_frags(idget_user_frags(id) + 1)
        }
        
team[id] = cs_get_user_team(id)
        
cs_set_user_teamidCS_TEAM_SPECTATORCS_DONTCHANGE)
    }
    return 
PLUGIN_HANDLED
}

public 
cmd_unspec(id)
{
    if(!
get_user_flags(id) && ACCESS)
        return 
PLUGIN_HANDLED
        
    
if(team[id])
        
cs_set_user_team(idteam[id])
        
    
team[id] = CS_TEAM_UNASSIGNED
    
    set_task
(3.0"respawn"id)
    
client_print(idprint_chat"You'll respawn in 3 seconds")
    return 
PLUGIN_HANDLED
}

public 
respawn(id)
{
    
ExecuteHamB(Ham_CS_RoundRespawnid)
    
client_cmd(id"kill")

It works good. But today I found a bug:
If I type "say /spec" when I'm choosing a model and then finally choose it - the server crashes.
__________________
play hard go pr0
dmg / slipknot!
slpknt is offline
Send a message via ICQ to slpknt
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-11-2010 , 15:18   Re: [req] humans_join_team + spec
Reply With Quote #24

how do you mean? Choosing a model?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
slpknt
Senior Member
Join Date: Dec 2007
Location: Russia
Old 05-12-2010 , 14:23   Re: [req] humans_join_team + spec
Reply With Quote #25

Press m (chooseteam), choose your team, DO NOT choose your model, then say /spec, NOW choose your model => server crashes.
__________________
play hard go pr0
dmg / slipknot!
slpknt is offline
Send a message via ICQ to slpknt
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-12-2010 , 14:50   Re: [req] humans_join_team + spec
Reply With Quote #26

do you search these bugs to make it harder on us? I have really no idea how to fix that
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
slpknt
Senior Member
Join Date: Dec 2007
Location: Russia
Old 05-12-2010 , 16:48   Re: [req] humans_join_team + spec
Reply With Quote #27

Sorry, I couldn't understand this part:
Quote:
Originally Posted by drekes View Post
do you search these bugs to make it harder on us?
The bug occurs when admins say /spec while choosing model and then choose the model. I mean this:
1. I connect to the server.
2. I DON'T choose my model.
3. I say /spec and begin spectating (model choose menu is still there)
4. I choose my model.
5. Server crashes.

May be you could make the plugin ignore /spec command while they have their model choose menu open. So that admins couldn't go /spec before they have their model chosen.
__________________
play hard go pr0
dmg / slipknot!
slpknt is offline
Send a message via ICQ to slpknt
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-12-2010 , 16:59   Re: [req] humans_join_team + spec
Reply With Quote #28

why don't you just choose team spec instead of doing this?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
slpknt
Senior Member
Join Date: Dec 2007
Location: Russia
Old 05-13-2010 , 10:50   Re: [req] humans_join_team + spec
Reply With Quote #29

Players are not allowed to choose anything but CT when humans_join_team is CT.
__________________
play hard go pr0
dmg / slipknot!
slpknt is offline
Send a message via ICQ to slpknt
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-13-2010 , 11:48   Re: [req] humans_join_team + spec
Reply With Quote #30

use this:http://forums.alliedmods.net/showthr...o+join+connect
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
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:31.


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