Jump to content

Why not working remove color coding?


Turbe$Z

Recommended Posts

Posted
addEventHandler("onPlayerLogin", getRootElement(),
function ()
local name = getPlayerName ( source )
name:gsub("#%x%x%x%x%x%x", "")
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
		exports[getResourceName(resource)]:addNotification(root, name.." tulajdonos szolgálatba lépett!", "warning")
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("SuperModerator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." szupermoderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Modi")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Operator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." operátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("zuker")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Adminseged")) then
		exports[getResourceName(resource)]:addNotification(root, name.." adminsegéd szolgálatba lépett!", "warning")
    end
end
)

i added 'gsub' but the color code not disappear :S

 

 
Posted
6 minutes ago, marty000123 said:

I'm sorry but I fail to see what this has to do with removing color codes.

Remove color codes from the player name

Posted
5 minutes ago, Turbo777 said:

Remove color codes from the player name

I get that that's what you're trying to achieve, but what I don't get is the script. Where's the part which is supposed to disable color codes? I fail to see it.

Posted
1 minute ago, marty000123 said:

I get that that's what you're trying to achieve, but what I don't get is the script. Where's the part which is supposed to disable color codes? I fail to see it.

name:gsub("#%x%x%x%x%x%x", "")

 

Posted
1 minute ago, marty000123 said:

I'm not really familiar with gsub, but I don't think that single line removes hex codes.

then how?

Posted

@Turbo777 try this

function getFixedName(player)
if isElement(player) then
local hisName = getPlayerName(player)
if hisName then
 result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
 if result then
 return result
 end
end
end
end

addEventHandler("onPlayerLogin", getRootElement(),
function ()
local name = getFixedName(source)
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
		exports[getResourceName(resource)]:addNotification(root, name.." tulajdonos szolgálatba lépett!", "warning")
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("SuperModerator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." szupermoderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Modi")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Operator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." operátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("zuker")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Adminseged")) then
		exports[getResourceName(resource)]:addNotification(root, name.." adminsegéd szolgálatba lépett!", "warning")
    end
end
)

 

  • Like 1
Posted
3 minutes ago, #BrosS said:

@Turbo777 try this


function getFixedName(player)
if isElement(player) then
local hisName = getPlayerName(player)
if hisName then
 result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
 if result then
 return result
 end
end
end
end

addEventHandler("onPlayerLogin", getRootElement(),
function ()
local name = getFixedName(source)
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
		exports[getResourceName(resource)]:addNotification(root, name.." tulajdonos szolgálatba lépett!", "warning")
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("SuperModerator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." szupermoderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Modi")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Operator")) then
		exports[getResourceName(resource)]:addNotification(root, name.." operátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("zuker")) then
		exports[getResourceName(resource)]:addNotification(root, name.." moderátor szolgálatba lépett!", "warning")
	elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Adminseged")) then
		exports[getResourceName(resource)]:addNotification(root, name.." adminsegéd szolgálatba lépett!", "warning")
    end
end
)

 

Thanks ! :D Working fine ^^:D

Posted

The problem was just that you did not use the return value from gsub.

local name = name:gsub("#%x%x%x%x%x%x", "")

There is no function needed for that.

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