Maybe talkaction ?
or you wanna go to npc to say fuck ?
crackd me up dunno why xDyou wanna go to npc to say fuck ?
function onSay(cid, words, param, channel)
local whatever = {
"fuck"
"noob"
"bitch"
"kurwa"
}
for i = 1, table.maxn(whatever) do
if words == i then
-- code here
something like
Lua:function onSay(cid, words, param, channel) local whatever = { "fuck" "noob" "bitch" "kurwa" } for i = 1, table.maxn(whatever) do if words == i then -- code here
function onSay(cid, words, param, channel)
local filter = {
"fuck"
"noob"
"bitch"
"kurwa"
}
for i = 1, 4 do
if words == filter[i] then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
doCreatureAddHealth(cid, -50)
end
end
return TRUE
end
function onSay(cid, words, param, channel)
local filter =
{
"fuck",
"noob",
"bitch",
"kurwa"
}
if filter[words] then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
doCreatureAddHealth(cid, -50)
end
return TRUE
end
local target = 0
local prevTarget = 0
local maxChaseDistance = 20
local origPos = 0
local lastAttack = 0
local followTimeout = 10
local function isSkulled(cid)
if(getCreatureSkullType(cid) >= 3 and isPlayerPzLocked(cid) == TRUE) then
return true
end
return false
end
local function goToOrigPos()
target = 0
lastAttack = 0
selfFollow(0)
doTeleportThing(getNpcCid(), origPos)
end
local function updateTarget()
if(isPlayer(target) == FALSE) then
goToOrigPos()
elseif(not isSkulled(target)) then
selfSay("Now, behave in the future.")
goToOrigPos()
end
if(target == 0) then
local list = getSpectators(getNpcPos(), 9, 9, false)
for i = 1, table.getn(list) do
local _target = list[i]
if(_target ~= 0) then
if(isPlayer(_target) == TRUE and isSkulled(_target)) then
if(getTilePzInfo(getCreaturePosition(_target)) == FALSE) then
if(selfFollow(_target)) then
target = _target
if(target ~= prevTarget) then
selfSay("We do not tolerate people like you here!")
end
prevTarget = target
break
end
end
end
end
end
end
end
function onCreatureAppear(cid)
if(cid == getNpcCid()) then
origPos = getNpcPos()
end
end
function onCreatureDisappear(cid)
if(cid == target) then
goToOrigPos()
end
end
function onCreatureMove(creature, oldPos, newPos)
--
end
function onThink()
updateTarget()
if(target == 0) then
return
end
local playerPos = getCreaturePosition(target)
local myPos = getNpcPos()
if(myPos.z ~= playerPos.z) then
goToOrigPos()
return
end
if(math.abs(myPos.x - origPos.x) > maxChaseDistance or math.abs(myPos.y - origPos.y) > maxChaseDistance) then
selfSay("I'll catch you next time.")
goToOrigPos()
return
end
if(lastAttack == 0) then
lastAttack = os.clock()
end
if(os.clock() - lastAttack > followTimeout) then
selfSay("You got me this time, but just wait.")
goToOrigPos()
return
end
if((math.abs(playerPos.x - myPos.x) <= 1) and (math.abs(playerPos.y - myPos.y) <= 1)) then
doTargetCombatHealth(getNpcCid(), target, COMBAT_LIFEDRAIN, -10, -50, CONST_ME_BLOCKHIT)
lastAttack = os.clock()
end
end
Why use "table.maxn"?.. and it will give error, because you are not using "," to separate the words.
I think this is better (not tested)
Lua:function onSay(cid, words, param, channel) local filter = { "fuck", "noob", "bitch", "kurwa" } if filter[words] then doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA) doCreatureAddHealth(cid, -50) end return TRUE end
function onSay(cid, words, param, channel)
local filter = {
"fuck",
"noob",
"bitch",
"kurwa"
}
for i = 1, 4 do
if words == filter[i] then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
doCreatureAddHealth(cid, -50)
end
end
return TRUE
end
<talkaction words="fuck" event="script" value="badwords.lua"/>
<talkaction words="noob" event="script" value="badwords.lua"/>
<talkaction words="bitch" event="script" value="badwords.lua"/>
<talkaction words="kurwa" event="script" value="badwords.lua"/>
PHP:<talkaction words="fuck" event="script" value="badwords.lua"/> <talkaction words="noob" event="script" value="badwords.lua"/> <talkaction words="bitch" event="script" value="badwords.lua"/> <talkaction words="kurwa" event="script" value="badwords.lua"/>
@btw what mean kurwa?
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NO BAD WORDS!" script="data/npc/scripts/badwords.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hiya |PLAYERNAME|! how may I help you?." />
</parameters>
</npc>
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'fuck') then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
doCreatureAddHealth(cid, -50)
npcHandler:say('Respect!!!', cid)
elseif msgcontains(msg, 'bitch') then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
doCreatureAddHealth(cid, -50)
npcHandler:say('Respect!!!', cid)
else
npcHandler:say('uuuuh? what?', cid)
end
return TRUE
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
well...
PHP:<?xml version="1.0" encoding="UTF-8"?> <npc name="NO BAD WORDS!" script="data/npc/scripts/badwords.lua" walkinterval="0" floorchange="0"> <health now="100" max="100"/> <look type="139" head="20" body="39" legs="45" feet="7" addons="0"/> <parameters> <parameter key="message_greet" value="Hiya |PLAYERNAME|! how may I help you?." /> </parameters> </npc>
my NPC version:
for more words, just add more elseifs...
Lua:local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'fuck') then doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA) doCreatureAddHealth(cid, -50) npcHandler:say('Respect!!!', cid) elseif msgcontains(msg, 'bitch') then doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA) doCreatureAddHealth(cid, -50) npcHandler:say('Respect!!!', cid) else npcHandler:say('uuuuh? what?', cid) end return TRUE end local shopModule = ShopModule:new() npcHandler:addModule(shopModule) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
if msgcontains(msg, 'fuck') then
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREAREA)
doCreatureAddHealth(cid, -50)
doCreatureAddHealth(cid, -20)
doCreatureAddHealth(cid, -10)
function attack(cid, damage)
doCreatureAddHealth(cid, damage)
return TRUE
end
addEvent(attack, 5000, cid, -20)
addEvent(attack, 10000, cid, -10)
msg = string.lower(msg)
You can possibly use addEvent...
Lua:function attack(cid, damage) doCreatureAddHealth(cid, damage) return TRUE end
And then after 'doCreatureAddHealth(cid, -50)' put
Lua:addEvent(attack, 5000, cid, -20) addEvent(attack, 10000, cid, -10)
And to your edit - yes there is a way, just put...
Lua:msg = string.lower(msg)
before the if functions.
Edit: I dno about the phrases part, it should work.