diff --git a/pTaxi/esx/client.lua b/pTaxi/esx/client.lua new file mode 100644 index 0000000..d30c029 --- /dev/null +++ b/pTaxi/esx/client.lua @@ -0,0 +1,193 @@ +-- Made with ❤️ by noahpombas.ch +if Pombas.legacy == true then + ESX = exports["es_extended"]:getSharedObject() +else + Citizen.CreateThread(function() + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end + end) +end + +local lastTaxiCallTime = nil +local cooldownTime = Pombas.delay * 60 + +RegisterCommand("chamarTaxi", function(source, args, rawCommand) + SetWaypointOff() + local currentTime = GetGameTimer() / 1000 + local ped = PlayerPedId() + local coords = GetEntityCoords(ped) + + if lastTaxiCallTime ~= nil and (currentTime - lastTaxiCallTime < cooldownTime) then + local remainingTime = cooldownTime - (currentTime - lastTaxiCallTime) + local time = math.floor(remainingTime / 60) + TriggerEvent("chat:addMessage", { args = { "^1Táxi ", "Você precisa esperar " .. time .. " minutos para chamar outro táxi!" } }) + return + end + + + lastTaxiCallTime = currentTime + + TriggerServerEvent("taxi:verificarSaldo") +end) + +-- Made with ❤️ by noahpombas.ch +RegisterNetEvent("taxi:saldoVerificado") +AddEventHandler("taxi:saldoVerificado", function(temSaldo) + if not temSaldo then + TriggerEvent("chat:addMessage", { args = { "^1Táxi", "Você não tem dinheiro suficiente no banco!" } }) + return + end + + local ped = PlayerPedId() + local coords = GetEntityCoords(ped) + local taxiModel = GetHashKey(Pombas.car) + local driverModel = GetHashKey(Pombas.driverModel) + + RequestModel(taxiModel) + RequestModel(driverModel) + while not HasModelLoaded(taxiModel) or not HasModelLoaded(driverModel) do + Wait(500) + end + + local foundRoad, outPos1, outPos2 = GetClosestRoad(coords.x, coords.y, coords.z, 1.0, 1, false) + local spawnCoords = vector3(0.0, 0.0, 0.0) + + if foundRoad then + spawnCoords = (outPos1 + outPos2) / 2 + else + spawnCoords = vector3(coords.x + 10, coords.y + 10, coords.z) + end + + local taxi = CreateVehicle(taxiModel, spawnCoords.x, spawnCoords.y, spawnCoords.z, GetEntityHeading(ped), true, false) + SetEntityAsMissionEntity(taxi, true, true) + + + local driver = CreatePedInsideVehicle(taxi, 26, driverModel, -1, true, false) + SetBlockingOfNonTemporaryEvents(driver, true) + SetPedCanBeDraggedOut(driver, false) + SetDriverAbility(driver, 1.0) + SetDriverAggressiveness(driver, 0.0) + TaskVehicleDriveWander(driver, taxi, 20.0, 786603) + SetEntityInvincible(taxi, true) + SetEntityInvincible(driver, true) + SetEntityAsMissionEntity(driver, true, true) + SetPedCombatAttributes(driver, 46, true) + SetPedFleeAttributes(driver, 0, false) + SetBlockingOfNonTemporaryEvents(driver, true) + + TaskVehicleDriveToCoord(driver, taxi, spawnCoords.x, spawnCoords.y, spawnCoords.z, 5000.0, 0, GetEntityModel(taxi), 786603, 1.0, true) + + + local taxiBlip = AddBlipForEntity(taxi) + SetBlipSprite(taxiBlip, 198) + SetBlipColour(taxiBlip, 46) + SetBlipScale(taxiBlip, 1.0) + + + local playerEntered = false + while not playerEntered do + local taxiCoords = GetEntityCoords(taxi) + local pedCoords = GetEntityCoords(ped) + + if #(pedCoords - taxiCoords) < 10.0 then + SetWaypointOff() + TaskEnterVehicle(ped, taxi, -1, 1, 1.0, 1, 0) + playerEntered = true + end + Wait(500) + end + + -- Solicitar que o jogador marque um destino no mapa + TriggerEvent("chat:addMessage", { args = { "^2Táxi", "Por favor, marque o destino no mapa!" } }) + local destinoMarcado = false + local waypointCoords = nil + + while not destinoMarcado do + local waypointBlip = GetFirstBlipInfoId(8) -- 8 é o ID de waypoint + if DoesBlipExist(waypointBlip) then + waypointCoords = GetBlipInfoIdCoord(waypointBlip) + destinoMarcado = true + end + Wait(500) + end + + local isPassenger = GetPedInVehicleSeat(taxi, 1) + local playerInside = false + + while not playerInside do + local pedCoords = GetEntityCoords(ped) + local taxiCoords = GetEntityCoords(taxi) + if #(pedCoords - taxiCoords) < 10.0 then + TaskEnterVehicle(ped, taxi, -1, 1, 1.0, 1, 0) + playerInside = true + end + end + + local foundRoad, outPos1, outPos2 = GetClosestRoad(waypointCoords.x, waypointCoords.y, waypointCoords.z, 1.0, 1, false) + if foundRoad then + spawnCoords = (outPos1 + outPos2) / 2 + else + spawnCoords = vector3(waypointCoords.x, waypointCoords.y, waypointCoords.z) + end + + + local destinoBlip = AddBlipForCoord(spawnCoords.x, spawnCoords.y, spawnCoords.z) + SetBlipSprite(destinoBlip, 1) + SetBlipColour(destinoBlip, 5) + SetBlipScale(destinoBlip, 1.0) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString("Destino") + EndTextCommandSetBlipName(destinoBlip) + + + local playerCoords = GetEntityCoords(PlayerPedId()) + local distancia = #(playerCoords - spawnCoords) + local preco = math.floor(distancia * Pombas.price) + + TriggerEvent("chat:addMessage", { args = { "^2Táxi", "Destino marcado! Custo estimado: $" .. preco } }) + + + TaskVehicleDriveToCoord(driver, taxi, spawnCoords.x, spawnCoords.y, spawnCoords.z, 5000.0, 0, GetEntityModel(taxi), 2883621, 1.0, true) + + local playerExited = 0 + local arrivedAtDestination = false + + while true do + local playerCoords = GetEntityCoords(PlayerPedId()) + local distancia = #(playerCoords - spawnCoords) + local isPassenger = GetPedInVehicleSeat(taxi, 1) + + + if isPassenger == 0 then + if playerExited == 0 then + playerExited = 1 + TriggerEvent("chat:addMessage", { args = { "^1Táxi", "Destino cancelado!" } }) + TriggerServerEvent('taxi:chargeFullPrice', preco) + Wait(3000) + DeleteVehicle(taxi) + DeletePed(driver) + RemoveBlip(destinoBlip) + end + end + + + if distancia < 10.0 and not arrivedAtDestination then + arrivedAtDestination = true + playerExited = 1 + TriggerEvent("chat:addMessage", { args = { "^1Táxi", "Chegou ao seu Destino!" } }) + TriggerServerEvent('taxi:chargeFullPrice', preco) + TaskLeaveVehicle(PlayerPedId(), taxi, 0) + Wait(3000) + DeleteVehicle(taxi) + DeletePed(driver) + RemoveBlip(destinoBlip) + end + + + + + Wait(1000) + end +end) \ No newline at end of file diff --git a/pTaxi/esx/config.lua b/pTaxi/esx/config.lua new file mode 100644 index 0000000..2069ef6 --- /dev/null +++ b/pTaxi/esx/config.lua @@ -0,0 +1,15 @@ +-- ███╗ ██╗ ██████╗ █████╗ ██╗ ██╗██████╗ ██████╗ ███╗ ███╗██████╗ █████╗ ███████╗ ██████╗██╗ ██╗ +-- ████╗ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔════╝ ██╔════╝██║ ██║ +-- ██╔██╗ ██║██║ ██║███████║███████║██████╔╝██║ ██║██╔████╔██║██████╔╝███████║███████╗ ██║ ███████║ +-- ██║╚██╗██║██║ ██║██╔══██║██╔══██║██╔═══╝ ██║ ██║██║╚██╔╝██║██╔══██╗██╔══██║╚════██║ ██║ ██╔══██║ +-- ██║ ╚████║╚██████╔╝██║ ██║██║ ██║██║ ╚██████╔╝██║ ╚═╝ ██║██████╔╝██║ ██║███████║ ██╗ ╚██████╗██║ ██║ +-- ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ +Pombas = {} + +Pombas.legacy = true -- true = legacy ||| false = esx +Pombas.delay = 5, -- command cooldown in minutes +Pombas.car = "taxi", -- Car Model +Pombas.driverModel = "s_m_m_movprem_01", -- Driver Model | https://docs.fivem.net/docs/game-references/ped-models/ +Pombas.price = 0.2, -- Price per Meter +Pombas.minBalance = 50 -- Minimum Balance to call a Taxi +-- Made with ❤️ by noahpombas.ch \ No newline at end of file diff --git a/pTaxi/esx/fxmanifest.lua b/pTaxi/esx/fxmanifest.lua new file mode 100644 index 0000000..f0188f4 --- /dev/null +++ b/pTaxi/esx/fxmanifest.lua @@ -0,0 +1,23 @@ +-- Made with ❤️ by noahpombas.ch +fx_version 'cerulean' +game 'gta5' + +author 'noahpombas.ch' +description 'pTaxi, made with ❤️ by noahpombas.ch' +version '1.0.0' + +client_scripts { + 'client.lua', +} + +server_scripts { + '@es_extended/locale.lua', + 'server.lua' +} + +shared_script 'config.lua' + +dependencies { + 'es_extended' +} +-- Made with ❤️ by noahpombas.ch \ No newline at end of file diff --git a/pTaxi/esx/pTaxi-esx.zip b/pTaxi/esx/pTaxi-esx.zip new file mode 100644 index 0000000..637c421 Binary files /dev/null and b/pTaxi/esx/pTaxi-esx.zip differ diff --git a/pTaxi/esx/server.lua b/pTaxi/esx/server.lua new file mode 100644 index 0000000..ed56cf1 --- /dev/null +++ b/pTaxi/esx/server.lua @@ -0,0 +1,28 @@ +-- Made with ❤️ by noahpombas.ch +ESX = exports["es_extended"]:getSharedObject() + +RegisterServerEvent("taxi:verificarSaldo") +AddEventHandler("taxi:verificarSaldo", function() + local xPlayer = ESX.GetPlayerFromId(source) + local saldo = xPlayer.getAccount('bank').money + + if saldo >= Pombas.minBalance then + TriggerClientEvent("taxi:saldoVerificado", source, true) + else + TriggerClientEvent("taxi:saldoVerificado", source, false) + end +end) + +RegisterServerEvent("taxi:chargeFullPrice") +AddEventHandler("taxi:chargeFullPrice", function(preco) + local _source = source + local xPlayer = ESX.GetPlayerFromId(_source) + + if xPlayer.getAccount('bank').money >= preco then + xPlayer.removeAccountMoney('bank', preco) + TriggerClientEvent('esx:showNotification', _source, "Você foi cobrado pelo valor total da viagem: $" .. preco) + else + TriggerClientEvent('esx:showNotification', _source, "Você não tem dinheiro suficiente para pagar a viagem!") + end +end) +-- Made with ❤️ by noahpombas.ch \ No newline at end of file diff --git a/pTaxi/qbcore/client.lua b/pTaxi/qbcore/client.lua new file mode 100644 index 0000000..df76e79 --- /dev/null +++ b/pTaxi/qbcore/client.lua @@ -0,0 +1,208 @@ +-- Made with ❤️ by noahpombas.ch +local QBCore = exports['qb-core']:GetCoreObject() + +local lastTaxiCallTime = nil +local cooldownTime = Pombas.delay * 60 + +-- Command to call a taxi +RegisterCommand("chamarTaxi", function() + local currentTime = GetGameTimer() / 1000 + if lastTaxiCallTime and (currentTime - lastTaxiCallTime < cooldownTime) then + local remainingTime = cooldownTime - (currentTime - lastTaxiCallTime) + QBCore.Functions.Notify("Espere " .. math.floor(remainingTime / 60) .. " minutos para chamar outro táxi.", "error") + return + end + + lastTaxiCallTime = currentTime + TriggerServerEvent("taxi:verificarSaldo") +end) + +-- Handle balance verification +RegisterNetEvent("taxi:saldoVerificado") +AddEventHandler("taxi:saldoVerificado", function(hasBalance) + if not hasBalance then + QBCore.Functions.Notify("Você não tem dinheiro suficiente no banco.", "error") + return + end + + -- Spawn taxi and driver + local ped = PlayerPedId() + local coords = GetEntityCoords(ped) + local taxiModel = GetHashKey(Pombas.car) + local driverModel = GetHashKey(Pombas.driverModel) + + RequestModel(taxiModel) + RequestModel(driverModel) + while not HasModelLoaded(taxiModel) or not HasModelLoaded(driverModel) do + Wait(500) + end + + + local foundRoad, outPos1, outPos2 = GetClosestRoad(coords.x, coords.y, coords.z, 1.0, 1, false) + local spawnCoords = vector3(0.0, 0.0, 0.0) + + if foundRoad then + spawnCoords = (outPos1 + outPos2) / 2 + else + + spawnCoords = vector3(coords.x + 10, coords.y + 10, coords.z) + end + + local taxi = CreateVehicle(taxiModel, spawnCoords.x, spawnCoords.y, spawnCoords.z, GetEntityHeading(ped), true, false) + TriggerEvent('fuel:setFuel', taxi, 100.0) + + SetEntityAsMissionEntity(taxi, true, true) + SetVehicleHasBeenOwnedByPlayer(taxi, true) + SetVehicleDoorsLocked(taxi, 1) + SetVehicleDoorsLockedForAllPlayers(taxi, false) + TriggerEvent('vehiclekeys:client:SetOwner', GetVehicleNumberPlateText(taxi)) + + local driver = CreatePedInsideVehicle(taxi, 26, driverModel, -1, true, false) + SetBlockingOfNonTemporaryEvents(driver, true) + SetPedCanBeDraggedOut(driver, false) + SetDriverAbility(driver, 1.0) + SetDriverAggressiveness(driver, 0.0) + SetEntityInvincible(taxi, true) + SetEntityInvincible(driver, true) + SetEntityAsMissionEntity(driver, true, true) + SetPedCombatAttributes(driver, 46, true) + SetPedFleeAttributes(driver, 0, false) + SetBlockingOfNonTemporaryEvents(driver, true) + + + TaskVehicleDriveToCoord(driver, taxi, spawnCoords.x, spawnCoords.y, spawnCoords.z, 5000.0, 0, GetEntityModel(taxi), 786603, 1.0, true) + + -- Taxi Blip + local taxiBlip = AddBlipForEntity(taxi) + SetBlipSprite(taxiBlip, 198) + SetBlipColour(taxiBlip, 46) + SetBlipScale(taxiBlip, 1.0) + + -- wait player to enter taxi + local playerEntered = false + while not playerEntered do + local taxiCoords = GetEntityCoords(taxi) + local pedCoords = GetEntityCoords(ped) + + if #(pedCoords - taxiCoords) < 10.0 then + Wait(500) + TaskEnterVehicle(ped, taxi, -1, 1, 1.0, 1, 0) + playerEntered = true + end + Wait(500) + end + + + QBCore.Functions.Notify("Por favor, marque um destino no mapa!.", "warning") + + local destinoMarcado = false + local waypointCoords = nil + + while not destinoMarcado do + local isPassenger = GetPedInVehicleSeat(taxi, 1) + local waypointBlip = GetFirstBlipInfoId(8) -- 8 é o ID de waypoint + if DoesBlipExist(waypointBlip) then + print(isPassenger) + if isPassenger ~= 0 then + waypointCoords = GetBlipInfoIdCoord(waypointBlip) + destinoMarcado = true + end + end + Wait(500) + end + + local playerInside = false + + while not playerInside do + local pedCoords = GetEntityCoords(ped) + local taxiCoords = GetEntityCoords(taxi) + + if IsPedInVehicle(ped, taxi, false) then + playerInside = true + else + if #(pedCoords - taxiCoords) < 10.0 then + TaskEnterVehicle(ped, taxi, -1, 1, 1.0, 1, 0) + else + + QBCore.Functions.Notify("Aproxime-se do táxi para entrar!", "info") + Wait(1000) + end + end + + Wait(500) + end + + local foundRoad, outPos1, outPos2 = GetClosestRoad(waypointCoords.x, waypointCoords.y, waypointCoords.z, 1.0, 1, false) + if foundRoad then + spawnCoords = (outPos1 + outPos2) / 2 + else + spawnCoords = vector3(waypointCoords.x, waypointCoords.y, waypointCoords.z) + end + + -- create new Blip named Destination + local destinoBlip = AddBlipForCoord(spawnCoords.x, spawnCoords.y, spawnCoords.z) + SetBlipSprite(destinoBlip, 1) -- Ícone simples + SetBlipColour(destinoBlip, 5) -- Cor amarela + SetBlipScale(destinoBlip, 1.0) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString("Destination") + EndTextCommandSetBlipName(destinoBlip) + + -- calculate price in base of the distance + local playerCoords = GetEntityCoords(PlayerPedId()) + local distancia = #(playerCoords - spawnCoords) + local preco = math.floor(distancia * Pombas.price) + + QBCore.Functions.Notify("Destination marked! Estimated Price: $" .. preco, "error") + + + -- taxi drives to destination + TaskVehicleDriveToCoord(driver, taxi, spawnCoords.x, spawnCoords.y, spawnCoords.z, 5000.0, 0, GetEntityModel(taxi), 2883621, 1.0, true) + + local playerExited = 0 + local arrivedAtDestination = false + + + Citizen.CreateThread(function() + while DoesEntityExist(driver) do + if not IsPedInVehicle(driver, taxi, true) then + ClearPedTasks(driver) + end + Wait(500) + end + end) + + while true do + local playerCoords = GetEntityCoords(PlayerPedId()) + local distancia = #(playerCoords - spawnCoords) + local isPassenger = GetPedInVehicleSeat(taxi, 1) + + + if isPassenger == 0 then + if playerExited == 0 then + playerExited = 1 + QBCore.Functions.Notify("Destino cancelado!.", "error") + TriggerServerEvent("taxi:charge", preco) + Wait(3000) + DeleteVehicle(taxi) + DeletePed(driver) + RemoveBlip(destinoBlip) + end + end + + if distancia < 10.0 and not arrivedAtDestination then + arrivedAtDestination = true + playerExited = 1 + QBCore.Functions.Notify("Chegou ao seu Destino!", "error") + TriggerServerEvent("taxi:charge", preco) + TaskLeaveVehicle(PlayerPedId(), taxi, 0) + Wait(3000) + DeleteVehicle(taxi) + DeletePed(driver) + RemoveBlip(destinoBlip) + end + + Wait(1000) +end +end) +-- Made with ❤️ by noahpombas.ch \ No newline at end of file diff --git a/pTaxi/qbcore/config.lua b/pTaxi/qbcore/config.lua new file mode 100644 index 0000000..776899a --- /dev/null +++ b/pTaxi/qbcore/config.lua @@ -0,0 +1,16 @@ +-- ███╗ ██╗ ██████╗ █████╗ ██╗ ██╗██████╗ ██████╗ ███╗ ███╗██████╗ █████╗ ███████╗ ██████╗██╗ ██╗ +-- ████╗ ██║██╔═══██╗██╔══██╗██║ ██║██╔══██╗██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔════╝ ██╔════╝██║ ██║ +-- ██╔██╗ ██║██║ ██║███████║███████║██████╔╝██║ ██║██╔████╔██║██████╔╝███████║███████╗ ██║ ███████║ +-- ██║╚██╗██║██║ ██║██╔══██║██╔══██║██╔═══╝ ██║ ██║██║╚██╔╝██║██╔══██╗██╔══██║╚════██║ ██║ ██╔══██║ +-- ██║ ╚████║╚██████╔╝██║ ██║██║ ██║██║ ╚██████╔╝██║ ╚═╝ ██║██████╔╝██║ ██║███████║ ██╗ ╚██████╗██║ ██║ +-- ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ + + +Pombas = { + car = "taxi", -- Car Model + driverModel = "s_m_m_movprem_01", -- Driver Model | https://docs.fivem.net/docs/game-references/ped-models/ + price = 0.2, -- Price per Meter + delay = 5, -- command cooldown in minutes + minBalance = 50 -- Minimum Balance to call a Taxi +} +-- Made with ❤️ by noahpombas.ch \ No newline at end of file diff --git a/pTaxi/qbcore/fxmanifest.lua b/pTaxi/qbcore/fxmanifest.lua new file mode 100644 index 0000000..d333520 --- /dev/null +++ b/pTaxi/qbcore/fxmanifest.lua @@ -0,0 +1,22 @@ +-- Made with ❤️ by noahpombas.ch +fx_version 'cerulean' +game 'gta5' + +author 'noahpombas.ch' +description 'pTaxi, made with ❤️ by noahpombas.ch' +version '1.0.0' + +client_scripts { + 'client.lua', +} + +server_scripts { + 'server.lua', +} + +shared_script 'config.lua' + +dependencies { + 'qb-core', +} +-- Made with ❤️ by noahpombas.ch \ No newline at end of file diff --git a/pTaxi/qbcore/pTaxi-qbcore.zip b/pTaxi/qbcore/pTaxi-qbcore.zip new file mode 100644 index 0000000..34abd4c Binary files /dev/null and b/pTaxi/qbcore/pTaxi-qbcore.zip differ diff --git a/pTaxi/qbcore/server.lua b/pTaxi/qbcore/server.lua new file mode 100644 index 0000000..393921d --- /dev/null +++ b/pTaxi/qbcore/server.lua @@ -0,0 +1,22 @@ +-- Made with ❤️ by noahpombas.ch +local QBCore = exports['qb-core']:GetCoreObject() + +RegisterNetEvent("taxi:verificarSaldo") +AddEventHandler("taxi:verificarSaldo", function() + local src = source + local Player = QBCore.Functions.GetPlayer(src) + if Player.Functions.GetMoney("bank") >= Pombas.minBalance then + TriggerClientEvent("taxi:saldoVerificado", src, true) + else + TriggerClientEvent("taxi:saldoVerificado", src, false) + end +end) + +RegisterNetEvent("taxi:charge") +AddEventHandler("taxi:charge", function(amount) + local src = source + local Player = QBCore.Functions.GetPlayer(src) + Player.Functions.RemoveMoney("bank", amount, "Pagamento do Taxi") +end) + +-- Made with ❤️ by noahpombas.ch \ No newline at end of file