• 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

poii

Member
Joined
Nov 11, 2008
Messages
188
Reaction score
8
Can someone do an NPC like this...
Player:hi
NPC:Hello dear, what are you looking for?
Player:Promotion
NPC:You must bring me a green, red, blue, yellow and violet gem so i can promote you.


Player:hi
NPC:Hello dear, what are you looking for?
Player:Items
NPC:You bring me all the gems I asked you for?
Player:Yes
NPC:Congatulations you are now able to get promoted... choose between <get vocation id> if sorc then choose between id (9 or 10 ) if druid choose between id (11 o 12) if paladin between (13 and 14) if knight between 15 and 16)
Player: Cuzader (id 15)
NPC: (if knight) are you sure about it? (any other vocation) only knights can become cruzader
Player:yes
NPC:= set player vocation = id congratulations you have become X vocation!
Player:bye





Level requirement = 120
items




Vocation id
5 6 7 8

New options
9 and 10(for voc 5) 11 and 12(for voc 6) 13 and 14(for voc 7) 15 and 16(for voc 8)

if vocation > 8 then already promoted
if vocation < 5 then you must be promoted once !
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Varkhal" script="addons.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="79" body="113" legs="105" feet="86" addons="0"/>
        <parameters>
                <parameter key="message_greet" value="Hello |PLAYERNAME|. What are you looking for?"/>
                <parameter key="message_farewell" value="Good bye."/>
                <parameter key="message_walkaway" value="Farewell then.." />
    </parameters>

</npc>


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



--player cucrrent voc        --voc1 name     id    voc2 name          id
    local voc = {[5] = {name ="Mage" , idd= 9,name2 ="Magee" , idd2= 10},
	              [6] = {name ="Inferno" , idd= 11,name2 ="Magican" , idd2= 12},
	              [7] = {name ="Shooter" , idd= 13,name2 ="Thrower" , idd2= 14},
	              [8] = {name ="Crus" , idd=15 ,name2 ="Cruz" , idd2= 16}
	              
						}
						local storage = 3030
						local storage2 = 3040
						local storage3 = 3070

function creatureSayCallback(cid, type, msg)
 local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local vocation = voc[getPlayerVocation(cid)]

    if(not npcHandler:isFocused(cid)) then
        return false
    end
	if getPlayerVocation(cid) > 8 then
	       npcHandler:say("You are already promoted.",cid)
		return false   
   elseif getPlayerVocation(cid) < 5 then
	       npcHandler:say("You must get the first promotion first.",cid)
   return false
	end
   if msgcontains(msg, 'Promotion') then

        npcHandler:say("Do you wish to get second promotion?",cid)
		   talkState[talkUser] = 1
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
          npcHandler:say("You must bring me a {green}, {red}, {blue}, {yellow} and {violet} gem so i can promote you.Go and come back when you get them.",cid)
		 talkState[talkUser] = 2
	elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
          npcHandler:say("Maybe another time.",cid)
		 talkState[talkUser] = 0
	elseif msgcontains(msg, 'Items') and talkState[talkUser] == 2 then
	        npcHandler:say("You brought me all the {gems} I asked you for?",cid)
			setPlayerStorageValue(cid,storage,1)

	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
	     itemremov = {2153,2154,2155,2156,2158}
	     if getPlayerItemCount(cid,2153) == 1 and getPlayerItemCount(cid,2158) == 1 and getPlayerItemCount(cid,2154) == 1 and getPlayerItemCount(cid,2156) == 1 and getPlayerItemCount(cid,2155) == 1 then
	       for i = 1, #itemremov do
		     doPlayerRemoveItem(cid, itemremov[i],1)
			end
			npcHandler:say("congatulations you are now able to get {promoted}... Choose between {" .. vocation.name.."} or a {" ..vocation.name2.."}.",cid)
			talkState[talkUser] = 4
			setPlayerStorageValue(cid,storage,0)
		 else
		  npcHandler:say("You haven't brought me all what i needed.",cid)
		
       end
	elseif msgcontains(msg, 'no') and getPlayerStorageValue(cid,storage) == 1 then
	    npcHandler:say("Get them and come later then.",cid)
	
	elseif msgcontains(msg, vocation.name) and talkState[talkUser] == 4 then
	   npcHandler:say("Are you sure you want to be a {"..vocation.name.."}?",cid)
	   setPlayerStorageValue(cid,storage2,1)
	elseif msgcontains(msg, "yes") and getPlayerStorageValue(cid,storage2) == 1 then
	        doPlayerSetVocation(cid,vocation.idd)
			npcHandler:say("You are now promoted to {"..vocation.name.."}.",cid)
			setPlayerStorageValue(cid,storage2,0)
			talkState[talkUser] = 0
	elseif msgcontains(msg, "no") and getPlayerStorageValue(cid,storage2) == 1 then
	       npcHandler:say("what would you like to be then?",cid)	
	elseif msgcontains(msg, vocation.name2) and talkState[talkUser] == 4 then
	   npcHandler:say("Are you sure you want to be a {"..vocation.name2.."}?",cid)
	   setPlayerStorageValue(cid,storage2,1)
	elseif  msgcontains(msg, "yes") and getPlayerStorageValue(cid,storage3) == 1  then
	        doPlayerSetVocation(cid,vocation.idd2)
			npcHandler:say("You are now promoted to {"..vocation.name2.."}.",cid)
			setPlayerStorageValue(cid,storage3,0)
			talkState[talkUser] = 0
	elseif  msgcontains(msg, "no") and getPlayerStorageValue(cid,storage3) == 1 then
	       npcHandler:say("what would you like to be then?",cid)	
	end
	
	 return true
end

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