laseczka1991
Advanced User
- Joined
- Jul 11, 2009
- Messages
- 260
- Reaction score
- 5
- Age
- 32
A wiec mam NPC Trader. w konsoli pokazuje mi bledy po napisaniu Hi, meat i inne nazwy ktore sa u npc. W tedy on nic nie pisze i w konsoli wychodza bledy.
Npc Reguje na hi,bye. Pisze Good bye,next please.
oto blad:
a tutaj caly skrypt npc.
P.S NPC wziety z 8.10 przeniesiony na TFS 0.3.6. Prosze nawet o przerobienie skryptu aby dzialal. Pewna osoba powiedziala mi ze bedzie dzialal
Npc Reguje na hi,bye. Pisze Good bye,next please.
oto blad:
[15/11/2010 14:40:02] [Error - Npc interface]
[15/11/2010 14:40:02] data/npc/scripts/food.luanCreatureSay
[15/11/2010 14:40:02] Description:
[15/11/2010 14:40:02] data/npc/scripts/food.lua:56: attempt to call global 'getCount' (a nil value)
[15/11/2010 14:40:02] stack traceback:
[15/11/2010 14:40:02] data/npc/scripts/food.lua:56: in function <data/npc/scripts/food.lua:36>
a tutaj caly skrypt npc.
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hello, ' .. getCreatureName(cid) .. '! I sell all foods for 1 dolars.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'dragon tail') then
buy(cid,11875,getCount(msg),4)
elseif msgcontains(msg, 'meat') then
buy(cid,11877,getCount(msg),3)
elseif msgcontains(msg, 'chicken') then
buy(cid,11873,getCount(msg),2)
elseif msgcontains(msg, 'hamburger') then
buy(cid,11876,getCount(msg),1)
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 45 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
P.S NPC wziety z 8.10 przeniesiony na TFS 0.3.6. Prosze nawet o przerobienie skryptu aby dzialal. Pewna osoba powiedziala mi ze bedzie dzialal