Matevsz Posted December 23, 2015 Share Posted December 23, 2015 hello, I want the entry into pickup gui appeared and disappeared after leaving. S: function Pickup() ubranie = createPickup(-1886.7001953125, 2142.7001953125, 1.7999999523163, 3, 1275, 3000) info = createPickup(-1891.5, 2148.7001953125, 1.7999999523163, 3, 1239, 3000) butlaTlenu = createPickup(-1890.1999511719, 2145.1000976563, 1.7999999523163, 3, 2690, 3000) end addEventHandler("onResourceStart", getRootElement(), Pickup) addEventHandler("onPickupHit", info, function(hitElement, matchingDimension) if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then triggerClientEvent(hitElement,"okno",hitElement) end end ) C: addEventHandler("onClientResourceStart", resourceRoot, function() okno = guiCreateWindow(619, 354, 454, 260, "Praca Nurka", false) guiWindowSetSizable(okno, false) memo = guiCreateMemo(16, 32, 419, 208, "...", false, okno) guiSetVisible(okno, false) end ) function ShowGui() guiSetVisible(okno, true) end addEvent("okno", true) addEventHandler("okno",root,ShowGui) Error: Server S. Bad argument addEventHandler expected element at argument 2 got nil (info) Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 maybe you may create a table in all pickups? Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 my example of panel simple S: local praia = createMarker (338, -1776, 4.1, "cylinder", 2, 0, 255, 255, 255) function open (source) triggerClientEvent (source, "open", root) end addEventHandler ("onMarkerHit", praia, open) C: painel = false function dx () dxDrawRectangle(239, 182, 548, 385, tocolor(0, 0, 0, 180), false) dxDrawRectangle(239, 530, 548, 37, tocolor(0, 247, 255, 209), false) dxDrawRectangle(434, 182, 138, 17, tocolor(0, 247, 255, 209), false) dxDrawText("SEU SERVER", 242, 530, 451, 547, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("AVISO ' REGRAS", 455, 182, 664, 199, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Fechar", 685, 537, 719, 563, tocolor(255, 255, 255, 255), 1.50, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("REGRAS SERVIDOR.", 252, 270, 434, 302, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("E Proibido Matar em cima de moto : Ban 5 Horas.", 252, 302, 434, 334, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Uso de handeling em areas Proibidas : Ban 24 Horas.", 252, 344, 434, 376, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Desrespeitos A Membros Da Staff ou a Players Tera Punição : Ban 24 Horas.", 252, 386, 434, 418, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Em Caso de Duvidas Favor Recorrer a um staff , Denunciar : Skype:", 252, 424, 434, 456, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("-----------------------------------------------------------------------------------------------------------------------------------------", 239, 233, 779, 242, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) dxDrawText("-----------------------------------------------------------------------------------------------------------------------------------------", 239, 481, 779, 490, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) end function abrirpainel () if painel == false then addEventHandler ("onClientRender", root, dx) showCursor (true) painel = true end end addEvent ("open", true) addEventHandler ("open", root, abrirpainel) function fecharpainel (_,state) if painel == true then if state == "down" then if isCursorOnElement (685, 537, 719, 563) then removeEventHandler ("onClientRender", root, dx) showCursor (false) painel = false end end end end addEventHandler ("onClientClick", root, fecharpainel) local x,y = guiGetScreenSize() function isCursorOnElement(x,y,w,h) local mx,my = getCursorPosition () local fullx,fully = guiGetScreenSize() cursorx,cursory = mx*fullx,my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 my table of example local Positions = { { -2408.83667, -600.25464, 132.64844 }, { -2408.72217, -590.46851, 132.64844 }, --{ -2408.72217, -590.46851, 132.64844 }, -- more positions } addEventHandler ( "onResourceStart", resourceRoot, function() for _, v in ipairs ( Positions ) do local tx, ty, tz = unpack ( v ) pickups.pickup[v] = createPickup(tx, ty, tz-2.0, 3, 1239, 3000) end end ) Link to comment
Matevsz Posted December 23, 2015 Author Share Posted December 23, 2015 S: local pickup = createPickup(-1891.5, 2148.7001953125, 1.7999999523163, 3, 1239, 3000) function PokazPanelInfo(source) triggerClientEvent(source, "PokazPanelInfo", root) end addEventHandler("onPickupHit", pickup, PokazPanelInfo) C: addEventHandler("onClientResourceStart", resourceRoot, function() okno = guiCreateWindow(619, 354, 454, 260, "Praca Nurka", false) guiWindowSetSizable(okno, false) memo = guiCreateMemo(16, 32, 419, 208, "...", false, okno) guiSetVisible(okno, false) end ) function ShowGui(element) if element ~= getLocalPlayer() then return end guiSetVisible(okno, true) else guiSetVisible(okno, false) end addEvent("PokazPanelInfo", true) addEventHandler("PokazPanelInfo", root, ShowGui) And Error: Bad argument 'addEventHandler' expected element at argument 2 got nil (server side (pickup) ) Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 (edited) try this local Positions = { { -1891.5, 2148.7001953125, 1.7999999523163 }, -- { 664.65936, -1755.74182, 13.45477 }, -- more positions } local pickups = { pickup = { } } function onHit ( ) for _, v in ipairs ( Positions ) do local x, y, z = unpack ( v ) pickups.pickup[v] = createPickup ( x, y, z, 3, 1239, 3000) addEventHandler ( "onPickupHit", pickups.pickup[v], function ( player ) usePickup ( pickups.pickup[v], player ) triggerClientEvent(player, "PokazPanelInfo", player) end) end end addEventHandler ( "onResourceStart", resourceRoot, onHit ) EDIT: Edited December 23, 2015 by Guest Link to comment
Matevsz Posted December 23, 2015 Author Share Posted December 23, 2015 S: local pickup = createPickup(-1891.5, 2148.7001953125, 1.7999999523163, 3, 1239, 3000) function PokazPanelInfo(source) triggerClientEvent(source, "PokazPanelInfo", root) end addEventHandler("onPickupHit", pickup, PokazPanelInfo) C: addEventHandler("onClientResourceStart", resourceRoot, function() okno = guiCreateWindow(619, 354, 454, 260, "Praca Nurka", false) guiWindowSetSizable(okno, false) memo = guiCreateMemo(16, 32, 419, 208, "...", false, okno) guiSetVisible(okno, false) end ) function ShowGui(element) if element ~= getLocalPlayer() then return end guiSetVisible(okno, true) else guiSetVisible(okno, false) end addEvent("PokazPanelInfo", true) addEventHandler("PokazPanelInfo", root, ShowGui) And Error: Bad argument 'addEventHandler' expected element at argument 2 got nil (server side (pickup) ) Server side is already running, now are these errors: ERROR: Server triggered clientside event PokazPanelInfo, but event is not added clientside Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 I edited my post try again Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 I edited my post try again You add in triggerEvent triggerClientEvent(source, "PokazPanelInfo", source) or triggerClientEvent(player, "PokazPanelInfo", player) Link to comment
Matevsz Posted December 23, 2015 Author Share Posted December 23, 2015 C: function ShowGui(element) if element ~= getLocalPlayer() then return end guiSetVisible(okno, true) else guiSetVisible(okno, false) end addEvent("PokazPanelInfo", true) addEventHandler("PokazPanelInfo", root, ShowGui) Link to comment
#RooTs Posted December 23, 2015 Share Posted December 23, 2015 server.lua local Positions = { { -1891.5, 2148.7001953125, 1.7999999523163 }, -- { 664.65936, -1755.74182, 13.45477 }, -- more positions } local pickups = { pickup = { } } function onHit ( ) for _, v in ipairs ( Positions ) do local x, y, z = unpack ( v ) pickups.pickup[v] = createPickup ( x, y, z, 3, 1239, 3000) addEventHandler ( "onPickupHit", pickups.pickup[v], function ( player ) usePickup ( pickups.pickup[v], player ) triggerClientEvent(player, "PokazPanelInfo", player) end) end end addEventHandler ( "onResourceStart", resourceRoot, onHit ) Client.lua addEventHandler("onClientResourceStart", resourceRoot, function() okno = guiCreateWindow(619, 354, 454, 260, "Praca Nurka", false) guiWindowSetSizable(okno, false) memo = guiCreateMemo(16, 32, 419, 208, "...", false, okno) guiSetVisible(okno, false) end ) function ShowGui(element) if element ~= getLocalPlayer() then return end guiSetVisible(okno, true) else guiSetVisible(okno, false) end addEvent("PokazPanelInfo", true) addEventHandler("PokazPanelInfo", root, ShowGui) Link to comment
Matevsz Posted December 23, 2015 Author Share Posted December 23, 2015 I've already done, about to close Link to comment
#RooTs Posted December 25, 2015 Share Posted December 25, 2015 I've already done, about to close done man? 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