Cyan Posted June 8, 2011 Share Posted June 8, 2011 I need help with Scripting Vehicles Spawns. It should be like: When player goes in a marker to automaticaly get in the vehicle specified in the script. If someone can help me please post it here. Link to comment
Castillo Posted June 8, 2011 Share Posted June 8, 2011 So you want to make like: marker1 = vehicle Infernus? and so on? If so, then use this. markers = {} markers[1] = createMarker(-706, 966, 12, "cylinder", 1, 255, 255, 0, 200) markers[2] = createMarker(-709, 966, 12, "cylinder", 1, 255, 255, 0, 200) vehicles = { [1] = "411", [2] = "432" } function onMarkerHitGiveVehicle(hitPlayer,matchingDimension) for i,v in pairs(markers) do if (source == v) then if getElementType(hitPlayer) == "player" and matchingDimension then local x, y, z = getElementPosition(hitPlayer) vehicle = createVehicle(vehicles[i],x,y,z) warpPedIntoVehicle(hitPlayer,vehicle) end end end end addEventHandler("onMarkerHit",getRootElement(),onMarkerHitGiveVehicle) Link to comment
Cyan Posted June 8, 2011 Author Share Posted June 8, 2011 And how can i set to use that vehicle spawn just for a specified team? Link to comment
Castillo Posted June 9, 2011 Share Posted June 9, 2011 markers = {} markers[1] = createMarker(-706, 966, 12, "cylinder", 1, 255, 255, 0, 200) markers[2] = createMarker(-709, 966, 12, "cylinder", 1, 255, 255, 0, 200) vehicles = { [1] = {"Civilian","411"}, [2] = {"Army","432"} } function onMarkerHitGiveVehicle(hitPlayer,matchingDimension) for i,v in pairs(markers) do if (source == v) then if getElementType(hitPlayer) == "player" and matchingDimension then local team = getPlayerTeam" class="kw2">getPlayerTeam(hitPlayer) if not team then return end local teamName = getTeamName(team) if vehicles[i][1] ~= teamName then return end local x, y, z = getElementPosition(hitPlayer) vehicle = createVehicle(vehicles[i][2],x,y,z) warpPedIntoVehicle(hitPlayer,vehicle) end end end end addEventHandler("onMarkerHit",getRootElement(),onMarkerHitGiveVehicle) Btw, next time try something by yourself first. Link to comment
Baseplate Posted June 16, 2011 Share Posted June 16, 2011 Well Castillo it contains error in the line 14 says it have an infinte string... Link to comment
karlis Posted June 16, 2011 Share Posted June 16, 2011 remove the " " class="kw2">getPlayerTeam "section, thats just lua highlighter bug. Link to comment
[DemoN] Posted June 16, 2011 Share Posted June 16, 2011 Well Castillo it contains error in the line 14 says it have an infinte string... Because it must be like this: local team = getPlayerTeam(hitPlayer) it's not Castillo's mistake. if you use [lua][/lua] it automatically turns it into: local team = getPlayerTeam" class="kw2">getPlayerTeam(hitPlayer) Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 Because you just copy paste without looking -.- If you really want to learn look at the code we give you, try to see what did you do wrong, this way you wont do it again. Copy paste get you in a bad habit, and you won't learn anything. Link to comment
Baseplate Posted June 16, 2011 Share Posted June 16, 2011 well i delete it but there is a bad arguement at getTeamName(team) Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 Wow you deleted the whole line here it is markers = {} markers[1] = createMarker(-706, 966, 12, "cylinder", 1, 255, 255, 0, 200) markers[2] = createMarker(-709, 966, 12, "cylinder", 1, 255, 255, 0, 200) vehicles = { [1] = {"Civilian","411"}, [2] = {"Army","432"} } function onMarkerHitGiveVehicle(hitPlayer,matchingDimension) for i,v in pairs(markers) do if (source == v) then if getElementType(hitPlayer) == "player" and matchingDimension then local team = getPlayerTeam1(hitPlayer) if not team then return end local teamName = getTeamName(team) if vehicles[i][1] ~= teamName then return end local x, y, z = getElementPosition(hitPlayer) vehicle = createVehicle(vehicles[i][2],x,y,z) warpPedIntoVehicle(hitPlayer,vehicle) end end end end addEventHandler("onMarkerHit",getRootElement(),onMarkerHitGiveVehicle) Remove 1 from getPlayerTeam can you do that yourself? Link to comment
Baseplate Posted June 16, 2011 Share Posted June 16, 2011 It works fine now but...I have a jobs system I create it when it is running and go to that marker you spawn as a job and when you desactivate it you can spawn a car..so what I do? Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 (edited) what you mean "desactivate" it? Edited June 16, 2011 by Guest Link to comment
Baseplate Posted June 16, 2011 Share Posted June 16, 2011 NVM here too EDIT:Can you help now?? Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 what you mean by "desactivate" ? quit the team or exits the marker explain better Link to comment
Baseplate Posted June 16, 2011 Share Posted June 16, 2011 I mean when I stop resource from running Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 Only one way you add a handler to onResourceStart to create a marker that sets your team when you hit it, And add a handler to onResourceStop that creates a marker in the same place and give you a car when you hit it. Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 You must use it from another script like this: addEventHandler('onResourceStart', getResourceFromName('markerResource'), ...) and add onResourceStart and stop create a marker that sets your team when you hit it, And add a handler to onResourceStop that changes the handler to a function that will spawn you a vehicle. Link to comment
Cyan Posted June 21, 2011 Author Share Posted June 21, 2011 When someone spawn a vehicle he can spawn another, and another how can i solve this bug? Players will spam with vehicles... Link to comment
Castillo Posted June 21, 2011 Share Posted June 21, 2011 (edited) markers = {} markers[1] = createMarker(-706, 966, 12, "cylinder", 1, 255, 255, 0, 200) markers[2] = createMarker(-709, 966, 12, "cylinder", 1, 255, 255, 0, 200) vehicles = { [1] = {"Civilian","411"}, [2] = {"Army","432"} } playerVehicles = {} function onMarkerHitGiveVehicle(hitPlayer,matchingDimension) for i,v in pairs(markers) do if (source == v) then if getElementType(hitPlayer) == "player" and matchingDimension then local team = getPlayerTeam1(hitPlayer) if not team then return end local teamName = getTeamName(team) if vehicles[i][1] ~= teamName then return end local x, y, z = getElementPosition(hitPlayer) if isElement(playerVehicles[hitPlayer]) then destroyElement(playerVehicles[hitPlayer]) end playerVehicles[hitPlayer] = createVehicle(vehicles[i][2],x,y,z) warpPedIntoVehicle(hitPlayer,playerVehicles[hitPlayer]) end end end end addEventHandler("onMarkerHit",getRootElement(),onMarkerHitGiveVehicle) Edited June 22, 2011 by Guest Link to comment
will briggs Posted June 22, 2011 Share Posted June 22, 2011 SolidSake, Just gunna add this... Error on line 23... warpPedIntoVehicle BadArgument... Thought id identify this to save others doing it 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