Flipi Posted October 22, 2013 Share Posted October 22, 2013 Hola, no logro hacerlo de manera correcta , me echan una mano?, trata sobre un shout para admin..... function shout(player, cmd, ...) local times = 5000 local accountname = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then for id, players in ipairs(getElementsByType("player")) do local message = table.concat({...}," ") dxDrawText(""..message, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "left", "top", false, false, true, true, false ) setTimer(stopDisplayDrawText, times, 1) end else outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) end end addCommandHandler("shout", shout) Link to comment
Castillo Posted October 22, 2013 Share Posted October 22, 2013 Y cual es el problema? Link to comment
Flipi Posted October 22, 2013 Author Share Posted October 22, 2013 Y cual es el problema? no me envia el mensaje Link to comment
Alexs Posted October 22, 2013 Share Posted October 22, 2013 Estas combinando funciones, utiliza 'triggerClientEvent'. Link to comment
Flipi Posted October 23, 2013 Author Share Posted October 23, 2013 Estas combinando funciones, utiliza 'triggerClientEvent'. en que parte? Link to comment
Chaz-CR Posted October 23, 2013 Share Posted October 23, 2013 triggea el dxDrawText, porque lo otro es serverside. Link to comment
Flipi Posted October 23, 2013 Author Share Posted October 23, 2013 triggea el dxDrawText, porque lo otro es serverside. algo asi?, se que esta mal Client.... function shouts(player, ...) local message = table.concat({...}," ") dxDrawText(""..message, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "center", "center", false, false, true, true, false ) if not outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) then end end addEvent( "onShouts", true ) addEventHandler( "onShouts", getRootElement(), shouts ) server... function shout(player, cmd, ...) local times = 5000 local accountname = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then for id, players in ipairs(getElementsByType("player")) do triggerClientEvent ( "onShouts", getRootElement()) setTimer("", times, 1) end else outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) end end addCommandHandler("shout", shout) Link to comment
AlvareZ_ Posted October 23, 2013 Share Posted October 23, 2013 Todo dxDraw debe ir con su respectivo "onClientRender" por esa razon no funciona Link to comment
Flipi Posted October 23, 2013 Author Share Posted October 23, 2013 Todo dxDraw debe ir con su respectivo "onClientRender" por esa razon no funciona como? me echas una manito? ? Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 como? me echas una manito? ? Se me ocurre algo así: Server: function shout( player, cmd, ... ) local accountname = getAccountName( getPlayerAccount( player ) ) local w = {...} local message = table.concat(w, " ") if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then triggerClientEvent ( root, "onShouts", root, message ) else outputChatBox( "* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true ) end end addCommandHandler( "shout", shout ) Client: function shouts( message ) if isTimer( d ) then killTimer( d ) end message = message addEventHandler ( "onClientRender", root, drawing ) d = setTimer ( function() removeEventHandler( "onClientRender", root, drawing ) end, 5000, 1 ) end addEvent( "onShouts", true ) addEventHandler( "onShouts", getRootElement(), shouts ) function drawing() dxDrawText( message, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "center", "center", false, false, true, true, false ) end Link to comment
Flipi Posted October 24, 2013 Author Share Posted October 24, 2013 como? me echas una manito? ? Se me ocurre algo así: Server: function shout( player, cmd, ... ) local accountname = getAccountName( getPlayerAccount( player ) ) local w = {...} local message = table.concat(w, " ") if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then triggerClientEvent ( root, "onShouts", root, message ) else outputChatBox( "* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true ) end end addCommandHandler( "shout", shout ) Client: function shouts( message ) if isTimer( d ) then killTimer( d ) end message = message addEventHandler ( "onClientRender", root, drawing ) d = setTimer ( function() removeEventHandler( "onClientRender", root, drawing ) end, 5000, 1 ) end addEvent( "onShouts", true ) addEventHandler( "onShouts", getRootElement(), shouts ) function drawing() dxDrawText( message, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "center", "center", false, false, true, true, false ) end lo probé y no manda el mensaje... Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 lo probé y no manda el mensaje... Reemplaza lo de client por esto: function shouts( message ) if isTimer( d ) then return end theText = message addEventHandler ( "onClientRender", root, drawing ) d = setTimer ( function() removeEventHandler( "onClientRender", root, drawing ) end, 5000, 1 ) end addEvent( "onShouts", true ) addEventHandler( "onShouts", getRootElement(), shouts ) function drawing() dxDrawText( theText, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "center", "center", false, false, true, true, false ) end Link to comment
Flipi Posted October 24, 2013 Author Share Posted October 24, 2013 lo probé y no manda el mensaje... Reemplaza lo de client por esto: function shouts( message ) if isTimer( d ) then return end theText = message addEventHandler ( "onClientRender", root, drawing ) d = setTimer ( function() removeEventHandler( "onClientRender", root, drawing ) end, 5000, 1 ) end addEvent( "onShouts", true ) addEventHandler( "onShouts", getRootElement(), shouts ) function drawing() dxDrawText( theText, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "center", "center", false, false, true, true, false ) end tampoco, no aparece nada en la pantalla Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 lo probé y no manda el mensaje... Reemplaza lo de client por esto: function shouts( message ) if isTimer( d ) then return end theText = message addEventHandler ( "onClientRender", root, drawing ) d = setTimer ( function() removeEventHandler( "onClientRender", root, drawing ) end, 5000, 1 ) end addEvent( "onShouts", true ) addEventHandler( "onShouts", getRootElement(), shouts ) function drawing() dxDrawText( theText, 0.5, 0.5, 2, 0, tocolor ( 255, 255, 255, 255 ), 3, "default-bold", "center", "center", false, false, true, true, false ) end tampoco, no aparece nada en la pantalla ya lo probé y funciona pero aparece a un costado, tienes que arreglar las coordenadas. Link to comment
Flipi Posted October 24, 2013 Author Share Posted October 24, 2013 ya lo probé y funciona pero aparece a un costado, tienes que arreglar las coordenadas. muchas gracias !, me dirías cuales podrían ser las coordenadas para que se adapte según cualquier resolución de pantalla, con tal de que quede centrado? Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 Te dejo el que yo uso, ponlo en client: local sx, sy = guiGetScreenSize() local sx = sx / 2 local sy = sy / 2 function drawText() local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width / 2 local topB = sy - (height + 5) local left = sx - width / 2 local top = sy - height dxDrawText(theText, leftB, topB, left, top, tocolor(255, 0, 0, 255), 3, "default", "left", "top", false, true, true) end draw = false function drawShout(text) if not draw then playSoundFrontEnd(5) theText = text addEventHandler("onClientRender", root, drawText) draw = true setTimer(function() draw = false removeEventHandler("onClientRender", root, drawText) end, 8000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) Link to comment
Flipi Posted October 24, 2013 Author Share Posted October 24, 2013 Te dejo el que yo uso, ponlo en client: Gracias, oie una consulta, para editar el color como setting en panel de admin agrege esto, pero el r,g,b (colores) como pongo para que se modifique el texto? local sx, sy = guiGetScreenSize() local sx = sx / 2 local sy = sy / 2 function drawText() local r,g,b = local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width / 2 local topB = sy - (height + 5) local left = sx - width / 2 local top = sy - height dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(theText, leftB, topB, left, top, RGBColor(r,g,b), 3, "default-bold", "left", "top", false, true, true) end draw = false function drawShout(text) if not draw then theText = text addEventHandler("onClientRender", root, drawText) draw = true setTimer(function() draw = false removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) function RGBColor(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return end Meta setting... name="*Color de texto" value="#0080FF" /> Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 usando la función get obtienes lo del setting Link to comment
Flipi Posted October 24, 2013 Author Share Posted October 24, 2013 usando la función get obtienes lo del setting claro pero para el color del texto que get uso? en el local r,g,b Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 usando la función get obtienes lo del setting claro pero para el color del texto que get uso? en el local r,g,b Ponle variables Link to comment
Flipi Posted October 24, 2013 Author Share Posted October 24, 2013 usando la función get obtienes lo del setting claro pero para el color del texto que get uso? en el local r,g,b Ponle variables entonces se borra el local r,g,b y la función que agregue abajo o no? Link to comment
Sensacion Posted October 24, 2013 Share Posted October 24, 2013 obtienes los 3 colores del settings, mandas esos valores a client, y ahí puedes poner algo como: local r, g, b = var1, var2, var3 Link to comment
Flipi Posted October 25, 2013 Author Share Posted October 25, 2013 obtienes los 3 colores del settings, mandas esos valores a client, y ahí puedes poner algo como:local r, g, b = var1, var2, var3 asi? local sx, sy = guiGetScreenSize() local sx = sx / 2 local sy = sy / 2 function drawText() local r,g,b = (0,128,255) local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width / 2 local topB = sy - (height + 5) local left = sx - width / 2 local top = sy - height dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(theText, leftB, topB, left, top, RGBColor(r,g,b), 3, "default-bold", "left", "top", false, true, true) end draw = false function drawShout(text) if not draw then theText = text addEventHandler("onClientRender", root, drawText) draw = true setTimer(function() draw = false removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) function RGBColor(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return end Link to comment
Sensacion Posted October 25, 2013 Share Posted October 25, 2013 obtienes los 3 colores del settings, mandas esos valores a client, y ahí puedes poner algo como:local r, g, b = var1, var2, var3 asi? local sx, sy = guiGetScreenSize() local sx = sx / 2 local sy = sy / 2 function drawText() local r,g,b = (0,128,255) local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width / 2 local topB = sy - (height + 5) local left = sx - width / 2 local top = sy - height dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(theText, leftB, topB, left, top, RGBColor(r,g,b), 3, "default-bold", "left", "top", false, true, true) end draw = false function drawShout(text) if not draw then theText = text addEventHandler("onClientRender", root, drawText) draw = true setTimer(function() draw = false removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) function RGBColor(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return end No, donde están las variables que representan los valores obtenidos del settings? Link to comment
AlvareZ_ Posted October 25, 2013 Share Posted October 25, 2013 creo que, Pruebalo: local sx, sy = guiGetScreenSize() local sx = sx / 2 local sy = sy / 2 function drawText() local color = tocolor(0,128,255,255) local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width / 2 local topB = sy - (height + 5) local left = sx - width / 2 local top = sy - height dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(theText, leftB, topB, left, top, color, 3, "default-bold", "left", "top", false, true, true) end draw = false function drawShout(text) if not draw then theText = text addEventHandler("onClientRender", root, drawText) draw = true setTimer(function() draw = false removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) function RGBColor(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return end Link to comment
Recommended Posts