Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google Log In with Steam Sign In
  • Create Account
Photo

ClientSwitchTeam

- - - - - lua

  • Please log in to reply
5 replies to this topic

#1
OFFLINE   Zelly

Zelly

    Regular Member

  • Coders
  • PipPipPip
  • 141 posts
73
Getting Better

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:

 



#2
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland

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....UserinfoChanged



#3
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland
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.



#4
OFFLINE   Sol

Sol

    Regular Member

  • Coders
  • PipPipPip
  • 113 posts
28
On a distinguished road
  • LocationPoland

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Я, 07 March 2014 - 04:16 PM.


#5
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland

Yes. I don't know if you want the intercept option only for client actions. If that is the case, then this callback might not be the best option.



#6
OFFLINE   Zelly

Zelly

    Regular Member

  • Coders
  • PipPipPip
  • 141 posts
73
Getting Better

Hmm, ok thank you guys. I will see if I can accomplish what I need using the et_clientUserInfoChanged method.







Also tagged with one or more of these keywords: lua

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users