The problem is that you should check if the hit player is the local player.
And the problem with the buttons not showing is that you are using the wrong tables.
GUIEditor = {
gridlist = {},
window = {},
button = {},
label = {}
}
car = {
{569},
{597},
{598},
{599}
}
local teamName = "police"
local marker = createMarker( -1604, 650, 7, "cylinder", 1.5, 0, 0, 255, 150 )
local marker2 = createMarker( -1629, 651, 7, "cylinder", 1.5, 0, 0, 255, 150 )
local marker3 = createMarker( -1600, 752, -5, "cylinder", 1.5, 0, 0, 255, 150 )
local marker4 = createMarker( 1598, -1609, 13, "cylinder", 1.5, 0, 0, 255, 150 )
local marker5 = createMarker( 1604, -1688, 5, "cylinder", 1.5, 0, 0, 255, 150 )
local marker6 = createMarker( 1583, -1410, 5, "cylinder", 1.5, 0, 0, 255, 150 )
local marker7 = createMarker( 2274, 2242, 10, "cylinder", 1.5, 0, 0, 255, 150 )
local marker8 = createMarker( 2272, 2478, 10, "cylinder", 1.5, 0, 0, 255, 150 )
GUIEditor.window[1] = guiCreateWindow(251,166,290,342,"Job vehicle", false)
guiSetVisible(GUIEditor.window[1],false)
GUIEditor.label[1] = guiCreateLabel(10,23,262,26,"Choose a car then click Spawn vehicle .", false, GUIEditor.window[1])
GUIEditor.gridlist[1] = guiCreateGridList(9,49,263,227, false, GUIEditor.window[1])
guiGridListSetSelectionMode(GUIEditor.gridlist[1],2)
guiGridListAddColumn(GUIEditor.gridlist[1],"vehicle name",60)
GUIEditor.button[1] = guiCreateButton(9,296,69,34,"Spawn Vehicle",false,GUIEditor.window[1])
GUIEditor.button[2] = guiCreateButton(152,291,129,41,"Close",false,GUIEditor.window[1])
for i,v in ipairs (car) do
local carName = getVehicleNameFromModel (v[1])
local row = guiGridListAddRow (GUIEditor.gridlist[1])
guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, carName, false, true)
end
function onClientClick (button, state, absoluteX, absoluteYe)
if (source == GUIEditor.button[1]) then
if (guiGridListGetSelectedItem (GUIEditor.gridlist[1])) then
local cars = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 1)
triggerServerEvent ("cars", getLocalPlayer(), cars)
end
end
end
addEventHandler ("onClientGUIClick", GUIEditor.button[1], onClientClick)
function onClientClick (button, state, absoluteX, absoluteYe)
if (source == GUIEditor.button[2]) then
guiSetVisible(GUIEditor.window[1],true)
showCursor(false)
end
end
addEventHandler ("onClientGUIClick", GUIEditor.button[2], onClientClick)
addEventHandler("onClientMarkerHit", marker,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)
addEventHandler("onClientMarkerHit", marker2,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker2) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)
addEventHandler("onClientMarkerHit", marker3,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker3) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)
addEventHandler("onClientMarkerHit", marker4,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker4) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)
addEventHandler("onClientMarkerHit", marker5,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker5) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
warnText("You are not police to have vehicle !!!",source,0,255,0)
end
end
end
)
addEventHandler("onClientMarkerHit", marker6,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker6) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)
addEventHandler("onClientMarkerHit", marker7,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker7) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)
addEventHandler("onClientMarkerHit", marker8,
function ( hitPlayer, matchingDimension )
if ( hitPlayer == localPlayer and isElementWithinMarker(hitPlayer, marker8) ) then
if ( getTeamName( getPlayerTeam( hitPlayer ) ) == teamName ) then
if getElementType(hitPlayer) == "player" then
guiSetVisible ( GUIEditor.window[1], true )
showCursor(false)
end
else
outputChatBox ( "you are not in the team", player, 255, 0, 0, true )
end
end
end
)