AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Immidate respawn after team change (work in progress ... not working) (https://forums.alliedmods.net/showthread.php?t=253023)

Cv3 12-13-2014 15:56

Immidate respawn after team change (work in progress ... not working)
 
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 :shock:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <csdm>
 
#pragma semicolon 1
 
new g_MapName[32], bool:g_VIPMap falsebool: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_MapNamecharsmax(g_MapName));
   if(
containi(g_MapName"as_") != -1g_VIPMap true;
}
 
public 
ShowMenu(id)
{
   new 
szMenu[512], iLen formatex(szMenucharsmax(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 iNumCtiLen += 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 iNumTeiLen += 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_CTiLen += 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_SPECTATORiLen += 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_SPECTATORiLen += 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(idiKeysszMenu, -1"Team Menu");
}
 
public 
HandleMenu(idiKey)
{
   switch(
iKey)
   {
      case 
0:
      {
         
set_pdata_int(id125get_pdata_int(id125) & ~(1<<8));
         
engclient_cmd(id"jointeam""1");
         
set_task(2.0"SpawnPlayer"id);
      }
      case 
1:
      {
         
set_pdata_int(id125get_pdata_int(id125) & ~(1<<8));
         
engclient_cmd(id"jointeam""2");
         
set_task(2.0"SpawnPlayer"id);
      }
      case 
2:
      {
         
set_pdata_int(id125get_pdata_int(id125) & ~(1<<8));
         
engclient_cmd(id"jointeam""3");
         
set_task(2.0"SpawnPlayer"id);
      }
      case 
4:
      {
         
set_pdata_int(id125get_pdata_int(id125) & ~(1<<8));
         
engclient_cmd(id"jointeam""5");
         
set_task(2.0"SpawnPlayer"id);
      }
      case 
5:
      {
         
user_kill(id1);
         
engclient_cmd(id"jointeam""6");
         
set_task(2.0"SpawnPlayer"id);
      }
   }
   return 
PLUGIN_HANDLED;
}
 
public 
MessageShowMenu(iMsgIdiMsgDestiReceiver)
{
   static 
szArg4[20]; get_msg_arg_string(4szArg4charsmax(szArg4));
   if(
equal(szArg4"#Team_Select"12) || equal(szArg4"#IG_Team_Select"15) || equal(szArg4"#IG_VIP_Team_Select"19))
   {
      
set_pdata_int(iReceiver2050);
      return 
ShowMenu(iReceiver);
   }
   return 
PLUGIN_CONTINUE;
}
 
public 
MessageVGUIMenu(iMsgIdiMsgDestiReceiver)
{
   if(
get_msg_arg_int(1) == 2)
   {
      
set_pdata_int(iReceiver2050);
      return 
ShowMenu(iReceiver);
   }
   return 
PLUGIN_CONTINUE;
}
 
get_teamplayersnum(const CsTeams:iTeam)
{
   static 
players[32], iNum;
   
get_players(playersiNum"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(id114))
   {
      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;




All times are GMT -4. The time now is 15:23.

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