Hello,
I have taken the cuff script from @Marxy to try and recreate the drag script from @Frazzle so that it doesn’t require essential mode. When you type in the command and the clients id it crashes that clients game. Any help is appreciated.
Client.lua
drag = false
RegisterNetEvent("dr:drag")
AddEventHandler('dr:drag', function(pl)
otherid = tonumber(pl)
drag = not drag
end)
Citizen.CreateThread(function()
while true do
if drag then
local ped = GetPlayerPed(GetPlayerFromServerId(otherid))
local myped = GetPlayerPed(-1)
AttachEntityToEntity(myped, ped, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
else
DetachEntity(GetPlayerPed(-1), true, false)
end
Citizen.Wait(0)
end
end)
Server.lua
AddEventHandler('chatMessage', function(source, n, message)
cm = stringsplit(message, " ")
if cm[1] == "/drag" then
CancelEvent()
if tablelength(cm) > 1 then
local tPID = tonumber(cm[2])
TriggerClientEvent("dr:drag", tPID)
end
end
end)
function stringsplit(self, delimiter)
local a = self:Split(delimiter)
local t = {}
for i = 0, #a - 1 do
table.insert(t, a[i])
end
return t
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end