Hi, i’ve a blank server with no mods and i i’ve created this client.lua :
Citizen.CreateThread(function()
local blip = AddBlipForCoord(-45.228, -1083.123, 25.816)
SetBlipSprite(blip,225)
SetBlipColour(blip, 3)
local modelName = "t20" --Name of model, can find all model names of vehicles on the wiki
local vehicleHash = GetHashKey(modelName) --Get the hash so we can pass it to CreateVehicle as it requires the hash
--A loop to make sure the model gets loaded properly
while (not HasModelLoaded(vehicleHash)) do
RequestModel(vehicleHash)
Citizen.Wait(0)
end
local rotation = 75.01 --Rotation/heading
local vehicle = CreateVehicle(vehicleHash, -45.228, -1083.123, 25.816, rotation, true, true) --Create the vehicle.
if GetDistanceBetweenCoords(-45.228,-1083.123,25.816,GetEntityCoords(LocalPed())) < 5 then
drawTxt('Vendez ce vehicule',0,1,0.5,0.8,0.6,255,255,255,255)
RemoveBlip(blip)
blip = AddBlipForCoord(5.228, -1083.123, 25.816)
SetBlipSprite(blip,290)
SetBlipColour(blip, 3)
end
end)
On the start, i’ve the blip on the map and the “t20” car is here. But normaly, when i’m near the car, there is a message and the blip is destroyed and a new blip must appear. But it don’t detect me : any idea ?
GetDistanceBetweenCoords() accepts coordinates in X1, Y1, Z1, X2, Y2, Z2 format. You need local coords = GetEntityCoords(LocalPed()) GetDistanceBetweenCoords(-45.228,-1083.123,25.816,coords.x,coords.y,coords.z))
Hello, ok i’m near to resolve that : Getdistance work fine now but drawtxt was on global NIL error. I though it was a native fonction but i saw that it needeed to be declared so i wrote this function found on another source :
function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
SetTextFont(font)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextCentre(centre)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x , y)
end
Now i’ve a NIL global error with SetTextEntry. But the source have not declared this function. How do i declare it please ?
Is my problem is because i don’t use essetialmode and i’ve no essetial declarations ?