|
Junior Member
|

12-13-2014
, 15:56
Immidate respawn after team change (work in progress ... not working)
|
#1
|
Got this great code from a russian site and been trying to make it work for hours.
This is the whole code draft, I've been trying to figure out what my mistake is. It can't run properly on deathmatch server, removed all the static checks required from it and yet .. When I switch the teams and force it to respawn me it switches me to spectator and respawns me as spectator with no gun and the model of the team I;ve chosen.
I'd appreciate some assistance to make it work
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <csdm>
#pragma semicolon 1
new g_MapName[32], bool:g_VIPMap = false, bool:g_iFirstSpawn[33] = false;
public plugin_init()
{
register_plugin("Change Team", "1.1", "neygomon");
register_clcmd("chooseteam", "ShowMenu");
register_menucmd(register_menuid("Team Menu"), MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_5|MENU_KEY_6|MENU_KEY_0, "HandleMenu");
register_message(96, "MessageShowMenu");
register_message(114, "MessageVGUIMenu");
get_mapname(g_MapName, charsmax(g_MapName));
if(containi(g_MapName, "as_") != -1) g_VIPMap = true;
}
public ShowMenu(id)
{
new szMenu[512], iLen = formatex(szMenu, charsmax(szMenu), "\ySelect a team:^n^n"), iKeys = MENU_KEY_0;
new iNumTe = get_teamplayersnum(CS_TEAM_T), iNumCt = get_teamplayersnum(CS_TEAM_CT), CsTeams:iTeam = cs_get_user_team(id);
if(iNumTe > iNumCt) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y1. \dTerrorist Force^n");
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y1. \wTerrorist Force^n");
iKeys |= MENU_KEY_1;
}
if(iNumCt > iNumTe) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y2. \dCounter-Terrorist Force^n^n");
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y2. \wCounter-Terrorist Force^n^n");
iKeys |= MENU_KEY_2;
}
if(g_VIPMap)
{
if(iTeam != CS_TEAM_CT) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y3. \dBecome VIP^n^n");
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y3. \wBecome VIP^n^n");
iKeys |= MENU_KEY_3;
}
}
if(CS_TEAM_UNASSIGNED < iTeam < CS_TEAM_SPECTATOR) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5. \dAuto-select^n");
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5. \wAuto-select^n");
iKeys |= MENU_KEY_5;
}
if(iTeam == CS_TEAM_SPECTATOR) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6. \dSpectator^n^n^n");
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6. \wSpectator^n^n^n");
iKeys |= MENU_KEY_6;
}
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y0. \wExit");
return show_menu(id, iKeys, szMenu, -1, "Team Menu");
}
public HandleMenu(id, iKey)
{
switch(iKey)
{
case 0:
{
set_pdata_int(id, 125, get_pdata_int(id, 125) & ~(1<<8));
engclient_cmd(id, "jointeam", "1");
set_task(2.0, "SpawnPlayer", id);
}
case 1:
{
set_pdata_int(id, 125, get_pdata_int(id, 125) & ~(1<<8));
engclient_cmd(id, "jointeam", "2");
set_task(2.0, "SpawnPlayer", id);
}
case 2:
{
set_pdata_int(id, 125, get_pdata_int(id, 125) & ~(1<<8));
engclient_cmd(id, "jointeam", "3");
set_task(2.0, "SpawnPlayer", id);
}
case 4:
{
set_pdata_int(id, 125, get_pdata_int(id, 125) & ~(1<<8));
engclient_cmd(id, "jointeam", "5");
set_task(2.0, "SpawnPlayer", id);
}
case 5:
{
user_kill(id, 1);
engclient_cmd(id, "jointeam", "6");
set_task(2.0, "SpawnPlayer", id);
}
}
return PLUGIN_HANDLED;
}
public MessageShowMenu(iMsgId, iMsgDest, iReceiver)
{
static szArg4[20]; get_msg_arg_string(4, szArg4, charsmax(szArg4));
if(equal(szArg4, "#Team_Select", 12) || equal(szArg4, "#IG_Team_Select", 15) || equal(szArg4, "#IG_VIP_Team_Select", 19))
{
set_pdata_int(iReceiver, 205, 0);
return ShowMenu(iReceiver);
}
return PLUGIN_CONTINUE;
}
public MessageVGUIMenu(iMsgId, iMsgDest, iReceiver)
{
if(get_msg_arg_int(1) == 2)
{
set_pdata_int(iReceiver, 205, 0);
return ShowMenu(iReceiver);
}
return PLUGIN_CONTINUE;
}
get_teamplayersnum(const CsTeams:iTeam)
{
static players[32], iNum;
get_players(players, iNum, "che", iTeam == CS_TEAM_T ? "TERRORIST" : "CT");
return iNum;
}
public SpawnPlayer(id)
{
//if(is_user_alive(id)) //|| g_iFirstSpawn[id]
// return;
//g_iFirstSpawn[id] = true;
log_amx("================= EXECUTED SpawnPlayer %d", id);
switch(get_pdata_int(id, 114))
{
case 1:
{
//ExecuteHamB(Ham_Spawn, id);
//set_task(0.1, "respawn");
csdm_respawn(id);
log_amx("================= 1 ID: %d", id);
}
case 2:
{
csdm_respawn(id);
//set_task(0.1, "respawn");
log_amx("================= 2 ID: %d", id);
}
}
log_amx("================= EXECUTED Ham_Spawn BOLI ME FARA SPAWNVAM TA %d", id);
csdm_respawn(id);
}
public respawn(id)
{
csdm_respawn(id);
return PLUGIN_CONTINUE;
}
|
|