hub.onChatMessage = function( this, user, text )
DC():PrintDebug( this:getHubName().."> Chat from "..user:getNick()..": "..text )
local s = string.lower( text )
if string.find( s, "dick" ) or string.find( s, "fuck" ) then
this:sendChat( "Watch ur mouth" )
end
end
how do i get this piece of coding go look for the triggers in a table something like :
trigs = { "fuck", "dick","prick","asshole"}
This is LUA 5.0,
for i,v in trigs do
if string.find(s,i) then
--// todo
but im not sure
yeah its lua 5 :-\
the script is for a bcdc++ based script not for ptokax
thats why its v5.0
but can u give me some sorta example?
well, i just did,
to use a for loop to go through the table...
for i,v in trigs do
if string.find(s,i) then
--// do some things
end
end
or maybe another solution
trigs = { ["fuck"]=1, ["dick"]=2,["prick"]=3,["asshole"]=4}
local s = string.lower( text )
if string.find( s, trigs[s]) then
this:sendChat( "Watch ur mouth" )
end
end
but im not sure about it
hnmm
geuss not :-\
LUA Error: attempt to call a nil value
hmm plop made a script for me that i could run on bcdc++ based clients
i found this in the code maye this helps
-- the array of forbidden things
trigs = { "fuck", "weingarten","ip.com","ass.org","dns2go","yhub","servemp3.net","mine,nu"}
else
for i=1,table.getn(trigs) do
if string.find(s, trigs) then
local ownNick = this:getOwnNick()
DC():SendHubMessage( this:getId(), "<"..ownNick.."> !kickuser "..user:getNick().." You have been kicked because of Offensive Language / Advertising.|" )
break
end
end
end
ive tried to make a bit of sence off this script but :-\ i think my best shot is here on the forum
and since plop is / was lanning i couldent gat ahold of him
but i hope u can use the code he wrote
did you try the for loop?
srry was editing my last post ;)
btw the trigs u made r fr lua v4.0 if im not mistaking look @ the trigs of the code thats lua v5.0
hrmz..
*not-sober and very sleepy*
you are modding this..?
hub.onChatMessage = function( this, user, text )
--DC():PrintDebug( this:getHubName().."> Chat from "..user:getNick()..": "..text )
local s = string.lower( text )
-- if string.find( s, "[^a-z]bier+[^a-z]" ) or string.find( s, "[^a-z]biertje[^a-z]" ) then
-- this:sendChat( "bier? ja lekker! :)" )
-- end
end
try this:
hub.onChatMessage = function( this, user, text )
local trigs = { "fuck", "weingarten","ip.com","ass.org","dns2go","yhub","servemp3.net","mine.nu"}
local s = string.lower( text )
for k,v in trigs do
if string.find( s, v, 1, 1 ) then
this:sendChat( "Watch your mouth" )
break
end
end
end
well tnx alot i heard u would prolly know it but i couldent get a hold of ya
hmmm ive been trying to get the nick from some1 out of the chat into the response but i keep getting this:
this:sendChat( "Watch your mouth " ) gives : nothing
this:sendChat( "Watch your mouth "..user:getNick()"" ) gives : \startup.lua:199: attempt to call a string value
well ive worked some stuff out myself and some stuff with some help
but now im stuck
the is the code now:
hub.onChatMessage = function( this, user, text )
local trigs1 = { "fuck", "dick","fag","homo","whore","cunt"}
local s = string.lower( text )
for k,v in trigs1 do
if string.find( s, v, 1, 1 ) then
this:sendChat( "Watch your mouth" ..user:getNick().. "those words could get u banned" )
break
local trigs2 = { "no-ip","dyndns","serverbeer.com"}
for k,v in trigs2 do
if string.find( s, v, 1, 1 ) then
this:sendChat( "+pban" ..user:getNick().. "dont Advertise for other hubs" )
break
end
end
end
and it gives
`end' expected (to close `if' at line 3) near `local'
what am i missing here?
start using [ code ] blocks for your code, and indentation or no one will help you
it's horrible to read unindented code, and it's also the cause of your errors
for k,v in bla do
if blah then
if blah2 then
do_something
end
end
end
^-- indentation, try it
huh? urm im just a simple dutchy workin on an idea i have :-\
plz explain in normal english what u meen :)