Dragonji Posted December 21, 2012 Share Posted December 21, 2012 Anybody know the answer?I think it's not possible at the moment, otherwise it'd be documented.The main way I want to use it currently is to have some configuration options available to the clients. For example, I am working on a script that plays custom sounds on our server. I would like to give the client the option to disable this functionality if they do not want to hear them. The way I am currently planning on doing this is to allow the clients to set a custom cvar such as playsound_disable, so they can just add the line "set playsound_disable "1"" to their config if they want them disabled on our server. This would be excellent functionality because setting cvars is mostly common knowledge in the ET community, and I would be able to avoid workarounds such as having to make players execute a custom command and recording the preference in some type of data file on the server.I wrote a similar script but didn't find a way to get client's specific cvar so I just used a work-around, I scan for a specific rate amount (userinfo) and if it matches the one defined for disabled sounds, the server doesn't send playsound request to the client. Indeed, it'd be great to have a possibility to check client's cvar value so we can create better scripts! Dzwiek = { [0] = "path/to/sound.wav" [1] = "path/to/sound.wav" -- etc. } client_sounds = { } function et_InitGame(levelTime, randomSeed, restart) sv_maxclients = tonumber(et.trap_Cvar_Get("sv_maxclients")) end function et_ClientBegin(id) CheckRate(id) end function et_ClientDisconnect(id) client_sounds[id] = 0 end function CheckRate(id) local rs = et.Info_ValueForKey(et.trap_GetUserinfo(id), "rate") if rs == "45123" then client_sounds[id] = 0 else client_sounds[id] = 1 end end function et_ConsoleCommand() if et.trap_Argv(0) == "pfsound" then if et.trap_Argc() == 2 then local indeks = tonumber(et.trap_Argv(1)) PlaySound(Dzwiek[indeks]) else sayClients("chat","^1ERROR: Not enough parameters given!") end end end function PlaySound(sound) local odtworz = et.G_SoundIndex(sound) for i=0, sv_maxclients-1 do if client_sounds[i] == 1 then et.G_ClientSound(i, odtworz) end end end Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted December 21, 2012 Management Share Posted December 21, 2012 It's not as simple as a Lua script asking the client for cvar value and then stop waiting to get the answer for it. Quote Link to comment Share on other sites More sharing options...
JvIasterMind Posted December 21, 2012 Author Share Posted December 21, 2012 I think it's not possible at the moment, otherwise it'd be documented.I wrote a similar script but didn't find a way to get client's specific cvar so I just used a work-around, I scan for a specific rate amount (userinfo) and if it matches the one defined for disabled sounds, the server doesn't send playsound request to the client. That is an interesting workaround. Thanks for posting the code... very fun to see how other people accomplish similar scripts! Quote Link to comment Share on other sites More sharing options...
JvIasterMind Posted December 21, 2012 Author Share Posted December 21, 2012 It's not as simple as a Lua script asking the client for cvar value and then stop waiting to get the answer for it. Hmmm... I guess I didn't think about the network part of it! I have a few questions if you don't mind answering them... (Keep in mind, I am not that good at coding, so the following questions might be just a bunch of nonsense. ) Doesn't silEnT have to read all the client cvars when they connect to the server and also when they modify them to make sure they comply with the cvar restrictions? Could the server just keep all the cvars in memory for the connected clients (or does it already)? What about only allowing the accessing function to be during the et_ClientConnect or et_InitGame callbacks so the time it takes to get the value wouldn't be as critical and maybe there could be some kind of timeout where the value would return nil or something? Also, there is the Userinfo string with some cvars already. Could an alternative to that be implemented in much the same way with different values (or certain cvars added to that string)? Most of the values in that string seem like ones that wouldn't change during game, but I do see that it has a name field. How is that field kept up up-to-date? Maybe the same could be done with cvars with a set prefix like lua_ or similar? Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted December 22, 2012 Management Share Posted December 22, 2012 Doesn't silEnT have to read all the client cvars when they connect to the server and also when they modify them to make sure they comply with the cvar restrictions?Cvar restrictions are completely client side. Server only tells what cvars are restricted. What about only allowing the accessing function to be during the et_ClientConnect or et_InitGame callbacks so the time it takes to get the value wouldn't be as critical and maybe there could be some kind of timeout where the value would return nil or something?The server is always, except during intermission, time critical. Also, there is the Userinfo string with some cvars already.This is handled by the engine. Mods can define cvars to be included into it. However, it's not practically good thing to add cvars that are not relevant to it. There are ways, but not simple solutions. At the moment I can not say if there will be anything made for this purpose. Quote Link to comment Share on other sites More sharing options...
JvIasterMind Posted December 23, 2012 Author Share Posted December 23, 2012 Ok, all that makes a lot of sense. Thanks for answering all my questions! Also, thanks for thinking about and considering the idea! I really appreciate all the work you put into the mod and how great your support is in these forums! Dragonji 1 Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted December 26, 2012 Management Share Posted December 26, 2012 In the next version it is possible to query client cvars with Lua. It works 2 parts. First API function to issue query, when the result is ready, a hook funtion in the Lua script is called with the client number, cvar name and cvar value. There is also option for logging these to the g_cheatLog. Quote Link to comment Share on other sites More sharing options...
JvIasterMind Posted December 26, 2012 Author Share Posted December 26, 2012 Thank you very much gaoesa!!! I'm really looking forward to this addition! Quote Link to comment Share on other sites More sharing options...
Dragonji Posted March 17, 2013 Share Posted March 17, 2013 (edited) Got a question. In the Lua docs, the description of G_shrubbot_permission says:Tells if the given player entity has the given shrubbot flag set. (...)ent is the player entity that is checked What is ent? Slot number? Edited March 17, 2013 by Dragonji Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted March 17, 2013 Management Share Posted March 17, 2013 It is the slot number, starting from 0. Fixed in the docs. Quote Link to comment Share on other sites More sharing options...
Dragonji Posted January 3, 2015 Share Posted January 3, 2015 I'd like to ask if there's a way to check how long a player is playing in his current team on the current map? Quote Link to comment Share on other sites More sharing options...
Zelly Posted January 3, 2015 Share Posted January 3, 2015 You could easily keep track, I am not sure if there exists an entity field though. Quote Link to comment Share on other sites More sharing options...
Aciz Posted January 3, 2015 Share Posted January 3, 2015 I'd like to ask if there's a way to check how long a player is playing in his current team on the current map?I'm interested, mind I'd I ask you what would you use this info for? Quote Link to comment Share on other sites More sharing options...
Management TheSilencerPL Posted January 3, 2015 Management Share Posted January 3, 2015 I don't know if there is such thing in the LUA (rather not), but we added a server cvar to show the real play time of the player, maybe this would help you.http://mygamingtalk.com/wiki/Silent_Mod_Server_Cvar#g_realPlayTime EDIT1:But you could write a lua plugin to track players time in each team, that is possible for sure. Quote Link to comment Share on other sites More sharing options...
Dragonji Posted January 3, 2015 Share Posted January 3, 2015 I'm interested, mind I'd I ask you what would you use this info for? I'd like to give extra XP bonus for every player of a winning team. Of course, to avoid jumping between teams at last seconds of the map just to get XP I'd like to check how long every player was a member of the team. Quote Link to comment Share on other sites More sharing options...
Zelly Posted January 3, 2015 Share Posted January 3, 2015 you may want to use this as reference: https://github.com/Zelly/ZellyLuas/blob/master/ZInfo.luaThe script it self isn't done, It is kind of on hold atm, probably some errors.There I keep track of players team time, however I add it to their total , not just the maptime. Dragonji 1 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.