Wei Posted March 21, 2012 Posted March 21, 2012 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?
-ffs-Sniper Posted March 21, 2012 Posted March 21, 2012 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?
-ffs-Sniper Posted March 21, 2012 Posted March 21, 2012 Well, then, as I said you will need to check the player's team in every single resource that outputs a name.
-RoCk-Alex Posted March 22, 2012 Posted March 22, 2012 so you have added group in ACL.xml? if yes then its way too easy
Moderators IIYAMA Posted March 22, 2012 Moderators Posted March 22, 2012 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.
TwiX! Posted March 22, 2012 Posted March 22, 2012 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)
Alpha Posted March 22, 2012 Posted March 22, 2012 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)
myyusuf Posted March 22, 2012 Posted March 22, 2012 -- 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?
-RoCk-Alex Posted March 22, 2012 Posted March 22, 2012 -- 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
Alpha Posted March 22, 2012 Posted March 22, 2012 -- 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.
-RoCk-Alex Posted March 22, 2012 Posted March 22, 2012 -- 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
TAPL Posted March 22, 2012 Posted March 22, 2012 -- 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 IIYAMA Posted March 22, 2012 Moderators Posted March 22, 2012 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 )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now