mr.ekoo Posted May 21, 2013 Author Share Posted May 21, 2013 مو شغال اخوي الكود -- Server Side -- lowspedMarker = createMarker (1808.0489501953, -2164.6923828125, 13.3828125, "cylinder", 20.0, 0, 0, 255, 0) stopspedMarker = createMarker (1787.9403076172, -2164.2365722656, 13.3828125, "cylinder", 20.0, 0, 0, 255, 0) addEventHandler("onMarkerHit",lowspedMarker, function ( player ) if ( getElementType ( player ) == "player" and isPedInVehicle ( player ) and getElementSpeed(player, "kph")) then setElementSpeed(player, "kph", 30) end end,false ) addEventHandler("onMarkerHit",stopspedMarker, function ( player ) if ( getElementType ( player ) == "player" and isPedInVehicle ( player ) and getElementSpeed(player, "kph")) then setElementSpeed(player, "kph", 0) end end,false ) Link to comment
iPrestege Posted May 21, 2013 Share Posted May 21, 2013 -- # Server Side ... function setElementSpeed(element, unit, speed) -- only work if element is moving! if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then -- if true - element is valid, no need to check again local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) return true end return false end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end local lowspedMarker = createMarker (1808.0489501953, -2164.6923828125, 13.3828125, "cylinder", 20.0, 0, 0, 255, 0) local stopspedMarker = createMarker (1787.9403076172, -2164.2365722656, 13.3828125, "cylinder", 20.0, 0, 0, 255, 0) addEventHandler("onMarkerHit",lowspedMarker, function ( vehicle ) if ( getElementType ( vehicle ) == "vehicle" ) then setElementSpeed(vehicle, "kph", 30) end end,false ) addEventHandler("onMarkerHit",stopspedMarker, function ( vehicle ) if ( getElementType ( vehicle ) == "vehicle" ) then setElementSpeed(vehicle, "kph", 0) end end,false ) Link to comment
кιηg-αвα∂у Posted May 21, 2013 Share Posted May 21, 2013 مو شغال اخويالكود -- Server Side -- lowspedMarker = createMarker (1808.0489501953, -2164.6923828125, 13.3828125, "cylinder", 20.0, 0, 0, 255, 0) stopspedMarker = createMarker (1787.9403076172, -2164.2365722656, 13.3828125, "cylinder", 20.0, 0, 0, 255, 0) addEventHandler("onMarkerHit",lowspedMarker, function ( player ) if ( getElementType ( player ) == "player" and isPedInVehicle ( player ) and getElementSpeed(player, "kph")) then setElementSpeed(player, "kph", 30) end end,false ) addEventHandler("onMarkerHit",stopspedMarker, function ( player ) if ( getElementType ( player ) == "player" and isPedInVehicle ( player ) and getElementSpeed(player, "kph")) then setElementSpeed(player, "kph", 0) end end,false ) جرب tM = createMarker( ..... ) addEventHandler('onMarkerHit', tM, function( tV ) if getElementType( tV ) == 'vehicle' then setElementSpeed( tV, 'kph', 30 ) end end ) function setElementSpeed(element, unit, speed) -- only work if element is moving! if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then -- if true - element is valid, no need to check again local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) return true end return false end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end Link to comment
mr.ekoo Posted May 21, 2013 Author Share Posted May 21, 2013 جربت كود #Mr.Pres[T]ege , وشغال 100% مشكورين على المساعدة 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