isa_Khamdan Posted August 25, 2013 Share Posted August 25, 2013 Hello , How can I set Speed limit for vehicles inside a colcircle? Link to comment
Imposter Posted August 25, 2013 Share Posted August 25, 2013 You could change their maxvelocity properties in handling when they hit the colsphere and restore it using elementdata. Link to comment
bandi94 Posted August 25, 2013 Share Posted August 25, 2013 before = getVehicleHandling ( theVehicle, "maxVelocity" ) setVehicleHandling ( theVehicle, "maxVelocity", value ) -- setting it back setVehicleHandling ( theVehicle, "maxVelocity", before ) Link to comment
Imposter Posted August 25, 2013 Share Posted August 25, 2013 you can use -- to store setElementData(theVehicle, "maxVelocity", theValue); -- to obtain getElementData(theVehicle, "maxVelocity"); Link to comment
50p Posted August 25, 2013 Share Posted August 25, 2013 you can use -- to store setElementData(theVehicle, "maxVelocity", theValue); -- to obtain getElementData(theVehicle, "maxVelocity"); This will not affect the vehicle itself. You still need to use setVehicleHandling, since there is getVehicleHandling there is no need to store element data. Link to comment
isa_Khamdan Posted August 25, 2013 Author Share Posted August 25, 2013 you can use -- to store setElementData(theVehicle, "maxVelocity", theValue); -- to obtain getElementData(theVehicle, "maxVelocity"); This will not affect the vehicle itself. You still need to use setVehicleHandling, since there is getVehicleHandling there is no need to store element data. They will still be able to change the speed because I have in-game handling editor so is there another way to add limit for max speed? like if get element speed ( Vehcile < 75 ) then set element speed to 75? Link to comment
WASSIm. Posted August 25, 2013 Share Posted August 25, 2013 exmple: local x,y,z = 0, 0, 0 local colcircler = createColCircle ( x,y,z,50 ) local before function hit(hitElement, matchingDimension) if (getElementType ( hitElement ) == "vehicle") then local oldmaxVelocity = getVehicleHandlingProperty ( hitElement, "maxVelocity" ) setElementData(theVehicle, "maxVelocity", oldmaxVelocity) setVehicleHandling ( hitElement, "maxVelocity", value ) end end addEventHandler("onColShapeHit", colcircler, hit) function leave(leaveElement, matchingDimension) if (getElementType ( leaveElement ) == "vehicle") then local oldmaxVelocity = getElementData(theVehicle, "maxVelocity"); if (oldmaxVelocity) then setVehicleHandling ( leaveElement, "maxVelocity", oldmaxVelocity ) end end end addEventHandler("onColShapeLeave", colcircler, leave) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable local value = handlingTable[property] -- Get the value from the table if value then -- If there's a value (valid property) return value -- Return it end end return false -- Not an element, not a vehicle or no valid property string. Return failure end Link to comment
isa_Khamdan Posted August 25, 2013 Author Share Posted August 25, 2013 exmple: local x,y,z = 0, 0, 0 local colcircler = createColCircle ( x,y,z,50 ) local before function hit(hitElement, matchingDimension) if (getElementType ( hitElement ) == "vehicle") then local oldmaxVelocity = getVehicleHandlingProperty ( hitElement, "maxVelocity" ) setElementData(theVehicle, "maxVelocity", oldmaxVelocity) setVehicleHandling ( hitElement, "maxVelocity", value ) end end addEventHandler("onColShapeHit", colcircler, hit) function leave(leaveElement, matchingDimension) if (getElementType ( leaveElement ) == "vehicle") then local oldmaxVelocity = getElementData(theVehicle, "maxVelocity"); if (oldmaxVelocity) then setVehicleHandling ( leaveElement, "maxVelocity", oldmaxVelocity ) end end end addEventHandler("onColShapeLeave", colcircler, leave) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable local value = handlingTable[property] -- Get the value from the table if value then -- If there's a value (valid property) return value -- Return it end end return false -- Not an element, not a vehicle or no valid property string. Return failure end People still can change the max speed from the in game handling editor I want to force the element to slow when the speed get more than 75 Link to comment
isa_Khamdan Posted August 27, 2013 Author Share Posted August 27, 2013 exmple: local x,y,z = 0, 0, 0 local colcircler = createColCircle ( x,y,z,50 ) local before function hit(hitElement, matchingDimension) if (getElementType ( hitElement ) == "vehicle") then local oldmaxVelocity = getVehicleHandlingProperty ( hitElement, "maxVelocity" ) setElementData(theVehicle, "maxVelocity", oldmaxVelocity) setVehicleHandling ( hitElement, "maxVelocity", value ) end end addEventHandler("onColShapeHit", colcircler, hit) function leave(leaveElement, matchingDimension) if (getElementType ( leaveElement ) == "vehicle") then local oldmaxVelocity = getElementData(theVehicle, "maxVelocity"); if (oldmaxVelocity) then setVehicleHandling ( leaveElement, "maxVelocity", oldmaxVelocity ) end end end addEventHandler("onColShapeLeave", colcircler, leave) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable local value = handlingTable[property] -- Get the value from the table if value then -- If there's a value (valid property) return value -- Return it end end return false -- Not an element, not a vehicle or no valid property string. Return failure end Where can I set the max speed in your code? Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 Here: setVehicleHandling ( hitElement, "maxVelocity", value ) Link to comment
isa_Khamdan Posted August 27, 2013 Author Share Posted August 27, 2013 Here: setVehicleHandling ( hitElement, "maxVelocity", value ) is there another way to force the car to slow down while it's inside the area without changing the handling? Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 What's wrong with changing the handling? Link to comment
isa_Khamdan Posted August 27, 2013 Author Share Posted August 27, 2013 What's wrong with changing the handling? It didn't save the old speed and set it again when you leave Link to comment
Castillo Posted August 27, 2013 Share Posted August 27, 2013 That's because WASSim made a mistake. local x,y,z = 0, 0, 0 local colcircler = createColCircle ( x,y,z,50 ) local before function hit(hitElement, matchingDimension) if (getElementType ( hitElement ) == "vehicle") then local oldmaxVelocity = getVehicleHandlingProperty ( hitElement, "maxVelocity" ) setElementData(hitElement, "maxVelocity", oldmaxVelocity) setVehicleHandling ( hitElement, "maxVelocity", value ) end end addEventHandler("onColShapeHit", colcircler, hit) function leave(leaveElement, matchingDimension) if (getElementType ( leaveElement ) == "vehicle") then local oldmaxVelocity = getElementData(leaveElement, "maxVelocity"); if (oldmaxVelocity) then setVehicleHandling ( leaveElement, "maxVelocity", oldmaxVelocity ) end end end addEventHandler("onColShapeLeave", colcircler, leave) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable local value = handlingTable[property] -- Get the value from the table if value then -- If there's a value (valid property) return value -- Return it end end return false -- Not an element, not a vehicle or no valid property string. Return failure end Link to comment
isa_Khamdan Posted August 27, 2013 Author Share Posted August 27, 2013 That's because WASSim made a mistake. local x,y,z = 0, 0, 0 local colcircler = createColCircle ( x,y,z,50 ) local before function hit(hitElement, matchingDimension) if (getElementType ( hitElement ) == "vehicle") then local oldmaxVelocity = getVehicleHandlingProperty ( hitElement, "maxVelocity" ) setElementData(hitElement, "maxVelocity", oldmaxVelocity) setVehicleHandling ( hitElement, "maxVelocity", value ) end end addEventHandler("onColShapeHit", colcircler, hit) function leave(leaveElement, matchingDimension) if (getElementType ( leaveElement ) == "vehicle") then local oldmaxVelocity = getElementData(leaveElement, "maxVelocity"); if (oldmaxVelocity) then setVehicleHandling ( leaveElement, "maxVelocity", oldmaxVelocity ) end end end addEventHandler("onColShapeLeave", colcircler, leave) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable local value = handlingTable[property] -- Get the value from the table if value then -- If there's a value (valid property) return value -- Return it end end return false -- Not an element, not a vehicle or no valid property string. Return failure end Thanks a lot Castillo , Can you please view my other theard " Little help needed " ? 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