Jump to content

onElementModelChange


Recommended Posts

Hi again. Well i have another problem.

I have this

  
function upgrade() 
local cuVehicle = getPedOccupiedVehicle(source) 
local account = getPlayerAccount ( source ) 
if not isGuestAccount(account) and getAccountName(account) == "x" then 
setTimer(addVehicleUpgrade, 1000, 1, cuVehicle, 1080 ) 
end 
end 
addEventHandler("onMapStarting", getRootElement(), upgrade) 
addEventHandler("onPlayerVehicleEnter", getRootElement(), upgrade) 
addEventHandler("onElementModelChange", getRootElement(), upgrade) 

The problem is. in Race gamemode, when i change vehicle, my wheels change to default. I want have ever my wheels.

But idk how fix it.

Thanks for your time :D

Link to comment

You are using three different events for one single function, and all these events have different arguments.

onMapStarting: It has no player argument as source.

onElementModelChange: 'source' is the element that got his model changed.

So you would need to use:

onVehicleEnter

onElementModelChange

and use 'source' as vehicle element.

Also, onMapStarting is not required because when you spawn, 'onVehicleEnter' will be triggered.

Link to comment

Thanks. Now i got this. But isnt work

function upgrade(player) 
local account = getPlayerAccount ( player ) 
if not isGuestAccount(account) and getAccountName(account) == "yakuza" then 
addVehicleUpgrade( source , 1080) 
end 
end 
addEventHandler("onVehicleEnter", resourceRoot, upgrade) 
addEventHandler("onElementModelChange", resourceRoot, upgrade) 
  

Same error, when i change model dont keep the wheels

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