I am creating a Tow Truck stop, I posted else where about setting fuel, we are stripping back most mods, to check it works without some mods, and it kind of works, but I having a problem the car will check if the user is in the car but does not check if the user is the driver, the passager can fix the car and it will fix on there screen only, but if the driver fix’s it it will fix it on both screens, I be happy to leave it to anyone in the car can pay for a fix if it fixed it on all the users screens but it don’t.
Any idea why
Client #1
Citizen.CreateThread(function()
PriceSet = getPrice();
while true do
local User = GetPlayerPed(-1);
local vehid = GetVehiclePedIsIn(User, false);
local p = GetEntityCoords(User, true);
for i in ipairs(garages) do
local garage = garages[i]
if IsPedSittingInAnyVehicle(User) then
DrawMarker(1, garage.x, garage.y, garage.z - 1, 0, 0, 0, 0, 0, 0, 3.4001, 3.4001, 0.8001, 0, 248, 248, 255, 0,0, 0,0)
if (Vdist(garage.x, garage.y, garage.z, p.x, p.y, p.z) < 2.4) then
if(IsPedInAnyVehicle(User, false))then
Broken = IsVehicleDamaged(vehid);
if not IsVehicleDriveable(vehid, false) then
Broken = true;
end
if Broken then
if FoxFix.Free then
DisplayHelpText("Press ~INPUT_CONTEXT~ to repair your vehicle");
else
DisplayHelpText("Press ~INPUT_CONTEXT~ to repair your vehicle for ~g~$"..PriceSet);
end
if IsControlJustPressed(1, 51) then
TriggerServerEvent('dufx:dofix', PriceSet);
DisplayHelpText("Fixed");
end
end
end
end
end
end
Citizen.Wait(0)
end
end)
Server
RegisterNetEvent('dufx:dofix')
AddEventHandler('dufx:dofix', function(CostPrice)
if FoxFix.Free then
else
TriggerEvent('es:getPlayerFromId', source, function(user)
local thissource = source
if user.getMoney() >= CostPrice then
user.removeMoney(CostPrice);
TriggerClientEvent('dufx:actionfix', thissource);
end
end)
end
end)
Client #2
RegisterNetEvent('dufx:actionfix')
AddEventHandler('dufx:actionfix', function()
vehid = GetVehiclePedIsIn(GetPlayerPed(-1), false);
SetVehicleFixed(vehid);
if FoxFix.Fuel then
SetVehicleUndriveable(vehid, true)
SetVehicleEngineOn(vehid, false, false, false)
Wait(300);
SetVehicleFuelLevel(vehid, 60.0);
Wait(300);
SetVehicleEngineOn(vehid, true, false, false)
SetVehicleUndriveable(vehid, false)
end
PriceSet = getPrice();
end)