Jump to content

Que sucede?


Flipi

Recommended Posts

Posted

Hola amigos, resulta que mi script muestra la hora y fecha, la hora la muestra correctamente, pero la fecha no, que sucede?

  
local time = getRealTime() 
local anio = string.format(" del %04d", time.year+1900) 
local day = string.format(" %02d de ", time.monthday) 
local mes = 
{ 
    [1] = "Enero", 
    [2] = "Febrero", 
    [3] = "Marzo", 
    [4] = "Abril", 
    [5] = "Mayo", 
    [6] = "Junio", 
    [7] = "Julio", 
    [8] = "Agosto", 
    [9] = "Septiembre", 
    [10] = "Octubre", 
    [11] = "Noviembre", 
    [12] = "Diciembre"   
} 
local dias = 
{ 
    [1] = "Domingo", 
    [2] = "Lunes", 
    [3] = "Martes", 
    [4] = "Miercoles", 
    [5] = "Jueves", 
    [6] = "Viernes", 
    [7] = "Sabado" 
} 
  
dxDrawText(dias[time.monthday]..day..mes[time.month+1]..anio, 0, screenHeight-21.8, screenWidth, screenHeight, tocolor (0,191,255,255), 1.2, "default-bold")   
  

Imagen:

http://imageshack.com/a/img661/3683/GXqWXq.png

Posted

El problema que tienes es que usas dxDrawText. Esa función usa onClientRender para que se vea.

Ten en cuenta que es un evento client-side. Quedaría algo tal que así.

  
local time = getRealTime() 
local anio = string.format(" del %04d", time.year+1900) 
local day = string.format(" %02d de ", time.monthday) 
local mes = 
{ 
    [1] = "Enero", 
    [2] = "Febrero", 
    [3] = "Marzo", 
    [4] = "Abril", 
    [5] = "Mayo", 
    [6] = "Junio", 
    [7] = "Julio", 
    [8] = "Agosto", 
    [9] = "Septiembre", 
    [10] = "Octubre", 
    [11] = "Noviembre", 
    [12] = "Diciembre"  
} 
local dias = 
{ 
    [1] = "Domingo", 
    [2] = "Lunes", 
    [3] = "Martes", 
    [4] = "Miercoles", 
    [5] = "Jueves", 
    [6] = "Viernes", 
    [7] = "Sabado" 
} 
function calendario () 
dxDrawText(dias[time.monthday]..day..mes[time.month+1]..anio, 0, screenHeight-21.8, screenWidth, screenHeight, tocolor (0,191,255,255), 1.2, "default-bold")   
end 
addEventHandler ( "onClientRender", root, calendario) 
  

Posted
El problema que tienes es que usas dxDrawText. Esa función usa onClientRender para que se vea.

No puse todo el codigo, pero si lo tengo (la funcion se llama createText):

  
function HandleTheRendering() 
    addEventHandler("onClientRender", root, createText) 
end 
addEventHandler("onClientResourceStart", resourceRoot, HandleTheRendering) 
  

Posted

¿Revisaste si pusiste bien la función createText? Creo que sé cual es el problema

dxDrawText(dias[time.monthday]..day..mes[time.month+1]..anio, 0, screenHeight-21.8, screenWidth, screenHeight, tocolor (0,191,255,255), 1.2, "default-bold")   

dias[time.monthday]..day..mes[time.month+1] 

Posted

Eso seria.

  
local screenWidth, screenHeight = guiGetScreenSize() 
function createText() 
    local time = getRealTime() 
    local anio = string.format(" del %04d", time.year+1900) 
    local day = string.format(" %02d de ", time.monthday) 
    local mes = 
    { 
        [1] = "Enero", 
        [2] = "Febrero", 
        [3] = "Marzo", 
        [4] = "Abril", 
        [5] = "Mayo", 
        [6] = "Junio", 
        [7] = "Julio", 
        [8] = "Agosto", 
        [9] = "Septiembre", 
        [10] = "Octubre", 
        [11] = "Noviembre", 
        [12] = "Diciembre"   
    } 
    local dias = 
    { 
        [1] = "Domingo", 
        [2] = "Lunes", 
        [3] = "Martes", 
        [4] = "Miercoles", 
        [5] = "Jueves", 
        [6] = "Viernes", 
        [7] = "Sabado" 
    } 
    dxDrawText(dias[time.monthday]..day..mes[time.month+1]..anio, 0, screenHeight-21.8, screenWidth, screenHeight, tocolor (0,191,255,255), 1.2, "default-bold")   
end 
  
function HandleTheRendering() 
    addEventHandler("onClientRender", root, createText) 
end 
addEventHandler("onClientResourceStart", resourceRoot, HandleTheRendering) 

Posted

Si, prueba eso.

Acabo de ver otra cosa, corrígeme si me equivoco. Arriba tú pusiste varias variables con el tiempo y demás, la única que no encuentro es ésta

  dxDrawText(dias[time.monthday]..day..mes[time.month+1]..anio, 0, screenHeight-21.8, screenWidth, screenHeight, tocolor (0,191,255,255), 1.2, "default-bold")   

time.month+1 

Posted

Estás usando 'monthday', debes usar 'weekday' (ten en cuenta que se ordena de la forma americana, Sábado [0], Domingo[1], Lunes[2] ... )

Posted
Estás usando 'monthday', debes usar 'weekday' (ten en cuenta que se ordena de la forma americana, Sábado [0], Domingo[1], Lunes[2] ... )

Cierto!, muchas gracias!

PD: ¿No que la forma americana parte del Sunday?

PD: Gracias a todos :D!

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...