Problem with my BLIP/MENU for Weapon Shop

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 :confused:

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)
1 Like

I’m currently working an a server side weaponstore that will work with essential mode (So save weapon and give them to the player when they log back in.)
I will try the same with vehicule mods, but that will be a lot trickier.

But there is something wrong here :

Citizen.CreateThread(function()
	while true do
		Wait(1)
--Missing some end I guess
function ShowTrainerBlips(bool)
1 Like

thx ^^ i try this :wink: u send me the serverside/SQL when u have finish ?? :stuck_out_tongue: and dont miss the weapon remove when the player died

I have remove the " while true do
Wait(1)" but the blip/marker doesnt work anyone… :confused:

I realase the Weapon Shop when i have found the error… pls help me dude :’(

I don’t see any menu… Are you using a trainer or some kind ?
Like I said, you have something wrong going in

Citizen.CreateThread(function()
	while true do
		Wait(1)
--Missing some end I guess
function ShowTrainerBlips(bool)

It is best to put the function out of the CreateThread() thingy

Yes a trainer in HTML the file with the blip/marker is only for launch the menu

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


Citizen.CreateThread(function()
				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 une ~b~arme',0,1,0.5,0.8,0.6,255,255,255,255) then
			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)

I have make this but anyone… i dont see the blip and the marker… :confused:

Ow i’m sorry… I don’t have any experience with trainers.
I try to avoid as many as possible. That is why I make the weapon shop server side. More work, but more control over what happens :slight_smile:

1 Like

I just need help for make a blip and a marker :confused:

Salut,
Je ne sais pas si ça peut t’aider mais j’ai trouvé ça :
https://github.com/FiveM-Scripts/es_freeroam/blob/master/player/map.lua

je sais mettre un blip mais celui que je met moi il est intéractive… en gros il affiche un marker, un petit point ou quand tu va dessus bhé ca ffiche le menu…

I guess that the drawMarker works already ?
If that is the case, then you need to check in the while if the distance between the player’s position and the marker is lower than say 1.5, then you open the menu.

Example :

if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), x,y,z, true) < 500 then
						DrawMarker(1,x,y,z-1.0001, 0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
 -- This will show the marker when the player is in range. distance '500' can be a local value.
						if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), x,y,z, true) < 1.599 then
--Open menu here
end
end

(Trust me it works fine for me using it as a teleport into apartments.)

English please? this is a english forum and this is not the first time we asked you to keep it english.

The marker doesnt work… :confused:

If he talk in French (my language) I will not reply in English… It just the logic

I’m french too and i want to make a server can you help me. I have teamspeak and discord if you want to talk about server.

Ohhh good dude u have speak English xDD

Seriously man, have you got discord or teamspeak ?

ts.merguezroleplay.fr or ts.evasionrp.eu OMG DUDE NOOO I HAVE SAY “.fr” and its french pls admin dont ban me

No srsly excuse me admin im joke :slight_smile: