Jump to content

working taxi driver


Estevam2d

Recommended Posts

Posted

I am creating the taxi driver working , I get money but not remove the passenger

someone help me ?

side-server

function test(client) 
local vehicle = getPedOccupiedVehicle( client ) 
local driver = getVehicleController( vehicle ) 
    timer = setTimer(function() 
     givePlayerMoney( driver, 1) 
     takePlayerMoney ( vehicle, 1 ) -- not cut passenger money 
    end,2000,0) 
  
end 
addEventHandler("onVehicleStartEnter",getRootElement(),test) 

Posted

Well obviously it won't, you're trying to take money away from the vehicle element. You need to specify the player element.

You can use getVehicleOccupant or getVehicleOccupants to find what other players are in the vehicle. Seat ID 0 should be the driver, go from there.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

was, it is true, thank you :lol::D:)

function test(player) 
if isPedInVehicle( player ) then 
            if getElementType ( player ) == "player" then 
local vehicle = getPedOccupiedVehicle ( player ) 
teste = getVehicleController ( source ) 
            if  vehicle then 
       Controller = setTimer(takePlayerMoney, 2000, 0, player, 1) 
       Passageiro = setTimer(givePlayerMoney, 2000, 0, teste, 1) 
       end 
       end 
    end 
end 
addEventHandler("onVehicleStartEnter",getRootElement(),test) 

Posted

Fixed it up for you:

function cabi(player) 
    if isPedInVehicle( player ) then 
        if getElementType ( player ) == "player" then 
            local vehicle = getPedOccupiedVehicle ( player ) 
            if  vehicle then 
                local driver = getVehicleController ( vehicle ) 
                Controller = setTimer(takePlayerMoney, 2000, 0, player, 1) 
                Passageiro = setTimer(givePlayerMoney, 2000, 0, driver, 1) 
            end 
        end 
    end 
end 
addEventHandler("onVehicleStartEnter",getRootElement(),cabi) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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