capitanazop Posted July 16, 2009 Share Posted July 16, 2009 hi i find in the interstate69 gamemode the "spring" code for jump whit alt key and its work perfectly here the code. function onCarDownResourceStart(resource) bindKey("lalt", "down", jump) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onCarDownResourceStart) function jump(player) local vehicle = getPlayerOccupiedVehicle(getLocalPlayer()) local velx, vely, velz = getElementVelocity(vehicle) setElementVelocity(vehicle, velx, vely, velz+0.3) end but i have 2 question a 1 problem. how i can create a timer for this? i want to set a timer protection for that command, only 1 time each 3 seconds. and make this for player jump, i tried but y think the function setelementvelocity doesnt work whit player. bye and sorry for my english. Link to comment
50p Posted July 16, 2009 Share Posted July 16, 2009 To make it available for players only once/sec then make a timer that changes their data eg. "allowjump". me = getLocalPlayer(); function onCarDownResourceStart(resource) setElementData( me, "allowjump", true ); bindKey("lalt", "down", jump ) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onCarDownResourceStart) function jump(player) if( getElementData( me, "allowjump" ) == true ) then -- can player jump? local vehicle = getPlayerOccupiedVehicle( me ) local velx, vely, velz = getElementVelocity( vehicle ) setElementVelocity( vehicle, velx, vely, velz+0.3 ) setElementData( me, "allowjump", false ) -- disable jumping setTimer( setElementData, 1000, 1, me, "allowjump", true )-- this is the key... allow them to jump after 1sec. -- ... end end Link to comment
capitanazop Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks Man its work! 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