NodZen Posted November 1, 2012 Posted November 1, 2012 Hola amigos, tengo un problema con un script. Miren local screenWidth, screenHeight = guiGetScreenSize ( ) function armor ( ) jugador = getLocalPlayer() local armadura = getPedArmor(jugador) dxDrawText ( armadura, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 0.5, "pricedown" ) end function check ( ) addEventHandler ( "onClientRender", root, armor ) end addEventHandler ( "onClientResourceStart", resourceRoot, check ) Buen el problema es que dibuja la armadura , pero sale asi Armor: 95.7516154879213 .Ven! , Como se puede hacer para que salga solo el 95 y no los otros numeros? Gracias
Arsilex Posted November 1, 2012 Posted November 1, 2012 que uses eso para que te reduzca las décimas a una unidad...
Renkon Posted November 1, 2012 Posted November 1, 2012 dxDrawText ( tostring(math.floor(armadura+0.5)), 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 0.5, "pricedown" ) Te lo mostrará como entero
NodZen Posted November 1, 2012 Author Posted November 1, 2012 Gracias Renkon y Pekio. Ahora si funciona.
Alexs Posted November 1, 2012 Posted November 1, 2012 Para quitar sus dudas, math.floor va al numero mas bajo, math.ceil al mas alto: Eg: math.floor(0.4) == 0 math.ceil(0.4) == 1
NodZen Posted November 1, 2012 Author Posted November 1, 2012 Para quitar sus dudas, math.floor va al numero mas bajo, math.ceil al mas alto:Eg: math.floor(0.4) == 0 math.ceil(0.4) == 1
Renkon Posted November 1, 2012 Posted November 1, 2012 math.floor(var + 0.5) --retorna si es x.4999999 x entero, y si es x.5 o mas devuelve x+1. Interesante funcion la de agregarle 0.5
Recommended Posts