xXGhostXx Posted September 8, 2018 Posted September 8, 2018 Hello Guys . How to make admin warn filter text ! Like this : players chat google.com and for admin send warn . [ADM-Warn]: xXGhostXx chat : google.com filters : .com - .org - .net and ...
xXGhostXx Posted September 8, 2018 Author Posted September 8, 2018 Just now, iMr.WiFi..! said: "onPlayerChat" string.find I did not get Can you make for me ?
iMr.WiFi..! Posted September 8, 2018 Posted September 8, 2018 (edited) 2 minutes ago, xXGhostXx said: I did not get Can you make for me ? addEventHandler("onPlayerChat", root, function ( message ) if( message:find( ".com" ) )then outputChatBox('Found .com in your message', source, 255, 255, 255, false ); end end ) This is just example, You need to make it by your self. Edited September 8, 2018 by iMr.WiFi..!
xXGhostXx Posted September 8, 2018 Author Posted September 8, 2018 1 minute ago, iMr.WiFi..! said: addEventHandler("onPlayerChat", root, function ( message ) if( message:find( ".com" ) )then outputChatBox('Found .com in your message', source, 255, 255, 255, false ); end end ) This is just example, You need to make it by your self. No ! i want for found message send to admin acl ! [ADM-Warn]: xXGhostXx : google.com For test
iMr.WiFi..! Posted September 8, 2018 Posted September 8, 2018 (edited) Then use loop with next function : getPlayersInGroup -- Usefull function. Edited September 8, 2018 by iMr.WiFi..!
xXGhostXx Posted September 8, 2018 Author Posted September 8, 2018 7 minutes ago, iMr.WiFi..! said: Then use loop with next function : getPlayersInGroup -- Usefull function. function awarn (message) if not ( isPlayerOnGroup ( thePlayer ) ) then return false end local filter = message find( ".com" ) if( message:find( ".com" ) )then outputChatBox("#ff0000[ADM-Warn]:" ..getPlayerFromName.. ": " ..filter.. "**", source, 255, 255, 255, true ) end end addEventHandler("onPlayerChat", root, awarn) Please debug my code
iMr.WiFi..! Posted September 8, 2018 Posted September 8, 2018 (edited) function getPlayersInGroup ( GroupName ) local aTable = {} assert ( tostring ( GroupName ) , "Bad Argument At Argument #1 Group Moust String" ) assert ( aclGetGroup ( tostring ( GroupName ) ) , "Bad Argument At Argument #1 Group not Found " ) for i , player_ in ipairs ( getElementsByType ( "player" ) ) do local TheAcc = getPlayerAccount ( player_ ) if not isGuestAccount ( TheAcc ) then if isObjectInACLGroup ( "user." ..getAccountName ( TheAcc ) , aclGetGroup ( tostring ( GroupName ) ) ) then table.insert ( aTable , player_ ) end end end return aTable end Words = { ".com", ".org" } addEventHandler("onPlayerChat", root, function ( message ) for _, word in ipairs(Words) do if( message:find( word ) )then for _, player in ipairs(getPlayersInGroup( 'Admin' )) do outputChatBox("#ff0000[ADM-Warn]:" ..getPlayerName(source).. ": " ..message.. "**", player, 255, 255, 255, true ) end break; end end end ) Edited September 8, 2018 by iMr.WiFi..!
xXGhostXx Posted September 8, 2018 Author Posted September 8, 2018 6 minutes ago, iMr.WiFi..! said: function getPlayersInGroup ( GroupName ) local aTable = {} assert ( tostring ( GroupName ) , "Bad Argument At Argument #1 Group Moust String" ) assert ( aclGetGroup ( tostring ( GroupName ) ) , "Bad Argument At Argument #1 Group not Found " ) for i , player_ in ipairs ( getElementsByType ( "player" ) ) do local TheAcc = getPlayerAccount ( player_ ) if not isGuestAccount ( TheAcc ) then if isObjectInACLGroup ( "user." ..getAccountName ( TheAcc ) , aclGetGroup ( tostring ( GroupName ) ) ) then table.insert ( aTable , player_ ) end end end return aTable end Words = { ".com", ".org" } addEventHandler("onPlayerChat", root, function ( message ) for _, word in ipairs(Words) do if( message:find( word ) )then for _, player in ipairs(getPlayersInGroup( 'Admin' )) do outputChatBox("#ff0000[ADM-Warn]:" ..getPlayerName(source).. ": " ..message.. "**", player, 255, 255, 255, true ) end break; end end end ) For this code use acl on group ? if not ( isPlayerOnGroup ( thePlayer ) ) then return false end
iMr.WiFi..! Posted September 8, 2018 Posted September 8, 2018 9 minutes ago, xXGhostXx said: For this code use acl on group ? if not ( isPlayerOnGroup ( thePlayer ) ) then return false end No, just change the Group name from line 31
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