hulpje Posted July 24, 2012 Share Posted July 24, 2012 Im not good with scripts but im using some scripts other people made (thank you) for my (race) maps. Now I have found a script on this forum https://forum.multitheftauto.com/viewtopic.php?f=91&t=30975 that exactly does what I want: Speedboost: function start() Speedboost = { createMarker (-3004,-841,0.11,"corona",10,255,0,0,105), } end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), start ) Multiplier = 5.0 function SpeedBoost (player) if player ~= getLocalPlayer() then return end if getElementType(player) == "player" then if isPedInVehicle ( player ) then local car = getPedOccupiedVehicle(player) if getVehicleController(car) == player then speedx, speedy, speedz = getElementVelocity ( car ) speedcnx = (speedx*Multiplier) speedcny = (speedy*Multiplier) speedcnz = (speedz*Multiplier) setElementVelocity ( car, speedcnx, speedcny,speedcnz ) fixVehicle(car) playSoundFrontEnd(46) end end end end addEventHandler ( "onClientMarkerHit", getResourceRootElement(getThisResource()), SpeedBoost ) And give my car a little bounce (changing Z) (same script actually:) function start() Speedboost = { createMarker (-3374,-837,19.5,"corona",10,255,0,0,105), } end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), start ) Multiplier = 1.5 function SpeedBoost (player) if player ~= getLocalPlayer() then return end if getElementType(player) == "player" then if isPedInVehicle ( player ) then local car = getPedOccupiedVehicle(player) if getVehicleController(car) == player then speedx, speedy, speedz = getElementVelocity ( car ) speedcnx = (speedx*Multiplier) speedcny = (speedy*Multiplier) speedcnz = (speedz*Multiplier) setElementVelocity ( car, speedcnx, speedcny,speedcnz+0.2 ) fixVehicle(car) playSoundFrontEnd(46) end end end end addEventHandler ( "onClientMarkerHit", getResourceRootElement(getThisResource()), SpeedBoost ) problem is both scripts work fine stand-alone but get confused with each other when I place them together in a map. I tried search for some other scripts but they don't work or bounce my car is a preset X,Y,Z (while I want it to bounce to the direction I drive). I searched on forum and tried to add some marker1, marker2 and stuff, also tried to add something with "If == then" but I just can't figure it out. If someone could help me with making both scripts work in 1 map would be really awsome. Link to comment
Dev Posted July 24, 2012 Share Posted July 24, 2012 Change the names of the following in ONE of the above mentioned scripts: 1. function attached to the onClientResourceStart event. 2. function attached to the onClientMarkerHit event. 3. Name of table containing the the marker. Link to comment
hulpje Posted July 24, 2012 Author Share Posted July 24, 2012 thanks, but I don't really understand what to do now yet 1/2- change function "Speedboost" for something I make up (like bounce)? 3 - I don't really understand what I have to do here, is this with marker1 in the location and adding it in OnClientMarkerHit? Link to comment
hulpje Posted July 24, 2012 Author Share Posted July 24, 2012 pls someone help Dev's comments makes it look very easy, but If someone could give me a little push further I'll be happier then mario after safing the princess. Link to comment
qaisjp Posted July 24, 2012 Share Posted July 24, 2012 try this: local unique = md5(math.random(1,999)..'smama') function start() Speedboost = { createMarker (-3004,-841,0.11,"corona",10,255,0,0,105), } for i,v in pairs(Speedboost) do setElementData(v, unique, true, false) end end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), start ) Multiplier = 1.5 function SpeedBoost (player) if player ~= getLocalPlayer() then return end if not getElementData(source, unique) then return end if getElementType(player) == "player" then if isPedInVehicle ( player ) then local car = getPedOccupiedVehicle(player) if getVehicleController(car) == player then speedx, speedy, speedz = getElementVelocity ( car ) speedcnx = (speedx*Multiplier) speedcny = (speedy*Multiplier) speedcnz = (speedz*Multiplier) setElementVelocity ( car, speedcnx, speedcny,speedcnz +0.2) fixVehicle(car) playSoundFrontEnd(46) end end end end addEventHandler ( "onClientMarkerHit", getResourceRootElement(getThisResource()), SpeedBoost ) Link to comment
hulpje Posted July 27, 2012 Author Share Posted July 27, 2012 I tried some more things but failed I think the easiest thing is to make the script react on a specific marker, so add something like "local myMarker4 =" and also add that specific marker in the line of the event handler. I tried adding it myself, but either the corona's became invisible or (and) stopped functioning. If someone could help how to properly add markers in one of the scrips in the first post I would really be grateful >: Link to comment
hulpje Posted July 28, 2012 Author Share Posted July 28, 2012 Thank you qais, I probaly did something wrong because it (somehow) worked this time ^^ But I have one more problem now, When I tried the script in my first post it speedboosted me (first corona) the way I was driving (I didn't had to do anything with setElementVelocity). Now if I dont set a X or Y or Z the corona simply isn't doing anything. Which means I had to set X at setElementVelocity to make it work, but lets say if I want to drive trough the speedboost from another angle it will totally push me the wrong way. Is there a way to change it so it speedboosts me in the direction I drive? (The script that make my car bounce works fine) I add video so you can see what I mean: this is the script (thank you qais) for the speedboost at first corona now: local unique = md5(math.random(1,999)..'smama') function start() Speedboost = { createMarker (-3004,-841,0.11,"corona",10,255,0,0,105), } for i,v in pairs(Speedboost) do setElementData(v, unique, true, false) end end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), start ) Multiplier = 5.0 function SpeedBoost (player) if player ~= getLocalPlayer() then return end if not getElementData(source, unique) then return end if getElementType(player) == "player" then if isPedInVehicle ( player ) then local car = getPedOccupiedVehicle(player) if getVehicleController(car) == player then speedx, speedy, speedz = getElementVelocity ( car ) speedcnx = (speedx*Multiplier) speedcny = (speedy*Multiplier) speedcnz = (speedz*Multiplier) setElementVelocity ( car, speedcnx-1.2,speedcny,speedcnz) fixVehicle(car) playSoundFrontEnd(46) end end end end addEventHandler ( "onClientMarkerHit", getResourceRootElement(getThisResource()), Speed Link to comment
qaisjp Posted July 28, 2012 Share Posted July 28, 2012 (edited) You're welcome. It does it for all markers in that table FYI. Don't use -1.2, use a multiply Edited August 31, 2016 by Guest Link to comment
Al3grab Posted July 28, 2012 Share Posted July 28, 2012 You have some errors .. local unique = md5(math.random(1,999)..'smama') function start() Speedboost = { createMarker (-3004,-841,0.11,"corona",10,255,0,0,105), } for i,v in pairs(Speedboost) do setElementData(v, unique, true, false) end end addEventHandler ( "onClientResourceStart",resourceRoot, start ) Multiplier = 5.0 function SpeedBoost (player) if player ~= getLocalPlayer() then return end if not getElementData(source, unique) then return end if getElementType(player) == "player" then if isPedInVehicle ( player ) then local car = getPedOccupiedVehicle(player) if getVehicleController(car) == player then speedx, speedy, speedz = getElementVelocity ( car ) speedcnx = (speedx*Multiplier) speedcny = (speedy*Multiplier) speedcnz = (speedz*Multiplier) setElementVelocity ( car, speedcnx-1.2,speedcny,speedcnz) fixVehicle(car) playSoundFrontEnd(46) end end end end addEventHandler ( "onClientMarkerHit",root, Speed) Link to comment
hulpje Posted July 28, 2012 Author Share Posted July 28, 2012 thanks qais, I indeed can change the following numbers (×) and it will speedboost me without changing my direction. Multiplier = × speedcnx = (speedx*×) speedcny = (speedy*×) everything works fine in my map editor now, so I guess my problem is solved ^^ @ Al3grab, idk im just using qais script, that one works fine now ^^ Link to comment
qaisjp Posted July 28, 2012 Share Posted July 28, 2012 Thanks thanks and you are welcome 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