Cyan Posted June 8, 2011 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.
Castillo Posted June 8, 2011 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) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Cyan Posted June 8, 2011 Author Posted June 8, 2011 And how can i set to use that vehicle spawn just for a specified team?
Castillo Posted June 9, 2011 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Baseplate Posted June 16, 2011 Posted June 16, 2011 Well Castillo it contains error in the line 14 says it have an infinte string...
karlis Posted June 16, 2011 Posted June 16, 2011 remove the " " class="kw2">getPlayerTeam "section, thats just lua highlighter bug. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
[DemoN] Posted June 16, 2011 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) My in game nick is Lemonade
JR10 Posted June 16, 2011 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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Baseplate Posted June 16, 2011 Posted June 16, 2011 well i delete it but there is a bad arguement at getTeamName(team)
JR10 Posted June 16, 2011 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? Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Baseplate Posted June 16, 2011 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?
JR10 Posted June 16, 2011 Posted June 16, 2011 (edited) what you mean "desactivate" it? Edited June 16, 2011 by Guest Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
JR10 Posted June 16, 2011 Posted June 16, 2011 what you mean by "desactivate" ? quit the team or exits the marker explain better Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
JR10 Posted June 16, 2011 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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
JR10 Posted June 16, 2011 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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Cyan Posted June 21, 2011 Author 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...
Castillo Posted June 21, 2011 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
will briggs Posted June 22, 2011 Posted June 22, 2011 SolidSake, Just gunna add this... Error on line 23... warpPedIntoVehicle BadArgument... Thought id identify this to save others doing it Founder of SAUR - Founder/Owner of ARC RPG
Castillo Posted June 22, 2011 Posted June 22, 2011 Lol, my bad, fixed. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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