Jump to content

Admin tags in Global


Eshtiz

Recommended Posts

Posted (edited)

I've been trying myself on this script lately, I've been trying to add admin in /o (GOOC), I keep failing, a new chat pops up in T /say instead, I'm getting really confused about it.

here's the script I'm trying on:

function globalOOC(thePlayer, commandName, ...) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then 
     cancelEvent(true) 
        outputChatBox("#855863[HEAD]  #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [HEAD] " .. name .. ": " .. text) 
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
     cancelEvent(true) 
        outputChatBox("#855863[sMOD]  #FFFFFF" .. name ..":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [sMOD] " .. name .. ": " .. text) 
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
     cancelEvent(true) 
        outputChatBox("#855863[MOD]  #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [MOD] " .. name .. ": " .. text) 
  
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
     cancelEvent(true) 
        outputChatBox(name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: " .. name .. ": " .. text) 
        end 
  
elseif (msgtype == 2) then 
  
end 
end 
addCommandHandler("o", globalOOC, false, false) 
addCommandHandler("GlobalOOC", globalOOC) 
  
function RGBToHex(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 nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 

https://community.multitheftauto.com/index.php?p= ... ls&id=2963

(Global Out Of Character)

Would be awesome if I could get some help with this.

Edited by Guest
Posted

Err... guy u are crazy look this like of your code

function globalOOC(thePlayer, commandName, ...) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then 
     cancelEvent(true) 

---------------------------------------

if (msgtype == 0) then

if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then

cancelEvent(true)

----------------------------------------

if noone talk u are asking for get the headadmin account then cancelevent? wtf

u have to get who don`t said then cancel the event then ask for account get

so look how:

if (msgtype == 0) then 
cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then 
  

then u can and u don`t need cancel the event all the time :)

Posted

Still the same problem,

here's the GOOC Script:

function globalOOC(thePlayer, commandName, ...) 
    local logged = tonumber(getElementData(thePlayer, "loggedin")) 
     
    if (logged==1) then 
        if not (...) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) 
        else 
            local oocEnabled = exports.global:getOOCState() 
            message = table.concat({...}, " ") 
            local muted = getElementData(thePlayer, "muted") 
            if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then 
                outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) 
            elseif (muted==1) then 
                outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) 
            else 
                local players = exports.pool:getPoolElementsByType("player") 
                local playerName = getPlayerName(thePlayer) 
                local playerID = getElementData(thePlayer, "playerid") 
                     
                exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) 
                for k, arrayPlayer in ipairs(players) do 
                    local logged = tonumber(getElementData(arrayPlayer, "loggedin")) 
                    local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") 
  
                    if (logged==1) and (targetOOCEnabled==1) then 
                        outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("o", globalOOC, false, false) 
addCommandHandler("GlobalOOC", globalOOC) 

Posted
function ChatSystem(msg,msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then 
        outputChatBox("#855863[HEAD]  #FFFFFF" .. name .. ":#FFFFFF " .. msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [HEAD] " .. name .. ": " .. msg) 
     else   
     if isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
        outputChatBox("#855863[sMOD]  #FFFFFF" .. name ..":#FFFFFF " ..msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [sMOD] " .. name .. ": " .. msg) 
      else  
   if isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
        outputChatBox("#855863[MOD]  #FFFFFF" .. name .. ":#FFFFFF " .. msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [MOD] " .. name .. ": " .. msg) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
        outputChatBox(name .. ":#FFFFFF " .. msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: " .. name .. ": " .. msg) 
end 
end 
end 
end 
end 
addEventHandler("onPlayerChat",getRootElement(),ChatSystem) 
  
function RGBToHex(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 nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 

maybe this will work?

Posted

Nop, afraid not :S

Here's my acl, I might of placed the 'HeadAdmin' account wrong( I don't think so, just making sure everything's correct).

  
  "Everyone"> 
      "Default"/> 
      "user.*"/> 
      "resource.*"/> 
    "resource.ucp"/> 
   
   "Moderator"> 
      "Moderator"/> 
      "resource.mapcycler"/> 
      "resource.mapmanager"/> 
      "resource.resourcemanager"/> 
      "resource.votemanager"/> 
   
   "SuperModerator"> 
      "Moderator"/> 
      "SuperModerator"/> 
      "HeadAdmin"/> 
      "user.testtest"> 
      "Developer"/> 
   
   "Admin"> 
      "Moderator"/> 
      "SuperModerator"/> 
      "Admin"/> 

Posted
function ChatSystem(msg,msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then 
        outputChatBox("#855863[HEAD]  #FFFFFF" .. name .. ":#FFFFFF " .. msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [HEAD] " .. name .. ": " .. msg) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
        outputChatBox("#855863[sMOD]  #FFFFFF" .. name ..":#FFFFFF " ..msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [sMOD] " .. name .. ": " .. msg) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
        outputChatBox("#855863[MOD]  #FFFFFF" .. name .. ":#FFFFFF " .. msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [MOD] " .. name .. ": " .. msg) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
        outputChatBox(name .. ":#FFFFFF " .. msg, root, 255, 255, 255, true) 
        outputServerLog("CHAT: " .. name .. ": " .. msg) 
        end 
    end 
end 
addEventHandler("onPlayerChat",getRootElement(),ChatSystem) 
  
function RGBToHex(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 nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 

Posted

Still the same I'm afraid, tested both, same problem, it creates a new chat in 'T' ( /say ), GOOC is in /o, any way to transfer it?

Posted

That script works fine, I've tested and if I'm SuperModerator it'll output with SMOD tag, same for HeadAdmin and so on.

What are you trying to achieve?

Posted

Well, I'm trying to get an 'admin tag' behind 'player(admins) names' in GOOC chat, /o and so on. Since it's a Roleplay script, there's three 'main chats', IC = /say, LOOC B = /b, GOOC = /o , when I use your script in a separete resource from the chat-system, it duplicates the /say chat which ain't exactly what I'm trying to achieve, I want/need it to squeeze in an admin tag behind the player names in GOOC.

Posted

You are using vG scripts, right? if I remember well, they use own account system, so that would mean they don't use the MTA default account's. If that's correct, then it'll never work like this.

Posted

Yeh, vg scripts.

But I discovered how to fix it, quite simple actually but I still need help with two things,

Here's the GOOC Script together with the admin tag script.

function globalOOC(thePlayer, commandName, ...) 
    local logged = tonumber(getElementData(thePlayer, "loggedin")) 
    
    if (logged==1) then 
        if not (...) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) 
        else 
            local oocEnabled = exports.global:getOOCState() 
            message = table.concat({...}, " ") 
            local muted = getElementData(thePlayer, "muted") 
            if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then 
                outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) 
            elseif (muted==1) then 
                outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) 
            else 
                local players = exports.pool:getPoolElementsByType("player") 
                local playerName = getPlayerName(thePlayer) 
                local playerID = getElementData(thePlayer, "playerid") 
                    
                exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) 
                for k, arrayPlayer in ipairs(players) do 
                    local logged = tonumber(getElementData(arrayPlayer, "loggedin")) 
                    local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") 
                    local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
                    if (logged==1) and (targetOOCEnabled==1) then 
                        outputChatBox("(( [GOOC] [" .. tostring(adminTitle) .. "] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("o", globalOOC, false, false) 
addCommandHandler("GlobalOOC", globalOOC) 

As you see, it was only two lines I had to add, but regular players(admin level 0) has tag name [Player], I need to remove it since it get's weird and not very special.

And I need to add a r g b color for the tag, someone knows how I add this to it?

Posted

I don't understand your problem. You want to add R, G, B to the chat message?

function globalOOC(thePlayer, commandName, ...) 
    local logged = tonumber(getElementData(thePlayer, "loggedin")) 
    
    if (logged==1) then 
        if not (...) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) 
        else 
            local oocEnabled = exports.global:getOOCState() 
            message = table.concat({...}, " ") 
            local muted = getElementData(thePlayer, "muted") 
            if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then 
                outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) 
            elseif (muted==1) then 
                outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) 
            else 
                local players = exports.pool:getPoolElementsByType("player") 
                local playerName = getPlayerName(thePlayer) 
                local playerID = getElementData(thePlayer, "playerid") 
                local r, g, b = getPlayerNametagColor(thePlayer) 
                local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
  
                exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) 
  
                for k, arrayPlayer in ipairs(players) do 
                    local logged = tonumber(getElementData(arrayPlayer, "loggedin")) 
                    local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") 
                    if (logged==1) and (targetOOCEnabled==1) then 
                        outputChatBox("(( [GOOC] [" .. tostring(adminTitle) .. "] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, r, g, b) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("o", globalOOC, false, false) 
addCommandHandler("GlobalOOC", globalOOC) 

Posted

To the admintag,

here:

outputChatBox("(( [GOOC] [" .. tostring(adminTitle) .. "] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204) 

this part:

[" .. tostring(adminTitle) .. "] 

I want to be a specific color a part from the chat text.

Posted
function globalOOC(thePlayer, commandName, ...) 
    local logged = tonumber(getElementData(thePlayer, "loggedin")) 
    
    if (logged==1) then 
        if not (...) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) 
        else 
            local oocEnabled = exports.global:getOOCState() 
            message = table.concat({...}, " ") 
            local muted = getElementData(thePlayer, "muted") 
            if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then 
                outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) 
            elseif (muted==1) then 
                outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) 
            else 
                local players = exports.pool:getPoolElementsByType("player") 
                local playerName = getPlayerName(thePlayer) 
                local playerID = getElementData(thePlayer, "playerid") 
                local r, g, b = getPlayerNametagColor(thePlayer) 
                local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
  
                exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) 
  
                for k, arrayPlayer in ipairs(players) do 
                    local logged = tonumber(getElementData(arrayPlayer, "loggedin")) 
                    local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") 
                    if (logged==1) and (targetOOCEnabled==1) then 
                        outputChatBox("(( [GOOC] #FF0000[" .. tostring(adminTitle) .. "]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("o", globalOOC, false, false) 
addCommandHandler("GlobalOOC", globalOOC) 

Posted

Works perfectly, thanks! but as I said in the comment above, I need to disable the tag for regular players, admin level 0, anyone have any idea how to do that?

Posted
function globalOOC(thePlayer, commandName, ...) 
    local logged = tonumber(getElementData(thePlayer, "loggedin")) 
    
    if (logged==1) then 
        if not (...) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) 
        else 
            local oocEnabled = exports.global:getOOCState() 
            message = table.concat({...}, " ") 
            local muted = getElementData(thePlayer, "muted") 
            if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then 
                outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) 
            elseif (muted==1) then 
                outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) 
            else 
                local players = exports.pool:getPoolElementsByType("player") 
                local playerName = getPlayerName(thePlayer) 
                local playerID = getElementData(thePlayer, "playerid") 
                local r, g, b = getPlayerNametagColor(thePlayer) 
                local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
  
                exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) 
  
                for k, arrayPlayer in ipairs(players) do 
                    local logged = tonumber(getElementData(arrayPlayer, "loggedin")) 
                    local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") 
                    if (logged==1) and (targetOOCEnabled==1) then 
                        if exports.global:isPlayerAdmin(thePlayer) then 
                            outputChatBox("(( [GOOC] #FF0000[" .. tostring(adminTitle) .. "]#FFFFCC (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) 
                        else 
                            outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204, true) 
                        end 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("o", globalOOC, false, false) 
addCommandHandler("GlobalOOC", globalOOC) 

Do you mean that?

Posted

Exactly like that, thank you so much.

But I just discovered another problem ;S

As there's hidden player admins, /hideadmin, it shows (hidden) in the chat.

I've tried to move around and use lines from this script:

                                                                        local hiddenAdmin = getElementData(thePlayer, "hiddenadmin") 
                     
                    if (hiddenAdmin==0) then 
                        local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) 
                        exports.global:sendMessageToAdmins(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " slapped " .. targetPlayerName .. ".") 
                    outputChatBox(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " slapped " .. targetPlayerName .. ".", getRootElement(), 255, 0, 51) 
                         
                        exports.logs:logMessage("[/slap] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." slapped ".. targetPlayerName , 4) 
                        triggerEvent("removeTintName", targetPlayer) 

To the GOOC script but I can't hide the hidden admin in GOOC.

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