Jump to content

Destroy Marker Help


Bean666

Recommended Posts

hi , i need help , i had scripted a pickup system , and i made a GUI System once i get in a marker it shows the gui , and when it press the button which gives u item and destroys the marker , but when i click the button it gives me weapons , but destroys all the markers. any help?

local marker1 = createMarker( 60.0234375, -1534.3251953125, 4.2, "Cylinder", 0.7, 0, 100, 0, 150) 
local marker2 = createMarker( 1177.5244140625, -1319.181640625, 13.2, "Cylinder", 0.7, 0, 100, 0, 150) 
local marker3 = createMarker( 735.3291015625, -1342.484375, 12.6, "Cylinder", 0.7, 0, 100, 0, 150) 
local marker4 = createMarker( -1419.8505859375, -1502.87109375, 104.2, "Cylinder", 0.7, 0, 100, 0, 150) 
local marker5 = createMarker( -90.94140625, -1576.6279296875, 1.7, "Cylinder", 0.7, 0, 100, 0, 150) 
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    label = {}, 
    memo = {} 
} 
        GUIEditor.window[1] = guiCreateWindow(435, 236, 394, 317, "Item Leftover", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
        GUIEditor.button[1] = guiCreateButton(124, 109, 142, 72, "First Aid Kit", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(130, 260, 136, 47, "Close", false, GUIEditor.window[1]) 
  
addEventHandler("onClientMarkerHit", marker1, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 
  
addEventHandler("onClientMarkerHit", marker2, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 
  
addEventHandler("onClientMarkerHit", marker3, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 
  
addEventHandler("onClientMarkerHit", marker4, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 
  
addEventHandler("onClientMarkerHit", marker5, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 
  
 addEventHandler("onClientGUIClick",GUIEditor.button[2],function() 
    if ( source == GUIEditor.button[2]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
       end 
   end )   
  
 addEventHandler("onClientGUIClick",GUIEditor.button[1],function() 
   if ( source == GUIEditor.button[1]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
           destroyElement(marker1) 
           triggerServerEvent ("givehp",getLocalPlayer(),givehp) 
       end 
   end )    
  
 addEventHandler("onClientGUIClick",GUIEditor.button[1],function() 
   if ( source == GUIEditor.button[1]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
           destroyElement(marker2) 
           triggerServerEvent ("givehp",getLocalPlayer(),givehp) 
       end 
   end )   
  
 addEventHandler("onClientGUIClick",GUIEditor.button[1],function() 
   if ( source == GUIEditor.button[1]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
           destroyElement(marker3) 
           triggerServerEvent ("givehp",getLocalPlayer(),givehp) 
       end 
   end )   
  
 addEventHandler("onClientGUIClick",GUIEditor.button[1],function() 
   if ( source == GUIEditor.button[1]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
           destroyElement(marker4) 
           triggerServerEvent ("givehp",getLocalPlayer(),givehp) 
       end 
   end )   
  
 addEventHandler("onClientGUIClick",GUIEditor.button[1],function() 
   if ( source == GUIEditor.button[1]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
           destroyElement(marker5) 
           triggerServerEvent ("givehp",getLocalPlayer(),givehp) 
       end 
   end )   

Link to comment

The problem why it destroys all the markers cuz I see in every function you made if player press the button1 will destroy the marker1 and in other function will destroy marker2 and so on which means that if the player press the button the script will call all the functions that are related with the button .

To fix this problem simply use setElementData to markers and use getElementData inside the functions.

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...