nwmafia Posted November 29, 2012 Posted November 29, 2012 I want a script to be able to set the max speed of a vehicle based on it model number. (example of model number for Bufallo = 402). I want this script to be based on km/h. If you know where I can find a script like this, it would be appreciated. If not, if someone could teach me how to script this, it would be ideal as well. Thanks.
Anderl Posted November 29, 2012 Posted November 29, 2012 You can either use onClientRender and check if vehicle's speed goes higher than the maximum you want ( should use a table for these things, if it's multiple vehicles ) and set it to the maximum until the player lets velocity go down ( I think this is not efficient - it might lag - and it's harder ) or use handling. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
nwmafia Posted November 29, 2012 Author Posted November 29, 2012 I don't want to keep track of their speed, I want to set the limit of speed a vehicle can go, let's say the Buffalo goes 180km/h, I want to limit to 140km/h.
Anderl Posted November 29, 2012 Posted November 29, 2012 And what did I just say? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
nwmafia Posted November 30, 2012 Author Posted November 30, 2012 I was asking how to make such script, since I don't know how...
Castillo Posted November 30, 2012 Posted November 30, 2012 I'm not sure, but maybe you can use the handling functions: setVehicleHandling San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
myonlake Posted November 30, 2012 Posted November 30, 2012 I'm not sure, but maybe you can use the handling functions: setVehicleHandling That's alright, but I think this is better since he wants to change all the Buffalos handling setModelHandling If I helped you, please click the like button on the right Thanks!
Anderl Posted November 30, 2012 Posted November 30, 2012 I was asking how to make such script, since I don't know how... And I said how to do it, you just need to search for the right functions. It ain't hard. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
nwmafia Posted December 1, 2012 Author Posted December 1, 2012 The code that Wiki showed me, doesn't work.. function handlingChange() setModelHandling(541, "mass", 1890) setModelHandling(541, "turnMass", 3780) setModelHandling(541, "dragCoeff", 0.7) setModelHandling(541, "centerOfMass", {0.0, 0.1, -0.2} ) setModelHandling(541, "percentSubmerged", 75) setModelHandling(541, "tractionMultiplier", 0.70) setModelHandling(541, "tractionLoss", 0.90) setModelHandling(541, "tractionBias", 0.50) setModelHandling(541, "numberOfGears", 5) setModelHandling(541, "maxVelocity", 407) setModelHandling(541, "engineAcceleration", 50) setModelHandling(541, "engineInertia", 10) setModelHandling(541, "driveType", "awd") setModelHandling(541, "engineType", "petrol") setModelHandling(541, "brakeDeceleration", 11) setModelHandling(541, "brakeBias", 0.45) setModelHandling(541, "ABS", false) setModelHandling(541, "steeringLock", 30) setModelHandling(541, "suspensionForceLevel", 0.80) setModelHandling(541, "suspensionDamping", 0.20) setModelHandling(541, "suspensionHighSpeedDamping", 0.0) setModelHandling(541, "suspensionUpperLimit", 0.10) setModelHandling(541, "suspensionLowerLimit", -0.09) setModelHandling(541, "suspensionFrontRearBias", 0.5) setModelHandling(541, "suspensionAntiDiveMultiplier", 0.6) setModelHandling(541, "seatOffsetDistance", 0.3) setModelHandling(541, "collisionDamageMultiplier", 0.50) setModelHandling(541, "monetary", 1460000) setModelHandling(541, "modelFlags", 0xC0222004) setModelHandling(541, "handlingFlags", 0x1400000) setModelHandling(541, "headLight", 1) setModelHandling(541, "tailLight", 1) setModelHandling(541, "animGroup", 0) end addEventHandler("onResourceStart", resourceRoot, handlingChange)
Blaawee Posted December 1, 2012 Posted December 1, 2012 (edited) function handlingChange( ) local theVehicle = getPedOccupiedVehicle( source ) if theVehicle then if carModel == getElementModel( theVehicle ) and carModel == 541 then setModelHandling( carModel, "mass", 1890 ) setModelHandling( carModel, "turnMass", 3780 ) setModelHandling( carModel, "dragCoeff", 0.7 ) setModelHandling( carModel, "centerOfMass", {0.0, 0.1, -0.2} ) setModelHandling( carModel, "percentSubmerged", 75 ) setModelHandling( carModel, "tractionMultiplier", 0.70 ) setModelHandling( carModel, "tractionLoss", 0.90 ) setModelHandling( carModel, "tractionBias", 0.50 ) setModelHandling( carModel, "numberOfGears", 5 ) setModelHandling( carModel, "maxVelocity", 407 ) setModelHandling( carModel, "engineAcceleration", 50 ) setModelHandling( carModel, "engineInertia", 10 ) setModelHandling( carModel, "driveType", "awd" ) setModelHandling( carModel, "engineType", "petrol" ) setModelHandling( carModel, "brakeDeceleration", 11 ) setModelHandling( carModel, "brakeBias", 0.45 ) setModelHandling( carModel, "ABS", false ) setModelHandling( carModel, "steeringLock", 30 ) setModelHandling( carModel, "suspensionForceLevel", 0.80 ) setModelHandling( carModel, "suspensionDamping", 0.20 ) setModelHandling( carModel, "suspensionHighSpeedDamping", 0.0 ) setModelHandling( carModel, "suspensionUpperLimit", 0.10 ) setModelHandling( carModel, "suspensionLowerLimit", -0.09 ) setModelHandling( carModel, "suspensionFrontRearBias", 0.5 ) setModelHandling( carModel, "suspensionAntiDiveMultiplier", 0.6 ) setModelHandling( carModel, "seatOffsetDistance", 0.3 ) setModelHandling( carModel, "collisionDamageMultiplier", 0.50 ) setModelHandling( carModel, "monetary", 1460000 ) setModelHandling( carModel, "modelFlags", 0xC0222004 ) setModelHandling( carModel, "handlingFlags", 0x1400000 ) setModelHandling( carModel, "headLight", 1 ) setModelHandling( carModel, "tailLight", 1 ) setModelHandling( carModel, "animGroup", 0 ) end end end addEventHandler("onResourceStart", resourceRoot, handlingChange) * Edit Edited December 1, 2012 by Guest
Castillo Posted December 1, 2012 Posted December 1, 2012 That wouldn't work, because "onResourceStart" has no player argument. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Anderl Posted December 1, 2012 Posted December 1, 2012 function handlingChange( ) local theVehicle = getPedOccupiedVehicle( source ) if theVehicle then if carModel == getElementModel( theVehicle ) and carModel == 541 then setModelHandling( carModel, "mass", 1890 ) setModelHandling( carModel, "turnMass", 3780 ) setModelHandling( carModel, "dragCoeff", 0.7 ) setModelHandling( carModel, "centerOfMass", {0.0, 0.1, -0.2} ) setModelHandling( carModel, "percentSubmerged", 75 ) setModelHandling( carModel, "tractionMultiplier", 0.70 ) setModelHandling( carModel, "tractionLoss", 0.90 ) setModelHandling( carModel, "tractionBias", 0.50 ) setModelHandling( carModel, "numberOfGears", 5 ) setModelHandling( carModel, "maxVelocity", 407 ) setModelHandling( carModel, "engineAcceleration", 50 ) setModelHandling( carModel, "engineInertia", 10 ) setModelHandling( carModel, "driveType", "awd" ) setModelHandling( carModel, "engineType", "petrol" ) setModelHandling( carModel, "brakeDeceleration", 11 ) setModelHandling( carModel, "brakeBias", 0.45 ) setModelHandling( carModel, "ABS", false ) setModelHandling( carModel, "steeringLock", 30 ) setModelHandling( carModel, "suspensionForceLevel", 0.80 ) setModelHandling( carModel, "suspensionDamping", 0.20 ) setModelHandling( carModel, "suspensionHighSpeedDamping", 0.0 ) setModelHandling( carModel, "suspensionUpperLimit", 0.10 ) setModelHandling( carModel, "suspensionLowerLimit", -0.09 ) setModelHandling( carModel, "suspensionFrontRearBias", 0.5 ) setModelHandling( carModel, "suspensionAntiDiveMultiplier", 0.6 ) setModelHandling( carModel, "seatOffsetDistance", 0.3 ) setModelHandling( carModel, "collisionDamageMultiplier", 0.50 ) setModelHandling( carModel, "monetary", 1460000 ) setModelHandling( carModel, "modelFlags", 0xC0222004 ) setModelHandling( carModel, "handlingFlags", 0x1400000 ) setModelHandling( carModel, "headLight", 1 ) setModelHandling( carModel, "tailLight", 1 ) setModelHandling( carModel, "animGroup", 0 ) end end end addEventHandler("onResourceStart", resourceRoot, handlingChange) * Edit It still won't work because there's no source neither there is a "carModel" variable. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Blaawee Posted December 2, 2012 Posted December 2, 2012 local myVehicles = { 541 , 507 } addEventHandler("onResourceStart", resourceRoot, function( ) for index, value in ipairs( myVehicles ) do setModelHandling( value, "mass", 1890 ) setModelHandling( value, "turnMass", 3780 ) setModelHandling( value, "dragCoeff", 0.7 ) setModelHandling( value, "centerOfMass", {0.0, 0.1, -0.2} ) setModelHandling( value, "percentSubmerged", 75 ) setModelHandling( value, "tractionMultiplier", 0.70 ) setModelHandling( value, "tractionLoss", 0.90 ) setModelHandling( value, "tractionBias", 0.50 ) setModelHandling( value, "numberOfGears", 5 ) setModelHandling( value, "maxVelocity", 407 ) setModelHandling( value, "engineAcceleration", 50 ) setModelHandling( value, "engineInertia", 10 ) setModelHandling( value, "driveType", "awd" ) setModelHandling( value, "engineType", "petrol" ) setModelHandling( value, "brakeDeceleration", 11 ) setModelHandling( value, "brakeBias", 0.45 ) setModelHandling( value, "ABS", false ) setModelHandling( value, "steeringLock", 30 ) setModelHandling( value, "suspensionForceLevel", 0.80 ) setModelHandling( value, "suspensionDamping", 0.20 ) setModelHandling( value, "suspensionHighSpeedDamping", 0.0 ) setModelHandling( value, "suspensionUpperLimit", 0.10 ) setModelHandling( value, "suspensionLowerLimit", -0.09 ) setModelHandling( value, "suspensionFrontRearBias", 0.5 ) setModelHandling( value, "suspensionAntiDiveMultiplier", 0.6 ) setModelHandling( value, "seatOffsetDistance", 0.3 ) setModelHandling( value, "collisionDamageMultiplier", 0.50 ) setModelHandling( value, "monetary", 1460000 ) setModelHandling( value, "modelFlags", 0xC0222004 ) setModelHandling( value, "handlingFlags", 0x1400000 ) setModelHandling( value, "headLight", 1 ) setModelHandling( value, "tailLight", 1 ) setModelHandling( value, "animGroup", 0 ) end end )
myonlake Posted December 2, 2012 Posted December 2, 2012 That's the same code as nwmafia's. I don't see any outstanding difference there. If I helped you, please click the like button on the right Thanks!
myonlake Posted December 2, 2012 Posted December 2, 2012 To be honest, I don't know why the model handling switch didn't work... probably it did and nwmafia is blind or then MTA is bugged and should be reported in the Bug Tracker. I think you should try using setVehicleHandling instead for now, that works perfectly at least. If I helped you, please click the like button on the right Thanks!
nwmafia Posted December 2, 2012 Author Posted December 2, 2012 The handling did not work, just to make sure it didn't work, I changed the velocity and acceleration to 2000 ... But anyways, clearly no one can help me.
TAPL Posted December 2, 2012 Posted December 2, 2012 The code work if you create the vehicle after using the code NOT before. This means, if you use the code and set the maxVelocity to 100, any new created vehicle will have maxVelocity = 100 if you again set maxVelocity to 200 any new created vehicle will have maxVelocity = 200 but the previous vehicle will stay at maxVelocity = 100. So this code does't change the current created vehicle but the newer.
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