drhx

marker bug

Recommended Posts

 

I recently created a job for my server, pizza delivery, but there is a problem, even if I set the marker as invisible (setElementVisibleTo) it becomes invisible more when I step over it, it performs the function, how do I solve it?

Share this post


Link to post

Use this function to check if the marker is visible to the player:

https://wiki.multitheftauto.com/wiki/IsElementVisibleTo

 

But why the marker hit event is still triggering in the first place, is even a mystery to me.

 

Note: this is the tutorial section.

Share this post


Link to post

 

the marker is invisible, but the function is executed even though I'm using setElementVisibleTo, I'm using the meta as "server" I did not find the error yet

Share this post


Link to post
3 hours ago, drhx said:

 

the marker is invisible, but the function is executed even though I'm using setElementVisibleTo, I'm using the meta as "server" I did not find the error yet

Yes, understood.

So use the solution I gave you for now.

Share this post


Link to post

We cannot help you efficiently unless you provide full code

@drhx

Share this post


Link to post
inimarker = createMarker (2102.8264160156, -1788.5377197266, 12.5546875, "cylinder", 1.5, 255, 0, 0)
marker1 = createMarker (2067.9577636719, -1731.6177978516, 12.87615776062, "cylinder", 1.5, 255, 0, 0)

inicio = createBlipAttachedTo(inimarker, 42)
blip1 = createBlipAttachedTo(marker1, 41)

vehjob = {}
function inicio(player)
    if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player])
        vehjob[player] = nil
    end
    vehjob[player] = createVehicle(462, 2107.9953613281, -1781.9140625, 13.388528823853)
    outputChatBox("#FF0000Você Aceitou O Emprego De Entregador De Pizza!", player, 255,255,255,true)
    outputChatBox("#FF0000Entregue As Pizzas Nos Locais Marcados Em Seu GPS!", player, 255,255,255,true)
    outputChatBox("#FF0000Para Cancelar Seu Emprego Digite /cancelar!", player, 255,255,255,true)
    createPed (297, 2067.1535644531,-1731.5858154297, 14.206628799438, 268.24844360352)
    warpPedIntoVehicle(player, vehjob[player])
    setElementVisibleTo(finblip, player, true)
    setElementVisibleTo(finmarker, player, true)
end
addEventHandler("onMarkerHit", inimarker, inicio)

 

I wanted to leave the marker1 invisible until the player passed the "inimarker", after the player passed the "inimarker" the "marker1" would be visible and with function

Share this post


Link to post

You can use the last argument of the function for this.

local inimarker = createMarker (2102.8264160156, -1788.5377197266, 12.5546875, "cylinder", 1.5, 255, 0, 0)
local marker1 = createMarker (2067.9577636719, -1731.6177978516, 12.87615776062, "cylinder", 1.5, 255, 0, 0, 255, resourceRoot)

local inicio = createBlipAttachedTo(inimarker, 42)
local blip1 = createBlipAttachedTo( marker1, 41, 2, 255, 0, 0, 255, 0, 16383, resourceRoot )

local vehjob = {}
function inicio(player)
    if getElementType(player) ~= "player" then return end
    if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player])
        vehjob[player] = nil
    end
    vehjob[player] = createVehicle(462, 2107.9953613281, -1781.9140625, 13.388528823853)
    outputChatBox("#FF0000Você Aceitou O Emprego De Entregador De Pizza!", player, 255,255,255,true)
    outputChatBox("#FF0000Entregue As Pizzas Nos Locais Marcados Em Seu GPS!", player, 255,255,255,true)
    outputChatBox("#FF0000Para Cancelar Seu Emprego Digite /cancelar!", player, 255,255,255,true)

    -- define a variable here, it should be for each player that enters the marker, so it must be stored in a table just like the vehicle is
    createPed (297, 2067.1535644531,-1731.5858154297, 14.206628799438, 268.24844360352)
     
    warpPedIntoVehicle(player, vehjob[player])

    setElementVisibleTo(marker1, player, true)
    setElementVisibleTo(blip1, player, true)
end
addEventHandler("onMarkerHit", inimarker, inicio)

Try it.

Share this post


Link to post
On 17/06/2019 at 13:39, DNL291 said:

You can use the last argument of the function for this.


local inimarker = createMarker (2102.8264160156, -1788.5377197266, 12.5546875, "cylinder", 1.5, 255, 0, 0)
local marker1 = createMarker (2067.9577636719, -1731.6177978516, 12.87615776062, "cylinder", 1.5, 255, 0, 0, 255, resourceRoot)

local inicio = createBlipAttachedTo(inimarker, 42)
local blip1 = createBlipAttachedTo( marker1, 41, 2, 255, 0, 0, 255, 0, 16383, resourceRoot )

local vehjob = {}
function inicio(player)
    if getElementType(player) ~= "player" then return end
    if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player])
        vehjob[player] = nil
    end
    vehjob[player] = createVehicle(462, 2107.9953613281, -1781.9140625, 13.388528823853)
    outputChatBox("#FF0000Você Aceitou O Emprego De Entregador De Pizza!", player, 255,255,255,true)
    outputChatBox("#FF0000Entregue As Pizzas Nos Locais Marcados Em Seu GPS!", player, 255,255,255,true)
    outputChatBox("#FF0000Para Cancelar Seu Emprego Digite /cancelar!", player, 255,255,255,true)

    -- define a variable here, it should be for each player that enters the marker, so it must be stored in a table just like the vehicle is
    createPed (297, 2067.1535644531,-1731.5858154297, 14.206628799438, 268.24844360352)
     
    warpPedIntoVehicle(player, vehjob[player])

    setElementVisibleTo(marker1, player, true)
    setElementVisibleTo(blip1, player, true)
end
addEventHandler("onMarkerHit", inimarker, inicio)

Try it.

 

I made a test, I put it every time I go through the marker1 he write something in the chat, and even invisible if I go through the marker1 he performs the function and leaves the message

 

Share this post


Link to post
On 17/06/2019 at 18:39, DNL291 said:

You can use the last argument of the function for this.


local inimarker = createMarker (2102.8264160156, -1788.5377197266, 12.5546875, "cylinder", 1.5, 255, 0, 0)
local marker1 = createMarker (2067.9577636719, -1731.6177978516, 12.87615776062, "cylinder", 1.5, 255, 0, 0, 255, resourceRoot)

local inicio = createBlipAttachedTo(inimarker, 42)
local blip1 = createBlipAttachedTo( marker1, 41, 2, 255, 0, 0, 255, 0, 16383, resourceRoot )

local vehjob = {}
function inicio(player)
    if getElementType(player) ~= "player" then return end
    if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player])
        vehjob[player] = nil
    end
    vehjob[player] = createVehicle(462, 2107.9953613281, -1781.9140625, 13.388528823853)
    outputChatBox("#FF0000Você Aceitou O Emprego De Entregador De Pizza!", player, 255,255,255,true)
    outputChatBox("#FF0000Entregue As Pizzas Nos Locais Marcados Em Seu GPS!", player, 255,255,255,true)
    outputChatBox("#FF0000Para Cancelar Seu Emprego Digite /cancelar!", player, 255,255,255,true)

    -- define a variable here, it should be for each player that enters the marker, so it must be stored in a table just like the vehicle is
    createPed (297, 2067.1535644531,-1731.5858154297, 14.206628799438, 268.24844360352)
     
    warpPedIntoVehicle(player, vehjob[player])

    setElementVisibleTo(marker1, player, true)
    setElementVisibleTo(blip1, player, true)
end
addEventHandler("onMarkerHit", inimarker, inicio)

Try it.

so how would he use it? I did not understand very well, I'm slow.
local inimarker = createMarker (2102.8264160156, -1788.5377197266, 12.5546875, "cylinder", 1.5, 255, 0, 0)
local marker1 = createMarker (2067.9577636719, -1731.6177978516, 12.87615776062, "cylinder", 1.5, 255, 0, 0, 255, resourceRoot)

local inicio = createBlipAttachedTo(inimarker, 42)
local blip1 = createBlipAttachedTo( marker1, 41, 2, 255, 0, 0, 255, 0, 16383, resourceRoot )

local vehjob = {}
function inicio(player)
    if getElementType(player) ~= "player" then return end
    if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player])
        vehjob[player] = nil
    end
    vehjob[player] = createVehicle(462, 2107.9953613281, -1781.9140625, 13.388528823853)
    outputChatBox("#FF0000Você Aceitou O Emprego De Entregador De Pizza!", player, 255,255,255,true)
    outputChatBox("#FF0000Entregue As Pizzas Nos Locais Marcados Em Seu GPS!", player, 255,255,255,true)
    outputChatBox("#FF0000Para Cancelar Seu Emprego Digite /cancelar!", player, 255,255,255,true)

    createPed (297, 2067.1535644531,-1731.5858154297, 14.206628799438, 268.24844360352)
     
    warpPedIntoVehicle(player, vehjob[player])

    setElementVisibleTo(marker1, player, true)
    setElementVisibleTo(blip1, player, true)
end
addEventHandler("onMarkerHit", inimarker, inicio)

function inicio2(player)
    outputChatBox("#FF0000Teste", player, 255,255,255,true,)
end
addEventHandler("onMarkerHit", marker1, inicio2)

 

Share this post


Link to post
57 minutes ago, drhx said:

so how would he use it? I did not understand very well, I'm slow.

local inimarker = createMarker (2102.8264160156, -1788.5377197266, 12.5546875, "cylinder", 1.5, 255, 0, 0)
local marker1 = createMarker (2067.9577636719, -1731.6177978516, 12.87615776062, "cylinder", 1.5, 255, 0, 0, 255, resourceRoot)

local inicio = createBlipAttachedTo(inimarker, 42)
local blip1 = createBlipAttachedTo( marker1, 41, 2, 255, 0, 0, 255, 0, 16383, resourceRoot )

local vehjob = {}
function inicio(player)
    if getElementType(player) ~= "player" then return end
    if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player])
        vehjob[player] = nil
    end
    vehjob[player] = createVehicle(462, 2107.9953613281, -1781.9140625, 13.388528823853)
    outputChatBox("#FF0000Você Aceitou O Emprego De Entregador De Pizza!", player, 255,255,255,true)
    outputChatBox("#FF0000Entregue As Pizzas Nos Locais Marcados Em Seu GPS!", player, 255,255,255,true)
    outputChatBox("#FF0000Para Cancelar Seu Emprego Digite /cancelar!", player, 255,255,255,true)

    createPed (297, 2067.1535644531,-1731.5858154297, 14.206628799438, 268.24844360352)
     
    warpPedIntoVehicle(player, vehjob[player])

    setElementVisibleTo(marker1, player, true)
    setElementVisibleTo(blip1, player, true)
end
addEventHandler("onMarkerHit", inimarker, inicio)

function inicio2(player)
    outputChatBox("#FF0000Teste", player, 255,255,255,true,)
end
addEventHandler("onMarkerHit", marker1, inicio2)

 

if isElementVisibleTo(theElement, visibleTo) then
	-- do something
end

theElement: The element you want to check the visibility of

visibleTo: The player you want to check against

Share this post


Link to post
14 hours ago, majqq said:

if isElementVisibleTo(theElement, visibleTo) then
	-- do something
end

theElement: The element you want to check the visibility of

visibleTo: The player you want to check against

even without these commands it becomes invisible more with the commands and with these commands does not change anything until now I did not realize the error

 

 

 
 
 
 

 

Share this post


Link to post
3 hours ago, drhx said:

even without these commands it becomes invisible more with the commands and with these commands does not change anything until now I did not realize the error


 


 


 
 
 
 

 

Send updated code.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.