ok look at this i made the glue system in server side but when a player is trying to glue on my car he can't . just me can glue on my car. here is the code
function gluePlayer(player, slot, vehicle, x, y, z, rotX, rotY, rotZ)
attachElements(player, vehicle, x, y, z + 0.16, rotX, rotY, rotZ)
setPedWeaponSlot(player, slot)
setElementData(player, "gluedYe", true)
end
function unglue(source, key, state)
detachElements(source)
setElementData(source, "gluedYe", false)
end
function glue(_, element)
if not getPedOccupiedVehicle(source) then
local owner = getElementData(element, "Owner")
local gmate = getElementData(source, "g")
local gmate2 = getElementData(owner, "g")
local smate = getElementData(source, "s")
local smate2 = getElementData(owner, "s")
if (getElementData(vehicle, "locked") == true) and not (owner == source) or not (gmate == gmate2) or not (smate == smate2) then
exports.CIThelp:displayAttachedHelp(0, 0, 1, vehicle, "Vehicle is locked by the owner only group/squad members can glue to it", 1, 255, 0, 0, 180, 5000)
return
elseif getElementType(element) == "vehicle" then --and getElementData(source, "CIFvip") == true or (getTeamName(getPlayerTeam(source)) == "Staff") then
local px, py, pz = getElementPosition(source)
local vx, vy, vz = getElementPosition(element)
local sx = px - vx
local sy = py - vy
local sz = pz - vz
local rotpX = 0
local rotpY = 0
local rotpZ = getPedRotation(source)
local rotvX,rotvY,rotvZ = getElementRotation(element)
local t = math.rad(rotvX)
local p = math.rad(rotvY)
local f = math.rad(rotvZ)
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
local slot = getPedWeaponSlot(source)
gluePlayer(source, slot, element, x, y, z, rotX, rotY, rotZ)
bindKey(source,"jump","down",unglue)
bindKey(source,"w","down",unglue)
bindKey(source,"a","down",unglue)
bindKey(source,"s","down",unglue)
bindKey(source,"d","down",unglue)
end
end
end
addEventHandler("onPlayerContact", root, glue)