Flipi Posted August 8, 2015 Posted August 8, 2015 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
aka Blue Posted August 8, 2015 Posted August 8, 2015 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)
Flipi Posted August 8, 2015 Author Posted August 8, 2015 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)
aka Blue Posted August 8, 2015 Posted August 8, 2015 ¿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]
Flipi Posted August 8, 2015 Author Posted August 8, 2015 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)
aka Blue Posted August 8, 2015 Posted August 8, 2015 Hum... Fijate en lo que puse, creo que el problema son los puntos porque lo veo bien.
Flipi Posted August 8, 2015 Author Posted August 8, 2015 Mmm, los entonces para separarlos tendría que mejor poner entremedio de los puntos unas (" ")?
aka Blue Posted August 8, 2015 Posted August 8, 2015 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
Flipi Posted August 8, 2015 Author Posted August 8, 2015 "time.month+1" quiere decir que está llamando el mes de "getRealTime()", dentro de ese metodo está "month", time es la variable del metodo. https://wiki.multitheftauto.com/wiki/GetRealTime
Pipee20k Posted August 8, 2015 Posted August 8, 2015 Hay necesidad de usar string.format? podrias poner anio = " del "..time.year+1900
Tomas Posted August 9, 2015 Posted August 9, 2015 Estás usando 'monthday', debes usar 'weekday' (ten en cuenta que se ordena de la forma americana, Sábado [0], Domingo[1], Lunes[2] ... )
Flipi Posted August 9, 2015 Author Posted August 9, 2015 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 !
Recommended Posts