aski Posted March 29, 2014 Share Posted March 29, 2014 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 Link to comment
LonelyRoad Posted March 30, 2014 Share Posted March 30, 2014 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
Anubhav Posted March 30, 2014 Share Posted March 30, 2014 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
aski Posted March 30, 2014 Author Share Posted March 30, 2014 whether it is a file. lua? and thank you for your help. Link to comment
Anubhav Posted March 30, 2014 Share Posted March 30, 2014 Its server.lua ... server sided Link to comment
WhoAmI Posted March 30, 2014 Share Posted March 30, 2014 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
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