Turbe$Z Posted October 22, 2016 Share Posted October 22, 2016 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? 1 Link to comment
pa3ck Posted October 22, 2016 Share Posted October 22, 2016 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... 2 Link to comment
Simple0x47 Posted October 22, 2016 Share Posted October 22, 2016 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
Turbe$Z Posted October 22, 2016 Author Share Posted October 22, 2016 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? 1 Link to comment
Simple0x47 Posted October 22, 2016 Share Posted October 22, 2016 Cuz it's a local function, you just can call it into the onPlayerChat function. Link to comment
Turbe$Z Posted October 22, 2016 Author Share Posted October 22, 2016 5 minutes ago, Simple01 said: Mert ez egy helyi funkció, csak hívja be a onPlayerChat funkciót. 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 ) 1 Link to comment
Simple0x47 Posted October 22, 2016 Share Posted October 22, 2016 You could add an event which would handle the local function but you'd do it two times. AddEvent AddEventHandler Link to comment
enzopaul4 Posted October 22, 2016 Share Posted October 22, 2016 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,255,0,true) end function changetag(author,message) outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,255,0,true) end addCommandHandler("rang",changetag) Link to comment
Turbe$Z Posted October 22, 2016 Author Share Posted October 22, 2016 3 minutes ago, enzopaul4 said: 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,255,0,true) end function changetag(author,message) outputChatBox("#ff0000[Tulaj] #FFffff"..author..": #FFd700"..message,getRootElement(),0,255,0,true) end addCommandHandler("rang",changetag) doesn't working, tag.lua:4: 'then' expected near '=' 1 Link to comment
Guest Posted October 22, 2016 Share Posted October 22, 2016 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
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