local marker = createMarker(1183.9000244141, -1331, 12.5, 'cylinder', 1.5, 255, 255, 255, 155)
local vehicles = {"BMX", "Bike", "Mountain Bike", "Faggio"}
function createVehGui ()
wnd = guiCreateWindow(0.39,0.1633,0.21,0.55,"Free Vehicles",true)
guiSetAlpha(CIGwnd,1)
guiWindowSetSizable(CIGwnd,false)
VehGrid = guiCreateGridList(0.0536,0.1394,0.8869,0.6273,true,wnd)
guiGridListSetSelectionMode(VehGrid,2)
_bikes = guiGridListAddColumn(VehGrid,"Vehicles name:",0.
Spownbtn = guiCreateButton(0.1667,0.7939,0.6905,0.0727,"Spown",true,wnd)
guiSetFont(Spownbtn,"clear-normal")
closebtn = guiCreateButton(0.1667,0.9,0.6905,0.0727,"Close",true,wnd)
guiSetFont(closebtn,"clear-normal")
for index, vehicle in ipairs(vehicles) do
local row = guiGridListAddRow (VehGrid)
guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false )
end
end
function markerspown( hitElement )
if ( hitElement == localPlayer ) then
createVehGui ( hitElement )
if ( wnd ~= nil ) then
guiSetVisible ( wnd, true )
showCursor ( true )
guiSetInputEnabled ( true )
setElementFrozen ( hitElement, true )
end
end
end
addEventHandler ( "onClientMarkerHit", marker, markerspown)
addEventHandler("onClientGUIClick", root,
function ()
if (source == Spownbtn) then
local row,col = guiGridListGetSelectedItem(VehGrid)
if (row and col and row ~= -1 and col ~= -1) then
local vehicleName = guiGridListGetItemText(VehGrid, row, 1)
if vehicleName == "BMX" then
triggerServerEvent("spawnvehicle",localPlayer,481)
elseif vehicleName == "Bike" then
triggerServerEvent("spawnvehicle",localPlayer,509)
elseif vehicleName == "Mountain Bike" then
triggerServerEvent("spawnvehicle",localPlayer,510)
elseif vehicleName == "Faggio" then
triggerServerEvent("spawnvehicle",localPlayer,462)
end
else
outputChatBox("Please,select a vehicle of the list.",255,0,0)
end
elseif (source == closebtn) then
triggerEvent("closeWindow", root )
end
end
)
addEventHandler("onClientGUIDoubleClick", root,
function ()
if ( source == VehGrid ) then
local row,col = guiGridListGetSelectedItem(VehGrid)
if (row and col and row ~= -1 and col ~= -1) then
local vehicleName = guiGridListGetItemText(VehGrid, row, 1)
if vehicleName == "BMX" then
triggerServerEvent("spawnvehicle",localPlayer,509)
elseif vehicleName == "Bike" then
triggerServerEvent("spawnvehicle",localPlayer,481)
end
end
end
end
)
addEventHandler("onClientMarkerLeave", marker,
function ()
triggerEvent("closeWindow", root )
end
)
addEvent("closeWindow", true)
addEventHandler("closeWindow", root,
function ()
guiSetVisible(wnd, false)
showCursor(false)
guiSetInputEnabled(false)
setElementFrozen(localPlayer, false)
end
)