Jump to content

ClientSwitchTeam


Zelly

Recommended Posts

Would there be anyway to create a callback that signals everytime a player switches team.

 

ClientSwitchTeam(clientNum,toteam) (or maybe add (clientNum,fromTeam,toTeam) )

function et_ClientSwitchTeam( clientNum , toTeam)
  local currentTeam = et.gentity_get(clientNum,"sess.sessionTeam")
  et.G_LogPrint("Stopping " .. clientNum .. " from switching from " .. currentTeam .. " " .. toTeam .."\n")
  return 1
end
function et_ClientSwitchTeam( clientNum ,fromTeam, toTeam)
  et.G_LogPrint("Stopping " .. clientNum .. " from switching from " .. fromTeam .. " " .. toTeam .."\n")
  return 1
end

I can't decide which switchteams it should catch though. There is /team and the limbo menu and then there is things like inactivity, ref putallies, !putteam, and !shuffle also I think there is an automove in the killrating playerbalance thing.
I would like them all but it seems like there could be problems that could cause.

It would be nice if I could possibly return 1 like I do in ClientCommand to stop them from joining.

 

I had originally thought that I could basically create my own with client command (And Possibly a runframe for inactivity) but it doesn't seem like the limbo menu passes any kind of command that lua catches(Or am I wrong?)

Anyways thoughts on the idea?

  :huh:

 

Link to comment
Share on other sites

  • Management

I don't know if et_clientUserinfoChanged could work as a trigger to check if the team has changed. I don't see a reason why we couldn't add it, but I'm saying that before investigating the issue at all. The callback would be probably called for all team changes though. However, as the single point for them all could be after forced team change information is printed to the game, there could be prints that seem wrong if the team change was cancelled. We will look into this.

 

http://mygamingtalk.com/wiki/index.php/Silent_Lua#et_ClientUserinfoChanged

Link to comment
Share on other sites

  • Management
function et_TeamCange( clientNum, fromTeam, toTeam )
	et.trap_SendServerCommand( -1, "chat \"Team change, client "..clientNum.." from team "..fromTeam.." to team "..toTeam.."\"")
	
	-- return 0 -- allow change
	-- return 1 -- disallow change
	-- no return value at all or any other value then 1 equals returning 0
end

This kind of hook is possible. It catches all team changes, but the called hook does not know why it is happening. It can quietly intercept and stop the team change. In case of inactivity, it could cause bad repetiting attempt to move the player to spectators. The inactivity timers can be seen using gentity_get though.

 

Thoughts about this? This is the time to change the behaviour if needed, before any existing Lua depends on it.

Link to comment
Share on other sites

I had originally thought that I could basically create my own with client command (And Possibly a runframe for inactivity) but it doesn't seem like the limbo menu passes any kind of command that lua catches(Or am I wrong?)

Yeah, any team, limbo changes are shown in et_clientUserinfoChanged always for sure.

You don't have to check them directly from userinfo, you can use instead et.gentity_get function, works faster imo.

 

edit:

If you want to stop client from team switching then catch commands from et_ClientCommand callback, check team etc. and then just return value to stop from post-executing or not.

Edited by solaЯ
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...