• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[8.5] [NPC] Lucius

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
308
Location
Poland
Witam. Chciałbym, żeby ktoś mi przerobił skrypt NPC. Zrobiłem go sam lecz gdy podchodzę do npc i pisze 'hi' to wyskakują błędy w konsoli. Dam tutaj skrypta i chciałbym, żeby mi ktoś pomogł.

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 exp = formula * formula2
local formula2 = getPlayerItemCount(cid, 10531)
local level = getPlayerLevel(cid)
local formula = (level * 30)


if msgcontains(msg, 'midnight shard') then
selfSay('Do you want change all of midnight shards for experience?')
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
selfSay('Are you really sure?')
talk_state = 2
elseif msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, formula2) == 0 then
selfSay('Thank you very much! Ill give you '..exp..' experience for returning it!')
doPlayerAddExp(cid, formula)
doSendMagicEffect(getPlayerPosition(cid), 14)
doSendAnimatedText(getPlayerPosition(cid), formula, TEXTCOLOR_WHITE)
talk_state = 3

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
selfSay('Good bye. |PLAYERNAME|!')
talk_state = 0
end
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())

W tym npc chodzi o to, żeby skupował itemy za expa i żeby np. podchodzę do niego i piszę, 'hi' 'midnight shard' (on piszę 'Do you want change all of midnight shards for experience?') ja piszę 'yes' i on zabiera wszystkie midnight shardy jakie mam.
Tu jest błąd jaki wyskakuje.
[04/12/2009 14:32:19] Lua Script Error: [Npc interface]
[04/12/2009 14:32:19] data/npc/scripts/shardnpc.lua:onCreatureSay

[04/12/2009 14:32:19] data/npc/lib/npcsystem/npchandler.lua:550: attempt to call global 'getDistanceTo' (a nil value)
[04/12/2009 14:32:19] stack traceback:
[04/12/2009 14:32:19] data/npc/lib/npcsystem/npchandler.lua:550: in function 'isInRange'
[04/12/2009 14:32:19] data/npc/lib/npcsystem/npchandler.lua:375: in function 'onCreatureSay'
[04/12/2009 14:32:19] data/npc/scripts/shardnpc.lua:8: in function <data/npc/scripts/shardnpc.lua:8>
 
Pod TFS ver. 0.3.5.2576
Pomoże ktoś ? :|
 
Last edited:
Back
Top