PeeQ. Posted April 3, 2020 Share Posted April 3, 2020 (edited) This script create a marker, when player passes the marker create a menu located in other script local binco1b = createMarker(217.5, -98, 1004, "cylinder", 1.0, 255, 0, 0) setElementInterior(binco1b, 15) local vendedor = createPed(12, 209, -99, 1005, 180) setElementInterior(vendedor, 15) addEventHandler("onMarkerHit", root, painel) This script create the menu GUIEditor = { gridlist = {}, scrollpane = {}, button = {}, window = {} } function painel() GUIEditor.window[1] = guiCreateWindow(838, 320, 375, 331, "PAGUE MENOS", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.92) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFEEB16") GUIEditor.button[1] = guiCreateButton(278, 300, 83, 21, "", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(269, 288, 92, 33, "Sair", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFEF0000") GUIEditor.button[3] = guiCreateButton(263, 316, 75, 5, "", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(9, 288, 97, 33, "Comprar", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF39EB3D") GUIEditor.button[5] = guiCreateButton(17, 292, 84, 29, "", false, GUIEditor.window[1]) GUIEditor.gridlist[1] = guiCreateGridList(175, 86, 75, 129, false, GUIEditor.window[1]) GUIEditor.scrollpane[1] = guiCreateScrollPane(76, 101, 65, 104, false, GUIEditor.window[1]) GUIEditor.gridlist[2] = guiCreateGridList(354, 270, 17, 18, false, GUIEditor.window[1]) GUIEditor.gridlist[3] = guiCreateGridList(9, 27, 352, 257, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[3], "Skins", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "ID", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "Preço", 0.3) for i = 1, 2 do guiGridListAddRow(GUIEditor.gridlist[3]) end guiGridListSetItemText(GUIEditor.gridlist[3], 0, 1, "skin1", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 3, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 1, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 3, "-", false, false) end ) function comandos() guiSetVisible(GUIEditor.window, false) end addEventHandler("onClientClick", GUIEditor.button[2], comandos) when player passes the marker nothing happens Edited April 3, 2020 by PeeQ. Link to comment
iwalidza Posted April 3, 2020 Share Posted April 3, 2020 change the addEventHandler("onMarkerHit", root, painel) to addEventHandler("onMarkerHit",binco1b, painel) or you can use that local binco1b = createMarker(217.5, -98, 1004, "cylinder", 1.0, 255, 0, 0) local vendedor = createPed(12, 209, -99, 1005, 180) setElementInterior(vendedor, 15) setElementInterior(binco1b, 15) addEventHandler("onMarkerHit",root,function(elementMark) if elementMark == binco1b then guiSetVisible(GUIEditor.window[1],true) end end) GUIEditor = { gridlist = {}, scrollpane = {}, button = {}, window = {} } GUIEditor.window[1] = guiCreateWindow(838, 320, 375, 331, "PAGUE MENOS", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.92) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFEEB16") GUIEditor.button[1] = guiCreateButton(278, 300, 83, 21, "", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(269, 288, 92, 33, "Sair", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFEF0000") GUIEditor.button[3] = guiCreateButton(263, 316, 75, 5, "", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(9, 288, 97, 33, "Comprar", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF39EB3D") GUIEditor.button[5] = guiCreateButton(17, 292, 84, 29, "", false, GUIEditor.window[1]) GUIEditor.gridlist[1] = guiCreateGridList(175, 86, 75, 129, false, GUIEditor.window[1]) GUIEditor.scrollpane[1] = guiCreateScrollPane(76, 101, 65, 104, false, GUIEditor.window[1]) GUIEditor.gridlist[2] = guiCreateGridList(354, 270, 17, 18, false, GUIEditor.window[1]) GUIEditor.gridlist[3] = guiCreateGridList(9, 27, 352, 257, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[3], "Skins", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "ID", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "Preço", 0.3) for i = 1, 2 do guiGridListAddRow(GUIEditor.gridlist[3]) end guiGridListSetItemText(GUIEditor.gridlist[3], 0, 1, "skin1", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 3, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 1, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 3, "-", false, false) guiSetVisible(GUIEditor.window[1],false) Link to comment
PeeQ. Posted April 4, 2020 Author Share Posted April 4, 2020 (edited) 1 hour ago, iwalidza said: change the addEventHandler("onMarkerHit", root, painel) to addEventHandler("onMarkerHit",binco1b, painel) or you can use that local binco1b = createMarker(217.5, -98, 1004, "cylinder", 1.0, 255, 0, 0) local vendedor = createPed(12, 209, -99, 1005, 180) setElementInterior(vendedor, 15) setElementInterior(binco1b, 15) addEventHandler("onMarkerHit",root,function(elementMark) if elementMark == binco1b then guiSetVisible(GUIEditor.window[1],true) end end) GUIEditor = { gridlist = {}, scrollpane = {}, button = {}, window = {} } GUIEditor.window[1] = guiCreateWindow(838, 320, 375, 331, "PAGUE MENOS", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.92) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFFEEB16") GUIEditor.button[1] = guiCreateButton(278, 300, 83, 21, "", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(269, 288, 92, 33, "Sair", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFEF0000") GUIEditor.button[3] = guiCreateButton(263, 316, 75, 5, "", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(9, 288, 97, 33, "Comprar", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF39EB3D") GUIEditor.button[5] = guiCreateButton(17, 292, 84, 29, "", false, GUIEditor.window[1]) GUIEditor.gridlist[1] = guiCreateGridList(175, 86, 75, 129, false, GUIEditor.window[1]) GUIEditor.scrollpane[1] = guiCreateScrollPane(76, 101, 65, 104, false, GUIEditor.window[1]) GUIEditor.gridlist[2] = guiCreateGridList(354, 270, 17, 18, false, GUIEditor.window[1]) GUIEditor.gridlist[3] = guiCreateGridList(9, 27, 352, 257, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[3], "Skins", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "ID", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "Preço", 0.3) for i = 1, 2 do guiGridListAddRow(GUIEditor.gridlist[3]) end guiGridListSetItemText(GUIEditor.gridlist[3], 0, 1, "skin1", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 3, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 1, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 3, "-", false, false) guiSetVisible(GUIEditor.window[1],false) The first solution dont work... nothing happens the second solution still nothin happening Edited April 4, 2020 by PeeQ. Link to comment
PeeQ. Posted April 4, 2020 Author Share Posted April 4, 2020 4 hours ago, PeeQ. said: This script create a marker, when player passes the marker create a menu located in other script function BuySkin() bincoB = createMarker(217.5, -98, 1006, "arrow", 1.5, 255, 0, 0) setElementInterior(bincoB, 15) vendedora = createPed(12, 209, -99, 1005, 180) setElementInterior(vendedora, 15) end addEventHandler("onClientResourceStart", resourceRoot, BuySkin) function ShowSkins(player) if (source == binco1m and getElementType(player) == "player") then exibir() end end addEventHandler("onClientMarkerHit", resourceRoot, ShowSkins) This script create the menu Painel = guiCreateWindow(838, 320, 375, 331, "PAGUE MENOS", false) guiWindowSetSizable(Painel, false) guiSetAlpha(Painel, 0.92) guiSetProperty(Painel, "CaptionColour", "FFFEEB16") guiSetVisible(Painel, false) sair = guiCreateButton(269, 288, 92, 33, "Sair", false, Painel) guiSetProperty(sair, "NormalTextColour", "FF39EB3D") GUIEditor.button[4] = guiCreateButton(9, 288, 97, 33, "Comprar", false, Painel) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF39EB3D") GUIEditor.gridlist[3] = guiCreateGridList(9, 27, 352, 257, false, Painel) guiGridListAddColumn(GUIEditor.gridlist[3], "Skins", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "ID", 0.3) guiGridListAddColumn(GUIEditor.gridlist[3], "Preço", 0.3) for i = 1, 2 do guiGridListAddRow(GUIEditor.gridlist[3]) end guiGridListSetItemText(GUIEditor.gridlist[3], 0, 1, "skin1", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 0, 3, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 1, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 2, "-", false, false) guiGridListSetItemText(GUIEditor.gridlist[3], 1, 3, "-", false, false) function exibir() guiSetVisible(Painel, not guiGetVisible(Painel)) showCursor(guiGetVisible(Painel)) end function click() if source == sair then exibir() end end addEventHandler("onClientGUIClick", resourceRoot, click) when player passes the marker nothing happens Link to comment
The_GTA Posted April 4, 2020 Share Posted April 4, 2020 9 hours ago, PeeQ. said: This script create a marker, when player passes the marker create a menu located in other script 9 hours ago, PeeQ. said: when player passes the marker nothing happens Hello PeeQ, do you know about the difference between server-side and client-side scripts? It looks like your first script is a server-side script because you are using the server-side "onMarkerHit" event. Is it intentional that you want to create server-side peds and markers? I am going to assume that it is, so let's fix your script! What iwalidza tried to do is put both code onto the client-side. But that user forgot to use the client-side onClientMarkerHit event instead of the server-side onMarkerHit. Please test your code next time, iwalidza. In order to synchronize data between server and client you have to use MTA event functions. We want to create a remote client-side event called "onClientShowGUI" and put our GUI code into an event handler of that event. Then inside of the server-side onMarkerHit event... addEventHandler("onMarkerHit", binco1b, function(hitElement) if (getElementType(hitElement) == "player") then triggerClientEvent(hitElement, "onClientShowGUI", root); end end ); I recommend you to read up on MTA events to catch up on good MTA Lua scripting 1 Link to comment
PeeQ. Posted April 4, 2020 Author Share Posted April 4, 2020 9 hours ago, The_GTA said: Hello PeeQ, do you know about the difference between server-side and client-side scripts? It looks like your first script is a server-side script because you are using the server-side "onMarkerHit" event. Is it intentional that you want to create server-side peds and markers? I am going to assume that it is, so let's fix your script! What iwalidza tried to do is put both code onto the client-side. But that user forgot to use the client-side onClientMarkerHit event instead of the server-side onMarkerHit. Please test your code next time, iwalidza. In order to synchronize data between server and client you have to use MTA event functions. We want to create a remote client-side event called "onClientShowGUI" and put our GUI code into an event handler of that event. Then inside of the server-side onMarkerHit event... addEventHandler("onMarkerHit", binco1b, function(hitElement) if (getElementType(hitElement) == "player") then triggerClientEvent(hitElement, "onClientShowGUI", root); end end); I recommend you to read up on MTA events to catch up on good MTA Lua scripting You are a hero, yes, i'm learning Lua script, i'm benning, thk for your help, and recommendations, i want kiss u <3 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