Skip to content
This repository has been archived by the owner on Oct 7, 2019. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpartaPT authored Apr 16, 2017
1 parent cd92388 commit a1bd845
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions carwash/__resource.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
client_script 'carwash_client.lua'
server_script 'carwash_server.lua'
67 changes: 67 additions & 0 deletions carwash/carwash_client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
--Settings--

price = 100 -- you may edit this to your liking and look bellow for the message when the payment was successful too

--DO-NOT-EDIT-BELLOW-THIS-LINE--

Key = 18 -- ENTER

vehicleWashStation = {
{26.5906, -1392.0261, 27.3634},
{167.1034, -1719.4704, 27.2916},
{-74.5693, 6427.8715, 29.4400},
{-699.6325, -932.7043, 17.0139}
}


Citizen.CreateThread(function ()
Citizen.Wait(0)
for i = 1, #vehicleWashStation do
garageCoords = vehicleWashStation[i]
stationBlip = AddBlipForCoord(garageCoords[1], garageCoords[2], garageCoords[3])
SetBlipSprite(stationBlip, 100) -- 100 = carwash
SetBlipAsShortRange(stationBlip, true)
end
return
end)

function DrawSpecialText(m_text, showtime)
SetTextEntry_2("STRING")
AddTextComponentString(m_text)
DrawSubtitleTimed(showtime, 1)
end

Citizen.CreateThread(function ()
while true do
Citizen.Wait(0)
if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
for i = 1, #vehicleWashStation do
garageCoords2 = vehicleWashStation[i]
DrawMarker(1, garageCoords2[1], garageCoords2[2], garageCoords2[3], 0, 0, 0, 0, 0, 0, 5.0, 5.0, 2.0, 0, 157, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), garageCoords2[1], garageCoords2[2], garageCoords2[3], true ) < 5 then
DrawSpecialText("Press [~g~ENTER~s~] to clean your vehicle!")
if(IsControlJustPressed(1, Key)) then
TriggerServerEvent('carwash:checkmoney', price)
end
end
end
end
end
end)


RegisterNetEvent('carwash:success')
AddEventHandler('carwash:success', function(price)
SetVehicleDirtLevel(GetVehiclePedIsUsing(GetPlayerPed(-1)))
SetVehicleUndriveable(GetVehiclePedIsUsing(GetPlayerPed(-1)), false)
msg = "Vehicle ~y~Clean~s~! ~g~-$" .. price .. "~s~!"
DrawSpecialText(msg, 5000)
Wait(5000)
end)

RegisterNetEvent('carwash:notenoughmoney')
AddEventHandler('carwash:notenoughmoney', function(moneyleft)
msg = "~h~~r~You don't have enough money! $" .. moneyleft .. " left!"
DrawSpecialText(msg, 5000)
Wait(5000)
end)
13 changes: 13 additions & 0 deletions carwash/carwash_server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
RegisterServerEvent('carwash:checkmoney')

AddEventHandler('carwash:checkmoney', function(price)
TriggerEvent('es:getPlayerFromId', source, function(player)
if(tonumber(player:money) >= tonumber(price)) then
player:removeMoney((price))
TriggerClientEvent('carwash:success', source, price)
else
moneyleft = price - player:money
TriggerClientEvent('carwash:notenoughmoney', source, moneyleft)
end
end)
end)

0 comments on commit a1bd845

Please sign in to comment.