Jump to content

[SOLVED] AdminTag, help needed.


Recommended Posts

hey guys, its me again, i am requesting some help, i learned from my if mistakes, but now i fear of my else mistakes, can someone tell me why this won't add [ADMIN]/[MOD]/[sMOD] before someone's name, i tried to get this working. I am a beginner, and i wish to make this public soon. it will be editable. I will give credit to those who helped. I do thank TAPL for his last hand. Now i need help on this. Please can someone also explain Else's, if's, elseif's, do's, ect, and examples. I have learn most of my knowledge off the wiki. Thats why i am posting here now, to take it the next step.

function chatbox(command, text) 
local ncolor = getPlayerNametagColor() 
local name = getPlayerName(source) 
if (aclGetGroup() == Admin) then 
outputChatBox("#FF0000[ADMIN] "..ncolor..name..": "..text) 
outputServerLog( "CHAT: [ADMIN] " .. getPlayerName ( source ).. ": " .. text) 
end 
else 
if (aclGetGroup() == SuperModerator) then 
outputChatBox("#FFAE00[sMOD] "..ncolor..name..": "..text) 
outputServerLog( "CHAT: [sMOD] " .. getPlayerName ( source ).. ": " .. text ) 
end 
else 
if (aclGetGroup() == Moderator) then 
outputChatBox("#00FF00[MOD] "..ncolor..name..": "..text) 
outputServerLog( "CHAT: [MOD] " .. getPlayerName ( source ).. ": " .. text ) 
end 
else 
if (aclGetGroup() == Everyone) then 
outputChatBox(ncolor..name..": "..text) 
outputServerLog( "CHAT: " .. getPlayerName ( source ).. ": " .. text ) 
end 
end 
addEventHandler("onPlayerChat", chatbox) 

Edited by Guest
Link to comment

well your event handler, function parameters,IF conditions and elses were a mess, just take a look below..

    function chatbox(text, command) 
    local ncolor = getPlayerNametagColor() 
    local name = getPlayerName(source) 
    local accountname = getAccountName (getPlayerAccount(v)) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
    cancelEvent() 
    outputChatBox("#FF0000[ADMIN] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [ADMIN] " .. getPlayerName ( source ).. ": " .. text) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "SuperModerator" ) ) then 
    cancelEvent() 
    outputChatBox("#FFAE00[sMOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [sMOD] " .. getPlayerName ( source ).. ": " .. text ) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Moderator" ) ) then 
    cancelEvent() 
    outputChatBox("#00FF00[MOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [MOD] " .. getPlayerName ( source ).. ": " .. text ) 
    end 
    end 
    addEventHandler("onPlayerChat", getRootElement(), chatbox) 

Link to comment

ok, so i see my mistakes, but the script won't work. I see where i went wrong, thank you alot. Do you know why it wont work?

well your event handler, function parameters,IF conditions and elses were a mess, just take a look below..
    function chatbox(text, command) 
    local ncolor = getPlayerNametagColor() 
    local name = getPlayerName(source) 
    local accountname = getAccountName (getPlayerAccount(v)) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
    cancelEvent() 
    outputChatBox("#FF0000[ADMIN] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [ADMIN] " .. getPlayerName ( source ).. ": " .. text) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "SuperModerator" ) ) then 
    cancelEvent() 
    outputChatBox("#FFAE00[sMOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [sMOD] " .. getPlayerName ( source ).. ": " .. text ) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Moderator" ) ) then 
    cancelEvent() 
    outputChatBox("#00FF00[MOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [MOD] " .. getPlayerName ( source ).. ": " .. text ) 
    end 
    end 
    addEventHandler("onPlayerChat", getRootElement(), chatbox) 

Link to comment

Well, a lot of things that had to be changed, but try this. Not tested!

function chatbox(player, ...) 
    local ncolor = getPlayerNametagColor() 
    local name = getPlayerName(player) 
     
    local word = { ... } 
    local text = table.concat(word, " ") 
     
    local account = getAccountName(getPlayerAccount(player)) 
  
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
        outputChatBox("#FF0000[ADMIN] " .. ncolor .. name .. ": " .. text, getRootElement(), 255, 255, 255, true) 
        outputServerLog("CHAT: [ADMIN] " .. name .. ": " .. text) 
         
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
        outputChatBox("#FFAE00[sMOD] " .. ncolor .. name ..": " .. text, getRootElement(), 255, 255, 255, true) 
        outputServerLog("CHAT: [sMOD] " .. name .. ": " .. text) 
         
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
        outputChatBox("#00FF00[MOD] " .. ncolor .. name .. ": " .. text, getRootElement(), 255, 255, 255, true) 
        outputServerLog("CHAT: [MOD] " .. name .. ": " .. text) 
    end 
end 
addEventHandler("onPlayerChat", getRootElement(), chatbox) 

Link to comment

meta.xml

<meta> 
    <info name="Chatbox" type="script" /> 
     
    <script src="server.lua" type="server" /> <!-- Server --> 
</meta> 

acl.xml

<group name="Admin"> 
        <acl name="Moderator"></acl> 
        <acl name="SuperModerator"></acl> 
        <acl name="Admin"></acl> 
        <acl name="RPC"></acl> 
        <object name="user.[color=#00FF00][b]youraccounthere[/b][/color]"></object> 
</group> 

server.lua (untested)

local root = getRootElement() 
  
function chatbox(...) 
    local account = getAccountName(getPlayerAccount(source)) 
    local name = getPlayerName(source) 
    
    local word = { ... } 
    local text = table.concat(word, " ") 
  
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
        outputChatBox("#FF0000[ADMIN] " .. name .. ": " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [ADMIN] " .. name .. ": " .. text) 
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
        outputChatBox("#FFAE00[sMOD] " .. name ..": " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [sMOD] " .. name .. ": " .. text) 
         
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
        outputChatBox("#00FF00[MOD] " .. name .. ": " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [MOD] " .. name .. ": " .. text) 
    end 
end 
addEventHandler("onPlayerChat", root, chatbox) 

Edited by Guest
Link to comment

YOU THINK IM A IDIOT!!!, Im admin, and console. and my meta is the same as that! IVE HAD OVER 5 SERVERS!

myne is:

<meta> 
    <info author="[EGL]Chris" version="0.1" type="script" name="Admin tag" description="This script add's admin before someone's name. ect, [MODERATOR] [EGL]Chris, or [ADMIN] [EGL]Chris. " /> 
    <script src="tag.Lua" type="server" /> 
</meta> 
 

im using Binslayer's one,

   function chatbox(text, command) 
    local ncolor = getPlayerNametagColor() 
    local name = getPlayerName(source) 
    local accountname = getAccountName (getPlayerAccount(source)) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
    cancelEvent() 
    outputChatBox("#FF0000[ADMIN] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [ADMIN] " .. getPlayerName ( source ).. ": " .. text) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "SuperModerator" ) ) then 
    cancelEvent() 
    outputChatBox("#FFAE00[sMOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [sMOD] " .. getPlayerName ( source ).. ": " .. text ) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Moderator" ) ) then 
    cancelEvent() 
    outputChatBox("#00FF00[MOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [MOD] " .. getPlayerName ( source ).. ": " .. text ) 
    end 
    end 
    addEventHandler("onPlayerChat", getRootElement(), chatbox) 
 

debugged:

these only came out from the debug.

WARNING: admintag\tag.Lua:2: Bad argument @ 'getPlayerNametagColor'

ERROR: admintag\tag.Lua:7: attempt to concatenate local 'ncolor' (a boolean value)

Link to comment
myne is:

<meta> 
    <info author="[EGL]Chris" version="0.1" type="script" name="Admin tag" description="This script add's admin before someone's name. ect, [MODERATOR] [EGL]Chris, or [ADMIN] [EGL]Chris. " /> 
    <script src="tag.lua" type="server" /> 
</meta> 

im using Binslayer's one,

   function chatbox(text, command) 
    local ncolor = getPlayerNametagColor() 
    local name = getPlayerName(source) 
    local accountname = getAccountName (getPlayerAccount(source)) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
    cancelEvent() 
    outputChatBox("#FF0000[ADMIN] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [ADMIN] " .. getPlayerName ( source ).. ": " .. text) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "SuperModerator" ) ) then 
    cancelEvent() 
    outputChatBox("#FFAE00[sMOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [sMOD] " .. getPlayerName ( source ).. ": " .. text ) 
    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Moderator" ) ) then 
    cancelEvent() 
    outputChatBox("#00FF00[MOD] "..ncolor..name..": "..text) 
    outputServerLog( "CHAT: [MOD] " .. getPlayerName ( source ).. ": " .. text ) 
    end 
    end 
    addEventHandler("onPlayerChat", getRootElement(), chatbox) 

debugged:

these only came out from the debug.

WARNING: admintag\tag.lua:2: Bad argument @ 'getPlayerNametagColor'

ERROR: admintag\tag.lua:7: attempt to concatenate local 'ncolor' (a boolean value)

I don't understand why are you using his code, because I just tested mine and it worked. His script doesn't even use tables which are CRITICAL for this kind of chatbox script..

And I think you should look around the nametag function, what do you think is wrong or do you want us to do everything now? It's basically the most basic thing that there is no player mentioned on that function, that's kind of... basic stuff... there should be some kind of player mentioned, you find out what.

Link to comment
local ncolor = getPlayerNametagColor(source) 

getPlayerNametagColor requires AN ARGUMENT

@ "YOU THINK IM A IDIOT!!!, Im admin, and console. and my meta is the same as that! IVE HAD OVER 5 SERVERS!"

Maybe you just calm the fuck down, I'm trying to help here and if you make me regret it I'll just ignore you from now on

Link to comment
csmit195 said:
I know, im terribly sorry. myonlake worked, and binslayer thank you for helping me, and myonlake. Im really sorry. I mean Super Really Absolutely sorry.

Yeah.. I know, but next time look the scripts yourself, even if the scripts are ours, you can fix them yourself too. And especially this happened because my script was working, and his weren't, before that you could of tested mine and his, see which one works and edit the scripts if you want to.

EDIT: Hmm, hold on, I'll try to fix it..

EDIT 2: I really don't have to think about that bug, I hope someone fixes it.

PS. No doubleposting, mate.

Link to comment

You can change the first six lines according to your needs,

adminTag = "[ADMIN]" 
sModTag = "[sMOD]" 
modTag = "[MOD]" 
  
adminColor = "#FF0000" -- leave blank if you dont want pre defined color 
sModColor = "#FF0000" -- leave blank if you dont want pre defined color 
modColor = "#FF0000" -- leave blank if you dont want pre defined color 
  
function chatbox( message ) 
    cancelEvent ( ) 
    local account = getAccountName ( getPlayerAccount ( source ) ) 
    if ( isAccountInGroup ( account, "Admin" ) ) then 
        tag = adminColor .. adminTag .. " " 
    elseif ( isAccountInGroup ( account, "SuperModerator" ) ) then 
        tag = sModColor .. sModTag .. " " 
    elseif ( isAccountInGroup ( account, "Moderator" ) ) then 
        tag = modColor .. modTag .. " " 
    else 
        tag = "" -- no tag 
    end 
    output ( tag, source, message ) 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
function output ( tag, player, text ) 
    if ( getPlayerTeam ( player) ) then 
        r,g,b = getTeamColor ( getPlayerTeam ( player) ) 
    else 
        r,g,b = getPlayerNametagColor ( player ) 
    end 
    outputChatBox ( tag .. "" .. getPlayerName ( player ) .. ":#FFFFFF " .. text, root, r, g, b, true ) 
    tag = string.gsub( tag, "#%x%x%x%x%x%x", "" ) 
    outputServerLog ( tag .. "" .. getPlayerName ( player ) .. ": " .. text ) 
end 
     
function isAccountInGroup ( _acc, _group ) 
    if ( isObjectInACLGroup ( "user." .. _acc, aclGetGroup ( _group ) ) ) then 
    return 
        true 
    end 
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...