• Inicio
  • Miembros
  • STAFF
  • Ayuda
  • Buscar
  • Register
  • Login
  • Inicio
  • Miembros
  • Ayuda
  • Buscar
Foros de Araboth Roleplay Comunidad Aportes Sistema de graffity

 
  • 0 voto(s) - 0 Media
Sistema de graffity
Lucass
Sin conexión

Usuario
Registrados
Mensajes: 6
Temas: 5
Registro en: Mar 2024
Reputación: 2
#1
24-04-2024, 07:21 PM
Buenas chicos, quería aportar la base de un sistema de grafitis pero creo que éste sistema puede aportar mucho al servidor y dar mucho rol para las familias. Creo que con ésta base se les puede ocurrir muchas ideas y mejorarlo en un 200%, éxitos.

Código:
-- Creamos una tabla para almacenar los grafitis pendientes de aprobación
local grafitisPendientes = {}

-- Creamos una tabla para almacenar los grafitis realizados por cada familia
local grafitisPorFamilia = {}

-- Definimos una función para mostrar el panel de escritura
function mostrarPanelDeEscritura(player)
    -- Verificamos si la familia del jugador ha alcanzado el límite diario de grafitis
    local playerTeam = getPlayerTeam(player)
    if not playerTeam then
        outputChatBox("Necesitas pertenecer a una familia para hacer grafiti.", player, 255, 0, 0)
        return
    end
   
    local teamName = getTeamName(playerTeam)
    if not grafitisPorFamilia[teamName] then
        grafitisPorFamilia[teamName] = 0
    end
   
    if grafitisPorFamilia[teamName] >= 3 then
        outputChatBox("Tu familia ha alcanzado el límite diario de grafitis.", player, 255, 0, 0)
        return
    end
   
    -- Mostramos el panel de escritura
    local screenWidth, screenHeight = guiGetScreenSize()
    local panel = guiCreateWindow((screenWidth - 400) / 2, (screenHeight - 200) / 2, 400, 200, "Escribir grafiti", false)
    local editText = guiCreateEdit(0.05, 0.3, 0.9, 0.4, "", true, panel)
    local button = guiCreateButton(0.3, 0.7, 0.4, 0.2, "Confirmar", true, panel)
   
    addEventHandler("onClientGUIClick", button, function()
        local grafitiText = guiGetText(editText)
        destroyElement(panel)
        solicitarAprobacion(player, grafitiText)
    end, false)
end

-- Definimos una función para solicitar la aprobación del grafiti
function solicitarAprobacion(player, texto)
    table.insert(grafitisPendientes, {player = player, texto = texto})
    outputChatBox("¡Nuevo grafiti pendiente de aprobación!", root, 255, 255, 0)
end

-- Definimos una función para mostrar el panel de grafitis pendientes
function mostrarPanelDeGrafitisPendientes(admin)
    local screenWidth, screenHeight = guiGetScreenSize()
    local panel = guiCreateWindow((screenWidth - 400) / 2, (screenHeight - 300) / 2, 400, 300, "Grafitis Pendientes", false)
    local gridList = guiCreateGridList(0.05, 0.05, 0.9, 0.8, true, panel)
    guiGridListAddColumn(gridList, "Jugador", 0.5)
    guiGridListAddColumn(gridList, "Texto", 0.5)
   
    for _, grafiti in ipairs(grafitisPendientes) do
        local row = guiGridListAddRow(gridList)
        guiGridListSetItemText(gridList, row, 1, getPlayerName(grafiti.player), false, false)
        guiGridListSetItemText(gridList, row, 2, grafiti.texto, false, false)
    end
   
    local button = guiCreateButton(0.3, 0.9, 0.4, 0.1, "Aprobar seleccionados", true, panel)
   
    addEventHandler("onClientGUIClick", button, function()
        local selectedItems = guiGridListGetSelectedItems(gridList)
       
        for _, item in ipairs(selectedItems) do
            local row = item.row
            local grafiti = grafitisPendientes[row]
            realizarGrafiti(grafiti.player, grafiti.texto)
            table.remove(grafitisPendientes, row)
        end
       
        guiGridListClear(gridList)
        for _, grafiti in ipairs(grafitisPendientes) do
            local row = guiGridListAddRow(gridList)
            guiGridListSetItemText(gridList, row, 1, getPlayerName(grafiti.player), false, false)
            guiGridListSetItemText(gridList, row, 2, grafiti.texto, false, false)
        end
    end, false)
end

-- Definimos una función para verificar si un jugador es administrador
function isPlayerAdmin(player)
    -- Aquí debes agregar tu lógica para determinar si un jugador es administrador
    -- Por ejemplo, puedes usar una tabla de administradores o una función específica del servidor
    return true -- Por ahora asumiremos que todos los jugadores son administradores para fines de demostración
end

-- Definimos una función para realizar el grafiti en el juego
function realizarGrafiti(player, texto)
    local x, y, z = getElementPosition(player)
    local _, _, rot = getElementRotation(player)
    local offset = 1.5
    local grafitiX = x + offset * math.cos(math.rad(rot))
    local grafitiY = y + offset * math.sin(math.rad(rot))
    local grafitiObject = create3DText(texto, grafitiX, grafitiY, z, 0, 0, 0)
    outputChatBox("¡Grafiti realizado! Texto: " .. texto, player, 0, 255, 0)
   
    local playerTeam = getPlayerTeam(player)
    if playerTeam then
        local teamName = getTeamName(playerTeam)
        grafitisPorFamilia[teamName] = (grafitisPorFamilia[teamName] or 0) + 1
    end
end

-- Definimos un comando para que los administradores vean los grafitis pendientes
addCommandHandler("grafitispendientes", function(player)
    if not isPlayerAdmin(player) then
        outputChatBox("No tienes permiso para usar este comando.", player, 255, 0, 0)
        return
    end
   
    mostrarPanelDeGrafitisPendientes(player)
end)

-- Definimos un comando para que los jugadores hagan grafiti
addCommandHandler("grafiti", function(player)
    mostrarPanelDeEscritura(player)
end)

-- Restablecemos el contador de grafitis diario para cada familia al inicio de cada día (cada 24 horas)
setTimer(function()
    grafitisPorFamilia = {}
end, 24 * 60 * 60 * 1000, 0) -- Se ejecuta cada 24 horas

Hay que ajustar la función "isPlayerAdmin" para que refleje la lógica real de tu servidor para determinar si un jugador es administrador.
« Tema anterior | Tema siguiente »

Usuarios navegando en este tema: 1 invitado(s)



Mensajes en este tema
Sistema de graffity - por Lucass - 24-04-2024, 07:21 PM
RE: Sistema de graffity - por Breeze slot - 25-04-2024, 02:13 PM
RE: Sistema de graffity - por Lucass - 28-04-2024, 05:28 PM
RE: Sistema de graffity - por Ivako - 16-05-2024, 01:02 PM
RE: Sistema de graffity - por lollypop - 27-06-2024, 03:44 PM
RE: Sistema de graffity - por Nicolashh - 07-07-2024, 02:21 AM
RE: Sistema de graffity - por lollypop - 07-07-2024, 05:00 PM
RE: Sistema de graffity - por Nicolashh - 07-07-2024, 08:00 PM
RE: Sistema de graffity - por lollypop - 08-07-2024, 09:28 PM
RE: Sistema de graffity - por lollypop - 09-07-2024, 01:41 AM
RE: Sistema de graffity - por bliss - 21-04-2025, 04:09 PM
RE: Sistema de graffity - por DarkCOL - 24-04-2025, 07:33 PM
RE: Sistema de graffity - por Ivako - 30-04-2025, 03:41 AM

Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  Sistema de inventario de una propiedad pab1ogg 1 31 07-04-2025, 08:50 AM
Último mensaje: Ivako
  Sistema Economico y Administrativo Peco22 11 925 09-07-2024, 01:54 AM
Último mensaje: lollypop

  • Ver la versión para impresión
  • Suscribirse a este tema
Salto de foro:

© Designed by D&D - Powered by MyBB

Modo extendido
Modo compacto