Jump to content

Tag


Wei

Recommended Posts

Posted

Is there any way to if it's player i team (in my case Staff team) to make a tag in a front of a name without changing nick?

Posted

You would need to edit every single resource that displays the player's name, there is no other way to do that. Normally you are changing the nicks. What gamemode are you using?

  • Moderators
Posted

Try:

  
  
-- server!!! 
function stafftag(text, msgtype) 
local root = getRootElement() -- get player 
local account = getAccountName(getPlayerAccount(source)) -- get account (admin) 
local name = getPlayerName(source) --your name 
if (msgtype == 0) then -- the type 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then -- check if admin 
     cancelEvent(true) -- stop using chat 
        outputChatBox("#000000[sTAFF]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) -- replace with [color=#000000][sTAFF][/color] Name and text 
        
end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, stafftag) 
  

Here you are.

Posted
Try:
  
  
-- server!!! 
function stafftag(text, msgtype) 
local root = getRootElement() -- get player 
local account = getAccountName(getPlayerAccount(source)) -- get account (admin) 
local name = getPlayerName(source) --your name 
if (msgtype == 0) then -- the type 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then -- check if admin 
     cancelEvent(true) -- stop using chat 
        outputChatBox("#000000[sTAFF]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) -- replace with [color=#000000][sTAFF][/color] Name and text 
        
end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, stafftag) 
  

Here you are.

lol wtf?

-- server!!! 
function stafftag(text, msgtype) 
    local root = getRootElement() -- get player 
    local account = getAccountName(getPlayerAccount(source)) -- get account (admin) 
    local name = getPlayerName(source) --your name 
    if (msgtype == 0) then -- the type 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then -- check if admin 
            outputChatBox("#000000[sTAFF]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) -- replace with [sTAFF] Name and text 
        else 
            outputChatBox(name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 
  

Posted

You need to cancel the event, else it will output two times.

-- server!!! 
function stafftag(text, msgtype) 
    local account = getAccountName(getPlayerAccount(source)) -- get account (admin) 
    local name = getPlayerName(source) --your name 
    if (msgtype == 0) then -- the type 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then -- check if admin 
            outputChatBox("#000000[sTAFF]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) -- replace with [sTAFF] Name and text 
            cancelEvent() 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

Posted
-- server!!! 
function stafftag(text, msgtype) 
    local root = getRootElement() 
    local account = getPlayerAccount ( source ) 
    local name = getPlayerName(source)  
    if (msgtype == 0) then 
    if isGuestAccount ( source ) then 
            outputChatBox("#000000[GUEST]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        else 
            outputChatBox(name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

is this code is right?

Posted
-- server!!! 
function stafftag(text, msgtype) 
    local root = getRootElement() 
    local account = getPlayerAccount ( source ) 
    local name = getPlayerName(source)  
    if (msgtype == 0) then 
    if isGuestAccount ( source ) then 
            outputChatBox("#000000[GUEST]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        else 
            outputChatBox(name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

is this code is right?

no man this ain't right

you didn't mentioned acl and the type of chat:-

function chatbox(text, msgtype) 
    local account = getAccountName(getPlayerAccount(source)) 
    local name = getPlayerName(source) 
    local r, g, b = getPlayerNametagColor(source) 
    local hex = RGBToHex(r, g, b) 
    if (msgtype == 0) then 
        if isObjectInACLGroup("user." .. account, aclGetGroup("[color=#FF4000]give acl here[/color]")) then 
            cancelEvent(true) 
            outputChatBox("  #8B1A1A[[color=#FF0000]Set the Tag here[/color]] ".. hex .."".. name ..": #FFFFFF".. text, root, 255, 255, 255, true) 
 end 
    end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
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
-- server!!! 
function stafftag(text, msgtype) 
    local root = getRootElement() 
    local account = getPlayerAccount ( source ) 
    local name = getPlayerName(source)  
    if (msgtype == 0) then 
    if isGuestAccount ( source ) then 
            outputChatBox("#000000[GUEST]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        else 
            outputChatBox(name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

is this code is right?

-- server 
function stafftag(text, msgtype) 
    local account = getPlayerAccount ( source ) 
    local name = getPlayerName(source) 
    if (msgtype == 0) then 
    if isGuestAccount (source) then 
            cancelEvent() 
            outputChatBox("#000000[GUEST]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

No need to define root, it's already defined.

Posted
-- server!!! 
function stafftag(text, msgtype) 
    local root = getRootElement() 
    local account = getPlayerAccount ( source ) 
    local name = getPlayerName(source)  
    if (msgtype == 0) then 
    if isGuestAccount ( source ) then 
            outputChatBox("#000000[GUEST]  #0066FF" .. name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        else 
            outputChatBox(name .. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

is this code is right?

man check it won't show the tag

it will simply give 2 and same outputs for every acl group

Posted
-- server!!! 
function stafftag(text, msgtype) 
    local account = getPlayerAccount(source) 
    local name = getPlayerName(source) 
    if (msgtype == 0) then 
    if isGuestAccount(account) then 
            outputChatBox("#000000[GUEST]  #0066FF"..name..":#0066FF "..text, root, 255, 255, 255, true) 
        else 
            outputChatBox(name.. ":#0066FF " .. text, root, 255, 255, 255, true) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, stafftag) 

  • Moderators
Posted

It is because your gamemode is PLAY (freeroam)...

This is in the resource freeroam:

addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
        if type == 0 then 
            cancelEvent() 
            if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then 
                outputChatBox("Stop spamming main chat!", source, 255, 0, 0) 
                return 
            else 
                chatTime[source] = getTickCount() 
            end 
            if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then 
                outputChatBox("Stop repeating yourself!", source, 255, 0, 0) 
                return 
            else 
                lastChatMessage[source] = msg 
            end 
            local r, g, b = getPlayerNametagColor(source) 
            outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. msg:gsub('#%x%x%x%x%x%x', ''), g_Root, r, g, b, true) 
            outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) 
        end 
    end 
) 

I think you have to change it to:

addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
        if type == 0 then 
            if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then 
            cancelEvent() 
            outputChatBox("Stop spamming main chat!", source, 255, 0, 0) 
  
            else 
                chatTime[source] = getTickCount() 
            end 
            if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then 
            cancelEvent() 
            outputChatBox("Stop repeating yourself!", source, 255, 0, 0) 
  
            else 
                lastChatMessage[source] = msg -- I am not sure if I have to remove this to. 
            end 
        end 
    end 
) 

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