yousseftawab Posted August 31, 2012 Share Posted August 31, 2012 I made spawn markers it's supposed that when you spawn a car it gets spawned with a certain rotation and with certain colors and if you spawn another car it still does the same functions but it destorys the previous car. My problem is: 1. it spawns the car with the 1st color only I need to make it with the 2 colors 2.it spawns cars from all markers not just this marker in the same rotation. example: I have four medic spawn markers they all spawn in the same rotation 3.When I edit the script to make each marker spawn in it's own rotation, when I spawn the previous car doesn't get destroyed. Client: local marker = createMarker(429, -1904, 2, 'cylinder', 1.5, 10, 10, 200, 200) local vehicles = {"Rancher", "HPV1000", "Police LV", "Police LS", "Police SF", "S.W.A.T.", "Police Ranger", "Enforcer", "Cheetah"} function createVehGui () MainGui = guiCreateWindow(408,203,240,349,"SWAT Spawn Marker",false) guiWindowSetSizable ( MainGui, false ) VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) guiGridListSetSelectionMode(VehGrid,2) _bikes = guiGridListAddColumn(VehGrid,"Vehicles",0.85) Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) guiSetFont(Spawn,"clear-normal") Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) guiSetFont(Cancel,"clear-normal") for index, vehicle in ipairs(vehicles) do local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) end end addEventHandler ( "onClientMarkerHit", marker, function ( hitElement ) if ( getTeamName(getPlayerTeam(hitElement)) == "SWAT Team") then if not isPedInVehicle ( hitElement ) then if isPedOnGround (hitElement) then if ( hitElement == localPlayer ) then createVehGui ( hitElement ) if ( MainGui ~= nil ) then guiSetVisible ( MainGui, true ) showCursor ( true ) guiSetInputEnabled ( true ) setElementFrozen ( hitElement, true ) end end end end end end ) addEventHandler("onClientGUIClick", root, function () if (source == Spawn) 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 == "Rancher" then triggerServerEvent("spawnvehicleSWAT",localPlayer,490) elseif vehicleName == "HPV1000" then triggerServerEvent("spawnvehicleSWAT",localPlayer,523) elseif vehicleName == "Police LV" then triggerServerEvent("spawnvehicleSWAT",localPlayer,598) elseif vehicleName == "Police LS" then triggerServerEvent("spawnvehicleSWAT",localPlayer,596) elseif vehicleName == "Police SF" then triggerServerEvent("spawnvehicleSWAT",localPlayer,597) elseif vehicleName == "S.W.A.T." then triggerServerEvent("spawnvehicleSWAT",localPlayer,601) elseif vehicleName == "Police Ranger" then triggerServerEvent("spawnvehicleSWAT",localPlayer,599) elseif vehicleName == "Enforcer" then triggerServerEvent("spawnvehicleSWAT",localPlayer,427) elseif vehicleName == "Cheetah" then triggerServerEvent("spawnvehicleSWAT",localPlayer,415) end else outputChatBox("Error: Please, select a vehicle of list.",255,0,0) end elseif (source == Cancel) then triggerEvent("closeWindow", root ) end end ) addEventHandler("onClientMarkerLeave", marker, function () triggerEvent("closeWindow", root ) end ) addEvent("closeWindow", true) addEventHandler("closeWindow", root, function () guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) setElementFrozen(localPlayer, false) end ) Server: local vehicles = { } addEvent ( "spawnvehicleSWAT", true ) addEventHandler ( "spawnvehicleSWAT", root, function ( vehID ) if ( isElement ( vehicles [ source ] ) ) then destroyElement ( vehicles [ source ] ) end vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) if ( vehicles [ source ] ) then setVehicleColor ( vehicles [ source ], 10, 10, 200 ) setVehicleRotation ( vehicles [ source ], 0, 0, 0 ) end setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) triggerClientEvent ( source, "closeWindow", root ) end ) and here is another marker just in-case: Client: local marker = createMarker(1598.6999511719, -1626.4000244141, 12.5, 'cylinder', 1.5, 55, 97, 255, 200) local vehicles = {"Police LS", "Police SF","Police LV","Police Ranger"} function createVehGui () MainGui = guiCreateWindow(408,203,240,349,"Police Spawn",false) guiWindowSetSizable ( MainGui, false ) VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) guiGridListSetSelectionMode(VehGrid,2) _bikes = guiGridListAddColumn(VehGrid,"Vehicles",0.85) Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) guiSetFont(Spawn,"clear-normal") Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) guiSetFont(Cancel,"clear-normal") for index, vehicle in ipairs(vehicles) do local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) end end addEventHandler ( "onClientMarkerHit", marker, function ( hitElement ) if ( getTeamName(getPlayerTeam(hitElement)) == "Police Service") then if not isPedInVehicle ( hitElement ) then if isPedOnGround ( hitElement ) then if ( hitElement == localPlayer ) then createVehGui ( hitElement ) if ( MainGui ~= nil ) then guiSetVisible ( MainGui, true ) showCursor ( true ) guiSetInputEnabled ( true ) setElementFrozen ( hitElement, true ) end end end end end end ) addEventHandler("onClientGUIClick", root, function () if (source == Spawn) 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 == "Police LV" then triggerServerEvent("spawnvehiclePOL",localPlayer,598) elseif vehicleName == "Police LS" then triggerServerEvent("spawnvehiclePOL",localPlayer,596) elseif vehicleName == "Police SF" then triggerServerEvent("spawnvehiclePOL",localPlayer,601) elseif vehicleName == "Police Ranger" then triggerServerEvent("spawnvehiclePOL",localPlayer,599) end else outputChatBox("Error: Please, select a vehicle of list.",255,0,0) end elseif (source == Cancel) then triggerEvent("closeWindow", root ) end end ) addEventHandler("onClientMarkerLeave", marker, function () triggerEvent("closeWindow", root ) end ) addEvent("closeWindow", true) addEventHandler("closeWindow", root, function () guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) setElementFrozen(localPlayer, false) end ) Server: local vehicles = { } addEvent ( "spawnvehiclePOL", true ) addEventHandler ( "spawnvehiclePOL", root, function ( vehID ) if ( isElement ( vehicles [ source ] ) ) then destroyElement ( vehicles [ source ] ) end vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) if ( vehicles [ source ] ) then setVehicleColor ( vehicles [ source ], 0, 0, 0 ) setVehicleRotation ( vehicles [ source ], 0, 0, 0 ) end setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) triggerClientEvent ( source, "closeWindow", root ) end ) 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