Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local prices = {
- {id = 0, price = 1600}, --compacts
- {id = 1, price = 2000}, --sedans
- {id = 2, price = 1200}, --SUV's
- {id = 3, price = 3400}, --coupes
- {id = 4, price = 2000}, --muscle
- {id = 5, price = 3500}, --sport classic
- {id = 6, price = 3200}, --sport
- {id = 7, price = 11000}, --super
- {id = 8, price = 1000}, --motorcycle
- {id = 9, price = 1800}, --offroad
- {id = 10, price = nil}, --industrial
- {id = 11, price = nil}, --utility
- {id = 12, price = 1400}, --vans
- {id = 13, price = 100}, --bicycles
- {id = 14, price = nil}, --boats
- {id = 15, price = 18200}, --helicopter
- {id = 16, price = nil}, --plane
- {id = 17, price = nil}, --service
- {id = 18, price = nil}, --emergency
- {id = 19, price = 6200}, --military
- {id = 20, price = 1400} --commercial
- }
- local vehPrice = nil
- Citizen.CreateThread(function()
- local blipX = 1200.63
- local blipY = -3116.04
- local blipZ = 5.54
- while true do
- Citizen.Wait(0)
- local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
- local distance = GetDistanceBetweenCoords(1204.3627929688,-3116.9548339844,4.5403227806092, x, y, z, true)
- --load marker and get price if player is in vehicle and close to the area
- if distance <= 20.0 and IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
- -- TriggerEvent("chatMessage", "^2Hello")
- DrawMarker(1,1204.3627929688,-3116.9548339844,4.5403227806092, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 2.0, 255, 0, 0, 100, false, true, 1, false, false, false, false)
- local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
- vehPrice = getPrice(GetVehicleClass(vehicle))
- -- abilty to sell if in range and vehicle can be bought
- if distance <= 4.0 then
- if vehPrice ~=nil then
- vehPrice = applyHealthModifier(vehPrice, vehicle)
- showHelp("Appuyez ~INPUT_PICKUP~ pour vendre le véhicule ~b~$" .. vehPrice .. "~s~!")
- if IsControlPressed(1, 38) then
- sellVehicle(vehicle, vehPrice)
- end
- else
- showHelp("Vous ne pouvez pas vendre cette voiture.")
- end
- end
- end
- end
- end)
- function getPrice(class)
- for k, price in pairs(prices) do
- if class == price.id then
- return price.price
- end
- end
- end
- function showHelp(message)
- SetTextEntry("STRING")
- AddTextComponentString(message)
- end
- function applyHealthModifier(price, vehicle)
- local health = GetEntityHealth(vehicle)
- local modifier = health/1000
- return round((modifier * price), 0)
- end
- RegisterNetEvent("deleteveh")
- AddEventHandler("deleteveh", function()
- local vehicle = SetEntityAsMissionEntity(GetVehiclePedIsIn(GetPlayerPed(-1)), true, true)
- DeleteVehicle(vehicle)
- vehPrice = nil
- end)
- function sellVehicle(vehicle, price)
- if price == nil then
- TriggerEvent("chatMessage", "^2Vous ne pouvez pas vendre cette voiture")
- else
- TriggerServerEvent("sellVehicle", price)
- Citizen.Wait(960000)
- end
- end
- function round(num, numDecimalPlaces)
- local mult = 10^(numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- -- Si tu lis ça, Bob Shawar t'emmerde ;)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement