StaaaR Posted March 2, 2018 Share Posted March 2, 2018 Now I want to add key in script Make the player press button 1 or 2 or 3 down the car in order window just it cilent local client = getLocalPlayer() local rootElement = getRootElement() local theMarker = nil vehicle_selector_window = guiCreateWindow(0.3555,0.2318,0.3027,0.4479,"Vehicles Spawners",true) guiWindowSetSizable(vehicle_selector_window,false) guiSetVisible(vehicle_selector_window,false) vehicle_selector_grid = guiCreateGridList(0.029,0.0698,0.9419,0.7762,true,vehicle_selector_window) guiGridListAddColumn(vehicle_selector_grid,"Vehicle name:",0.9) vehicle_selector_select = guiCreateButton(0.1194,0.8779,0.3194,0.0756,"Spawn",true,vehicle_selector_window) vehicle_selector_close = guiCreateButton(0.5742,0.8808,0.3194,0.0756,"Close",true,vehicle_selector_window) addEventHandler("onClientGUIClick",rootElement, function () if (source == vehicle_selector_close) then guiSetVisible(vehicle_selector_window,false) showCursor(false) elseif (source == vehicle_selector_select) then local row,col = guiGridListGetSelectedItem(vehicle_selector_grid) if row and col and row ~= -1 and col ~= -1 then local vehicleName = guiGridListGetItemText(vehicle_selector_grid, row, col) triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) guiSetVisible(vehicle_selector_window,false) showCursor(false) end end end) addEvent("show_vehicle_selector",true) addEventHandler("show_vehicle_selector",rootElement, function (vehiclesTable,marker) theMarker = marker guiSetVisible(vehicle_selector_window,true) showCursor(true) guiGridListClear(vehicle_selector_grid) for i,v in pairs(vehiclesTable) do local row = guiGridListAddRow(vehicle_selector_grid) guiGridListSetItemText(vehicle_selector_grid, row, 1, getVehicleNameFromModel(v), false, false) end end) server local rootElement = getRootElement() local markers = {} local playerVehicles = {} local playerTrailers = {} local lawTeams = {["Police"] = true, ["SWAT"] = true, ["Military"] = true, ["Staff"] = true} local vehiclesTable = { {{"SWAT"}, 2291.08, 2477.57, 9.82, 0, 0, 240, 150, {546,560,601,490,528,427,522}, 180, "Job",0}, {{"SWAT"}, 1602.12, -1613.41, 12.53, 0, 0, 240, 150, {546,560,601,490,528,427,522}, 90, "Job",0}, {{"SWAT"}, -1622.34, 651.49, 6.19, 0, 0, 240, 150, {546,560,601,490,528,427,522}, 0, "Job",0}, {{"Military"}, 1602.36, -1620.58, 12.53, 0, 102, 0, 150, {546,560,601,490,528,427,522}, 90, "Job",0}, } addEventHandler("onResourceStart", resourceRoot, function () for i,v in pairs(vehiclesTable) do local marker = createMarker(tostring(v[2]), tostring(v[3]), tostring(v[4]), "cylinder", 2, tostring(v[5]), tostring(v[6]), tostring(v[7]), tostring(v[8]), rootElement) setElementDimension ( marker, tostring(v[12]) ) if marker then markers[marker] = {v[1], v[9], v[10], v[11], v[12]} addEventHandler("onMarkerHit", marker, onSpawnerMarkerHit) setElementData(marker,"teamMarker",true) end end end) function onSpawnerMarkerHit(hitPlayer, matchingDimension) if not matchingDimension then return end if getElementType(hitPlayer) == "player" then if isPedInVehicle(hitPlayer) then return end local markerTeam = getElementData(source,"teamMarker") if not markerTeam then return end local teamName = getElementData(hitPlayer,tostring(markers[source][4])) if not teamName then return end for i,v in pairs(markers[source][1]) do if v == teamName then triggerClientEvent(hitPlayer,"show_vehicle_selector",hitPlayer,markers[source][2],source) end end end end addEvent("vehicle_spawn",true) addEventHandler("vehicle_spawn",rootElement, function (player, vehicleID, marker) if isElement(playerVehicles[player]) then destroyElement(playerVehicles[player]) end if isElement(playerTrailers[player]) then destroyElement(playerTrailers[player]) end local x, y, z = getElementPosition(marker) playerVehicles[player] = createVehicle(vehicleID, x, y, z+3, 0, 0, markers[marker][3]) local r, g, b = getMarkerColor(marker) setVehicleColor( playerVehicles[player], r, g, b ) warpPedIntoVehicle(player, playerVehicles[player]) if ( exports.NGVIP:isPlayerVIP ( player ) ) then addVehicleUpgrade ( playerVehicles[player], 1010 ) end setElementData(playerVehicles[player],"allowedRoles",markers[marker][1]) setElementData(playerVehicles[player],"allowedData",markers[marker][4]) if markers[marker][5] then playerTrailers[player] = createVehicle(markers[marker][4], x-9, y, z + 3, 0, 0, markers[marker][3]) if playerTrailers[player] then setElementData(playerVehicles[player],"trailer",playerTrailers[player]) addEventHandler("onVehicleExplode",playerTrailers[player],function () if isElement(source) then destroyElement(source) end end) end end addEventHandler("onVehicleExplode",playerVehicles[player],function () if isElement(source) then if getElementData(source,"trailer") and isElement(getElementData(source,"trailer")) then destroyElement(getElementData(source,"trailer")) end destroyElement(source) end end) end) function vehicleEnterCheck(player, seat, jacked) if (seat ~= 0) then return end local allowedRoles = getElementData(source, "allowedRoles") if not allowedRoles or not type(allowedRoles) == "table" then return end local allowedData = getElementData(source, "allowedData") local teamName = getElementData(player, tostring(allowedData)) if not teamName then return end local tempTable = {} for index, role in ipairs(allowedRoles) do tempTable[role] = true end local driver = getVehicleController(source) local wanted = 0 if (driver) then wanted = getPlayerWantedLevel(driver) end if (tempTable[teamName] or lawTeams[getTeamName(getPlayerTeam(player))] and wanted > 1) then return else cancelEvent() exports["NGMessages"]:sendClientMessage("You cannot enter this vehicle.", player, 255, 100, 0) end end addEventHandler("onVehicleStartEnter",root,vehicleEnterCheck) function onLogoutOrQuit() if isElement(playerVehicles[source]) then destroyElement(playerVehicles[source]) end if isElement(playerTrailers[source]) then destroyElement(playerTrailers[source]) end end addEventHandler("onPlayerLogout",root,onLogoutOrQuit) addEventHandler("onPlayerQuit",root,onLogoutOrQuit) Link to comment
Storm-Hanma Posted March 2, 2018 Share Posted March 2, 2018 Then use bind function ,and what down mean spawn the car ? 1 Link to comment
AserOsama Posted March 2, 2018 Share Posted March 2, 2018 use bindKey warpPedIntoVehicle Link to comment
alonemta Posted March 3, 2018 Share Posted March 3, 2018 What this belongs for ?vehicles panel? Link to comment
StaaaR Posted March 3, 2018 Author Share Posted March 3, 2018 5 hours ago, alonemta said: What this belongs for ?vehicles panel? I want a way to get off the car using the buttons I do not want using the mouse 20 hours ago, Khadeer143 said: Then use bind function ,and what down mean spawn the car ? I want a way to get off the car using the buttons I do not want using the mouse 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