Jump to content

SYSTEM TAXI :C


aski

Recommended Posts

l can not do something like that if someone gets into a vehicle Taxi, Cabbie, the driver gives the example $ 5 every 5 seconds, and the customer takes $ 5 every 5 seconds when two clients it takes all and gives the driver for two people, when the driver goes no action alone is not happening. How do such a thing to begin if someone can help me? Please how do I do this taxi system

sorry for my bad english :oops:

Link to comment

You need to find a way to control money, that includes storing it to the play in some way. After you've stored money you can simply use a little bit of timer-based magic to deduct the money from the client and give the money to the driver.

You just need to check if the cab has a driver and a passenger, and store those two players in some way and continually pay them whilst continuing to check if they are both inside the vehicle.

Link to comment

function moneyToDriver(thePlayer)

local model = getElementModel(thePlayer)

local vehicle = getVehicleOccupants(thePlayer)

if model == 438 or 420 and vehicle >1 then

local timer = setTimer(givePlayerMoney,5000,0,thePlayer,5)

local timer2 = setTimer(takePlayerMoney,5000,0,vehicle,5)

end

end

function insertTaxdi( thePlayer, seat, jacked)

local model = getElementModel(thePlayer)

local vehicle = getVehicleOccupants(thePlayer)

if model == 438 or 420 and seat == 0 and jacked or not jacked then

killTimer(timer)

killTimer(timer2)

elseif model == 438 or 420 and seat >1 then

killTimer(timer)

killTimer(timer2)

end

end

addEventHandler ( "onVehicleExit", getRootElement(), insertTaxdi)

Link to comment
taxi_ids = { [420] = true, [438] = true } 
local sekundy = 5 --seconds 
local kasa = 5 --money 
  
addEventHandler ( "onVehicleEnter", root, 
    function ( player, seat ) 
        if ( taxi_ids [ getElementModel ( source ) ] ) then 
            if ( seat ~= 0 ) then 
                local kierowca = getVehicleController ( source ) 
                if ( kierowca ) then 
                    local timer = setTimer ( 
                        function ( ) 
                            takePlayerMoney ( player, kasa ) 
                            givePlayerMoney ( kierowca, kasa ) 
                        end, 
                    sekundy * 1000, 0 ) 
                    setElementData ( player, "timer:taxi", timer ) 
                end 
            end 
        end 
    end 
) 
  
addEventHandler ( "onVehicleExit", root, 
    function ( player, seat ) 
        if ( taxi_ids [ getElementModel ( source ) ] ) then 
            if ( seat ~= 0 ) then 
                local timer = getElementData ( player, "timer:taxi" ) 
                if ( isTimer ( timer ) ) then 
                    killTimer ( timer ) 
                end 
            end 
        end 
    end 
) 

Isn't that better way?

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