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

[Request] Sweety Cyclops

Here you go with NPC channel working! Testes in TFS 0.3 Beta 2!


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

-- use the real conversation? (true/false)
real = true

if real == true then
tradeMsg = 'Me can make good item from item me need. Me make uth\'kean, za\'ralator, uth\'lokr, uth\'prta and nasty lil\' bolts.'
crownMsg = 'Very noble. Shiny. Me like. But breaks so fast. Me can make from shiny armour. Lil\' one want to trade?'
devilMsg = 'Hellsteel is. Cursed and evil. Dangerous to work with. Me can make from evil helmet. Lil\' one want to trade?'
dragoMsg = 'Firy steel it is. Need green ones\' breath to melt. Or red even better. Me can make from shield. Lil\' one want to trade?'
giantMsg = 'Good iron is. Me friends use it much for fight. Me can make from weapon. Lil\' one want to trade?'
souloMsg = 'Uh. Me can make some nasty lil\' bolt from soul orbs. Lil\' one want to trade all?'
hasNoMsg = 'Lil\' one no have item I want.'
noMsg = 'Lil\' one no want item?'
else
tradeMsg = 'I can forge you royal steel from crown armors, hell steel from devil helmets, draconian steel from dragon shields, crude iron from giant swords and infernal bolts from soul orbs.'
crownMsg = 'Do you want trade a crown armor for royal steel?'
devilMsg = 'Do you want trade a devil helmet for hell steel?'
dragoMsg = 'Do you want trade a dragon shield for draconian steel?'
giantMsg = 'Do you want trade a giant sword for crude iron?'
souloMsg = 'Do you want trade a soul orb for 2 infernal bolts?'
hasNoMsg = 'Come back when you have more!'
noMsg = 'Ok than.'
end
if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'forge') then
selfSay(tradeMsg,cid)
elseif msgcontains(msg, 'royal steel') or msgcontains(msg, 'royal') or msgcontains(msg, 'crown') or msgcontains(msg, 'crown armor') or msgcontains(msg, 'uth\'kean') then
selfSay(crownMsg,cid)
talk_state = 1
elseif msgcontains(msg, 'hell steel') or msgcontains(msg, 'hell') or msgcontains(msg, 'devil') or msgcontains(msg, 'devil helmet') or msgcontains(msg, 'za\'ralator') then
selfSay(devilMsg,cid)
talk_state = 2
elseif msgcontains(msg, 'draconian steel') or msgcontains(msg, 'draconian') or msgcontains(msg, 'dragon') or msgcontains(msg, 'dragon shield') or msgcontains(msg, 'uth\'lokr') then
selfSay(dragoMsg,cid)
talk_state = 3
elseif msgcontains(msg, 'crude iron') or msgcontains(msg, 'crude') or msgcontains(msg, 'giant') or msgcontains(msg, 'gs') or msgcontains(msg, 'giant sword') or msgcontains(msg, 'uth\'prta') then
selfSay(giantMsg,cid)
talk_state = 4
elseif msgcontains(msg, 'infernal') or msgcontains(msg, 'infernal bolt') or msgcontains(msg, 'infernal bolts') or msgcontains(msg, 'soul') or msgcontains(msg, 'soul orb') or msgcontains(msg, 'soul orbs') or msgcontains(msg, 'nasty lil\' bolt') then
selfSay(souloMsg,cid)
talk_state = 5
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,2487) >= 1 then
if doPlayerTakeItem(cid,2487,1) == 0 then
selfSay('Here you are.',cid)
doPlayerAddItem(cid,5887,1)
end
else
selfSay(hasNoMsg,cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if getPlayerItemCount(cid,2462) >= 1 then
if doPlayerTakeItem(cid,2462,1) == 0 then
selfSay('Here you are.',cid)
doPlayerAddItem(cid,5888,1)
end
else
selfSay(hasNoMsg,cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
if getPlayerItemCount(cid,2516) >= 1 then
if doPlayerTakeItem(cid,2516,1) == 0 then
selfSay('Here you are.',cid)
doPlayerAddItem(cid,5889,1)
end
else
selfSay(hasNoMsg,cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
if getPlayerItemCount(cid,2393) >= 1 then
if doPlayerTakeItem(cid,2393,1) == 0 then
selfSay('Here you are.',cid)
doPlayerAddItem(cid,5892,1)
end
else
selfSay(hasNoMsg,cid)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 5 then
if getPlayerItemCount(cid,5944) >= 1 then
if doPlayerTakeItem(cid,5944,1) == 0 then
selfSay('Here you are.',cid)
doPlayerAddItem(cid,6529,2)
end
else
selfSay(hasNoMsg,cid)
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay(noMsg,cid)
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I think is this one:

PHP:
<?xml version="1.0"?> 
<npc name="A Sweaty Cyclops" script="data/npc/scripts/sweaty cyclops.lua" access="5" lookdir="2" autowalk="25"> 
  <mana now="800" max="800" /> 
  <health now="200" max="200" /> 
  <look type="22" head="0" body="0" legs="0" feet="0" /> 
  <parameters> 
    <parameter key="message_greet" value="Hello |PLAYERNAME|. Me can make good items from items me need." /> 
    <!--<parameter key="message_greet" value="Hello |PLAYERNAME|. I can give you different steels for different items." />--> 
  </parameters> 
</npc>

Rep+++++?
 
Back
Top