Xeno Posted April 6, 2012 Share Posted April 6, 2012 Pretty much I'm trying to make a pilot job, I've done most of it except the money taking when the man is in the vehicle... I know it goes along the lines of: onVehicleEnter getVehicleOccupant takeMoney GiveMoney But I have no clue how to put it into one big thing. Please help, Thanks Xeno Link to comment
drk Posted April 6, 2012 Share Posted April 6, 2012 addEventHandler ( 'onVehicleEnter', root, function ( uPlayer ) setTimer ( function ( ) takePlayerMoney ( uPlayer, 1000 ); givePlayerMoney ( getVehicleController ( source ), 1000 ); end, 5000, 0 ) end ) Just example. Link to comment
Kenix Posted April 6, 2012 Share Posted April 6, 2012 You should add arguments to setTimer callback function. addEventHandler ( 'onVehicleEnter', root, function ( uPlayer ) setTimer ( function ( uPlayer, source ) takePlayerMoney ( uPlayer, 1000 ); givePlayerMoney ( getVehicleController ( source ), 1000 ); end, 5000, 0, uPlayer, source ) end ) Link to comment
Xeno Posted April 6, 2012 Author Share Posted April 6, 2012 Thank you both for the quick replys. If I wanted to make it so it only worked when the mans Job was pilot, would I do this? addEventHandler ( 'onVehicleEnter', root, function ( uPlayer ) setTimer ( function ( uPlayer, source ) local job = getElementData(uPlayer) if job == "Pilot" then takePlayerMoney ( uPlayer, 1000 ); givePlayerMoney ( getVehicleController ( source ), 1000 ); end, 5000, 0, uPlayer, source ) end ) Something like this? Link to comment
drk Posted April 6, 2012 Share Posted April 6, 2012 addEventHandler ( 'onVehicleEnter', root, function ( uPlayer ) setTimer ( function ( uPlayer, uVehicle ) local job = getElementData ( uPlayer, 'Job' ); -- change 'Job' to your job element data if ( job == 'Pilot' ) then takePlayerMoney ( uPlayer, 1000 ); givePlayerMoney ( getVehicleController ( uVehicle ), 1000 ); end end, 5000, 0, uPlayer, source ) end ) Link to comment
Xeno Posted April 6, 2012 Author Share Posted April 6, 2012 Thanks, you've both been fantastic. I've just come back from a break so I'm getting back into things. Thanks! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now