What's new

Skrypty & Kody Npc task - TFS OLDSCHOOL v.2 7.60

Status
Not open for further replies.

Dark Magican

Senior User
Joined
Apr 13, 2009
Messages
677
Reaction score
42
Witam, posiadam taki b??d - kto? potrafi sobie z nim poradzi?? Silnik tak jak w nazwie tematu.

[26/01/2016 22:42:52] data/npc/scripts/task.lua:13: attempt to call method 'isFocused' (a nil value)
[26/01/2016 22:42:52] stack traceback:
[26/01/2016 22:42:52] data/npc/scripts/task.lua:13: in function 'callback'
[26/01/2016 22:42:52] ./data/npc/lib/npcsystem/npchandler.lua:299: in function 'onCreatureSay'
[26/01/2016 22:42:52] data/npc/scripts/task.lua:8: in function <data/npc/scripts/task.lua:8>


a to 12 linijka i ca?a funkcja;

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

Pozdrawiam :)
 

#NOOB

Senior User
Joined
May 25, 2014
Messages
901
Reaction score
89
Odp: Npc task - TFS OLDSCHOOL v.2 7.60

[LUA]function creatureSayCallback(cid, typemsg, msg)
if npcHandler.focus ~= cid then
return false
end[/LUA]
 

Dark Magican

Senior User
Joined
Apr 13, 2009
Messages
677
Reaction score
42
Odp: Npc task - TFS OLDSCHOOL v.2 7.60

[LUA]function creatureSayCallback(cid, typemsg, msg)
if npcHandler.focus ~= cid then
return false
end[/LUA]

Dzi?kuj?, co? si? ruszy?o - lecz teraz kolejny, dziwny problem. Npc rozmawia, ale chc?c wzi?? taska, odpowiada mi zawsze tak? liczb?:

23:01 GOD Tryller: mission
23:01 Richard: 268436457

Posiada kto?, task system przerobiony pod TFS'a 7.60? :)
 

#NOOB

Senior User
Joined
May 25, 2014
Messages
901
Reaction score
89
Odp: Npc task - TFS OLDSCHOOL v.2 7.60

Te? si? bawi? tym silnikiem i przerabia?em ju? ten problem :D
1) Z wszystkich selfSay w skrypcie wywal cid
2) [LUA]function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, typemsg, msg) npcHandler:eek:nCreatureSay(cid, typemsg, msg) end
function onThink() npcHandler:eek:nThink() end[/LUA]
 

Dark Magican

Senior User
Joined
Apr 13, 2009
Messages
677
Reaction score
42
Odp: Npc task - TFS OLDSCHOOL v.2 7.60

Witam, jak w temacie - posiadam silnik "The Forgotten Server (Crying Damson) - Old School v2" i nadal mam problem z taskiem, nie zalicza mi zabitych potwor?w. Ma kto? jakie? pomys?y? - kod.

Skrypt npc:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local storage = 5002

function creatureSayCallback(cid, typemsg, msg)
if npcHandler.focus ~= cid then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, "mission") then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("I have a mission for you to kill 5 dragons and 3 dragon lords, do you accept?")
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Did you kill 5 dragons and 3 dragon lords?")
talkState[talkUser] = 1
else
selfSay("You already did the mission.")
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Good, come back when you killed them.")
setPlayerStorageValue(cid, storage, 1)
else
if getPlayerStorageValue(cid, 19000) == 5 and getPlayerStorageValue(cid, 19001) == 3 then
selfSay("Good job, here is your reward.")
doPlayerAddItem(cid, 2160, 5)
doPlayerAddExp(cid, 50000)
setPlayerStorageValue(cid, storage, 2)
else
selfSay("You didn't kill them all.")
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

kill.lua creaturescripts

local config = {
['dragon'] = {amount = 5, storage = 19000, startstorage = 5002, startvalue = 1},
['dragon lord'] = {amount = 3, storage = 19001, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end

if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end


screaturescripts.xml

<event type="kill" name="kill" event="script" value="kill.lua"/>

login.lua

registerCreatureEvent(cid, "kill")

hm..[/QUOTE]
 

#NOOB

Senior User
Joined
May 25, 2014
Messages
901
Reaction score
89
Odp: Npc task - TFS OLDSCHOOL v.2 7.60

Spr?buj w NPC doda? funkcje, kt?ra nada monsterstorage o warto?ci 0 i zobaczy? czy wtedy zacznie nalicza? (Chodzi o storage 19000, 19001)
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Npc task - TFS OLDSCHOOL v.2 7.60

Sprawd? funkcj?:
PHP:
isSummon(target)
Na pr?b? usu? j? z kodu, je?li zacznie nalicza? to znaczy, ?e jest ?le napisana.
 
Status
Not open for further replies.
Top