Bean666 Posted June 5, 2016 Share Posted June 5, 2016 (edited) SOLVED Edited June 6, 2016 by Guest Link to comment
StefanAlmighty Posted June 5, 2016 Share Posted June 5, 2016 1. Are you having both markers visible at the same time? If so, you need two different variables for each rather than just 'marker'. 2. Does debugscript display any errors? Link to comment
Bean666 Posted June 5, 2016 Author Share Posted June 5, 2016 yes i have markers visible at the same time because it's a loot system anyways , when i click the "M4" Button in the second marker, it destroys the first marker from the table, no errors, but when i do it first to the 1st marker from table, i press M4 Button, it destroys the current marker "first marker", no errors, but when the first marker is destroyed, i go to second marker, pressed M4 Button, doesnt destroy the second marker and this is the error: Client line 13 Bad Argument @ 'destroyElement' [Expected element at argument 1] Link to comment
Abdul KariM Posted June 5, 2016 Share Posted June 5, 2016 Use This : local spots = { { 2490.173828125, -1670.1630859375, 12.3 }, { 2492.6298828125, -1675.1650390625, 12.3 } } GUIEditor = { button = {}, window = {} } window = guiCreateWindow(0.38, 0.28, 0.26, 0.48, "Loot Point", true) guiWindowSetSizable(window, false) guiSetVisible(window, false) button = guiCreateButton(0.25, 0.22, 0.49, 0.20, "M4", true, window) guiSetFont(button, "default-bold-small") cancel = guiCreateButton(0.25, 0.60, 0.49, 0.20, "Cancel", true, window) guiSetFont(cancel, "default-bold-small") addEventHandler ( "onClientResourceStart",resourceRoot, function ( ) for k,v in ipairs( spots ) do marker = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) addEventHandler ( "onClientMarkerHit", marker, MarkerHit ) end end ) ; function MarkerHit ( hitPlayer ) if ( hitPlayer == localPlayer ) then guiSetVisible( window, true ) showCursor( true ) end end addEventHandler("onClientGUIClick",button,function() if ( source == button ) then guiSetVisible( window , false ) showCursor( false ) if isElement ( marker ) then destroyElement( marker ) end end end ) Link to comment
Bean666 Posted June 5, 2016 Author Share Posted June 5, 2016 no errors, i can destroy 1st marker, but when i go to 2nd marker, still doesn't destroy it. Link to comment
فاّرس Posted June 5, 2016 Share Posted June 5, 2016 Try with resourceRoot and element data like this : local spots = { { 2490.173828125, -1670.1630859375, 12.3 }, { 2492.6298828125, -1675.1650390625, 12.3 } } GUIEditor = { button = {}, window = {} } window = guiCreateWindow(0.38, 0.28, 0.26, 0.48, "Loot Point", true) guiWindowSetSizable(window, false) guiSetVisible(window, false) button = guiCreateButton(0.25, 0.22, 0.49, 0.20, "M4", true, window) guiSetFont(button, "default-bold-small") cancel = guiCreateButton(0.25, 0.60, 0.49, 0.20, "Cancel", true, window) guiSetFont(cancel, "default-bold-small") for k,v in ipairs( spots ) do marker = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) end function MarkerHit ( hitPlayer, matchingDimension ) if (hitPlayer == localPlayer) then guiSetVisible(window, true) showCursor(true) setElementData( localPlayer, 'm', source) end end addEventHandler ( "onClientMarkerHit", resourceRoot, MarkerHit ) addEventHandler("onClientGUIClick",button,function() if ( source == button) then guiSetVisible(window,false) showCursor(false) destroyElement(getElementData(localPlayer, 'm') ) end end ) Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 it worked , thank you. but is there anyway to respawn the certain marker you destroyed after like 50000 millisecond? what functions do i need to use? any help appreciated. Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 what functions do i need to use to respawn the certain marker you destroyed? any help appreciated. Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 i used this and it works for the normal marker, how to make it work on the table? EDIT: I noticed a problem in this Code. it only recovers in the first time i destroy it , the second time i destroy it it doesnt recover anymore, this needs a table maybe? local bankmarker = createMarker( 2493.93823, -1665.07031, 13.34375, "cylinder", 1.5, 255, 0, 0, 255 ) addEventHandler("onClientElementDestroy", getRootElement(), function () if getElementType(source) == "marker" and source == bankmarker then setTimer ( function() local bankmarker = createMarker( 2493.93823, -1665.07031, 13.34375, "cylinder", 1.5, 255, 0, 0, 255 ) end,3000,1) end end ) Link to comment
فاّرس Posted June 6, 2016 Share Posted June 6, 2016 function MarkerHit ( hitPlayer, matchingDimension ) if (hitPlayer == localPlayer) then guiSetVisible(window, true) showCursor(true) setElementData( localPlayer, 'm', { source_ = source, pos = {getElementPosition (source) } } ) end end addEventHandler ( "onClientMarkerHit", resourceRoot, MarkerHit ) addEventHandler("onClientGUIClick",button,function() if ( source == button) then guiSetVisible(window,false) showCursor(false) destroyElement(getElementData(localPlayer, 'm').source_ ) 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() local bankmarker = createMarker( x, y, z, "cylinder", 1.5, 255, 0, 0, 255 ) end,3000,1) end end ) Note: resourceRoot for all markers in the script! Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 okay thanks i got it working now, Solved. ill keep resourceRoot in mind. all i need is the marker colshape / hitElement now since i can access it from higher locations. solved. Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 anyways does hitElement work with client, no right? nvm it doesn't. Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 anyways i got one more prob, i want this loot system to have multiple weapons, i tried to make another table and GUis of different weapons, but it doesnt work, it just shows me the M4 GUI. if i make another table of markers ,it shows me just the M4 GUI. this is my very last problem now. each marker i make , it' shows the Same GUI, i think it's because of the resourceroot , i think it's easier in serverside? Link to comment
Bean666 Posted June 6, 2016 Author Share Posted June 6, 2016 bump. sorry for double post Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now