I try to create a weapon shop but i have a error in my code…
I have make a BLIP and a marker but he doesnt work
Where are my error pls ?
and i dont have error in console…
local trainer = {
marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
local trainer_locations = {
{entering = {17.540010452271,-1114.6591796875,29.80933380127}, inside = {22.290538787842,-1107.3607177734,29.797027587891}, outside = {-31.849,-1090.648,25.998,322.345}},
}
local showtrainer = false
local trainer_blips ={}
function ShowTrainerBlips(bool)
if bool and #trainer_blips == 0 then
for station,pos in pairs(trainer_locations) do
local loc = pos
pos = pos.entering
local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
-- 60 58 137
SetBlipSprite(blip,110)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Vendeur d'Armes")
EndTextCommandSetBlipName(blip)
SetBlipAsShortRange(blip,true)
SetBlipAsMissionCreatorBlip(blip,true)
table.insert(trainer_blips, {blip = blip, pos = loc})
end
Citizen.CreateThread(function()
while #trainer_blips > 0 do
Citizen.Wait(0)
for i,b in ipairs(trainer_blips) do
if IsPlayerWantedLevelGreater(GetPlayerIndex(),0) == false and IsPedInAnyVehicle(LocalPed(), true) == false and GetDistanceBetweenCoords(b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],GetEntityCoords(LocalPed())) < 5 then
DrawMarker(1,b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
drawTxt('Appuie sur ~g~ENTRER~s~ pour acheter un ~b~véhicule',0,1,0.5,0.8,0.6,255,255,255,255)
if not showtrainer then
showtrainer = true
SendNUIMessage({
showtrainer = true
})
else
showtrainer = false
SendNUIMessage({
hidetrainer = true
})
end
end
end
end)
end)
--[[if IsControlJustReleased(1, 167) and not blockinput then -- f6
if not showtrainer then
showtrainer = true
SendNUIMessage({
showtrainer = true
})
else
showtrainer = false
SendNUIMessage({
hidetrainer = true
})
end
end]]
if showtrainer and not blockinput then
if IsControlJustReleased(1, 176) then -- enter
SendNUIMessage({
trainerenter = true
})
elseif IsControlJustReleased(1, 177) then -- back / right click
SendNUIMessage({
trainerback = true
})
end
if IsControlJustReleased(1, 172) then -- up
SendNUIMessage({
trainerup = true
})
elseif IsControlJustReleased(1, 173) then -- down
SendNUIMessage({
trainerdown = true
})
end
if IsControlJustReleased(1, 174) then -- left
SendNUIMessage({
trainerleft = true
})
elseif IsControlJustReleased(1, 175) then -- right
SendNUIMessage({
trainerright = true
})
end
end
end
end)
RegisterNUICallback("playsound", function(data, cb)
PlaySoundFrontend(-1, data.name, "HUD_FRONTEND_DEFAULT_SOUNDSET", true)
cb("ok")
end)
RegisterNUICallback("trainerclose", function(data, cb)
showtrainer = false
cb("ok")
end)
function drawNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
end)