• 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!

NPC: epic vocation npc

YugiNao

Banned User
Joined
Nov 22, 2008
Messages
211
Reaction score
3
I want a npc script: that' grands you epic vocation when finnish the quest the mission should be that he wants you to collect 30 dragon scale's and 50 spider webs and 10 perfect behemoth fangs.

can someone make me this?
 
npc/scripts/epic.lua
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local cost = 10
local lvl = 20
	if msgcontains(msg, 'epic promotion') then
		if getPlayerItemCount(cid, 2160) >= cost then
			if getPlayerLevel(cid) >= lvl then
				if getPlayerPromotionLevel(cid) == 1 then
					selfSay('Do you want to be promoted to epic ?')
					talk_state = 1
				else
				selfSay('You must be promoted.')
				end
			else
			selfSay('You must have level ".. lvl .." or higher')
			end
		else
		selfSay('You have to pay ".. cost .." crystal coins.')						
talk_state = 0
end

elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid, 2160) >= cost then
if doPlayerRemoveItem(cid, 2160, cost) == TRUE then

selfSay('You are now promoted to epic.')
end
else
selfSay('You don\'t have money.')
end

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end

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

[Tested on TFS 0.3.6]
 
Hey wait, I forgot about those items

use this
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
config = {
lvl = 20
}
	if msgcontains(msg, 'epic promotion') then
		if getPlayerItemCount(cid, 5920) >= 30 and getPlayerItemCount(cid, 5879) >= 50 and getPlayerItemCount(cid, 5893) >= 10 then
			if getPlayerLevel(cid) >= lvl then
				if getPlayerPromotionLevel(cid) == 1 then
					selfSay('Do you want to be promoted to epic ?')
					talk_state = 1
				else
				selfSay('You must be promoted.')
				end
			else
			selfSay('You must have level ".. config.lvl .." or higher')
			end
		else
		selfSay('I need 30 green dragon scales, 50 giant spider silks and 10 perfect behemoth fangs to promote you.')						
talk_state = 0
end

elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid, 5920) >= 30 and getPlayerItemCount(cid, 5879) >= 50 and getPlayerItemCount(cid, 5893) >= 10 then
if doPlayerRemoveItem(cid, 5920, 30) == TRUE and doPlayerRemoveItem(cid, 5879, 50) == TRUE and doPlayerRemoveItem(cid, 5893, 10) == TRUE then

selfSay('You are now promoted to epic.')
end
else
selfSay('You don\'t have money.')
end

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end

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

:P
 
Code:
[30/04/2010 17:09:17] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/promotion.xml).
[30/04/2010 17:09:17] Info: failed to load external entity "data/npc/promotion.xml"
 
M xml is
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Proe" script="data/npc/scripts/promotion.lua" walkinterval="1" floorchange="0">
	<health now="100" max="100"/>
	<look type="133" head="20" body="39" legs="45" feet="7" addons="0"/>
</npc>

And I wrote the corrected script with ur items :D
 
Code:
[30/04/2010 17:17:26] [Error - LuaScriptInterface::loadFile] data/npc/scripts/promotion.lua:16: unexpected symbol near 'local'
[30/04/2010 17:17:26] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/promotion.lua
 
It is from my OTS - working npc so it must work :S

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
config = {
lvl = 20
}
        if msgcontains(msg, 'epic promotion') then
                if getPlayerItemCount(cid, 5920) >= 30 and getPlayerItemCount(cid, 5879) >= 50 and getPlayerItemCount(cid, 5893) >= 10 then
                        if getPlayerLevel(cid) >= lvl then
                                if getPlayerPromotionLevel(cid) == 1 then
                                        selfSay('Do you want to be promoted to epic ?')
                                        talk_state = 1
                                else
                                selfSay('You must be promoted.')
                                end
                        else
                        selfSay('You must have level ".. config.lvl .." or higher')
                        end
                else
                selfSay('I need 30 green dragon scales, 50 giant spider silks and 10 perfect behemoth fangs to promote you.')                                           
talk_state = 0
end

elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid, 5920) >= 30 and getPlayerItemCount(cid, 5879) >= 50 and getPlayerItemCount(cid, 5893) >= 10 then
if doPlayerRemoveItem(cid, 5920, 30) == TRUE and doPlayerRemoveItem(cid, 5879, 50) == TRUE and doPlayerRemoveItem(cid, 5893, 10) == TRUE then

selfSay('You are now promoted to epic.')
end
else
selfSay('You don\'t have money.')
end

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I think that can has some bugs, when you find any bugs, try this:

I can't test it now, because I'm not on my computer :P
LUA:
  local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local lvl = 20

        if msgcontains(msg, 'epic promotion') then
                if getPlayerItemCount(cid, 5920) >= 30 and getPlayerItemCount(cid, 5879) >= 50 and getPlayerItemCount(cid, 5893) >= 10 then
                        if getPlayerLevel(cid) >= lvl then
                                if getPlayerPromotionLevel(cid) == 1 then
                                        selfSay('Do you want to be promoted to epic ?')
                                        talk_state = 1
                                else
                                selfSay('You must be promoted.')
                                end
                        else
                        selfSay('You must have level 20 or higher')
                        end
                else
                selfSay('I need 30 green dragon scales, 50 giant spider silks and 10 perfect behemoth fangs to promote you.')                                          
talk_state = 0
end

elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid, 5920) >= 30 and getPlayerItemCount(cid, 5879) >= 50 and getPlayerItemCount(cid, 5893) >= 10 then
if doPlayerRemoveItem(cid, 5920, 30) == TRUE and doPlayerRemoveItem(cid, 5879, 50) == TRUE and doPlayerRemoveItem(cid, 5893, 10) == TRUE then

selfSay('You are now promoted to epic.')
end
else
selfSay('You don\'t have money.')
end

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end

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

Sorry for so many posts and problems xD
 
Back
Top