Jump to content

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


mint3d

Recommended Posts

Posted (edited)

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

Skype: Jordan_Nymph

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

Datastore - Store data to a database quickly. (Useful for saving scripted tables)

Posted

Ye line 17 is like that because its 0. 8 ) its a smiley... so I just made it 0.9) to make life easier lol

Skype: Jordan_Nymph

Posted

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 

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

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

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

Posted

Your first script worked for only elegys and ye I have a lot of different values at each of them so I don't know xD

Skype: Jordan_Nymph

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