Skrypty & Kody NPC daj?cy zadanie

buuuszek

Active User
Zarejestrowany
Dołączył
Sierpień 27, 2012
Posty
71
Liczba reakcji
0
Cze??, pisz? do was z pro?b? o pomoc w napisaniu NPC kt?ry da?by nam zadanie na pokonanie jakiej? "x" liczby "y" mob?w i da?by za to jak?? nagrod?. Szuka?em podobnego NPC w swoim tfs silniku, ale nie znalaz?em, ni?ej podaj? przyk?ad jak s? napisani NPC w moim silniku :

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Aldo" script="bootmaker.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, I am a bootmaker."/>
</parameters>
</npc>

Najlepiej jakby po zabiciu tego "y" moba wy?wietli? si? komunikat ile jeszcze ich zosta?o do zabicia, czyli chodzi o co? bardzo podobnego ( jak nie to samo ) co taski
B?d? wdzi?czny za ka?d? pomoc :D
 
Odp: NPC daj?cy zadanie

autor: limos
creaturescript
[lua]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[/lua]

xml
[lua]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 storage = 5002

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, "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?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Did you kill 5 dragons and 3 dragon lords?", cid)
talkState[talkUser] = 1
else
selfSay("You already did the mission.", cid)
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Good, come back when you killed them.", cid)
setPlayerStorageValue(cid, storage, 1)
else
if getPlayerStorageValue(cid, 19000) == 5 and getPlayerStorageValue(cid, 19001) == 3 then
selfSay("Good job, here is your reward.", cid)
doPlayerAddItem(cid, 2160, 5)
doPlayerAddExp(cid, 50000)
setPlayerStorageValue(cid, storage, 2)
else
selfSay("You didn't kill them all.", cid)
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())[/lua]
 
Odp: NPC daj?cy zadanie

Da si? przyj?? misj?, jednak po zabiciu mob?w nadal pisze ?e nie pokonano ich wystarczaj?co aby oddac quest
 
Ostatnia edycja:
Back
Do góry