Jump to content

getTickCount()


Recommended Posts

why its dont work? -_-

Which equation correctly for Timer?

server:

function sitPr ( thePlayer, cmd, timer, Psource ) 
                                            local timer = getTickCount() + timer*60*1000 
                                            triggerClientEvent ( Psource, 'checkTimer', Psource, Psource, timer ) 
addCommandHandler ( 'sPr', sitPr ) 

Client:

function check(Psource, timer) 
timerCheck = setTimer(function() 
    outputChatBox('1 '..tonumber(timer)) 
    outputChatBox('2 '..tonumber(current)) 
    outputChatBox('3 '..tonumber(rezoneTimer)) 
    if timer <= getTickCount() then 
        triggerServerEvent( 'Vipustit', getLocalPlayer(), localPlayer ) 
        killTimer( timerCheck ) 
    end 
end, 1000, 0 ) 
end 
addEvent( 'checkTimer', true ) 
addEventHandler( 'checkTimer', getRootElement(), check ) 

Edited by Guest
Link to comment
The client tickcount starts when the client starts.

The server tickcount starts when the server starts.

They never start at the same time, so you can't compare them.

getTickCount () show the work of the server itself, no?

'This function returns amount of time that your system has been running in milliseconds. '

Link to comment
The mta server is the system it self.

I mentioned the mta server not the machine.

then, why does it work?

server:

function takeMoneyDet( thePlayer, money ) 
local accPlayer = getPlayerAccount( thePlayer ) 
    local money = getTickCount() + money/210*60*1000 
    setAccountData ( accPlayer, "detector-have", money ) 
    timerDetect = tonumber(getAccountData ( accPlayer, "detector-have" )) 
    triggerClientEvent( thePlayer, 'rasschet', thePlayer, client, timerDetect ) 
end 
addEvent( 'takeMoneyDet', true ) 
addEventHandler( 'takeMoneyDet', getRootElement(), takeMoneyDet ) 

client:

function rasschet( player, timerDetect ) 
    timerCheck = setTimer(function() 
        timerDetect = timerDetect-getTickCount() 
        triggerServerEvent( 'update30', localPlayer, timerDetect ) 
        if timerDetect <= 0 then 
            triggerServerEvent( 'unableDetect', localPlayer ) 
            killTimer( timerCheck ) 
        end 
    end, 30000, 0 ) 
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...