Jump to content

bug


Bean666

Recommended Posts

Why is it like this? it seems working fine but, see shown in the video, i want it to work like a loot system the problem is when one marker is destroyed, u still need to wait for the marker to respawn to go to another marker so it won't be bugged, how can it be fixed?, what do i need to do? here is the bug shown in the video:

sometimes im getting errors:

attempt to index boolean value in line 27 as shown in the code.

EDIT: I also tested it with a player, if i destroy the marker, player still sees it.

code:

local spots = { 
    { 2490.173828125, -1670.1630859375, 12.3 }, 
    { 2492.6298828125, -1675.1650390625, 12.3 }, 
    { 2496.60840, -1675.31177, 12.3 } 
} 
  
local marker = { } 
  
function MarkerHit ( hitPlayer, matchingDimension ) 
    if (hitPlayer == localPlayer) then 
    if isPedInVehicle(hitPlayer) then return; end 
        if source == marker[1] then 
            setElementData( localPlayer, 'm', { n = 1, source_ = source, pos = {getElementPosition (source) } } ) 
            triggerEvent("m4show", localPlayer) 
        elseif source == marker[2] then 
            setElementData( localPlayer, 'm', { n = 2, source_ = source, pos = {getElementPosition (source) } } ) 
            triggerEvent("akshow", localPlayer) 
        elseif source == marker[3] then 
            setElementData( localPlayer, 'm', { n = 3, source_ = source, pos = {getElementPosition (source) } } ) 
            triggerEvent("snshow", localPlayer) 
        end 
    end 
end 
  
addEventHandler("onClientElementDestroy", resourceRoot,function () 
    if getElementType(source) == "marker" and getElementData( localPlayer, 'm' ).source_ == source then 
       local x,y,z = unpack (getElementData( localPlayer, 'm' ).pos) 
            setTimer ( function() 
                marker[getElementData(localPlayer,'m').n] = createMarker( x, y, z, "cylinder", 1, 255, 255, 255, 100 ) 
                addEventHandler ( "onClientMarkerHit", marker[getElementData(localPlayer,'m').n], MarkerHit ) 
            end,10000,1) 
        end 
    end 
) 
  
for k,v in ipairs( spots ) do 
        marker[k] = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) 
        addEventHandler ( "onClientMarkerHit", marker[k], MarkerHit ) 
end 
  
addEventHandler("onClientGUIClick",resourceRoot,function() 
    if ( source == button) then 
           guiSetVisible(window,false) 
           showCursor(false) 
           destroyElement(getElementData(localPlayer, 'm').source_) 
           triggerServerEvent("m4", getLocalPlayer(), m4) 
    elseif ( source == button2) then 
           guiSetVisible(window,false) 
           showCursor(false) 
           destroyElement(getElementData(localPlayer, 'm').source_) 
           triggerServerEvent("ak", getLocalPlayer(), ak) 
    elseif ( source == button3) then 
           guiSetVisible(window,false) 
           showCursor(false) 
           destroyElement(getElementData(localPlayer, 'm').source_) 
           triggerServerEvent("sn", getLocalPlayer(), sn) 
    elseif ( source == cancel) then 
           guiSetVisible(window,false) 
           showCursor(false) 
       end 
   end ) 

Link to comment

It's not a but, it is because you repeatedly use the setTimer function with one element data before it ends !

try with two or three elements data?

if source == marker[1] then 
            setElementData( localPlayer, 'm', { n = 1, source_ = source, pos = {getElementPosition (source) } } ) 
            triggerEvent("m4show", localPlayer) 
elseif source == marker[2] then 
            setElementData( localPlayer, 'm2', { n = 2, source_ = source, pos = {getElementPosition (source) } } ) 
            triggerEvent("akshow", localPlayer) 
                                  -- etc. 
Link to comment

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.
×
×
  • Create New...