Jump to content

[Help] I need some help on a script I have been working on


mint3d

Recommended Posts

Ok so I need help on this script I have been working on so basically it sets all vehicles in the faction but I only want it to set all elegys in the faction can someone help me out please?

function setHandling() 
  for key,veh in ipairs(getElementsByType("vehicle")) do 
   if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 20) 
    setVehicleHandling(veh, "maxVelocity", 165) 
    setVehicleHandling(veh, "steeringLock", 45) 
   end 
   if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 22) 
    setVehicleHandling(veh, "maxVelocity", 200) 
    setVehicleHandling(veh, "steeringLock", 50) 
   end 
   if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 15) 
    setVehicleHandling(veh, "maxVelocity", 180) 
    setVehicleHandling(veh, "brakeDeceleration", 1000) 
    setVehicleHandling(veh, "tractionMultiplier", 0.9) 
    end 
    if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 22) 
    setVehicleHandling(veh, "maxVelocity", 200) 
    setVehicleHandling(veh, "steeringLock", 50) 
    setVehicleHandling(veh, "brakeDeceleration", 1000) 
    end 
  end 
end 
addEventHandler("onResourceStart", getRootElement(), setHandling) 

Edited by Guest
Link to comment
function setHandling() 
  for key,veh in ipairs(getElementsByType("vehicle")) do 
   if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 20) 
    setVehicleHandling(veh, "maxVelocity", 165) 
    setVehicleHandling(veh, "steeringLock", 45) 
   end 
   if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 22) 
    setVehicleHandling(veh, "maxVelocity", 200) 
    setVehicleHandling(veh, "steeringLock", 50) 
   end 
   if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 15) 
    setVehicleHandling(veh, "maxVelocity", 180) 
    setVehicleHandling(veh, "brakeDeceleration", 1000) 
    setVehicleHandling(veh, "tractionMultiplier", 0)--. 
    end 
    if (getElementData(veh, "faction") == 72) then 
    setVehicleHandling(veh, "engineAcceleration", 22) 
    setVehicleHandling(veh, "maxVelocity", 200) 
    setVehicleHandling(veh, "steeringLock", 50) 
    setVehicleHandling(veh, "brakeDeceleration", 1000) 
    end 
  end 
end 
addEventHandler("onResourceStart", getRootElement(), setHandling) 

Link to comment

Double post, you can't bump your post which its latest reply was 9 minutes ago. Way to go man, anyway.

If you only want to edit the Elegy, just add a check in there;

if ( getElementModel ( veh ) == ) then 

like so;

function setHandling() 
    for key,veh in ipairs ( getElementsByType ( "vehicle" ) ) do 
        if ( getElementModel ( veh ) == 562 ) then 
            if ( getElementData ( veh, "faction" ) == 72 ) then 
                setVehicleHandling ( veh, "engineAcceleration", 20 ); 
                setVehicleHandling ( veh, "maxVelocity", 165 ); 
                setVehicleHandling ( veh, "steeringLock", 45 ); 
            end 
             
            if ( getElementData ( veh, "faction" ) == 72) then 
                setVehicleHandling ( veh, "engineAcceleration", 22 ); 
                setVehicleHandling ( veh, "maxVelocity", 200 ); 
                setVehicleHandling ( veh, "steeringLock", 50 ); 
            end 
             
            if ( getElementData ( veh, "faction" ) == 72) then 
                setVehicleHandling ( veh, "engineAcceleration", 15 ); 
                setVehicleHandling ( veh, "maxVelocity", 180 ); 
                setVehicleHandling ( veh, "brakeDeceleration", 1000 ); 
                setVehicleHandling ( veh, "tractionMultiplier", 0.9 ); 
            end 
             
            if ( getElementData ( veh, "faction" ) == 72) then 
                setVehicleHandling ( veh, "engineAcceleration", 22 ); 
                setVehicleHandling ( veh, "maxVelocity", 200 ); 
                setVehicleHandling ( veh, "steeringLock", 50 ); 
                setVehicleHandling ( veh, "brakeDeceleration", 1000 ); 
            end 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), setHandling ) 

And why do you have the if-statement 4 times btw? I'm talking about this one;

if ( getElementData ( veh, "faction" ) == 72 ) then 

Link to comment
function setHandling() 
    for key,veh in ipairs ( getElementsByType ( "vehicle" ) ) do 
        if ( getElementModel ( veh ) == 562 ) then 
            if ( getElementData ( veh, "faction" ) == 72 ) then 
                setVehicleHandling ( veh, "tractionMultiplier", 0.9 ); 
                setVehicleHandling ( veh, "engineAcceleration", 22 ); 
                setVehicleHandling ( veh, "maxVelocity", 200 ); 
                setVehicleHandling ( veh, "steeringLock", 50 ); 
                setVehicleHandling ( veh, "brakeDeceleration", 1000 ); 
            end 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), setHandling ) 

Link to comment

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