• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

fix npc script (CYKO AGAIN PWN) fixed.

iruga

#S¥Ơ'..
Joined
May 18, 2009
Messages
371
Reaction score
4
Location
Brazil
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:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local spell_box_id = 102
local support_box = 114
	
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
	elseif msgcontains(msg, 'strong haste') then
		if isInArray({1,5,9}, getPlayerVocation(cid)) then
			if not getPlayerLearnedInstantSpell(cid, 'Strong Haste') then
				npcHandler:say("Would you like to buy the spell {strong haste} for 100 gold coins?", cid)
				talkState[cid] = 1
			else
				npcHandler:say("You already have this spell.", cid)
			end
		else
			npcHandler:say("You don\'t have the right vocation.", cid)
		end
	elseif msgcontains(msg, 'yes') and talkState[cid] == 1 then
		if doPlayerRemoveMoney(cid, 100) then
			npcHandler:say("Congratulations! Now you have a brand new spell! Check your spell box to use this spell.", cid)
			doPlayerLearnInstantSpell(cid, 'Strong Haste')
			doSendMagicEffect(getThingPos(cid), 12)
			local box = getPlayerSlotItem(cid, CONST_SLOT_AMMO)
			if box.itemid == spell_box_id and 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 don\'t have enough money.", cid)
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top