AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   switch player to spec (https://forums.alliedmods.net/showthread.php?t=82848)

whosyourdaddy 12-30-2008 23:55

switch player to spec
 
im using this code to switch player to spec but for some reason its glitching. it switches the player to spec for 5 seconds and then switches them back to their old team. when u tab it shows ur on ur old team but ur really in spec and wont spawn next round or round after that. any1 know why the score board is glitching heres the code

Code:

stock fm_set_user_team(id, CsTeams:team)
{
  set_pdata_int(id, OFFSET_TEAM, _:team)
 
  dllfunc(DLLFunc_ClientUserInfoChanged, id)
 
  static teaminfo[12], iMsgid_TeamInfo
 
  switch(team)
  {
        case CS_TEAM_UNASSIGNED:
            teaminfo="UNASSIGNED"
      case CS_TEAM_T:
          teaminfo="TERRORIST"
      case CS_TEAM_CT:
          teaminfo="CT"
      case CS_TEAM_SPECTATOR:
          teaminfo="SPECTATOR"
    }
 
  if(!iMsgid_TeamInfo)
      iMsgid_TeamInfo = get_user_msgid("TeamInfo")
 
 
  message_begin(MSG_ALL, iMsgid_TeamInfo)
  write_byte(id)
  write_string(teaminfo)
  message_end()
}


Hawk552 12-31-2008 00:54

Re: switch player to spec
 
Does cs_set_user_team() not work?

ConnorMcLeod 12-31-2008 01:23

Re: switch player to spec
 
Depending on what you want, you can also use :
dllfunc(DLLFunc_ClientPutInServer, id)

whosyourdaddy 12-31-2008 01:34

Re: switch player to spec
 
naw cs_set_user_team does hte same thing ill try the clientputinserver thing

whosyourdaddy 12-31-2008 02:15

Re: switch player to spec
 
Quote:

Originally Posted by ConnorMcLeod (Post 735919)
Depending on what you want, you can also use :
dllfunc(DLLFunc_ClientPutInServer, id)

well put in server shows me in spec on tab but also pops up the motd and team selection menu, do u think theres other ways in doing it without having those popping up?

ConnorMcLeod 12-31-2008 11:00

Re: switch player to spec
 
Quote:

Originally Posted by ConnorMcLeod (Post 735919)
Depending on what you want

If you don't want to allow the player to choose, then, just kill him and set gis team to spec, example in plmenu.sma
PHP Code:

            if (g_cstrike)
            {
                if (
is_user_alive(player))
                {
                    new 
deaths cs_get_user_deaths(player)
                    
user_kill(player1)
                    
cs_set_user_deaths(playerdeaths)
                }
                
// This modulo math just aligns the option to the CsTeams-corresponding number
                
cs_set_user_team(player, (g_menuOption[id] % 3) + 1)
                
cs_reset_user_model(player)
            } 


whosyourdaddy 12-31-2008 17:53

Re: switch player to spec
 
what would i replace with
Code:

(g_menuOption[id] % 3) + 1


to make it become spectator

Exolent[jNr] 12-31-2008 18:15

Re: switch player to spec
 
CS_TEAM_SPECTATOR, or 3

Dores 12-31-2008 18:30

Re: switch player to spec
 
You can use this instead of your code:
PHP Code:

fm_set_user_teamindexteam )
{
    
set_pdata_intindexOFFSET_TEAMteam );
    
dllfuncDLLFunc_ClientUserInfoChangedindexengfuncEngFunc_GetInfoKeyBufferindex ) );
    switch( 
team )
    {
        case 
3:    dllfuncDLLFunc_ClientKillindex );
        
        default:    
dllfuncDLLFunc_Spawnindex );
    }
    
    
message_beginMSG_ONEg_Msg_TeamInfo_index );
    
write_byteindex );
    static 
Teams[][] =
    {
        
""// LOL NULL
        
"TERRORIST",
        
"CT",
        
"SPECTATOR"
    
}
    
write_stringTeamsteam ] );
    
message_end();
    
    return;


g_Msg_TeamInfo is a global variable with the "TeamInfo" message id.
Also, this code doesn't require cstrike tags. :D

whosyourdaddy 12-31-2008 19:02

Re: switch player to spec
 
g_Msg_TeamInfo = get_user_msgid("TeamInfo")?? in plugin_init

and if so it just puts me in spec for 2 seconds and then back to my old team. but i dont respawn on new round i just stay dead


All times are GMT -4. The time now is 09:19.

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