Skip to content

Commit

Permalink
Update v1.0.1
Browse files Browse the repository at this point in the history
* Fixed Error: GetPedVehicleSeat
* Added missing Translation
  • Loading branch information
Musiker15 committed Aug 10, 2024
1 parent 8207dbb commit b6dc152
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
67 changes: 37 additions & 30 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ getVehNodeType = function(coords)
end

callTaxi = function()
if not canCallTaxi then return end
local npcId, vehId = math.random(#Config.Taxi.pedmodels), math.random(#Config.Taxi.vehicles)
local npc, veh = Config.Taxi.pedmodels[npcId], Config.Taxi.vehicles[vehId]
taskDriverName = npc.name or 'Alex'
Expand All @@ -49,15 +50,15 @@ callTaxi = function()
local vehicleSpawned = spawnVehicle(driverHash, vehHash)

if not vehicleSpawned then
advancedNotification(Translation[Config.Locale]['not_available'], 'Downtown Cab Co.', 'Taxi', 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['not_available'], 'Downtown Cab Co.', 'Taxi', 'CHAR_TAXI')
return
end

local toCoords = getStoppingLocation(playerCoords)
local speed = (Config.SpeedZones[getVehNodeType(toCoords)] or 60) / Config.SpeedType
TaskVehicleDriveToCoordLongrange(taskNPC, taskVehicle, toCoords.x, toCoords.y, toCoords.z, speed, Config.DrivingStyle, 5.0)
SetPedKeepTask(taskNPC, true)
advancedNotification(Translation[Config.Locale]['on_the_way'], 'Downtown Cab Co.', 'Taxi', 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['on_the_way'], 'Downtown Cab Co.', 'Taxi', 'CHAR_TAXI')
taxiOnRoad = true
end
exports('callTaxi', callTaxi)
Expand Down Expand Up @@ -106,7 +107,7 @@ startDriveToCoords = function(waypoint)

if distance < 10.0 then
PlayPedAmbientSpeechNative(taskNPC, "TAXID_CLOSE_AS_POSS", "SPEECH_PARAMS_FORCE_NORMAL")
advancedNotification(Translation[Config.Locale]['end'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['end'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
TriggerServerEvent('msk_aitaxi:payTaxiPrice', math.ceil(Config.Price.base + (Config.Price.tick * ((GetGameTimer() - taskStartTime) / Config.Price.tickTime))))
taxiDriveFinished = true
break
Expand All @@ -132,19 +133,19 @@ abortTaxiDrive = function(keyPressed)
taxiDriveCancelled = true

if not taxiInDriveMode then
advancedNotification(Translation[Config.Locale]['abort'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['abort'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
leaveTarget()
return
end

if not taxiDriveFinished and not keyPressed then
advancedNotification(Translation[Config.Locale]['abort'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['abort'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
leaveTarget()
return
end

if not taxiDriveFinished and keyPressed then
advancedNotification(Translation[Config.Locale]['abort'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['abort'], 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
TaskVehicleTempAction(taskNPC, taskVehicle, 27, 1000)
end

Expand Down Expand Up @@ -215,7 +216,7 @@ enteredVehicle = function(vehicle, plate, seat)
SetVehicleDoorsShut(vehicle, false)
SetPedIntoVehicle(PlayerPedId(), taskVehicle, seat)
PlayPedAmbientSpeechNative(taskNPC, "TAXID_WHERE_TO", "SPEECH_PARAMS_FORCE_NORMAL")
advancedNotification(Translation[Config.Locale]['welcome']:format(taskDriverName), 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')
AdvancedNotification(Translation[Config.Locale]['welcome']:format(taskDriverName), 'Downtown Cab Co.', taskDriverName, 'CHAR_TAXI')

while taxiOnRoad and not IsWaypointActive() do
Wait(1000)
Expand Down Expand Up @@ -312,34 +313,13 @@ CreateThread(function()
if taxiOnRoad and taskVehicle and taxiInDriveMode and taskStartPosition and not taxiDriveCancelled and not taxiDriveFinished then
sleep = 1
HelpNotification(Translation[Config.Locale]['input']:format(Config.AbortTaxiDrive.hotkey))
local distance = #(taskStartPosition - GetEntityCoords(taskVehicle))
DrawGenericText(('Price: $%s'):format(comma(math.ceil(Config.Price.base + (Config.Price.tick * ((GetGameTimer() - taskStartTime) / Config.Price.tickTime))))))
DrawGenericText(Translation[Config.Locale]['price']:format(comma(math.ceil(Config.Price.base + (Config.Price.tick * ((GetGameTimer() - taskStartTime) / Config.Price.tickTime))))))
end

Wait(sleep)
end
end)

HelpNotification = function(text)
BeginTextCommandDisplayHelp('STRING')
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayHelp(0, false, true, -1)
end

DrawGenericText = function(text)
SetTextColour(Config.Price.color.r, Config.Price.color.g, Config.Price.color.b, Config.Price.color.a)
SetTextFont(0)
SetTextScale(0.30, 0.30)
SetTextWrap(0.0, 1.0)
SetTextCentre(true)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 205)
SetTextOutline()
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayText(Config.Price.position.width, Config.Price.position.height)
end

loadModel = function(modelHash)
if not HasModelLoaded(modelHash) then
RequestModel(modelHash)
Expand Down Expand Up @@ -368,6 +348,13 @@ GetAvailableParkingSpots = function()
end
end

GetPedVehicleSeat = function(ped, vehicle)
for i = -1, 16 do
if (GetPedInVehicleSeat(vehicle, i) == ped) then return i end
end
return -1
end

round = function(num, decimal)
return tonumber(string.format("%." .. (decimal or 0) .. "f", num))
end
Expand All @@ -387,7 +374,27 @@ comma = function(int, tag)
return newInt
end

advancedNotification = function(text, title, subtitle, icon, flash, icontype)
HelpNotification = function(text)
BeginTextCommandDisplayHelp('STRING')
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayHelp(0, false, true, -1)
end

DrawGenericText = function(text)
SetTextColour(Config.Price.color.r, Config.Price.color.g, Config.Price.color.b, Config.Price.color.a)
SetTextFont(0)
SetTextScale(0.30, 0.30)
SetTextWrap(0.0, 1.0)
SetTextCentre(true)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 205)
SetTextOutline()
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayText(Config.Price.position.width, Config.Price.position.height)
end

AdvancedNotification = function(text, title, subtitle, icon, flash, icontype)
if not flash then flash = true end
if not icontype then icontype = 1 end
if not icon then icon = 'CHAR_TAXI' end
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_aitaxi'
description 'AI Taxi NPC'
version '1.0.0'
version '1.0.1'

lua54 'yes'

Expand Down
2 changes: 2 additions & 0 deletions translation.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Translation = {
['de'] = {
['input'] = 'Drücke ~r~X~s~ um die Fahrt zu stoppen',
['price'] = 'Aktueller Preis: $%s',
['paid'] = 'Du hast $%s bezahlt',
['not_available'] = 'Es ist gerade kein Fahrer verfügbar, bitte versuche es erneut!',
['on_the_way'] = 'Ein Fahrer ist unterwegs zu dir.',
Expand All @@ -10,6 +11,7 @@ Translation = {
},
['en'] = {
['input'] = 'Press ~r~X~s~ to abort the taxi drive',
['price'] = 'Current Price: $%s',
['paid'] = 'You paid $%s',
['not_available'] = 'Currently is no driver available, please call us again!',
['on_the_way'] = 'The Driver is on the way.',
Expand Down

0 comments on commit b6dc152

Please sign in to comment.