Woovie Posted August 30, 2009 Share Posted August 30, 2009 A script I've had for a while written by me and OffRoader23. Decided to release it. Here you go: ramps.lua ramp = {} rampid = {} function spawnRamp (player) if (isPedInVehicle( player ) == true) then local vehicle = getPedOccupiedVehicle ( player ) local speed = getPlayerSpeed ( player, 2 ) speed = speed / 12 local px, py, pz = getElementPosition ( vehicle ) local rx, ry, rz = getVehicleRotation ( vehicle ) local pingdis = getPlayerPing ( player ) / 20 if rx > 180 then rx = rx - 360 end local x = (speed + 15 + pingdis)*math.cos((rz+90)*math.pi/180) local y = (speed + 15 + pingdis)*math.sin((rz+90)*math.pi/180) local a2 = (speed + 15 + pingdis) local b2 = a2 / math.cos(rx*math.pi/180) local c2 = math.sqrt(b2*b2 - a2*a2) if rx < 0 then c2 = -c2 end local nx = px + x local ny = py + y local carseat = getPedOccupiedVehicleSeat ( player ) if carseat ~= 0 then --if player is not driving outputConsole ( "No ramp spawning as passenger.", player ) else --if player is driver if rampid[player] == 0 then outputConsole ( "Ramp disabled. Type /setramp 1-7 to restore.", player ) elseif rampid[player] == nil or rampid[player] == 1 then ramp = createObject ( 1632, nx, ny, pz + c2, rx, ry, rz ) setTimer ( deleteRamp, 10000, 1, ramp ) elseif rampid[player] == 2 then ramp = createObject ( 1655, nx, ny, pz + c2, 0, 0, rz ) setTimer ( deleteRamp, 10000, 1, ramp ) elseif rampid[player] == 3 then ramp = createObject ( 13641, nx, ny, pz + c2, 0, 0, rz + 90) setTimer ( deleteRamp, 10000, 1, ramp ) elseif rampid[player] == 4 then ramp = createObject ( 1660, nx, ny, pz + c2 - 1.5, 0, 0, rz ) setTimer ( deleteRamp, 10000, 1, ramp ) elseif rampid[player] == 5 then ramp = createObject ( 1631, nx, ny, pz + c2, 0, 0, rz ) setTimer ( deleteRamp, 10000, 1, ramp ) elseif rampid[player] == 6 then ramp = createObject ( 4870, nx, ny, pz - 1.5, 0, 0, rz - 90 ) setTimer ( deleteRamp, 10000, 1, ramp ) elseif rampid[player] == 7 then ramp = createObject ( 4870, nx, ny, pz + c2 - 1.5, 0, 15, rz - 90 ) setTimer ( deleteRamp, 10000, 1, ramp ) end end end end addCommandHandler ( "ram", spawnRamp) function setRamp (player, commandname, numb) local rampnum = tonumber(numb) if rampnum >= 1 and rampnum <= 7 then outputChatBox ( "Ramp set as " ..numb.. ".", player ) rampid[player] = rampnum else outputChatBox ( "Ramp disabled. Type /setramp 1-7 to restore.", player ) rampid[player] = 0 end end addCommandHandler ( "setramp", setRamp) function getPlayerSpeed( source, mode ) if (isPedInVehicle( source ) == true) then vehicle = getPedOccupiedVehicle( source ) if (mode == "MPH" or mode == 1) then return math.floor(getDistanceBetweenPoints3D(0,0,0,getElementVelocity(vehicle)) * 100 * 1.14) end if (mode == "KMH" or mode == 2) then return math.floor(getDistanceBetweenPoints3D(0,0,0,getElementVelocity(vehicle)) * 100 * 1.61 * 1.14) end else return 0 end end function deleteRamp ( ramp, player ) destroyElement ( ramp ) end function playerJoin () bindKey ( source, "num_0", "down", spawnRamp, "Spawn Ramp N Shit Yo" ) bindKey ( source, "lalt", "down", spawnRamp, "Spawn Ramp N Shit Yo" ) bindKey ( source, "mouse4", "down", spawnRamp, "Spawn Ramp N Shit Yo" ) rampid[source] = 1 end function playerLeave () if rampid[source] ~= nil then rampid[source] = nil end end function thisResourceStart () local players = getElementsByType ( "player" ) for k,v in ipairs(players) do bindKey ( v, "num_0", "down", spawnRamp, "Spawn Ramp N Shit Yo" ) bindKey ( v, "lalt", "down", spawnRamp, "Spawn Ramp N Shit Yo" ) bindKey ( v, "mouse4", "down", spawnRamp, "Spawn Ramp N Shit Yo" ) rampid[v] = 1 end end local thisResourceRoot = getResourceRootElement(getThisResource()) addEventHandler ( "onResourceStart", thisResourceRoot, thisResourceStart ) addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) addEventHandler ( "onPlayerQuit", getRootElement(), playerLeave ) meta.xml <meta> <info author="Woovie" version="1" name="Ramp Spawning Script" description="Press left ALT to spawn a ramp" type="script"/> <script src="ramps.lua" /> </meta> Link to comment
cokacola Posted August 30, 2009 Share Posted August 30, 2009 thanks tried it out, but i added a bindKey so when i press ']' on the keyboard a ramp spawned, was fun Link to comment
Risky-Firsky Posted March 5, 2011 Share Posted March 5, 2011 if i spawning ramp every one can see ? Link to comment
GerardWay Posted April 10, 2011 Share Posted April 10, 2011 it just says couldnt find meta.xml...so on Link to comment
CowTurbo Posted April 10, 2011 Share Posted April 10, 2011 lol, you have to make different files. ramp.lua and meta.xml Link to comment
GerardWay Posted April 11, 2011 Share Posted April 11, 2011 lol, you have to make different files. ramp.lua and meta.xml i know but is it a notepad document that i do meta.xml in if so it doesnt work!!!! Link to comment
Xierra Posted April 16, 2011 Share Posted April 16, 2011 *sigh* To change the format of the document, click tools, then press "Folder Options". After you open it, go to the "view" tab. Find the "Hide extension for known file types", then untick that box. After that, you can find the extensions for each file. Now you can easily change txt. to xml. by simply renaming it. meta.txt --> meta.xml (Windows XP, may be different in future versions) Link to comment
Evildropbear Posted May 2, 2011 Share Posted May 2, 2011 Thank you, this is awesome, saw it on another server once where I had so much fun with it. I'm not a scripter myself, but I was wondering if I could request a small modification from somebody. If left alt spawns a ramp infront of the player depending on which angle he is facing, would it be difficult to modify the script so that another key could be binded to spawn a ramp infront of the player, but have the same Y axis. (so that e.g. if your in the air on a bike angled upwards, the ramp doesn't spawn above you) Even if my request is ignored thanks for the script again. Link to comment
Nitride Posted August 16, 2011 Share Posted August 16, 2011 How do you change the activation key. This scrip ROCKS . Thank you so much Link to comment
Benevolence Posted August 17, 2011 Share Posted August 17, 2011 What exactly is it for? I'd like to know more. Link to comment
Castillo Posted August 17, 2011 Share Posted August 17, 2011 "Ramp spawning" It's kinda self explained... it spawns a ramp infront of your vehicle. Link to comment
Benevolence Posted August 17, 2011 Share Posted August 17, 2011 "Ramp spawning"It's kinda self explained... it spawns a ramp infront of your vehicle. Thought so, just hoped it'd be something more since I can already do this with map editor.... Link to comment
Castillo Posted August 17, 2011 Share Posted August 17, 2011 Do this with map editor? I didn't know map editor could create this kind of script , do you know what does this? have you even started the resource? Link to comment
Nitride Posted August 17, 2011 Share Posted August 17, 2011 (edited) How do you change the activation key. This scrip ROCKS . Thank you so much Edited August 17, 2011 by Guest Link to comment
Castillo Posted August 17, 2011 Share Posted August 17, 2011 bindKey ( v, "num_0", "down", spawnRamp, "Spawn Ramp N :~ Yo" ) bindKey ( v, "lalt", "down", spawnRamp, "Spawn Ramp N :~ Yo" ) bindKey ( v, "mouse4", "down", spawnRamp, "Spawn Ramp N :~ Yo" ) Link to comment
Nitride Posted August 17, 2011 Share Posted August 17, 2011 Can I change any line. Do I change the word in between the v and the down to change 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