What's new

Ahhh.... NPC Trader. B??d!! Prosze o pomoc.

Status
Not open for further replies.

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:
[15/11/2010 14:40:02] [Error - Npc interface]
[15/11/2010 14:40:02] data/npc/scripts/food.lua:eek:nCreatureSay
[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
 

Daniel13

Senior User
Joined
Jun 19, 2008
Messages
910
Reaction score
32
Odp: Ahhh.... NPC Trader. B??d!! Prosze o pomoc.

powiedz mi tylko czy ma sprzedawa? to jedzenie co wida? wy?ej ?

Czy ma by? jedzenie ka?dego rodzaju jak na real tibi ? :)
 

laseczka1991

Advanced User
Joined
Jul 11, 2009
Messages
260
Reaction score
5
Age
32
Odp: Ahhh.... NPC Trader. B??d!! Prosze o pomoc.

To jedzenie co wyzej :) Jezeli kolejny raz mi pomozesz to REp leci :)
 

Daniel13

Senior User
Joined
Jun 19, 2008
Messages
910
Reaction score
32
Odp: Ahhh.... NPC Trader. B??d!! Prosze o pomoc.

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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'dragon tail'}, 11875, 5, 'dragon tail')
shopModule:addBuyableItem({'meat'}, 11877, 5, 'meat')
shopModule:addBuyableItem({'chicken'}, 11873, 3, 'chicken')
shopModule:addBuyableItem({'hamburger'}, 11876, 3, 'hamburger')

npcHandler:addModule(FocusModule:new())

prosze bardzo ;)

mam nadziej?, ?e dzia?a ;)
 

laseczka1991

Advanced User
Joined
Jul 11, 2009
Messages
260
Reaction score
5
Age
32
I co mam podmienic twoj skrypt za moj?? I tak samo bedzie dzialal?? Na komendy Hi,yes.
bedzie odpisywal Good bye, next please, Hello name??
Przepraszam za double posta.... Ale nie chce robic nowego tematu... NPC dalej nie dziala chociaz tylko otwiera rozmowe w nowym oknie. wczesniej tego nie bylo... Sadze ze jezeli zdobede funkcje " getCount " i umieszcze ja w silniku bedzie chodzilo na wczesniejszym skrypcie. Czy mozesz mi podac lub wiesz jak zrobic taka funkcje??
Notka moderatorska:
Sklejone
 
Last edited by a moderator:
Status
Not open for further replies.
Top