Chciałem zrobić coś własnego u npc ale nie mogę tego nawet przetestować bo cały czas jakieś błędy mam.
Moim celem było, żeby npc 'Więzień' sprawdzał czy drzwi na danym polu są otwarte.
Ogólnie sam nie umiem pisać skryptów to skopiowałem z jakiegoś innego większość i własną funkcje chciałem mu dodać.
Cały skrypt:
Kod:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local doorpos = {x=1064, y=1238, z=12}
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
if msgcontains(msg, 'hi;hello;h') then
npcHandler:say("Please, can you open this doors? Im not a bandit or anything, someone thrown me here and closed the doors.. Im a prisoner now. Wanna know where the key is?", cid)
else
npcHandler:say("Trust me, downstairs there are many treasures and rare items! You can get them if you open this doors. Wanna know where the key is?", cid)
elseif msgcontains(msg, 'yes;key;pass;door;') then
npcHandler:say("Ok then, the key is in dead tree, the dead tree is close to dragon lords and close from here, go and search it!", cid)
end
if msgcontains(msg, 'open;door;hi;') then
function check (item, toposition)
if item.itemid == 5111
itempos = getThingfromPos(doorpos) then
npcHandler:say("You openned the doors!! Mwahahhaha, go for you reward now mortal! Im free and gonna rule the world!", cid)
end
else
npcHandler:say("Mwahahaha azure syh sumer fallah tahn!", cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Podkreślone i kolorem jest to co chciałem dodać od siebie.
Przykładowy błąd:
Pisze niby, że brakuje 'end' tam, a jak dodam end to pisze wtedy, że jakby za dużo ich dałem >.<
ps:Tak przy okazji, dlaczego quest mi działa skoro nie zmieniłem w nim storage (jest 50305) a na mapce i w actions jest 57497?? Jak dałbym to 50305 uid. do skrzynki questowej to by nie działało wtedy ;/.. Ma ktoś jakieś racjonalne wytłumaczenie?