someone can fix this script for me?
PHP:
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
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local spell_box_id = 102
local support_box = 114
if msgcontains(msg, 'buy strong haste') or msgcontains(msg, 'strong haste') then
if getPlayerVocation(cid,1) or getPlayerVocation(cid,5) or getPlayerVocation(cid,9) then
if getPlayerLearnedInstantSpell(cid, 'Utani Gran Hur') == false then
npcHandler:say("Would you like to buy the spell {strong haste} for 100 gold coins?", cid)
talkState[talkUser] = 1
else
npcHandler:say("You don\'t have the right vocation.", cid)
end
else
npcHandler:say("You already have this spell.", cid)
end
elseif msgcontains(msg, 'yes') then
if talkState[talkUser] == 1 then
if getPlayerMoney(cid) >= 100 then
doPlayerRemoveMoney(cid, 100)
npcHandler:say("Congratulations! Now you have a brand new spell! Check your spell box to use this spell.", cid)
doPlayerLearnInstantSpell(cid, 'Utani Gran Hur')
doSendMagicEffect(getCreaturePosition(cid), 12)
local box = getPlayerSlotItem(cid, CONST_SLOT_AMMO)
if (box.itemid == spell_box_id) then
if isContainer(box.uid) then
for k = (getContainerSize(box.uid) - 1), 0, -1 do
local tmp = getContainerItem(box.uid, k)
if (tmp.itemid == support_box) then
local icon = doCreateItemEx(2741, 1) -- item to add
doAddContainerItemEx(tmp.uid, icon)
doTransformItem(icon, 208, 1) -- itemID
break
end
end
end
else
npcHandler:say("You already have this spell.", cid)
end
else
npcHandler:say("You don\'t have enough money.", cid)
end
end
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: