This is a old script scammer posted a while back, it still sort of works…the problem is once you lock your vehicle door, you can’t unlock it. Any thoughts? I plan on using this for my GUI menu.
--CLIENT
RegisterNetEvent("CGC:lockdoors")
local lastCar = nil
AddEventHandler("CGC:lockdoors", function()
Citizen.CreateThread(function()
car = GetVehiclePedIsIn(GetPlayerPed(-1), false)
if not car and lastCar == nil then
TriggerEvent("chatMessage", "ERROR", {255, 0, 0}, "You have to sit in a vehicle to set it as yours.")
return
elseif car then
lastCar = car
end
lockStatus = GetVehicleDoorLockStatus(lastCar)
if lockStatus == 0 or lockStatus == 1 then
SetVehicleDoorsLocked(lastCar, 2)
SetVehicleDoorsLockedForPlayer(lastCar, PlayerId(), false)
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "Door is now ^1locked^0.")
else
SetVehicleDoorsLocked(lastCar, 1)
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "Door is now ^2unlocked^0.")
end
end)
end)
--SERVER
RegisterServerEvent("chatCommandEntered")
RegisterServerEvent('chatMessageEntered')
AddEventHandler("chatMessage", function(p, color, msg)
if msg:sub(1, 1) == "/" then
fullcmd = stringSplit(msg, " ")
cmd = fullcmd[1]
if cmd == "/lock" then
TriggerClientEvent("CGC:lockdoors", p)
CancelEvent()
end
end
end)
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end