Jump to content

New chat


Eshtiz

Recommended Posts

I'm trying to add a new chat, /i /info /ichat

This is what I got so far:

function infochat(thePlayer, commandName, ...) 
    if ( exports.global:isPlayerBronzeDonator(thePlayer) or exports.global:isPlayerAdmin(thePlayer) ) then 
        if not (...) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) 
        else 
            local message = table.concat({...}, " ") 
            local title = "" 
            local hidden = getElementData(thePlayer, "hiddenadmin") or 0 
  
  
  
  
            if ( exports.global:isPlayerAdmin(thePlayer) ) then 
                if (hidden == 1) or (exports.global:getPlayerAdminTitle(thePlayer) == "Player") then 
                    if not (exports.global:isPlayerBronzeDonator(thePlayer)) then 
                        title = "Bronze Donator" 
                    else 
                        title = exports.global:getPlayerDonatorTitle(thePlayer) 
                    end 
                else 
                    title = exports.global:getPlayerAdminTitle(thePlayer) 
                end 
            elseif ( exports.global:isPlayerBronzeDonator(thePlayer) ) then 
                title = exports.global:getPlayerDonatorTitle(thePlayer) 
            end 
                 
            for key, value in ipairs(getElementsByType("player")) do 
                if ( exports.global:isPlayerBronzeDonator(value) or exports.global:isPlayerAdmin(value) ) then 
                    if ( getElementData(value, "infochat") == 1 ) then 
                        outputChatBox("[Donator] " .. title .. " " .. getPlayerName(thePlayer) .. ": " .. message, value, 160, 164, 104) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("i", infochat, false, false) 
addCommandHandler("info", infochat, false, false) 
addCommandHandler("ichat", infochat, false, false) 

There is no error messages but it doesn't work.

Link to comment

Server side.

function infochat( thePlayer, commandName,... ) 
    if exports.global:isPlayerBronzeDonator( thePlayer ) or exports.global:isPlayerAdmin( thePlayer ) then 
        local tArgs = { ... } 
        if #tArgs == 0 then 
            outputChatBox( "SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14 ) 
        else 
            local message = table.concat( tArgs, " " ) 
            local title = "" 
            local hidden = getElementData( thePlayer, "hiddenadmin" ) or 0 
  
            if exports.global:isPlayerAdmin( thePlayer ) then 
                if hidden == 1 or exports.global:getPlayerAdminTitle( thePlayer ) == "Player" then 
                    if not exports.global:isPlayerBronzeDonator( thePlayer ) then 
                        title = "Bronze Donator" 
                    else 
                        title = exports.global:getPlayerDonatorTitle( thePlayer ) 
                    end 
                else 
                    title = exports.global:getPlayerAdminTitle( thePlayer ) 
                end 
            elseif exports.global:isPlayerBronzeDonator( thePlayer ) then 
                title = exports.global:getPlayerDonatorTitle( thePlayer ) 
            end 
                 
            for key, value in pairs( getElementsByType 'player' ) do 
                if exports.global:isPlayerBronzeDonator( value ) or exports.global:isPlayerAdmin( value ) then 
                    if getElementData( value, "infochat" ) == 1 then 
                        outputChatBox( "[Donator] " .. title .. " " .. getPlayerName( thePlayer ) .. ": " .. message, value, 160, 164, 104 ) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler( "i", infochat, false, false ) 
addCommandHandler( "info", infochat, false, false ) 
addCommandHandler( "ichat", infochat, false, false ) 

Link to comment
Show code in 1084 line.

Here:

function infochat( thePlayer, commandName,... ) 
    if exports.global:isPlayerBronzeDonator( thePlayer ) or exports.global:isPlayerAdmin( thePlayer ) then 
        local tArgs = { ... } 
        if #tArgs == 0 then 
            outputChatBox( "SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14 ) 
        else 
            local message = table.concat( tArgs, " " ) 
            local title = "" 
            local hidden = getElementData( thePlayer, "hiddenadmin" ) or 0 
  
            if exports.global:isPlayerAdmin( thePlayer ) then 
                if hidden == 1 or exports.global:getPlayerAdminTitle( thePlayer ) == "Player" then 
                    if not exports.global:isPlayerBronzeDonator( thePlayer ) then 
                        title = "Bronze Donator" 
                    else 
                        title = exports.global:getPlayerDonatorTitle( thePlayer ) 
                    end 
                else 
                    title = exports.global:getPlayerAdminTitle( thePlayer ) 
                end 
            elseif exports.global:isPlayerBronzeDonator( thePlayer ) then 
                title = exports.global:getPlayerDonatorTitle( thePlayer ) 
            end 
                
            for key, value in pairs( getElementsByType 'player' ) do 
                if exports.global:isPlayerBronzeDonator( value ) or exports.global:isPlayerAdmin( value ) then 
                    if getElementData( value, "infochat" ) == 1 then 
                        outputChatBox( "[Donator] " .. title .. " " .. getPlayerName( thePlayer ) .. ": " .. message, value, 160, 164, 104 ) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler( "i", infochat, false, false ) 
addCommandHandler( "info", infochat, false, false ) 
addCommandHandler( "ichat", infochat, false, false ) 

It's the fifth 'end'

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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