Veteran Member
Join Date: Jul 2006
Location: France (95)
|
04-01-2013
, 10:47
Re: /spec /ct won't work properly
|
#2
|
I think i have something really better but i can't find it, so try this for the moment :
PHP Code:
/* Formatright © 2009, ConnorMcLeod
Kz 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 Kz ChooseTeam; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <amxmodx> #include <fakemeta>
#define VERSION "0.3.0"
#define m_fGameHUDInitialized 349
#define SetIdBits(%1,%2) %1 |= 1<<(%2 & 31) #define ClearIdBits(%1,%2) %1 &= ~( 1<<(%2 & 31) ) #define GetIdBits(%1,%2) %1 & 1<<(%2 & 31)
new g_bDontHook
#define CS_TEAM_CT 2 #define CS_TEAM_SPECTATOR 4 #define fm_cs_get_user_team(%1) get_pdata_int(%1, 114)
#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)
new gmsgTextMsg
public plugin_init() { register_plugin("Kz ChooseTeam", VERSION, "ConnorMcLeod")
register_clcmd("say /spec", "ClientCommand_Spec") register_clcmd("say /ct", "ClientCommand_CT") register_clcmd("chooseteam", "ClientCommand_ChooseTeam")
register_menucmd(register_menuid("#Team_Select_Spect"), 51, "Menu_ChooseTeam")
gmsgTextMsg = get_user_msgid("TextMsg") }
public client_putinserver(id) { SetIdBits(g_bDontHook, id) }
public ClientCommand_ChooseTeam(id) { ClearIdBits(g_bDontHook, id) AllowPlayerChooseTeam(id) show_menu(id, 51, "#Team_Select_Spect", -1)
return PLUGIN_HANDLED }
public Menu_ChooseTeam(id, iKey) { if( GetIdBits(g_bDontHook, id) ) { ClearIdBits(g_bDontHook, id) return PLUGIN_CONTINUE }
switch(iKey) { case 1: { ClientCommand_CT(id) } case 5: { ClientCommand_Spec(id) } } return PLUGIN_HANDLED }
public ClientCommand_Spec(id) { if( fm_cs_get_user_team(id) != CS_TEAM_SPECTATOR ) { SetIdBits(g_bDontHook, id) new BLOCK_RESTORE = get_msg_block(gmsgTextMsg) set_msg_block(gmsgTextMsg, BLOCK_ONCE) dllfunc(DLLFunc_ClientPutInServer, id) set_msg_block(gmsgTextMsg, BLOCK_RESTORE) set_pdata_int(id, m_fGameHUDInitialized, 1) engclient_cmd(id, "jointeam", "6") client_cmd(id, "slot1") return PLUGIN_CONTINUE } return PLUGIN_HANDLED }
public ClientCommand_CT(id) { if( fm_cs_get_user_team(id) != CS_TEAM_CT ) { new iRestore = get_pdata_int(id, 510) new bVGUI = iRestore & (1<<0) if( bVGUI ) { set_pdata_int(id, 510, iRestore & ~(1<<0)) } AllowPlayerChooseTeam(id) new BLOCK_RESTORE = get_msg_block(gmsgTextMsg) set_msg_block(gmsgTextMsg, BLOCK_ONCE) engclient_cmd(id, "jointeam", "2") engclient_cmd(id, "joinclass", "1") set_msg_block(gmsgTextMsg, BLOCK_RESTORE) client_cmd(id, "slot1") if( bVGUI ) { set_pdata_int(id, 510, iRestore) } return PLUGIN_CONTINUE } return PLUGIN_HANDLED }
EDIT : Try rather this :
PHP Code:
/* Formatright © 2011, ConnorMcLeod
This plugin 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 this plugin; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <amxmodx> #include <fakemeta>
#define VERSION "0.0.1" #define PLUGIN "Spec"
#define m_iDefaultItems 120 #define m_iJoinedState 121 #define m_iMenuId 205
const DEFAULTITEMS_GIVEN = (1<<0) #define JOIN_ONTEAM 5
new gmsgShowMenu, gmsgVGUIMenu
public plugin_init() { register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
gmsgShowMenu = get_user_msgid("ShowMenu") gmsgVGUIMenu = get_user_msgid("VGUIMenu")
register_clcmd("say /spec", "ClCmd_Spec") register_clcmd("say /ct", "ClCmd_Ct") }
public ClCmd_Spec( id ) { if( is_user_alive(id) ) { user_kill(id, 1) // this is exactly what is done if you select spectator team during freezetime } engclient_cmd(id, "jointeam", "6") }
public ClCmd_Ct( id ) { set_pev(id, pev_deadflag, DEAD_NO) // allow return CT the same round set_pdata_int(id, m_iMenuId, 0) // in case we are already in such a menu
new iBlockShowMenu = get_msg_block(gmsgShowMenu) if( iBlockShowMenu != BLOCK_SET ) { if( !iBlockShowMenu ) { set_msg_block(gmsgShowMenu, BLOCK_ONCE) } } new iBlockVGUIMenu = get_msg_block(gmsgVGUIMenu) if( iBlockVGUIMenu != BLOCK_SET ) { if( !iBlockVGUIMenu ) { set_msg_block(gmsgVGUIMenu, BLOCK_ONCE) } }
engclient_cmd(id, "jointeam", "2")
if( !iBlockShowMenu ) { set_msg_block(gmsgShowMenu, BLOCK_NOT) } if( !iBlockVGUIMenu ) { set_msg_block(gmsgVGUIMenu, BLOCK_NOT) }
engclient_cmd(id, "joinclass", "2")
set_pdata_int(id, m_iDefaultItems, get_pdata_int(id, m_iDefaultItems) & ~DEFAULTITEMS_GIVEN) set_pdata_int(id, m_iJoinedState, JOIN_ONTEAM) set_pev(id, pev_deadflag, DEAD_RESPAWNABLE) dllfunc(DLLFunc_Think, id) }
// Observator modes // enum // { // OBS_NONE = 0, // OBS_CHASE_LOCKED, // OBS_CHASE_FREE, // OBS_ROAMING, // free look // OBS_IN_EYE, // first person view // OBS_MAP_FREE, // OBS_MAP_CHASE, // }
__________________
Last edited by ConnorMcLeod; 04-01-2013 at 10:48.
|
|