Jump to content

Take cash from customer


Xeno

Recommended Posts

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
addEventHandler ( 'onVehicleEnter', root, 
    function ( uPlayer ) 
        setTimer (  
            function ( ) 
                takePlayerMoney ( uPlayer, 1000 ); 
                givePlayerMoney ( getVehicleController ( source ), 1000 ); 
            end, 
        5000, 0 ) 
    end 
) 

Just example.

Link to comment

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

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

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