Jump to content

Ayuda, problema resource de anuncios


ztarkito

Recommended Posts

Buenas, les explico mi problema, me han dejado a cargo de un servidor, su creador se ha retirado y me ha dejado a mi (novato en script) y el problema que tengo es que el resource de anuncios( indica mensajes random en la parte superior de la pantalla) funciona perfectamente en mi servidor casero, pero al momento de hostearlo y iniciarlo en el servidor, no pasa absolutamente nada, no me sale ningun error ni nada, pero no logro hacer que los mensajes funcionen automaticamente...

Lo que pido es que me ayuden a encontrar este problema para que el resource funcione en el servidor online.

Muchas Gracias de Antemano.

CLIENTE

--ANUNCIOS 
root = getRootElement() 
rroot = getResourceRootElement() 
lplayer = getLocalPlayer() 
addEvent("mostraraviso",true) 
  
sx,sy = guiGetScreenSize() 
function ConvertRelativeToXY(rx, ry) 
  local x = sx * rx 
  local y = sy * ry 
  return x, y 
end 
  
local color = 200 
local adtxt = "" 
local _,ady = ConvertRelativeToXY(0, 0.05) 
local timer 
function cargaraviso() 
    if color > 0 then 
        color = color - 5 
    end 
    dxDrawRectangle(0.0,0,sx,ady,tocolor(color,color,0,200),false) 
    dxDrawText(adtxt,0,0,sx,ady,tocolor(255,255,255,255),2,"default","center") 
end 
  
function aviso(texto) 
    color = 200 
    adtxt = texto 
    if not timer then 
        addEventHandler("onClientRender",root,cargaraviso) 
        timer = setTimer(function() 
            removeEventHandler("onClientRender",root,cargaraviso) 
            timer = nil 
        end,10000,1) 
    else 
        killTimer(timer) 
        timer = setTimer(function() 
            removeEventHandler("onClientRender",root,cargaraviso) 
            timer = nil 
        end,10000,1) 
    end 
end 
addEventHandler("mostraraviso",root,aviso) 

MAIN

packets = {} 
packets[1] = 0 
packets[2] = 0 
packets[3] = 0 
packets[4] = 0 
packets[5] = 0 
  
addEventHandler("onResourceStart",getResourceRootElement(),function() 
    setTimer(anuncios,240000,0) 
end) 
  
--ANUNCIOS 
local anuncio = { 
    "Cheaters? /report", 
    "Cuidado con chocar", 
} 
  
function anuncios() 
    local rand = math.random(1,#anuncio) 
     
    triggerClientEvent("mostraraviso",getRootElement(),anuncio[rand]) 
    packets[1] = packets[1] + 1 
     
    packets[1] = 0 
    packets[2] = 0 
    packets[3] = 0 
    packets[4] = 0 
    packets[5] = 0 
     
    local tiempo = getRealTime() 
    local hora = getTime() 
    if tiempo.hour == 22 and (hora > 23 or hora < 3) then 
        iniciarUFO() 
    end 
end 

Link to comment

Client

--ANUNCIOS 
root = getRootElement() 
rroot = getResourceRootElement() 
lplayer = getLocalPlayer() 
  
  
sx,sy = guiGetScreenSize() 
function ConvertRelativeToXY(rx, ry) 
  local x = sx * rx 
  local y = sy * ry 
  return x, y 
end 
  
local color = 200 
local adtxt = "" 
local ady = ConvertRelativeToXY(0, 0.05) 
local timer = setTimer 
function cargaraviso() 
    if color > 0 then 
        color = color - 5 
    end 
    dxDrawRectangle(0.0,0,sx,ady,tocolor(200,200,0,200),false) 
    dxDrawText(adtxt,0,0,sx,ady,tocolor(255,255,255,255),2,"default","center") 
end 
  
function aviso(texto) 
    color = 200 
    adtxt = texto 
    if not timer then 
        addEventHandler("onClientRender",root,cargaraviso) 
        timer = setTimer(function() 
            removeEventHandler("onClientRender",root,cargaraviso) 
            timer = nil 
        end,10000,1) 
    else 
        killTimer(timer) 
        timer = setTimer(function() 
            removeEventHandler("onClientRender",root,cargaraviso) 
            timer = nil 
        end,10000,1) 
    end 
end 
addEvent("mostraraviso",true) 
addEventHandler("mostraraviso",root,aviso) 

main server

packets = {} 
packets[1] = 0 
packets[2] = 0 
packets[3] = 0 
packets[4] = 0 
packets[5] = 0 
  
addEventHandler("onResourceStart",getResourceRootElement(),function() 
    setTimer(anuncios,240000,0) 
end) 
  
--ANUNCIOS 
local anuncio = { 
    "Cheaters? /report", 
    "Cuidado con chocar", 
} 
  
function anuncios() 
    local rand = math.random(1,#anuncio) 
    
    triggerClientEvent("mostraraviso",getRootElement(),anuncio) 
    packets[1] = packets[1] + 1 
    
    packets[1] = 0 
    packets[2] = 0 
    packets[3] = 0 
    packets[4] = 0 
    packets[5] = 0 
    
    local tiempo = getRealTime() 
    local hora = getTime() 
    if tiempo.hora == 22 and (hora > 23 or hora < 3) then 
        iniciarUFO() 
    end 
end 

Link to comment
  • Recently Browsing   0 members

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