Jump to content

Handling problem


KITT1995

Recommended Posts

Posted

I have a problem with this code

function resourceStarted() 
    local handling = createHandling()                                -- create a new handling element 
    addDefaultHandling(getVehicleModelFromName("infernus"), handling)   -- attach it to the Infernus ID 
    handlingSetEngineAcceleration(handling, 50)                      -- change its acceleration property (thereby changing the acceleration of all Infernus cars) 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStarted) 

When i start the script i get an error in the server log "ERROR: replace\script3.lua:2: attempt to call global 'createHandling' (a nil value)".

How I can fix this?

Posted

I saw that function, but I don't know how to use it to give the handling to all cars of the same model (for example all infernus). Can someone please explain how to do this?

Posted
So, your trying to create a Handler for all Vehicles that are Infernus?

Yes

  
for i,v in ipairs(getElementsByType("vehicle")) do 
     if getElementModel(v) == INFERNUSMODELNUMBERHERE then 
          setVehicleHandling(v, handlingType, value) 
     end 
end 
  

Where i need to write the handling values?

1.1 only.

I have 1.1

  • MTA Team
Posted

Create locals or globals.

  
handlingType = "acceleration" 
value = 99^99*99^99*99^99*99^99 
  

That should work.

Posted
Create locals or globals.
  
handlingType = "acceleration" 
value = 99^99*99^99*99^99*99^99 
  

That should work.

Can u please write the full script with only one handling value?

  • MTA Team
Posted
  
handlingType = "acceleration" 
value = 99^99*99^99*99^99*99^99 
doForall = false -- iF you wanna do it for all 
MODELNUMBERHERE = 411 -- infernus 
  
for i,v in ipairs(getElementsByType("vehicle")) do 
     if doForall then 
                     setVehicleHandling(v, handlingType, value) 
                      break 
      end 
     if getElementModel(v) == MODELNUMBERHERE then 
          setVehicleHandling(v, handlingType, value) 
     end 
end 
  

Posted
  
handlingType = "acceleration" 
value = 99^99*99^99*99^99*99^99 
doForall = false -- iF you wanna do it for all 
MODELNUMBERHERE = 411 -- infernus 
  
for i,v in ipairs(getElementsByType("vehicle")) do 
     if doForall then 
                     setVehicleHandling(v, handlingType, value) 
                      break 
      end 
     if getElementModel(v) == MODELNUMBERHERE then 
          setVehicleHandling(v, handlingType, value) 
     end 
end 
  

It doesn't work, I get this error "WARNING: replace\script3.lua:8: Bad 'property' pointer @ 'setVehicleHandling'(2)

  • MTA Team
Posted
  
handlingType = "maxVelocity" 
value = 99^99*99^99*99^99*99^99 
doForall = false -- iF you wanna do it for all 
MODELNUMBERHERE = 411 -- infernus 
  
for i,v in ipairs(getElementsByType("vehicle")) do 
     if doForall then 
                     setVehicleHandling(v, handlingType, value) 
                      break 
      end 
     if getElementModel(v) == MODELNUMBERHERE then 
          setVehicleHandling(v, handlingType, value) 
     end 
end 
  

Lazy.

Posted
  
handlingType = "maxVelocity" 
value = 99^99*99^99*99^99*99^99 
doForall = false -- iF you wanna do it for all 
MODELNUMBERHERE = 411 -- infernus 
  
for i,v in ipairs(getElementsByType("vehicle")) do 
     if doForall then 
                     setVehicleHandling(v, handlingType, value) 
                      break 
      end 
     if getElementModel(v) == MODELNUMBERHERE then 
          setVehicleHandling(v, handlingType, value) 
     end 
end 
  

Lazy.

Same error

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