Jump to content

Script Problem


IvkO

Recommended Posts

Hi Guys :)

I have a little problem and cant solve it even though i'm trying to understand scripting . I wanna combine colouredchat + admin tags for my server.I made an account ivo and when i'm not logged in as you can see in "1" part of the script works ( player's message's color becomes like his nametag color ).But when i log in my acc and i time a thing it gets that double effect bug in "2".

My point is when i login to be only this [sMOD] ivo: eeeee and inverse

333ka.png

Heres the code :

function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
    cancelEvent(true) 
        outputChatBox("#DD23D4[sMOD] #DD23D4" .. name ..":#DD23D4 " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [sMOD] " .. name .. ": " .. text) 
    
   elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
    cancelEvent(true) 
        outputChatBox("#F4F82C[MOD] #F4F82C".. name .. ":#F4F82C " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [MOD] " .. name .. ": " .. text) 
  
  elseif isObjectInACLGroup(aclGetName("Default")) then 
   function colouredChat ( message, theType ) 
    if theType == 0  then 
        cancelEvent() 
        message = string.gsub(message, "#%x%x%x%x%x%x", "") 
        local r,g,b = getPlayerNametagColor ( source ) 
        local chatterName = getPlayerName ( source ) 
        outputChatBox ( chatterName..": " ..message, getRootElement(), r, g, b, true ) 
     end 
   end 
  addEventHandler("onPlayerChat", getRootElement(), colouredChat)    
  end 
elseif (msgtype == 2) then 
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 

I will be very grateful if you help me :)

Link to comment
function chatbox ( text, msgtype ) 
    local account = getAccountName ( getPlayerAccount ( source ) ) 
    local name = getPlayerName ( source ) 
    if ( msgtype == 0 ) then 
        if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "SuperModerator" ) ) then 
            outputChatBox ( "#DD23D4[sMOD] #DD23D4" .. name ..":#DD23D4 " .. text, root, 255, 255, 255, true ) 
            outputServerLog ( "CHAT: [sMOD] " .. name .. ": " .. text ) 
        elseif isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Moderator" ) ) then 
            outputChatBox ( "#F4F82C[MOD] #F4F82C".. name .. ":#F4F82C " .. text, root, 255, 255, 255, true ) 
            outputServerLog ( "CHAT: [MOD] " .. name .. ": " .. text ) 
        else 
            local message = string.gsub ( text, "#%x%x%x%x%x%x", "" ) 
            local r, g, b = getPlayerNametagColor ( source ) 
            outputChatBox ( name ..": ".. message, getRootElement(), r, g, b, true ) 
        end 
    cancelEvent ( true ) 
    elseif ( msgtype == 2 ) then 
    end 
end 
addEventHandler ( "onPlayerChat", root, chatbox ) 

Try that.

Link to comment

Is there a way to write smth in my code here

if (msgtype == 0) then 
    if isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
         cancelEvent(true) 
        outputChatBox("#DD23D4[sMOD] #DD23D4" .. name ..":#DD23D4 " .. text, root, 255, 255, 255, true) 
        outputServerLog ( "CHAT: [sMOD] " .. name .. ": " .. text ) 

that can skip or stop the function "colouredchat" below ?

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