# Problem With Ped

## Recommended Posts

When I Am Trying To Stand On Train While Moving, Ped Was Throwd Out, is it anyway fix thiss

• 1 month later...

You may use a glue system
Try mine

```local glues = {}

function glue (plr, cmd)

local veh = getPedContactElement(plr)
if (getElementData(plr, "glue") == false) then
-- Boolean again >_<
if isElement(veh) and (getElementType(veh) == "vehicle") then
local px, py, pz = getElementPosition(plr)
local vx, vy, vz = getElementPosition(veh)
local sx = px - vx
local sy = py - vy
local sz = pz - vz

local rotpX = 0
local rotpY = 0
local rotpZ = getElementRotation(plr)

local rotvX,rotvY,rotvZ = getVehicleRotation(veh)

local ct = math.cos(t)
local st = math.sin(t)
local cp = math.cos(p)
local sp = math.sin(p)
local cf = math.cos(f)
local sf = math.sin(f)

local z = ct*cp*sz + (sf*st*cp + cf*sp)*sx + (-cf*st*cp + sf*sp)*sy
local x = -ct*sp*sz + (-sf*st*sp + cf*cp)*sx + (cf*st*sp + sf*cp)*sy
local y = st*sz - sf*ct*sx + cf*ct*sy

local rotX = rotpX - rotvX
local rotY = rotpY - rotvY
local rotZ = rotpZ - rotvZ
attachElements(plr, veh, x,y,z, rotX, rotY, rotZ)
setElementData(plr, "glue", true)
glues[plr] = veh
end
else
if (isElement(glues[plr])) then
detachElements(plr, glues[plr])
setElementData(plr, "glue", false)
end
end
end

## Create an account

Register a new account