Jump to content

[Ayuda] sistema de anuncios


DanielZ3RO

Recommended Posts

Hola..

estoy haciendo un sistema de anuncios para cuando un admin escriba /anuncio (texto) salga el anuncio en la parte inferior de la pantalla, pero no tengo ni idea que es lo que no funciona :c

Client-Side

addEvent("Anuncios",true) 
addEventHandler("Anuncios",localPlayer, 
function Anuncios(message) 
message = message 
addEventHandler("onClientRender", getRootElement(), 
    function () 
        local sWidth, sHeight =  guiGetScreenSize ( ) 
        dxDrawRectangle(sWidth * 0,sHeight * 0.95,sWidth * 1,sHeight* 0.05, tocolor(0, 0, 0, 150), true) 
        dxDrawText(message,sWidth * 1,sHeight * 0.933,sWidth * 0.05,sHeight * 1.01, tocolor(255, 255, 0, 255), 2.20, "default", "center", "center", false, false, true, false, false) 
 end) 
) 
end 
  
  
function remover() 
removeEventHandler("onClientRender", getRootElement(), drawText, drawRectangle) 
end 
  
setTimer ( remover, 5000, 1) 

Sever-Side

function Anuncio1( thePlayer, commandName, ...) 
local usuario = getAccountName ( getPlayerAccount ( thePlayer ) ) 
if isObjectInACLGroup ( "user.".. usuario, aclGetGroup ( "Admin" ) ) then 
 local message = table.concat({...}," ") 
 triggerClientEvent ( "onAnuncios", getRootElement(), message ) 
end 
end 
addCommandHandler( "anuncio", Anuncio1 ) 

Si me pueden ayudar todos se los agradeceria muchisimo

Link to comment
  • MTA Team

Client:

  
addEvent("onAnuncios",true) 
addEventHandler("onAnuncios",localPlayer, 
function (message) 
message = message 
addEventHandler("onClientRender", localPlayer,drawText) 
 setTimer(removeEventHandler,5000,1,localPlayer,drawText) 
) 
end 
sWidth, sHeight =  guiGetScreenSize ( ) 
function drawText () 
        dxDrawRectangle(sWidth * 0,sHeight * 0.95,sWidth * 1,sHeight* 0.05, tocolor(0, 0, 0, 150), true) 
        dxDrawText(message,sWidth * 1,sHeight * 0.933,sWidth * 0.05,sHeight * 1.01, tocolor(255, 255, 0, 255), 2.20, "default", "center", "center", false, false, true, false, false) 
        end 

Link to comment

me pueden ayudar porfa, ahora sale el cuadro antes de que ponga el anuncio, y pongo el anuncio y el cuadro sale por un segundo o menos :c (y pasa lo mismo cuando le cambio el tiempo del setTimer )

server

function anuncios(player, cmd, ...) 
    local accountname = getAccountName(getPlayerAccount(player)) 
    if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then 
        for id, players in ipairs(getElementsByType("player")) do 
            local message = table.concat({...}," ") 
            local textChat = textCreateDisplay () 
            local textItem = textCreateTextItem( message, 0.5, 0.971, 1.5, 255 ,255, 0, 255, 2.2, "center", "center") 
            textDisplayAddText ( textChat, textItem ) 
            textDisplayAddObserver ( textChat, players ) 
            setTimer ( textDestroyTextItem, 3000, 1, textItem ) 
            setTimer ( textDestroyDisplay, 3000, 1, textChat ) 
            triggerClientEvent ( "onCuadro", getRootElement())   
        end 
    end 
end 
addCommandHandler("anuncio", anuncios) 

client

function cuadrito () 
        local sWidth, sHeight =  guiGetScreenSize () 
        dxDrawRectangle(sWidth * 0,sHeight * 0.95,sWidth * 1,sHeight* 0.05, tocolor(0, 0, 0, 150), false) 
        setTimer ( remover, 7000, 1, cuadro) 
end 
addEvent( "onCuadro", true ) 
addEventHandler( "onCuadro", getRootElement(), cuadrito ) 
  
addEventHandler("onClientRender", getRootElement(), cuadrito ) 
  
function remover() 
removeEventHandler("onClientRender", getRootElement(), cuadrito ) 
end 

Link to comment
  • Recently Browsing   0 members

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