Jump to content

Why not working remove HEX codes from admin messages?


Turbe$Z

Recommended Posts

function aAction ( type, action, admin, player, data, more ) 
    if ( aLogMessages[type] ) then 
        function aStripString ( string ) 
            string = tostring ( string ) 
            string = string.gsub ( string, "$admin", getPlayerName ( admin ):gsub("#%x%x%x%x%x%x","") ) 
            string = string.gsub ( string, "$by_admin_4all", isAnonAdmin4All( admin )    and "" or " by " .. getPlayerName ( admin ):gsub("#%x%x%x%x%x%x","") ) 
            string = string.gsub ( string, "$by_admin_4plr", isAnonAdmin4Victim( admin ) and "" or " by " .. getPlayerName ( admin ):gsub("#%x%x%x%x%x%x","") ) 
            string = string.gsub ( string, "$data2", more or "" ) 
            if ( player ) then string = string.gsub ( string, "$player", getPlayerName ( player ) ) string = string:gsub("#%x%x%x%x%x%x","") end 
            return tostring ( string.gsub ( string, "$data", data or "" ) ) 
        end 
        local node = aLogMessages[type][action] 
        if ( node ) then 
            local r, g, b = node["r"], node["g"], node["b"] 
            if ( node["all"] ) then outputChatBox ( aStripString ( node["all"] ), _root, r, g, b ) end 
            if ( node["admin"] ) and ( admin ~= player ) then outputChatBox ( aStripString ( node["admin"] ), admin, r, g, b ) end 
            if ( node["player"] ) then outputChatBox ( aStripString ( node["player"] ), player, r, g, b ) end 
            if ( node["log"] ) then outputServerLog ( aStripString ( node["log"] ) ) end 
        end 
    end 
end 

i added this lines to 'admin_server.lua', but doesn't working the script :S 

i got a lot of errors from  'admin_sync.lua':194: attempt to index global 'aPlayers' (a nil value)
and rom 'admin serverjoiner.lua':48: attempt to call global 'checkClient' (a nil value)

but when i add the original 'aActions' function, the errors will disappear. O.o why? how to fix this?

Link to comment
8 hours ago, TheMOG said:

I think you talking about this? 

 

 

BTW you should use your own administrator system. (setElementData, getElementData, setAccountData, getAccountData) So easily. If you need help pm be.

a long time ago, this script is worked, but now doesn't working :S why?

Link to comment

Replace the function with same name in your "mods\deathmatch\resources\[admin]\admin\server\admin_server.lua" file with this:

function aAction ( type, action, admin, player, data, more )
	if ( aLogMessages[type] ) then
		function aStripString ( string )
			string = tostring ( string )
			local adminguy
			if getElementType ( admin ) == "player" then
				adminguy = addTeamColor(admin)
			else
				adminguy = getPlayerName(admin)
			end
			string = string.gsub ( string, "$admin", adminguy )
			string = string.gsub ( string, "$by_admin_4all", isAnonAdmin4All( admin )    and "" or "" .. adminguy )
			string = string.gsub ( string, "$by_admin_4plr", isAnonAdmin4Victim( admin ) and "" or "" .. adminguy )
			string = string.gsub ( string, "$data2", more or "" )
			if ( player ) then string = string.gsub ( string, "$player", addTeamColor ( player ) ) end
			return tostring ( string.gsub ( string, "$data", data or "" ) )
		end
		
		local node = aLogMessages[type][action]
		if ( node ) then
			local r, g, b = node["r"], node["g"], node["b"]
			if ( node["all"] ) then
				outputChatBox ( aStripString ( node["all"] ), _root, r, g, b, true )
			end
			if ( node["admin"] ) and ( admin ~= player ) then
				outputChatBox ( aStripString ( node["admin"] ), admin, r, g, b, true )
			end
			if ( node["player"] ) then
				outputChatBox ( aStripString ( node["player"] ), player, r, g, b, true )
			end
			if ( node["log"] ) then
				outputServerLog ( aStripString ( node["log"] ) )
			end
		end
	end
end

function addTeamColor(player)
	local playerTeam = getPlayerTeam(player)
	if ( playerTeam ) then
		local r,g,b = getTeamColor(playerTeam)
		local n1 = toHex(r)
		local n2 = toHex(g)
		local n3 = toHex(b)
		if r <= 16 then n1 = "0"..n1 end
		if g <= 16 then n2 = "0"..n2 end
		if b <= 16 then n3 = "0"..n3 end
		return "#"..n1..""..n2..""..n3..""..getPlayerNametagText(player)
	else
		return getPlayerNametagText(player)
	end
end

function toHex(n)
    local hexnums = {"0","1","2","3","4","5","6","7",
                     "8","9","A","B","C","D","E","F"}
    local str,r = "",n%16
    if n-r == 0 then str = hexnums[r+1]
    else str = toHex((n-r)/16)..hexnums[r+1] end
    return str
end

And replace everything in your "mods\deathmatch\resources\[admin]\admin\conf\messages.xml" file with this:

<messages>
  <!-- Accepted subgroups:
            all - Output to chatbox for all
            log - Log file output
            player - Victim/Player chatbox output
            admin - Admin chatbox output
       Variables:
            $player - player
            $admin - admin
            $data - Additional information, not all the nodes use it.
            $data2 - Additional information, not all the nodes use it.
    -->
  <player>
    <group action="ban" r="255" g="0" b="0">
      <all>#FFFFFF$player #FF0000was banned by #FFFFFF$by_admin_4all#FF0000. $data2</all>
      <log>ADMIN: $admin has banned $player $data $data2</log>
    </group>
    <group action="kick" r="255" g="0" b="0">
      <all>#FFFFFF$player #FF0000was kicked by #FFFFFF$by_admin_4all#FF0000.</all>
      <log>ADMIN: $admin has kicked $player $data</log>
    </group>
    <group action="mute" r="255" g="0" b="0">
      <all>#FFFFFF$player #FF0000was muted by #FFFFFF$by_admin_4all#FF0000.#FF0000 #00FF00$data2</all>
      <log>ADMIN: $admin has muted $player $data $data2</log>
    </group>
	<group action="setnick" r="255" g="0" b="0">
      <log>ADMIN: $player name changed to $data2 $by_admin_4all.</log>
    </group>
    <group action="unmute" r="0" g="255" b="100">
      <all>#FFFFFF$player #00FF00was unmuted by #FFFFFF$by_admin_4all#00FF00.</all>
      <log>ADMIN: $admin has unmuted $player</log>
    </group>
    <group action="freeze" r="255" g="0" b="0">
      <admin>#FFFFFF$player #FF0000was frozen by #FFFFFF$by_admin_4all#FF0000.</admin>
      <player>#FF0000You were frozen by #FFFFFF$by_admin_4plr#FF0000.</player>
      <log>ADMIN: $admin has frozen $player</log>
    </group>
    <group action="unfreeze" r="0" g="255" b="100">
      <admin>#FFFFFF$player #00FF00was unfrozen by #FFFFFF$by_admin_4all#00FF00.</admin>
      <player>#00FF00You were unfrozen by #FFFFFF$by_admin_4plr#00FF00.</player>
      <log>ADMIN: $admin has unfrozen $player</log>
    </group>
    <group action="slap" r="235" g="20" b="200">
      <all>#FFFFFF$player #EB14C8was slapped by #FFFFFF$by_admin_4all#EB14C8. #00FF00($data HP)</all>
      <log>ADMIN: $admin has slapped $player ($data HP)</log>
    </group>
    <group action="shout" r="255" g="100" b="30">
      <admin>#FF641EYou shouted at #FFFFFF$player#FF641E.</admin>
    </group>
    <group action="sethealth" r="0" g="170" b="170">
      <admin>#FFFFFF$player#00AAAA's health was changed to #FFFFFF$data#00AAAA.</admin>
      <player>#00AAAAYour health was changed to #FFFFFF$data#00AAAA by #FFFFFF$by_admin_4plr#00AAAA.</player>
      <log>ADMIN: $admin has changed $player's health to $data</log>
    </group>
    <group action="setarmour" r="122" g="122" b="122">
      <admin>#FFFFFF$player#7A7A7A's armour was changed to #FFFFFF$data#7A7A7A.</admin>
      <player>#7A7A7AYour armour was changed to #FFFFFF$data #7A7A7Aby #FFFFFF$by_admin_4plr#7A7A7A.</player>
      <log>ADMIN: $admin has changed $player's armour to $data</log>
    </group>
    <group action="setmoney" r="225" g="170" b="90">
      <admin>#FFFFFF$player#FFAA5A's money was set to #FFFFFF$data#FFAA5A.</admin>
      <player>#FFAA5AYour money was set to #FFFFFF$data #FFAA5Aby #FFFFFF$by_admin_4plr#FFAA5A.</player>
      <log>ADMIN: $admin has set $player's money to $data</log>
    </group>
    <group action="setskin" r="255" g="122" b="0">
      <admin>#FFFFFF$player#FF7A00's skin was changed to #FFFFFF$data#FF7A00.</admin>
      <player>#FF7A00Your skin was changed to #FFFFFF$data #FF7A00by #FFFFFF$by_admin_4plr#FF7A00.</player>
      <log>ADMIN: $admin has changed $player's skin to $data</log>
    </group>
    <group action="setteam" r="255" g="255" b="0">
      <admin>#FFFFFF$player #FFFF00was moved to team #FFFFFF$data#FFFF00.</admin>
      <player>#FFFF00You were moved to team #FFFFFF$data #FFFF00by #FFFFFF$by_admin_4plr#FFFF00.</player>
      <log>ADMIN: $admin has moved $player to the $data team</log>
    </group>
	<group action="removefromteam" r="255" g="255" b="0">
      <admin>#FFFFFF$player #FFFF00was removed from team #FFFFFF$data#FFFF00.</admin>
      <player>#FFFF00You were removed from team #FFFFFF$data #FFFF00by #FFFFFF$by_admin_4plr#FFFF00.</player>
      <log>ADMIN: $admin has removed $player from the $data team</log>
    </group>
    <group action="setinterior" r="0" g="255" b="0">
      <admin>#FFFFFF$player #00FF00was moved to the #FFFFFF$data #00FF00interior.</admin>
      <player>#00FF00You were moved to the #FFFFFF$data #00FF00interior by #FFFFFF$by_admin_4plr#00FF00.</player>
      <log>ADMIN: $admin has moved $player to the $data interior</log>
    </group>
    <group action="setdimension" r="0" g="255" b="0">
      <admin>#FFFFFF$player #00FF00was moved to the #FFFFFF$data #00FF00dimension.</admin>
      <player>#00FF00You were moved to the #FFFFFF$data #00FF00dimension by #FFFFFF$by_admin_4plr#00FF00.</player>
      <log>ADMIN: $admin has moved $player to the $data dimension</log>
    </group>
    <group action="setstat" r="255" g="122" b="0">
      <admin>#FFFFFF$player#FF7A00's #FFFFFF$data #FF7A00was set to #FFFFFF$data2#FF7A00.</admin>
      <player>#FF7A00Your #FFFFFF$data #FF7A00was set to #FFFFFF$data2 #FF7A00by #FFFFFF$by_admin_4plr#FF7A00.</player>
      <log>ADMIN: $admin has changed $player's $data to $data2</log>
    </group>
    <group action="jetpackr" r="255" g="0" b="0">
      <admin>#FFFFFF$player#FF0000's jetpack was removed.</admin>
      <player>#FF0000Your jetpack was removed by #FFFFFF$by_admin_4plr#FF0000.</player>
      <log>ADMIN: $admin has removed $player's jetpack</log>
    </group>
    <group action="jetpacka" r="255" g="122" b="0">
      <admin>#FFFFFF$player #FF7A00was given a jetpack.</admin>
      <player>#FF7A00You were given a jetpack by #FFFFFF$by_admin_4plr#FF7A00.</player>
      <log>ADMIN: $admin has given a jetpack to $player</log>
    </group>
    <group action="adminr" r="255" g="0" b="0">
      <admin>#FFFFFF$player#FF0000's admin rights were revoked.</admin>
      <player>#FF0000Your admin rights were revoked by #FFFFFF$by_admin_4plr#FF0000.</player>
      <log>ADMIN: $admin has revoked admin privilegies from $player</log>
    </group>
    <group action="admina" r="0" g="255" b="0">
      <admin>#FFFFFF$player #00FF00was given admin rights.</admin>
      <player>#00FF00You were give admin rights by #FFFFFF$by_admin_4plr#00FF00.</player>
      <log>ADMIN: $admin has given admin privilegies to $player</log>
    </group>
    <group action="givevehicle" r="0" g="255" b="0">
      <admin>#FFFFFF$player #00FF00was given a #FFFFFF$data#00FF00.</admin>
      <player>#00FF00You were given a #FFFFFF$data #00FF00by #FFFFFF$by_admin_4plr#00FF00.</player>
      <log>ADMIN: $admin has given $player a '$data'" </log>
    </group>
    <group action="giveweapon" r="0" g="0" b="255">
      <admin>#FFFFFF$player #0000FFwas given a #FFFFFF$data #0000FF(#FFFFFF$data2#0000FF).</admin>
      <player>#0000FFYou were given a #FFFFFF$data #0000FF(#FFFFFF$data2#0000FF) by #FFFFFF$by_admin_4plr#0000FF.</player>
      <log>ADMIN: $admin has given $player '$data'</log>
    </group>
    <group action="warp" r="0" g="200" b="50">
      <admin>#00C832You warped to #FFFFFF$player#00C832.</admin>
      <log>ADMIN: $admin has warped to $player</log>
    </group>
    <group action="warpto" r="0" g="200" b="50">
      <admin>#FFFFFF$player #00C832was warped to #FFFFFF$data#00C832.</admin>
      <player>#00C832You were warped to #FFFFFF$data #00C832by #FFFFFF$by_admin_4plr#00C832.</player>
      <log>ADMIN: $admin has moved $player to $data</log>
    </group>
  </player>
  <team>
    <group action="createteam" r="225" g="170" b="90">
      <admin>#E1AA5ASuccessfully created team $data#E1AA5A.</admin>
      <log>ADMIN: $admin has created a team '$data'</log>
    </group>
    <group action="destroyteam" r="225" g="170" b="90">
      <admin>#E1AA5ASuccessfully destroyed team $data#E1AA5A.</admin>
      <log>ADMIN: $admin has destroyed a team '$data'</log>
    </group>
  </team>
  <vehicle>
    <group action="repair" r="0" g="255" b="0">
      <admin>#FFFFFF$player#00FF00's vehicle was fixed.</admin>
      <player>#00FF00Your vehicle was fixed by #FFFFFF$by_admin_4plr#00FF00.</player>
      <log>ADMIN: $admin has fixed vehicle of $player</log>
    </group>
    <group action="blowvehicle" r="255" g="0" b="0">
      <admin>#FFFFFF$player#FF0000's vehicle was blown.</admin>
      <player>#FF0000Your vehicle was blown by #FFFFFF$by_admin_4plr#FF0000.</player>
      <log>ADMIN: $admin has blown vehicle of $player</log>
    </group>
    <group action="destroyvehicle" r="255" g="0" b="0">
      <admin>#FFFFFF$player#FF0000's vehicle was destroyed.</admin>
      <player>#FF0000Your vehicle was destroyed by #FFFFFF$by_admin_4plr#FF0000.</player>
      <log>ADMIN: $admin has destroyed vehicle of $player</log>
    </group>
    <group action="customize" r="225" g="170" b="90">
      <admin>#FFFFFF$player#E1AA5A's vehicle was upgraded. (#FFFFFF$data#E1AA5A)</admin>
      <player>#E1AA5AYour vehicle was upgraded by #FFFFFF$by_admin_4plr#E1AA5A.</player>
      <log>ADMIN: $admin has upgraded vehicle of $player ($data)</log>
    </group>
    <group action="customizer" r="225" g="170" b="90">
      <admin>#FFFFFF$player#E1AA5A's vehicle upgrades were removed.</admin>
      <player>#E1AA5AYour vehicle upgrades were removed by #FFFFFF$by_admin_4plr#E1AA5A.</player>
      <log>ADMIN: $admin has has removed vehicle upgrades of $player</log>
    </group>
    <group action="setpaintjob" r="225" g="170" b="90">
      <admin>#FFFFFF$player#E1AA5A's vehicle paint job set to #FFFFFF$data#E1AA5A.</admin>
      <player>#E1AA5AYour vehicle paint job was changed to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4plr#E1AA5A.</player>
      <log>ADMIN: $admin has changed paint job of $player's vehicle to $data</log>
    </group>
    <group action="setcolor" r="225" g="170" b="90">
      <admin>#FFFFFF$player#E1AA5A's vehicle color changed.</admin>
      <player>#E1AA5AYour vehicle color was changed by #FFFFFF$by_admin_4plr#E1AA5A.</player>
      <log>ADMIN: $admin has changed color of $player's vehicle</log>
    </group>
	<group action="setlights" r="225" g="170" b="90">
      <admin>#FFFFFF$player#E1AA5A's vehicle lights color changed.</admin>
      <player>#E1AA5AYour vehicle lights color was changed by #FFFFFF$by_admin_4plr#E1AA5A.</player>
      <log>ADMIN: $admin has changed lights color of $player's vehicle</log>
    </group>
	<group action="setplates" r="225" g="170" b="90">
      <admin>#FFFFFF$player#E1AA5A's license plates were changed to #FFFFFF$data#E1AA5A.</admin>
      <player>#E1AA5AYour vehicle license plates were changed to #FFFFFF$data #E1AA5Aby #FFFFFF$by_admin_4plr#E1AA5A.</player>
      <log>ADMIN: $admin has changed license plates of $player's vehicle to '$data'</log>
    </group>
  </vehicle>
  <resource>
    
  </resource>
  <server>
    <group action="setgame" r="225" g="170" b="90">
      <admin>#E1AA5AASE gamemode info was changed to #FFFFFF$data#E1AA5A.</admin>
      <log>ADMIN: $admin has changed ASE gamemode to '$data'</log>
    </group>
    <group action="setmap" r="225" g="170" b="90">
      <admin>#E1AA5AASE map info was changed to #FFFFFF$data#E1AA5A.</admin>
      <log>ADMIN: $admin has changed ASE map info to '$data'</log>
    </group>
    <group action="setwelcome" r="225" g="170" b="90">
      <admin>#E1AA5AWelcome message was set to #FFFFFF$data#E1AA5A.</admin>
      <log>ADMIN: $admin has set welcome message to '$data'</log>
    </group>
    <group action="resetwelcome" r="225" g="170" b="90">
      <admin>#E1AA5AWelcome message was reset.</admin>
      <log>ADMIN: $admin has reset the welcome message</log>
    </group>
    <group action="setpassword" r="225" g="170" b="90">
      <admin>#E1AA5AServer's password was set to #FFFFFF$data#E1AA5A.</admin>
      <log>ADMIN: $admin has set server password to '$data'</log>
    </group>
    <group action="resetpassword" r="225" g="170" b="90">
      <admin>#E1AA5AServer's password was reset.</admin>
      <log>ADMIN: $admin has reset server password</log>
    </group>
    <group action="settime" r="225" g="170" b="90">
      <all>#E1AA5ATime was set to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4all#E1AA5A.</all>
      <log>ADMIN: $admin has changed time to $data</log>
    </group>
    <group action="setweather" r="225" g="170" b="90">
      <all>#E1AA5AWeather was set to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4all#E1AA5A.</all>
      <log>ADMIN: $admin has set weather to '$data'</log>
    </group>
    <group action="blendweather" r="225" g="170" b="90">
      <admin>#E1AA5ABlending weather to #FFFFFF$data#E1AA5A.</admin>
      <log>ADMIN: $admin is blending weather to '$data'</log>
    </group>
    <group action="setgravity" r="225" g="170" b="90">
      <all>#E1AA5AGravitation value was set to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4all#E1AA5A.</all>
      <log>ADMIN: $admin has set gravitation to $data</log>
    </group>
    <group action="setgamespeed" r="225" g="170" b="90">
      <all>#E1AA5AGame speed was set to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4all#E1AA5A.</all>
      <log>ADMIN: $admin has set game speed to '$data'</log>
    </group>
    <group action="setwaveheight" r="225" g="170" b="90">
      <all>#E1AA5AWaves height was set to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4all#E1AA5A.</all>
      <log>ADMIN: $admin has set waves height to '$data'</log>
    </group>
    <group action="setblurlevel" r="225" g="170" b="90">
      <all>#E1AA5ABlur level was set to #FFFFFF$data#E1AA5A by #FFFFFF$by_admin_4all#E1AA5A.</all>
      <log>ADMIN: $admin has set blur level to '$data'</log>
    </group>
  </server>
  <bans>
    <group action="unbanip" r="225" g="170" b="90">
      <admin>#E1AA5AIP: $data was successfully removed from bans list.</admin>
      <log>ADMIN: $admin has unbanned IP $data</log>
    </group>
    <group action="unbanserial" r="225" g="170" b="90">
      <admin>#E1AA5ASERIAL: $data was successfully removed from bans list.</admin>
      <log>ADMIN: $admin has unbanned Serial $data</log>
    </group>
    <group action="banip" r="225" g="170" b="90">
      <admin>#E1AA5AIP: $data was successfully added to bans list.</admin>
      <log>ADMIN: $admin has banned IP $data</log>
    </group>
    <group action="banserial" r="225" g="170" b="90">
      <admin>#E1AA5ASERIAL: $data was successfully added to bans list.</admin>
      <log>ADMIN: $admin has banned Serial $data</log>
    </group>
  </bans>
  <admin>
    <group action="create" r="225" g="170" b="90">
      <admin>#FFFFFF$data #E1AA5Awas successfully created.</admin>
      <log>ADMIN: $data has been created by $admin</log>
    </group>
    <group action="destroy" r="225" g="170" b="90">
      <admin>#FFFFFF$data #E1AA5Awas successfully destroyed.</admin>
      <log>ADMIN: $data has been destroyed by $admin</log>
    </group>
    <group action="password" r="50" g="255" b="50">
      <admin>#32FF32Your password was successfully changed to #FFFFFF$data#32FF32.</admin>
    </group>
    <group action="settings" r="225" g="170" b="90">
      <admin>#E1AA5A#FFFFFF$data #E1AA5Awas set to #FFFFFF$data2#E1AA5A.</admin>
      <log>ADMIN: Set '$data' to '$data2' by $admin</log>
    </group>
  </admin>
</messages>

Ofcourse make a backup before doing any of this :P Good luck, looks nice if you ask me (better than to just remove color codex imo). :)

Edited by koragg
Forgot to add the functions which put team color as well.
  • Like 1
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...