Jump to content

[Вопрос]Не отнимается бабло.


Recommended Posts

function taxi1(thePlayer, seat, jacked) 
  theVehicleID = getElementModel ( source ) 
  if  (theVehicleID == 420) and ( seat ~= 0 ) then 
    driver = getVehicleOccupant(source, 0) 
    setTimer (taxitakemoney, 30000, 0) 
  end 
end 
addEventHandler ("onVehicleEnter", getRootElement(), taxi1)  
  
--function for take money 
function taxitakemoney( seat, jaked, thePlayer ) 
    givePlayerMoney (driver, 30) 
    takePlayerMoney (thePlayer, 30) 
end 

Вот собсна,бабло прибавляется,но не убавляется у игрока.

Edited by Guest
Link to comment
local uTimers = { } 
  
--function for take money 
function taxitakemoney( uPlayer,uDriver ) 
    givePlayerMoney ( uDriver, 30 ) 
    takePlayerMoney ( uPlayer, 30 ) 
end 
  
function taxi1( uPlayer, nSeat ) 
    local nVehicleID = getElementModel ( source ) 
    if nVehicleID == 420 and nSeat ~= 0 then 
        local uDriver = getVehicleOccupant( source, 0 ) 
        uTimers[ uPlayer ] = setTimer ( taxitakemoney, 30000, 0,uPlayer,uDriver ) 
    end 
end 
addEventHandler ( "onVehicleEnter", root, taxi1 )  
  
addEventHandler ( "onVehicleExit", root,  
    function( uPlayer )  
        if isTimer( uTimers[ uPlayer ] ) then 
            killTimer( uTimers[ uPlayer ] )  
        end 
    end 
)    
  
addEventHandler ( "onPlayerQuit",root, 
    function( ) 
        uTimers[ source ] = nil 
    end 
)    

Link to comment
function taxi1(thePlayer, seat, jacked) 
  
  theVehicleID = getElementModel(source) 
   
  if  (theVehicleID == 420) and (seat ~= 0) then 
    driver = getVehicleOccupant(source, 0) -- 0 можно убрать и оставить getVehicleOccupant(source). 0 - уже стоит по-умолчанию. 
    setTimer(taxitakemoney, 30000, 0, driver, thePlayer) -- 0 - у тебя будет каждые 30 секунд давать и отнимать деньги. 
  end 
   
end 
addEventHandler ("onVehicleEnter", root, taxi1)  
  
function taxitakemoney(driver, player) 
    if driver and player then 
        givePlayerMoney(driver, 30) 
        takePlayerMoney(thePlayer, 30) 
    end 
end 

Edited by Guest
Link to comment
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), 
    function( ) 
        bindKey( "0", "down", startRadio); 
    end 
) 
  
function startRadio( thePalyer ) 
if not sound then 
    sound = playSound('http://217.147.86.151:20175/listen.pls')  
setSoundVolume(sound, 5) 
else  
stopSound (sound) 
unbindKey ( thePlayer, "0", "down", startRadio ) 
end 
        end 
  

Знаю,говнокод,но это не мой код,просто он щас не может написать тут.)

Почему не работает?

Надо что б если музыка играется-она остановилась и потом можно было ещё раз её проиграть.

Link to comment
local sound,state 
  
function startRadio( ) 
    local state = not state 
    if state then 
        sound = playSound( 'http://217.147.86.151:20175/listen.pls' )  
        setSoundVolume( sound, 1.0 ) 
    else  
        stopSound ( sound ) 
    end 
end 
  
addEventHandler( "onClientResourceStart", resourceRoot, 
    function( ) 
        bindKey( "0", "down", startRadio ) 
    end 
) 
  

Link to comment
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        bindKey("0", "down", startRadio) 
    end 
) 
  
function startRadio() 
  
    if not sound then 
        sound = playSound('http://217.147.86.151:20175/listen.pls')  
        setSoundVolume(sound, 5.0) 
    else  
        destroyElement(sound) 
        sound = nil 
    end 
     
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...