I see, thanks
how do I make the gui that when i press the key again it closes?
addEvent("playerOnClick", true)
addEventHandler("playerOnClick", root,
function()
guiGridListClear ( w.gridList.main )
for i,veh in ipairs(getElementsByType("vehicle")) do
if veh ~= vehicle then
local row = guiGridListAddRow ( w.gridList.main )
local x,y,z = getElementPosition(veh)
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column1, getVehicleName ( veh ), false, false )
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column2, x, false, false )
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column3, y, false, false )
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column4, z, false, false )
end
end
guiSetVisible(w.main, true)
showCursor(true)
end )
function hasPermission(key,keyState)
if getElementData(localPlayer, "logedin") then
triggerServerEvent("hasPermissionEvent",localPlayer,key,keyState)
end
end
bindKey("p", "down", hasPermission)
Edit : you can disregard these, I made if else statement and created to false.
function playerOnClick(key,keyState)
if (keyState == "down") then
if (guiGetVisible(w.main) == false) then
guiGridListClear ( w.gridList.main )
for i,veh in ipairs(getElementsByType("vehicle")) do
if veh ~= vehicle then
local row = guiGridListAddRow ( w.gridList.main )
local x,y,z = getElementPosition(veh)
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column1, getVehicleName ( veh ), false, false )
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column2, x, false, false )
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column3, y, false, false )
guiGridListSetItemText ( w.gridList.main, row, w.gridList.column4, z, false, false )
end
end
guiSetVisible(w.main, true)
showCursor(true)
else
guiSetVisible(w.main, false)
showCursor(false)
end
end
end
addEvent("playerOnClick",true)
addEventHandler("playerOnClick",root,playerOnClick)
but of course, If you can recommend a better way than what I did please feel free to share your opinion I would very much appreciate it.