I'm looking fo anti-stuck script, maybe someone can help me with it?
[url]http://www.facepunch.com/threads/1043843-!stuck-command[/url]
Or are you talking about a script that never allows you to get stuck in the first place?
Yea, i need code to prevent player from stucking when he spawns
Have a look at [b][url=http://wiki.garrysmod.com/?title=Gamemode.IsSpawnpointSuitable]THIS[/url][/b]
The problem is what I'm using setpos after I spawn player, so this is not what I want. So I need to check if player can be moved to desired position and if not then select closest position where he can be moved
Well, there's a code in assmod that's borrowed from Megiddo, it's in something like
ass_teleporting, if I remember correctly it does something to check that the player is not somewhere out of the map, and if is, then make them go closest spot in map. Anyway, you should probably go have a look in there.
Thanks, i think this is just what i need
[QUOTE=uberpwns;27293781]Well, there's a code in assmod that's borrowed from Megiddo, it's in something like
ass_teleporting, if I remember correctly it does something to check that the player is not somewhere out of the map, and if is, then make them go closest spot in map. Anyway, you should probably go have a look in there.[/QUOTE]
[lua] -- Code from ULX so thank Megiddo for this. This is so players don't get stuck in the world when you teleport them
local function playerSend( from, to, force )
if not to:IsInWorld() and not force then return false end -- No way we can do this one
local yawForward = to:EyeAngles().yaw
local directions = { -- Directions to try
math.NormalizeAngle( yawForward - 180 ), -- Behind first
math.NormalizeAngle( yawForward + 180 ), -- Front
math.NormalizeAngle( yawForward + 90 ), -- Right
math.NormalizeAngle( yawForward - 90 ), -- Left
yawForward,
}
local t = {}
t.start = to:GetPos() + Vector( 0, 0, 15 ) -- Move them up a bit so they can travel across the ground
t.filter = { to, from }
local i = 1
t.endpos = to:GetPos() + Angle( 0, directions[ i ], 0 ):Forward() * 47 -- (33 is player width, this is sqrt( 33^2 * 2 ))
local tr = util.TraceEntity( t, from )
while tr.Hit do -- While it's hitting something, check other angles
i = i + 1
if i > #directions then -- No place found
if force then
return to:GetPos() + Angle( 0, directions[ 1 ], 0 ):Forward() * 47
else
return false
end
end
t.endpos = to:GetPos() + Angle( 0, directions[ i ], 0 ):Forward() * 47
tr = util.TraceEntity( t, from )
end
return tr.HitPos
end
[/lua]
This?
Sorry, you need to Log In to post a reply to this thread.