yea send me that ice always like to check out other codes
Its a bit messy, but it should work xD, in one hour ill be at the pc so i can send you it
oo ill not use it but ill read code best way to learn
@wpgn Here’s an example on getting the taxi meters working and some audio stuff.
https://github.com/throwarray/gtav-rendertarget/tree/master/taxihud
https://pastebin.com/kg684cRz
ok cheers ill take a look
-- variables --
ambulance=GetHashKey('ambulance')
paramedic=GetHashKey("S_M_M_Paramedic_01")
nearesthospital=nil
-- spawning events --
RegisterNetEvent('EMS:Spawn')
RegisterNetEvent('Coroner:Spawn')
-- report progress events --
RegisterNetEvent('EMS:Half')
RegisterNetEvent('Coroner:Half')
RegisterNetEvent('EMS:Arrived')
RegisterNetEvent('Coroner:Arrived')
-- spawning events handlers --
AddEventHandler('EMS:Spawn', function(target)
Citizen.CreateThread(function()
local pc = GetEntityCoords(target)
RequestModel(ambulance)
RequestModel(paramedic)
while not HasModelLoaded(ambulance) and RequestModel(paramedic) do
RequestModel(ambulance)
RequestModel(paramedic)
Citizen.Wait(0)
end
local offset=GetOffsetFromEntityInWorldCoords(PlayerPedId(), 50, 50, 0)
local heading, spawn = GetNthClosestVehicleNodeFavourDirection(offset.x, offset.y, offset.z, pc.x, pc.y, pc.z, 50, 1, 0x40400000, 0)
print('spawn point found!')
local vehicle = CreateVehicle(ambulance, spawn.x, spawn.y, spawn.z, heading, true, false)
created_ped = CreatePed(5, paramedic , spawn.x +2 , spawn.y+ 2, spawn.z+1, heading, true, true)
SetEntityAsMissionEntity(created_ped, false, false)
SetEntityAsMissionEntity(vehicle, false, false)
AddBlipForEntity(created_ped)
SetVehicleSiren(vehicle, true)
LoadAllPathNodes(true)
while not AreAllNavmeshRegionsLoaded() do
Wait(1)
end
TaskEnterVehicle(created_ped, vehicle, 1000, -1, 20, 1, 0)
while GetIsTaskActive(created_ped, 160) do
Wait(1)
end
TaskVehicleDriveToCoordLongrange(created_ped, vehicle, pc.x, pc.y, pc.z, 15.0, 1074004284, 2.0)
local arrived = false
while not arrived do
Citizen.Wait(0)
local coords = GetEntityCoords(created_ped, true)
local distance=Vdist(coords.x, coords.y, coords.z, pc.x, pc.y, pc.z)
if distance < 25.0 then
break
end
end
print('arrived')
local pheading, parking = GetNthClosestVehicleNodeFavourDirection(pc.x, pc.y, pc.z, pc.x, pc.y, pc.z, 10, 1, 0x40400000, 0)
TaskVehiclePark(created_ped, vehicle, parking.x, parking.y, parking.z, pheading, 1, 60.0, 1)
while GetEntitySpeed(vehicle)>0 do
Wait(1)
end
ClearPedTasks(created_ped)
TaskLeaveVehicle(created_ped, vehicle, 0)
while IsPedInAnyVehicle(created_ped, false) do
Wait(1)
end
print('exited veh')
ClearPedTasks(created_ped)
TaskGoToEntity(created_ped, target, -1, 4.0, 100, 1073741824, 0)
while not arrived do
Citizen.Wait(0)
local coords = GetEntityCoords(created_ped, true)
local distance=Vdist(coords.x, coords.y, coords.z, pc.x, pc.y, pc.z)
if distance < 2.0 then
print('arrived to target... kneeling...')
break
end
end
TaskStartScenarioInPlace(created_ped, 'CODE_HUMAN_MEDIC_KNEEL', 0, true)
while IsPedActiveInScenario(created_ped) do
Wait(1)
end
print("we're done here!")
end)
end)
-- command --
RegisterCommand("ems", function()
local target = GetClosestSuitablePed()
if target~=nil then
TriggerEvent('EMS:Spawn', target)
else
print('no peds found :^/')
end
end, false)
-- useful functions --
function table_to_string(tbl)
local result = "{"
for k, v in pairs(tbl) do
-- Check the key type (ignore any numerical keys - assume its an array)
if type(k) == "string" then
result = result.."[\""..k.."\"]".."="
end
-- Check the value type
if type(v) == "table" then
result = result..table_to_string(v)
elseif type(v) == "boolean" then
result = result..tostring(v)
else
result = result.."\""..v.."\""
end
result = result..","
end
-- Remove leading commas from the result
if result ~= "" then
result = result:sub(1, result:len()-1)
end
return result.."}"
end
function GetPositionInfrontOfEntity(ped, scalar)
target= nil
entity = GetEntity(ped)
right, forward, up, pos = GetEntityMatrix(entity)
return pos + forward * scalar
end
function GetClosestSuitablePed()
local handle, p = FindFirstPed()
local success
target=nil
repeat
success, p = FindNextPed(handle)
local pos = GetEntityCoords(p)
local distance = Vdist(pos.x, pos.y, pos.z, GetEntityCoords(PlayerPedId(), true).x, GetEntityCoords(PlayerPedId(), true).y, GetEntityCoords(PlayerPedId(), true).z)
if distance <= 4 and p ~= GetPlayerPed(-1) then
target=p
break
end
until not success
return target
end
it’s a client_script obviously. it’s also incomplete xD
oh yeah, i forgot to mention some people who helped me
@Syntasu for the GetPositionInfrontOfEntity function
@d0p3t for the GetClosestSuitablePed function
More audio stuff mostly…
-- Driver
model = GetHashKey("a_m_y_stlat_01");
voice = "A_M_M_EASTSA_02_LATINO_FULL_01"
vehicle = -- ...
driver = -- ...
dest = -- ...
dist = CalculateTravelDistanceBetweenPoints(GetEntityCoords(GetPlayerPed(-1), dest))
-- AUDIO
SetAmbientVoiceName(driver, voice)
Talk(driver, "TAXID_WHERE_TO", 7)
"TAXID_WHERE_TO" -- 7 or "SPEECH_PARAMS_FORCE_NORMAL_CLEAR"
"TAXID_BEGIN_JOURNEY" -- 7
"TAXID_BANTER" -- 24 or "SPEECH_PARAMS_ADD_BLIP"
"TAXID_ARRIVE_AT_DEST" -- 7
"TAXID_CLOSE_AS_POSS" -- 7
"TAXID_NO_MONEY" -- 7
"TAXID_CHANGE_DEST" -- 7
"TAXID_RUN_AWAY" -- 7
"TAXID_GET_OUT_EARLY" -- 7
"TAXID_TRASHED" -- 7
"TAXID_AFFORD_PART_JOURNEY" -- 7
"TAXID_TAKE_FIRST_CAB" -- 7
"TAXID_SPEED_UP" -- 7
-- Passenger
-- RADIO
if not IsAmbientSpeechPlaying(GetPlayerPed(-1)) then
Talk(GetPlayerPed(-1), RadioIndexAudioString(GetPlayerRadioStationIndex()), "SPEECH_PARAMS_FORCE_NORMAL_CLEAR")
SetVehicleRadioEnabled(vehicle, true)
end
-- AUDIO
"TAXI_CHANGE_DEST" -- 7
"TAXI_STEP_ON_IT" -- 7
"THANKS" -- 7
Can we get this on a GitHub Repo so we can contribute
@LGDevelopment It was what I’ve planned for this script.
@wpgn worked on it and did a basic version. He requested to not share it until it’s stable. He is the creator of this script so, let’s see with him.
yea ill have a new version soon any feed back TomTom?
I’ve tryed it, and even if its a basic version, the biggest part of the job is done. It totally correspond to the idea I had.
Suggestion that you could take into account if you have some free time:
- When you get inside the taxi
- place marker
- presse E to go there
-
- Add delay (wait(10000)) to let the time to passengers to get in.
If passengers enters before triggering E, the script bug.
- Add delay (wait(10000)) to let the time to passengers to get in.
-When the taxi arrive at the location
- Difficulties to find the nearest position
- Dont really stop
-
- Add a delay (wait(10000)) to let the time to passengers to exit the taxi
-When the taxi leaves
- He can do circles around your destination marker
-
- make him drives to one direction and desappears after 10 secondes even if he is visible by all.
The script is fonctionnal for me (basic version) but most of users will complains about bugs if they aren’t able to fix it by themself.
@wpgn You are the owner so you have to take the decision between sharing it in this state, sharing it as a github project or continue to work on it or something else
nice feedback my friend i will sort some of this in next build
@wpgn Would you be willing to share the script early? Been working on my own and would love to compare. Otherwise I’ll wait until it’s on GitHub and contribute
script is still being worked one once i have a working version i will share it there no point doing a github with code that dont work as I learn that most fivem people are lazy and dont want to code anything them selfs and will complain if it dont work out of the box so waiting till it works is best option then people can just add to it when needed.
@ghosty From where did you find this ? Never saw it before… By the way, thank you for re-sharing this resourse to all.
@wpgn, Seems that we didn’t find it. What will you do, optimize it or stopping dev ?
oo nice ill keep working on mine but that resource may come in handy, this seams a new upload so its taken ideas from the post and thats a good thing
@Tomtom the script was actually planned a while ago for fs_freemode, but for some unknown reason it is released as a standalone resource.
@wpgn since you already admit that the resource could become handy for your own resource, why don’t you just contribute to the project?
instead of trying to reinventing the wheel.
No offense and i am not trying to be rude, but what is the point for having multiple resources for the same result if you can put all the features into one?
I like to write my own scripts when i say the resource may come in handy that is for my personal reference this does not mean I will use any of the code in my own product normally building code on top of other projects codes can lead to bugs and issues, it is better practice and much more cleaner to write your own scripts from ground up.
Hey man did you ever end up finishing the Ambulance script? Im super keen to put it in to my server. Im happy to help out testing etc