Jump to content

Speed limit


isa_Khamdan

Recommended Posts

Posted
before = getVehicleHandling ( theVehicle, "maxVelocity" ) 
setVehicleHandling ( theVehicle, "maxVelocity",  value ) 
  
  
 -- setting it back  
  
setVehicleHandling ( theVehicle, "maxVelocity",  before ) 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

you can use

  
-- to store 
setElementData(theVehicle, "maxVelocity", theValue); 
-- to obtain 
getElementData(theVehicle, "maxVelocity"); 
  

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted
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.

Posted
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?

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

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 

Omerta Roleplay

Posted
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

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted
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? :S

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

Here:

setVehicleHandling ( hitElement, "maxVelocity",  value ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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?

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

What's wrong with changing the handling?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 " ?

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...