• Need a bit of help with a stuck command.
    13 replies, posted
So, I run a prophunt server and players keep getting stuck. I'm trying to think of how to code a !stuck command so it tp's you a few feet away from where you are. I haven't been able to think of any way to do it so I'm posting here to see if anyone has any ideas. ws
One idea I can think of is to perform several hull traces around the player until a position is found that is free of obstacles, and then teleport the player there.
[QUOTE=typedef state;41407057]One idea I can think of is to perform several hull traces around the player until a position is found that is free of obstacles, and then teleport the player there.[/QUOTE] I could do that but, it would be a lot of work. To be honest that level of coding is out of my reach. I was thinking of a just sending the stuck player to spawn and putting a timer on the command.
Ignore this, my idea wouldn't work.
[code] concommand.Add("stuck", function(ply) ply = LocalPlayer() ply:SetPos(ply:GetPos() + Vector(0, 0, 60)) end ) hook.Add("PlayerSay", "playersaystuck", function(ply, text) if text == "!stuck" then ply:ConCommand("stuck") end end ) [/code]
Has anyone tried this? Is this the reason he got banned? I am looking for the same thing too, but don't know jack shit about lua coding. Thanks
[QUOTE=Xer0n;42242400]Has anyone tried this? Is this the reason he got banned? I am looking for the same thing too, but don't know jack shit about lua coding. Thanks[/QUOTE] That would change his position to +60 z(not sure what it's calculated in like units or what), which can't assure that the player wouldn't move into new props or world, and could be abused to move yourself through walls etc.
Okay, I have another question while you are here. I see snippets of code, I do not know where to add them to. I don't know specifically where to put them to ensure the game has loaded them, should I put it in a pre-existing lua code file or something?
[QUOTE=Xer0n;42248154]Okay, I have another question while you are here. I see snippets of code, I do not know where to add them to. I don't know specifically where to put them to ensure the game has loaded them, should I put it in a pre-existing lua code file or something?[/QUOTE] Typically, temporary scripts or scripts fit for a particular purpose without needing to interact with the base gamemode are put into a script in /garrysmod/lua/autorun. You can name the file anything and it will be ran, as long as it's a *.lua file I believe. In this case since the code is only being run on the Server, you would want to put that lua file in the server subfolder, if it were only client, you would put it in the client subfolder, if it is shared (meaning both will run the code) you need to leave it in the autorun folder.
Hi, I ran this script and it shot out a LUA error which isn't surprising. [quote][09/20/13 03:49:04] |TBB| Xer0n [STEAM_0:1:36549678|192.168.1.104:27006] ran co mand 'stuck' with arguments '' via chat. [09/20/13 03:49:04] |TBB| Xer0n [STEAM_0:1:36549678|192.168.1.104:27006]: !stuc |TBB| Xer0n: !stuck L 09/20/2013 - 03:49:04: "|TBB| Xer0n<2><STEAM_0:1:36549678><Team>" say "!stuck L 09/20/2013 - 03:49:04: Lua Error: [ERROR] lua/autorun/server/stuck.lua:2: attempt to call global 'LocalPlayer' (a nil value) 1. unknown - lua/autorun/server/stuck.lua:2 2. unknown - lua/includes/modules/concommand.lua:69 [ERROR] lua/autorun/server/stuck.lua:2: attempt to call global 'LocalPlayer' (a nil value) 1. unknown - lua/autorun/server/stuck.lua:2 2. unknown - lua/includes/modules/concommand.lua:69[/quote]
[QUOTE=Xer0n;42251369]Hi, I ran this script and it shot out a LUA error which isn't surprising.[/QUOTE] Remove ply = LocalPlayer(); but either way, it's not a good function. It moves you +60 in Z, which could be into a wall, out of world, into someones house.
Okay, thanks for the advice. I have been searching all over the place trying to find something that is suitable to get the job done, and quite honestly I can't find anything other than this snippet of code. Would you have any recommendations of your own, or know something else that will work better? Thanks again for the replies Busan, much more appreciated then the usual bashing.
[QUOTE=Xer0n;42251514]Okay, thanks for the advice. I have been searching all over the place trying to find something that is suitable to get the job done, and quite honestly I can't find anything other than this snippet of code. Would you have any recommendations of your own, or know something else that will work better? Thanks again for the replies Busan, much more appreciated then the usual bashing.[/QUOTE] If you want to teleport him to spawn that's easily doable, otherwise I can only see this as a solution:[QUOTE=typedef state;41407057]One idea I can think of is to perform several hull traces around the player until a position is found that is free of obstacles, and then teleport the player there.[/QUOTE] [editline]20th September 2013[/editline] To teleport him to spawn, go to spawn, type "getpos" in console, you get something like this: setpos -1088.270020 5364.000000 -130.333252 Make a file, stuck.lua, put in lua/autorun/server: [LUA] hook.Add( "PlayerSay", "playersaystuck", function( ply, text ) if text == "!stuck" then ply:SetPos( Vector( -1088, 5364, -130 ) ); end end ); [/LUA]
I made a little command you lot might find useful; [URL=http://facepunch.com/showthread.php?t=1309052]Thread[/URL] [URL=http://uppercutservers.com/rejax/UnStuck.zip]Download link[/URL]
Sorry, you need to Log In to post a reply to this thread.