Simbad de Zeeman Posted February 14, 2008 Share Posted February 14, 2008 (edited) Ok i saw an old topic where they were talking about spawning ramps, but the problem was ( i tested that scripts ) When 2 players (or more) spawned the ramps at the same time, the first ramp that was spawned didnt disappear. So that means when your server is a populair you will get a lot of ramps in your server that dont disappear. I changed that script a bit, and this script allows you to spawn a ramp which disappears 2 seconds later. Other players can spawn their ramp too at the same time, and all ramps will disappear. Just get a vehicle and push 'c' and BAM... there is a ramp infront of you Here you are -- Somewhere at the top ramp = { } rampspawned = { } --- Put this somewhere in onPlayerJoin event or something, of sterf.. bindKey ( source, "c", "down", createRamp ) -- Somewhere in your script function createRamp ( source ) if(isPlayerInVehicle ( source ) ) then if( rampspawned [ source ] ~= true ) then local x, y, z = getElementPosition ( source ) local theVehicle = getPlayerOccupiedVehicle ( source ) local a,b,r = getVehicleRotation ( theVehicle ) x = x - math.sin ( math.rad(r) ) * 20 y = y + math.cos ( math.rad(r) ) * 20 ramp [ source ] = createObject ( 1655, x, y, z, 0, 0, r ) rampspawned [ source ] = true setTimer ( RemoveRamp, 2000, 1, source ) end end end function RemoveRamp ( source ) destroyramp = destroyElement( ramp [ source ] ) if ( destroyramp ) then rampspawned [ source ] = false end end Edited February 16, 2008 by Guest Link to comment
Tommis Posted February 14, 2008 Share Posted February 14, 2008 Good job. Very handy script. Link to comment
DSC-L|Gr00vE[Ger] Posted February 14, 2008 Share Posted February 14, 2008 sry for this very nooby question but how i can spawn a ramp? Link to comment
Jumba' Posted February 14, 2008 Share Posted February 14, 2008 sry for this very nooby question but how i can spawn a ramp? press c Link to comment
OffRoader23 Posted February 14, 2008 Share Posted February 14, 2008 IMO 1655 is too big of a ramp, I have something like this in my server, it defaults to ramp 1632 which is smaller, but you can /setramp number, and theres no time limit between spawning ramps. It also uses Left Alt, and Numpad 0, and if your flying you can disable it with /setramp 0. 2 Seconds also is WAY too short of a time, mine is 10 sec, but good script for people to build off of. Link to comment
XetaQuake Posted February 14, 2008 Share Posted February 14, 2008 is this server or client side? Link to comment
OffRoader23 Posted February 14, 2008 Share Posted February 14, 2008 If it uses player/source then it's server side. So, server side Link to comment
XetaQuake Posted February 14, 2008 Share Posted February 14, 2008 okok, i have think this already but what the hell, than why dont work this? -- Somewhere at the top ramp = { } rampspawned = { } --- Put this somewhere in onPlayerJoin event or something, of sterf.. function keyboard ( source ) bindKey ( source, "c", "down", createRamp ) end -- Somewhere in your script function createRamp ( source, command ) if(isPlayerInVehicle ( source ) ) then if( rampspawned [ source ] ~= true ) then local x, y, z = getElementPosition ( source ) local theVehicle = getPlayerOccupiedVehicle ( source ) local a,b,r = getVehicleRotation ( theVehicle ) x = x - math.sin ( math.rad(r) ) * 20 y = y + math.cos ( math.rad(r) ) * 20 ramp [ source ] = createObject ( 1655, x, y, z, 0, 0, r ) rampspawned [ source ] = true setTimer ( RemoveRamp, 2000, 1, source ) end end end function RemoveRamp ( source ) destroyramp = destroyElement( ramp [ source ] ) if ( destroyramp ) then rampspawned [ source ] = false end end addEventHandler ( "onPlayerJoin", getRootElement(), keyboard) (debugscript says nothing) Link to comment
Quest Posted February 14, 2008 Share Posted February 14, 2008 (edited) Make sure the script is server side. Also: function keyboard ( source, key, state ) bindKey ( source, "c", "down", createRamp ) end Edited February 14, 2008 by Guest Link to comment
XetaQuake Posted February 14, 2008 Share Posted February 14, 2008 <script src="ramp.lua" type="server" /> yep, it is server side Link to comment
Simbad de Zeeman Posted February 14, 2008 Author Share Posted February 14, 2008 I think, dont know for sure you need to remove 'Source' so it looks like this: function keyboard () Link to comment
Quest Posted February 14, 2008 Share Posted February 14, 2008 No he forgot to mention the key and the state of the key in the function declaration. function keyboard ( source, key, state ) bindKey ( source, "c", "down", createRamp ) end Link to comment
Simbad de Zeeman Posted February 14, 2008 Author Share Posted February 14, 2008 ... why ? its just a "onPlayerJoin" event.. Link to comment
Quest Posted February 14, 2008 Share Posted February 14, 2008 Your right I think it can work both ways. (puts foot in mouth) I forgot that you can leave it blank. I've had a few key binding issues, so I usually do that. Link to comment
XetaQuake Posted February 14, 2008 Share Posted February 14, 2008 I think, dont know for sure you need to remove 'Source'so it looks like this: function keyboard () thanks, now it works it is possibly to remove the blockade to spawn more then one ramp in the same time? 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