trying to have a lua_run entity execute a console command in a map...
7 replies, posted
I'm trying to have this command entered in the player's console with a lua_run entity in my map:
cl_detaildist 999999
So I put this in the "Code" field of the lua_run properties:
[code]RunConsoleCommand("cl_detaildist", "999999"); end[/code]
and have a logic_auto activate the lua_run entity.
BUT when I start the map in Garry's Mod, the command does not get executed. I am thinking the code is wrong or something. Can anyone tell me what I'm doing wrong?
I'm trying to make it where the detail prop fade distance is set really far away, so people don't see vegetation in my map just "pop up" when they're 30 feet away.
I'm not a mapper, but I know there's a better way to do this. Anyhow, try running that with ulx cexec, and watch console. If you see something like [I]FCVAR_SERVER_CAN_EXECUTE[/I] preventing the command from being run, your under the water and have to find a way to get it to run without lua.
Also, remove the [I]; end[/I] part of the lua and try again.
[b][url=http://wiki.garrysmod.com/?title=G.RunConsoleCommand]G.RunConsoleCommand [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=http://wiki.garrysmod.com/?title=Player.ConCommand]Player.ConCommand [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
I'm pretty sure cl_detaildist is a clientside command and non executable on clients.
[QUOTE=nicatronTg;21356906]I'm not a mapper, but I know there's a better way to do this. Anyhow, try running that with ulx cexec, and watch console. If you see something like [I]FCVAR_SERVER_CAN_EXECUTE[/I] preventing the command from being run, your under the water and have to find a way to get it to run without lua.
Also, remove the [I]; end[/I] part of the lua and try again.
[B][URL="http://wiki.garrysmod.com/?title=G.RunConsoleCommand"]G.RunConsoleCommand [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B]
[B][URL="http://wiki.garrysmod.com/?title=Player.ConCommand"]Player.ConCommand [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B][/QUOTE]
I have solved my problem and got it working, finally. My original code was just wrong, it should have been:
[code]RunConsoleCommand('cl_detaildist', '999999')[/code]I removed the "; end" part, and replaced the double-quotes " with single quotes '
Thanks for your help!!!
Actually, I have discovered another problem:
When I start the map in singleplayer, it works perfectly fine. But when I start the map in a listen server, the command doesn't get executed.
Is the RunConsoleCommand function blocked in Gmod Multiplayer?
That's what I was afraid of. It's not that it's blocked on multiplayer--it's actually used quite a lot--it's that the command cl_detaildist is blocked from being executed server side. You might consider asking mapping, I'm not sure what else to do :/
player:ConCommand("wait 1;cl_detaildist 999999")
[QUOTE=nicatronTg;21370398]That's what I was afraid of. It's not that it's blocked on multiplayer--it's actually used quite a lot--it's that the command cl_detaildist is blocked from being executed server side. You might consider asking mapping, I'm not sure what else to do :/[/QUOTE]
[quote=|FlapJack|]player:ConCommand("wait 1;cl_detaildist 999999") [/quote]
I originally had the logic_auto activate the lua_run entity with a 0 second delay, but when I made it a 2 second delay, it miraculously worked! Now the command is successfully executed in both singleplayer and multiplayer.
Is that what the little "wait 1;" part of the code is, FlapJack? I should have checked this thread out before I pulled out all my hair figuring it out on my own, lol.
Thanks, you guys are really helpful!
Yeah, wait 1 would tell it to wait one frame before processing, as far as I know. It might be a second, but none the less glad it worked :)
Sorry, you need to Log In to post a reply to this thread.