Jump to content

Why not working this admintag?


Turbe$Z

Recommended Posts

addEventHandler ( "onPlayerChat", root,
function ( msg, type )
    if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Admin" ) ) and type == 0 then
        cancelEvent ( )
	function outputMessage(author,message)
		outputChatBox("#ff0000[T] #FFffff"..author..": #FF0000"..message,getRootElement(),0,0,0,true)
	end
	function changetag(author,message)
		outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,0,0,true)
	end
addCommandHandler("rang",changetag)

why not working this? what wrong? 

  • Like 1
Link to comment

You are keep creating posts and asking "what's wrong?, what's wrong?", but you should be the one telling us what's wrong. Please take your time and look at it YOURSELF, don't expect us to fix everything in your code, that's just not gonna happen. So please, use"/debugscript 3" and debug your code yourself and if you can't fix it, come back here with the error. That's how programmers ask for help.

 

Don't take this as an insult, but I mean you can spot the errors right away (not closing the end or function) and debugscript 3 will even tell you them...

  • Like 2
Link to comment

It should be like this:

addEventHandler ( "onPlayerChat", root,
function ( msg, type )
    if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Admin" ) ) and type == 0 then
        cancelEvent ( )
	local function outputMessage(author,message)
		outputChatBox("#ff0000[T] #FFffff"..author..": #FF0000"..message,getRootElement(),0,0,0,true)
	end
	local function changetag(author,message)
		outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,0,0,true)
	end
    addCommandHandler("rang",changetag)
end

 

Link to comment
34 minutes ago, Simple01 said:

It should be like this:


addEventHandler ( "onPlayerChat", root,function ( msg, type )    if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Admin" ) ) and type == 0 then        cancelEvent ( )	local function outputMessage(author,message)		outputChatBox("#ff0000[T] #FFffff"..author..": #FF0000"..message,getRootElement(),0,0,0,true)
	end
	local function changetag(author,message)
		outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,0,0,true)
	end
    addCommandHandler("rang",changetag)
end

 

tag.lua:208: attempt to call global 'outputMessage' (a nil value)

			outputMessage(getPlayerName(source),msg)

Why? :S

  • Like 1
Link to comment
5 minutes ago, Simple01 said:

Mert ez egy helyi funkció, csak hívja be a onPlayerChat funkciót. :P

i tried this, but doesn't working :c

addEventHandler ( "onPlayerChat", root,
function ( msg, type )
    if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Admin" ) ) and type == 0 then
        cancelEvent ( )
	local function outputMessage(author,message)
		outputChatBox("#ff0000[T] #FFffff"..author..": #FF0000"..message,getRootElement(),0,0,0,true)
	end
	local function changetag(author,message)
		outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,0,0,true)
	end
addCommandHandler("rang",changetag)

    elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Everyone" ) ) and type == 0 then   
        cancelEvent ( )
        local r, g, b = getPlayerNametagColor(source)
	local function outputMessage(author,message)
		local message = string.gsub(message, "#%x%x%x%x%x%x", "  ")
		outputChatBox(author.."#ffFFff: #ffffff"..message,getRootElement(),r,g,b,true)
	end
        --outputChatBox ( " " .. getPlayerName ( source ) .. " #00Baff:#ffffff " .. msg, getRootElement(), r, g, b, true )
        end
    end
	
function(msg,type)

	-- Only affect normal messages
	if type == 0 then

		-- Cancel output
		cancelEvent()

		-- Clean up the message from any bad words
		local new = ""
		local iter = 0
		for word in msg:gmatch("%S+") do
			iter = iter + 1
			for i,swr in ipairs(swearWords) do
				local src = word:lower():gsub("%s","")
				local src = src:gsub("#%x%x%x%x%x%x","")
				local src = src:gsub("%c","")
				local src = src:gsub("%p","")
				local pat = swr:lower():gsub("%s","")
				if src:find(pat) then
					local replaceString = ""
					for x=1,word:gsub("#%x%x%x%x%x%x",""):len() do
						replaceString = replaceString.."*"
					end
					word = word:gsub(word,replaceString)
				end
			end
			--if iter == 1 and word:len() > 2 then
				--word = word:gsub("%a",string.upper,1)
			--end
			--new = new..word.." "
		end
		if new ~= "" then msg = new end

		-- Get appropriate team colors and output the clean message
		local pTeam = getPlayerTeam(source)
		if pTeam then
			local r,g,b = getTeamColor(pTeam)
			local hr,hg,hb = decToHex(r),decToHex(g),decToHex(b)
			local color = "#"..hr..hg..hb
			outputMessage(color..getPlayerName(source),msg)
		else
			outputMessage(getPlayerName(source),msg)
		end
	end
end
)

 

  • Like 1
Link to comment
  1. addEventHandler ( "onPlayerChat", root,
  2. function ( msg, type )
  3. if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Admin" ) and type = 0 then
  4. cancelEvent ( )
  5. function outputMessage(author,message)
  6. outputChatBox("#ff0000[T] #FFffff"..author..": #FF0000"..message,getRootElement(),0,255,0,true)
  7. end
  8. function changetag(author,message)
  9. outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,255,0,true)
  10. end
  11. addCommandHandler("rang",changetag)
Link to comment
3 minutes ago, enzopaul4 said:
  1. addEventHandler ( "onPlayerChat", root,
  2. function ( msg, type )
  3. if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Admin" ) and type = 0 then
  4. cancelEvent ( )
  5. function outputMessage(author,message)
  6. outputChatBox("#ff0000[T] #FFffff"..author..": #FF0000"..message,getRootElement(),0,255,0,true)
  7. end
  8. function changetag(author,message)
  9. outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,255,0,true)
  10. end
  11. addCommandHandler("rang",changetag)

doesn't working, tag.lua:4: 'then' expected near '='

  • Like 1
Link to comment

Here you go,
 Tested.

--[[// Note: Groups must be ordered from the highest to the lowest ranks, 
	for example, Owner, Admin, Moderator, Player. Highest rank is in the script
	always first and lowest rank absolute last! ]]--

addEventHandler("onPlayerChat", root, function(msg, type)
	local account = getAccountName(getPlayerAccount(source));
	local name = getPlayerName(source);
	local root = getRootElement();
		
--// This is the section for Tags
		--// Admin group tag //--
	if isObjectInACLGroup("user."..account, aclGetGroup("Admin")) and type == 0 then
		cancelEvent();
		outputChatBox("#111111[Admin] #ffffff"..name..": #33cc00"..msg, root, 255, 255, 255, true);
		--// output for console
		outputServerLog("CHAT: [Admin] "..name..": "..msg);
		
	--// THIS TEXT REPLACE WITH NEW RANKS / TAGS (GROUPS)

		--// Everyone group tag (for all players) //--
	elseif isObjectInACLGroup("user."..account, aclGetGroup("Everyone")) and type == 0 then
		cancelEvent();
		outputChatBox("#fff000 [Player] #ffffff"..name..": #33cc00" ..msg, root, 255, 255, 255, true);
		--// output for console
		outputServerLog("CHAT: [Player] "..name..": " ..msg);
	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...