Geo Posted April 6, 2013 Share Posted April 6, 2013 I'm working on a script to promote spectators automatically to shoutcaster status. The idea is when a client connects, they instantly become a shoutcaster, thus enjoying the additional features that SC allows in comparison to a spectator. I'm now doubting whether this is actually possible, but I'll explain what I was thinking. So here is the code: function et_ClientConnect( clientNum, firstTime, isBot) local connect = et.gentity_get(clientNum, "pers.connected") if connect == 2 then return end local team = et.gentity_get(clientNum, "sess.sessionTeam") if isBot(clientNum) then return end if team == 3 then et.trap_SendConsoleCommand( et.EXEC_APPEND, "makesc "..clientNum.."\n") return end if isBot(clientNum) then return end if team == "" then et.trap_SendConsoleCommand( et.EXEC_APPEND, "removesc "..clientNum.."\n") return end function isBot(clientNum) if et.gentity_get(clientNum,"ps.ping") == 0 then return true endend The script works as in it detects when a client is connected, and makes them a shoutcaster, however this doesn't happen if they have to reconnect to download a map for example.The main issue: I can't log them out of SC so that they can join a team. I originally was going to use "removesc" to take away their elevated status once they joined either b/r. However, they can't actually join a team so it's pointless trying to look for when they join a team. Is there a way to log them out as they are choosing a team (ie - limbo, looking for a /team cvar etc) or is this just impossible currently. If so, an idea I would like to request is Shoutcaster automatically logging the client out when they join a team. They log in, it is normal in spec but once a team is chosen they are logged out and have a normal status as per usual. Thanks for reading. Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted April 6, 2013 Management Share Posted April 6, 2013 I don't know if it will be possible. You can test intercepting "team" command from client and manipulating sess.shoutcaster. To make shoutcaster:sess.shoutcaster to value 1sess.spec_invite to value 3 To remove shoutcaster:sess.shoutcaster to value 0if the player is not referee (sess.referee is 0), sess.spec_invite to value 0 The reason why manipulating directly is so that the change would take effect before the actual client team command is handled. The team command is sent from the client only when they press ok button from the limbo panel or use it directly from the console. You probably don't need to call http://mygamingtalk.com/wiki/index.php/Silent_Lua#ClientUserinfoChanged after manipulating the status as the team command execution will do it. But otherwise this is needed. Quote Link to comment Share on other sites More sharing options...
Geo Posted April 6, 2013 Author Share Posted April 6, 2013 The reason why manipulating directly is so that the change would take effect before the actual client team command is handled. The team command is sent from the client only when they press ok button from the limbo panel or use it directly from the console. You probably don't need to call http://mygamingtalk.com/wiki/index.php/Silent_Lua#ClientUserinfoChanged after manipulating the status as the team command execution will do it. But otherwise this is needed. This is what I was wondering, thanks for clarifying this. I will test this soon and see what happens Quote Link to comment Share on other sites More sharing options...
Sol Posted April 6, 2013 Share Posted April 6, 2013 The team command is sent from the client only when they press ok button from the limbo panel or use it directly from the console.As Gaoesa said, you just need to check for 'team ...' command and then function et_ClientCommand( clientNum, command ) if command == "team" and et.trap_Argv(1) ~= "s" then et.gentity_set(clientNum, "sess.shoutcaster", 0) return true elseif command == "team" and et.trap_Argv(1) == "s" then et.gentity_set(clientNum, "sess.shoutcaster", 1) return true end end Now client will able to join the team and he will also be able to be shoutcaster again if he go to the spectator. Quote Link to comment Share on other sites More sharing options...
Geo Posted April 7, 2013 Author Share Posted April 7, 2013 I took the advice from these replies and wrote a new script. Sol - your script worked perfectly but I also wanted clients to become shoutcaster when they connect. Therefore I had to add in two new functions at the beginning of the script. Code: function et_ClientConnect( clientNum, firstTime, isBot) local connect = et.gentity_get(clientNum, "pers.connected") if connect == 2 then return end local team = et.gentity_get(clientNum, "sess.sessionTeam") if team == 3 then et.gentity_set(clientNum, "sess.shoutcaster", 1) et.gentity_set(clientNum, "sess.spec_invite", 3) return true elseif team == 0 then et.gentity_set(clientNum, "sess.shoutcaster", 0) return true end end function et_ClientCommand( clientNum, command) if command == "team" and et.trap_Argv(1) ~= "s" then et.gentity_set(clientNum, "sess.shoutcaster", 0) return true elseif command == "team" and et.trap_Argv(1) == "s" then et.gentity_set(clientNum, "sess.shoutcaster", 1) et.gentity_set(clientNum, "sess.spec_invite", 3) return true end end I had to use sess.sessionTeam in order to log people in when they connected, but I had the problem then of clients being refused to join a team. Therefore, I used the "0" (not on a team) value which I assumed included limbo status and this worked fine for the purpose. From then on the next function allowed people to become SC in spec and rejoin a team. The problem now is bots become shoutcasters and cannot join teams, whereupon more bots join until the server is full. I guessed that this was because it was detecting that no bots were playing so automatically more joined in an attempt to play (no idea if that is correct). I don't know if using sess.sessionTeam value 0 is an effective way but I couldn't get anything else to work. If someone has any improvements, or mainly to solve my bot issue, it would be appreciated. I tried a function isBot using the ps.ping == 0 but this returned an error in the log. It was something like tried to call local isBot (number value) which I don't understand. Thanks! Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted April 7, 2013 Management Share Posted April 7, 2013 Bots don't use limbo panel and don't use the team command either. You need to check if the player entity is a bot and exclude it if that is the case. Quote Link to comment Share on other sites More sharing options...
Sol Posted April 7, 2013 Share Posted April 7, 2013 (edited) You don't need to use et_ClientConnect callback to check sess.sessionTeam state it's useless imo, there is another callback for that "et_ClientBegin". Also if you want to check bots just check their ping for ex: function et_ClientBegin( clientNum ) if et.gentity_get( clientNum, "ps.ping" ) ~= 0 then -- stuffs end end Edited April 7, 2013 by Sol Quote Link to comment Share on other sites More sharing options...
Geo Posted April 8, 2013 Author Share Posted April 8, 2013 (edited) I managed to fix the bot problem but in a different way. I tested the et.ClientBegin callback but this is executed only once per map, and I mainly wanted clients to become shoutcaster automatically as soon as they connect. This is why I used et.ClientConnect instead. Also, this allowed me to use the local isBot value and add a line of code to exclude bots if isBot returns 1. The script works when clients connect, they can join a team and become shoutcaster once they become a spectator. However, the problem now is use of the !putteam command. I tried to look for clients executing this command but it didn't work, so if any help can be offered it would be useful. I'd like for when clients use the command to join a team it removes shoutcaster, and when they become a spectator they become shoutcaster (same behaviour as "team..." command). This is the code: function et_ClientConnect(clientNum, firstTime, isBot) if isBot == 1 then return end local team = et.gentity_get(clientNum, "sess.sessionTeam") if team == 3 then et.gentity_set(clientNum, "sess.shoutcaster", 1) et.gentity_set(clientNum, "sess.spec_invite", 3) return true elseif team == 0 then et.gentity_set(clientNum, "sess.shoutcaster", 0) return true end end function et_ClientCommand( clientNum, command) if command == "team" and et.trap_Argv(1) ~= "s" then et.gentity_set(clientNum, "sess.shoutcaster", 0) return true elseif command == "team" and et.trap_Argv(1) == "s" then et.gentity_set(clientNum, "sess.shoutcaster", 1) et.gentity_set(clientNum, "sess.spec_invite", 3) return true end end A couple of other things worth mentioning are that when I am running this script, the inactivity detection does not seem to work, I was afk for over 10 minutes and still remained in a team. This worked fine without the script being loaded. Perhaps it is using something similar to !putteam? I must note that !putteam works when the client is in a team, but it doesn't work from spec (as it won't let you !putteam a client into a team as you're shoutcaster). Also, Gaoesa you mentioned checking for whether sess.referee is at 0 before setting sess.spec_invite to 0, I was wondering why this is needed? Thankyou. Edited April 8, 2013 by Arcane Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted April 8, 2013 Management Share Posted April 8, 2013 Shoutcaster are not affected by the inactivity timer. The spec_invite allows following the team regardless of spec lock. Quote Link to comment Share on other sites More sharing options...
Geo Posted April 8, 2013 Author Share Posted April 8, 2013 Ok thanks for clarifying. Is there a way to change shoutcaster status if the client uses !putteam (like team) to move clients? I did try a similar way but I assumed I would need to get the targetClientNum as et.trap_Argv(1) and the team as (2). (like !putteam name/slot r/b/s) but this didn't work. Quote Link to comment Share on other sites More sharing options...
Geo Posted April 10, 2013 Author Share Posted April 10, 2013 Getting !putteam to work from spec to a team is the only problem now. I tried what Sol suggested but I can't seem to make the client either be shoutcaster when !putteam name/slot s is done or remove shoutcaster when !putteam name/slot r/b is done. Any ideas? Quote Link to comment Share on other sites More sharing options...
Geo Posted April 13, 2013 Author Share Posted April 13, 2013 Created a script that works and accounts for use of /team and !putteam cmds. However it's quite buggy and I don't really like it, so i've stopped working on it. Thought i'd upload something that works to an extent anyway. function et_ClientConnect(clientNum, firstTime, isBot) if isBot == 1 then return end local team = et.gentity_get(clientNum, "sess.sessionTeam") if team == 3 then et.gentity_set(clientNum, "sess.shoutcaster", 1) et.gentity_set(clientNum, "sess.spec_invite", 3) return true end end function et_ClientCommand( clientNum, command) if command == "team" and et.trap_Argv(1) ~= "s" then et.gentity_set(clientNum, "sess.shoutcaster", 0) et.gentity_set(clientNum, "sess.spec_invite", 0) return true elseif command == "team" and et.trap_Argv(1) == "s" then et.gentity_set(clientNum, "sess.shoutcaster", 1) et.gentity_set(clientNum, "sess.spec_invite", 3) return true end end function et_ClientCommand( clientNum, command) if command ~= "say" then return end local targetClientNum = et.ClientNumberFromString(et.trap_Argv(2)) if et.trap_Argv(1) == "!putteam" and targetClientNum ~= nil and et.trap_Argv(3) == "s" then et.gentity_set(targetClientNum, "sess.shoutcaster", 1) et.gentity_set(targetClientNum, "sess.spec_invite", 3) return true end if et.trap_Argv(1) == "!putteam" and targetClientNum ~= nil and et.trap_Argv(3) ~= "s" then et.gentity_set(targetClientNum, "sess.shoutcaster", 0) et.gentity_set(targetClientNum, "sess.spec_invite", 0) return true end end Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.