gokalpfirat Posted June 20, 2011 Posted June 20, 2011 kufurtablo = {} function kufur:ekle( kufur ) table.insert( kufurtablo, kufur ) end function playerChat ( message, messageType ) if messageType == 0 then for k,v in ipairs(kufurtablo) do if string.find((string.gsub)message,v) then cancelEvent() banPlayer ( source, Serial = true, reason = "Bad word", seconds = 12000 ) outputChatBox ( getPlayerName(source).." has banned 2 minutes for saying bad word..", getRootElement(), 0, 255, 0, true ) end end end end This is my code and this is my another .lua file. function onResourceStart(res) kufur:ekle ("fuck") end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onResourceStart) I havent got error when i debug it but it doesnt works.
JR10 Posted June 20, 2011 Posted June 20, 2011 function playerChat ( message, messageType ) if messageType == 0 then for k,v in ipairs(kufurtablo) do if string.find((string.gsub)message,v) then cancelEvent() banPlayer ( source, Serial = true, reason = "Bad word", seconds = 12000 ) here is what you want addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then if string.find(msg:lower, '[bad word whatever]', 0) then --the code if a bad word was found end end end ) here: '[bad word whatever]' enter the bad words separated by a space and your banPlayer function is wrong banPlayer ( player bannedPlayer, [ bool IP = true, bool Username = false, bool Serial = false, player responsiblePlayer = nil, string reason = nil, int seconds = 0 ] so: banPlauer(source, false, false, true, nil, 'Bad Word', 12000)
will briggs Posted June 20, 2011 Posted June 20, 2011 end end end end Erm btw, a good scripter always sets there scripts out in a pattern or sertain way... Trust me it helps to stagger it to the corrisponding functions... e.g. End End End End
JR10 Posted June 20, 2011 Posted June 20, 2011 Well, when i write a code here i wont do a lot of spaces there is not tab, but he probably copied it.
will briggs Posted June 20, 2011 Posted June 20, 2011 True, and i didnt mean a load of spaces, just I.E on forums doesnt let you tab as in moving in the text, just changing element in the browser... I.E Sucks!
gokalpfirat Posted June 21, 2011 Author Posted June 21, 2011 function playerChat ( message, messageType ) if messageType == 0 then for k,v in ipairs(kufurtablo) do if string.find((string.gsub)message,v) then cancelEvent() banPlayer ( source, Serial = true, reason = "Bad word", seconds = 12000 ) here is what you want addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then if string.find(msg:lower, '[bad word whatever]', 0) then --the code if a bad word was found end end end ) here: '[bad word whatever]' enter the bad words separated by a space and your banPlayer function is wrong banPlayer ( player bannedPlayer, [ bool IP = true, bool Username = false, bool Serial = false, player responsiblePlayer = nil, string reason = nil, int seconds = 0 ] so: banPlauer(source, false, false, true, nil, 'Bad Word', 12000) But i want find the badword in table kufurtablo{ }
Castillo Posted June 21, 2011 Posted June 21, 2011 kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( v ) if ( string.find ( str, v ) ) then banPlayer(source, false, false, true, nil, 'Bad Word', 12000) break end end end end )
gokalpfirat Posted June 21, 2011 Author Posted June 21, 2011 kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( v ) if ( string.find ( str, v ) ) then banPlayer(source, false, false, true, nil, 'Bad Word', 12000) break end end end end ) Its work if i say with caps lock
Blueman Posted June 21, 2011 Posted June 21, 2011 You could put and in the if statements like this. if (getPlayerPing ( source ) < 100 ) and ( pingkick == true ) then
Castillo Posted June 21, 2011 Posted June 21, 2011 kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( v ) if ( string.find ( str, v ) ) then banPlayer(source, false, false, true, nil, 'Bad Word', 12000) break end end end end ) Its work if i say with caps lock You are wrong, it works with caps and without caps, proof: I said: son Of a BiTch and it worked.
gokalpfirat Posted June 23, 2011 Author Posted June 23, 2011 Sorry for flood but banPlayer doesnt works.
Castillo Posted June 23, 2011 Posted June 23, 2011 kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( v ) if ( string.find ( str, v ) ) then addBan( nil, nil, getPlayerSerial(source), nil, 'Bad word', 12000 ) break end end end end )
JR10 Posted June 23, 2011 Posted June 23, 2011 Post errors warnings. I didn't pay attention but how is this: kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( v ) if ( string.find ( str, v ) ) then banPlayer(source, false, false, true, nil, 'Bad Word', 12000) break end end end end ) here function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( v ) if ( string.find ( str, v ) ) then str is the lower of v then how you are checking if v is found in str i am not sure if iam right but shouldn't it be like this: kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( msg ) if ( string.find ( str, v ) ) then banPlayer(source, false, false, true, nil, 'Bad Word', 12000) break end end end end )
Castillo Posted June 23, 2011 Posted June 23, 2011 Yeah..... my mistake , btw, use addBan, banPlayer won't work. kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( msg ) if ( string.find ( str, v ) ) then addBan( nil, nil, getPlayerSerial(source), nil, 'Bad word', 12000 ) break end end end end )
JR10 Posted June 23, 2011 Posted June 23, 2011 Yeah..... my mistake , btw, use addBan, banPlayer won't work. kufurtablo = { "son of a bitch", } addEventHandler('onPlayerChat', root, function(msg, msgType) if msgType == 0 then for i,v in pairs(kufurtablo) do local str = string.lower ( msg ) if ( string.find ( str, v ) ) then addBan( nil, nil, getPlayerSerial(source), nil, 'Bad word', 12000 ) break end end end end ) Hmm, why wont it work? Sorry but i just want to understand why
Castillo Posted June 23, 2011 Posted June 23, 2011 I don't know why, but this function is outdated if i'm right, and we should use addBan instead.
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