Jump to content

Shout Admin


Flipi

Recommended Posts

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
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

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

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

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

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

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

ya lo probé y funciona pero aparece a un costado, tienes que arreglar las coordenadas.

muchas gracias :D!, 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

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
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
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
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

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
  • Recently Browsing   0 members

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