Sasu Posted May 31, 2013 Posted May 31, 2013 Me explican el uso del getTickCount y me dan un ejemplo?
Alexs Posted May 31, 2013 Posted May 31, 2013 getTickCount es una función simple, devuelve el tiempo en milisegundos que el sistema lleva corriendo, comparando dos de estos valores puedes calcular el tiempo transcurrido entre un evento y otro, los demás usos imaginatelos. Ejemplo: screenX,screenY = guiGetScreenSize() function startTheClock () if not systemUpTime then systemUpTime = getTickCount () --Store the system tick count, this will be 0 for us end currentCount = getTickCount () dxDrawRectangle (screenX *.40, screenY * .09, 250, 50, tocolor(0,0,0,150)) dxDrawText ( currentCount - systemUpTime, screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) end addEventHandler ( "onClientRender", root, startTheClock )
Sasu Posted June 2, 2013 Author Posted June 2, 2013 Cree un script para server cuanto tiempo estuvo jugando desde que se conecto pero me regresa "477986" al conectarse. Que acaso no deberia ser muchos menos de 10000 milisegundos? ._. Porque me conecto y ya tiene 477 segundos ._.. Client: function updateData() local miliseconds2 = getTickCount() local tickcountseconds = miliseconds2/1000 local time = getRealTime(tickcountseconds) local seconds = time.second local minutes = time.minute local hours = time.hour setElementData(localPlayer, "PlayTime", seconds.." S "..minutes.." M "..hours.." H") end addEventHandler("onClientRender", root, updateData) Y encima me muesta 21 horas ._.
Sasu Posted June 2, 2013 Author Posted June 2, 2013 Tenes que restarle ese tiempo al tiempo de ahora. Serial algo asi?: function updateData() local miliseconds2 = getTickCount() local tickcountseconds = miliseconds2/1000 local time = getRealTime(tickcountseconds) local realTime = getRealTime() local seconds = time.second-realTime.second local minutes = time.minute-realTime.minute local hours = time.hour-realTime.hour setElementData(localPlayer, "PlayTime", seconds.." S "..minutes.." M "..hours.." H") end addEventHandler("onClientRender", root, updateData)
Recommended Posts