kaspertje100
Member
- Joined
- May 8, 2008
- Messages
- 236
- Reaction score
- 7
Code:
Hi there!
I got a problem with my 2 scripts djinn and cyclops for my real addon system here are the scripts :
[CODE]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 cycmsg = 'Cling Clang!'
local noimsg = 'Lil\' one no have that thing!'
local deny = 'Lil\' one is no sure? Okay'
local infbolt = 4 -- change this to adjust the number of infernal bolts you want to give to the players for 1 soul orb.
--------------------MESSAGES------------------------------------------------------------------------------
if msgcontains(msg, 'help') or msgcontains(msg, 'trade') then
selfSay('Me can make {royal steel}, {draconian steel}, {hell steel} and {crude iron}. Me also make lil\' {infernal bolt}.', cid)
elseif msgcontains(msg, 'royal steel') then
selfSay('Very noble. Shiny. Me like. But breaks so fast. Me can make from shiny armour. Lil\' one want to trade?', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'draconian steel') then
selfSay('Firy steel it is. Need green ones\' breath to melt. Or red even better. Me can make from shield. Lil\' one want to trade?', cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'hell steel') then
selfSay('Hellsteel is. Cursed and evil. Dangerous to work with. Me can make from evil helmet. Lil\' one want to trade?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'crude iron') then
selfSay('Good iron is. Me friends use it much for fight. Me can make from weapon. Lil\' one want to trade?', cid)
talkState[talkUser] = 4
elseif msgcontains(msg, 'infernal bolt') then
selfSay('Uh. Me can make some nasty lil\' bolt from soul orbs. Lil\' one want to trade all?', cid)
talkState[talkUser] = 5
-------------GETTING METALS FROM HIM-------------------
-- Royal Steel
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, 2487, 1) == true then
doPlayerAddItem(cid, 5887, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
-- Draconian Steel
elseif talkState[talkUser] == 2 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 2516, 1) == true then
doPlayerAddItem(cid, 5889, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
-- Hell Steel
elseif talkState[talkUser] == 3 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 2462, 1) == true then
doPlayerAddItem(cid, 5888, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
-- Crude Iron
elseif talkState[talkUser] == 4 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 2393, 1) == true then
doPlayerAddItem(cid, 5892, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
elseif talkState[talkUser] == 5 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 5944, 1) == true then
doPlayerAddItem(cid, 6529, infbolt)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
and the xml of the cyclop
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="A Sweaty Cyclops" script="data/npc/scripts/cyclop.lua" walkinterval="2000" floorchange="0" access="5" >
<health now="150" max="150"/>
<look type="22" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hum Humm! Welcume lil' Player.."/>
<parameter key="message_farewell" value="Good bye lil' one."/>
</parameters>
</npc>
and the djinn scripts:
[/CODE]<?xml version="1.0" encoding="UTF-8"?>
<npc name="Addon Djinn" script="data/npc/scripts/djinn.lua" walkinterval="2000" floorchange="0" access="5" >
<health now="150" max="150"/>
<look type="51" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Welcome to my shop! lil' Player.."/>
<parameter key="message_farewell" value="Good bye lil' one."/>
</parameters>
</npc>[/CODE]
the lua of the djinn
Code:
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 cycmsg = 'Cling Clang!'
local noimsg = 'Lil\' one no have that thing!'
local deny = 'Lil\' one is no sure? Okay'
local infbolt = 4 -- change this to adjust the number of infernal bolts you want to give to the players for 1 soul orb.
--------------------MESSAGES------------------------------------------------------------------------------
if msgcontains(msg, 'help') or msgcontains(msg, 'trade') then
selfSay('I can make {warrior sweat}, {fighting spirit}, {enchanted chicken wing} and {magic sulphur}. Me also make lil\' {infernal bolt}.', cid)
elseif msgcontains(msg, 'warrior sweat') then
selfSay('It contains the sweat spilled in many battles and is said to be used for certain perfumes too.Bring me 4 warrior helmet and i will give it to you Lil\' one want to trade?', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'fighting spirit') then
selfSay('it contains pure fighting spirit.Bring me 2 royal helmet and i will give it to you. Lil\' one want to trade?', cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'enchanted chicken wing') then
selfSay('It is said to make your feet fly.Bring me boots of haste and i will give it to you. Lil\' one want to trade?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'magic sulphur') then
selfSay('It smells rather badly but is said to be an important catalyst for magical rituals.Bring me 3 fire swords and i will give it to you. Lil\' one want to trade?', cid)
talkState[talkUser] = 4
elseif msgcontains(msg, 'infernal bolt') then
selfSay('Uh. Me can make some nasty lil\' bolt from soul orbs. Lil\' one want to trade all?', cid)
talkState[talkUser] = 5
-------------GETTING METALS FROM HIM-------------------
-- warrior sweat
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, 2474, 4) == true then
doPlayerAddItem(cid, 5885, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
-- fighting spirit
elseif talkState[talkUser] == 2 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 2498, 2) == true then
doPlayerAddItem(cid, 5884, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
-- enchanted chicken wing
elseif talkState[talkUser] == 3 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 2195, 1) == true then
doPlayerAddItem(cid, 5891, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
-- Magic Sulphur
elseif talkState[talkUser] == 4 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 2392, 3) == true then
doPlayerAddItem(cid, 5904, 1)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
elseif talkState[talkUser] == 5 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, 5944, 1) == true then
doPlayerAddItem(cid, 6529, infbolt)
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
ok now the error if I summon the npc in my ot i can talk to it etc an example: I want an enchanted chicken wing and i say enchanted chicken wing then the npc take my boh but it says i 't dont got the item and it wont give me the enchanted chicken wing.
in the startup exe stands lua script error npc interface data/npc/scripts/djinn.lua on think
some info about my server:
Im using tfs mystic spirit 0.2.7 (client 8.54-8.57)
p.s sorry for my bad english ;d