Hazard| Posted August 3, 2014 Share Posted August 3, 2014 Hello guys, I'm creating an autoban script for 2 clans, and I'm having some problem in finding ONLY the clantag. 1st clantag = Wild 2nd clantag = KekZ| if getPlayerName ( player ):find ( "Wild" ) then if getPlayerName ( player ):find ( "KekZ|" ) then Now this result above would ban everyone with a 'W' in their name, or 'K' or '|', doesn't matter really. Well I want it to ban the players with the complete tag, only. So I tried something like this: if getPlayerName ( player ):find ( "%[%Wild%]" ) then if getPlayerName ( player ):find ( "%K%ekZ%|" ) then But that didn't work properly either, can you help me with this? I want it to ban the players who wears the tag only, e.g: KekZ|Randomguy [Wild]Randomguy Thx Link to comment
Max+ Posted August 3, 2014 Share Posted August 3, 2014 (edited) Try this , Make sure you add the resource to admin group --ServerSide Tag = {"Wild", "KekZ|"} addEventHandler ( 'onPlayerChangeNick',root, function ( _,Nick ) for _, v in ipairs(Tag) do if string.find( Nick, v) then banPlayer ( source, true, true, true, nil, "Sorry, You got Baneed For Tag " ) end end end ) addEventHandler ( 'onPlayerJoin',root, function ( ) for _, v in ipairs(Tag) do if string.find( source, v) then banPlayer ( source, true, true, true, nil, "Sorry, You got Baneed For Tag " ) end end end ) Edited August 3, 2014 by Guest Link to comment
Hazard| Posted August 3, 2014 Author Share Posted August 3, 2014 Nope, I tested that, and it banned me if my nick was ONLY 'W'. heres my code btw. function banPlayer2 () for _, player in ipairs ( getElementsByType ( "player" ) ) do if getPlayerName ( player ):find ( "%W%il%d" ) then if ( player ) then banPlayer ( player, true ) end end end end addEventHandler ( "onPlayerChangeNick", getRootElement(), banPlayer2) addEventHandler ( "onPlayerJoin", root, banPlayer2) Link to comment
Saml1er Posted August 3, 2014 Share Posted August 3, 2014 local clans = {"KekZ|","[Wild]"} -- insert as many clans you want function banPlayer2 () local player = source for _ ,v in pairs (clans) do local v = v:upper() local pname = getPlayerName ( player ):gsub("#%x%x%x%x%x%x", ""):upper() -- remove those color codes and lets find clantag using uppercase if pname:find(v, 1, true) then banPlayer ( player, true ) --- Btw players can easily change ip so this banning method is not so secure, do it with serials. end end end addEventHandler ( "onPlayerChangeNick", getRootElement(), banPlayer2) addEventHandler ( "onPlayerJoin", root, banPlayer2) EDIT: aaaaa, max. 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