Martix97
User
- Joined
- Apr 13, 2018
- Messages
- 16
- Reaction score
- 0
Testowany na TFS 0.3.6pl1 8.54 and TFS 0.2.14 9.6
Mitrox.xml
itemsmissions.lua
Mo?esz usun?? t? linijke, je?li nie chcesz nagrody lub expu za okre?lon? misj?.
Jak to dzia?a:
NPC daje misje do zbierania przedmiot?w, kt?ra rozpoczyna sie od pierwszej misji.
NPC powie ci, kt?re przedmioty wci?? Ci brakuje.
Je?li chcesz dowiedziec sie wiecej na temat przedmiotow z bie??cej misji, mo?esz zapyta? NPC, wypowiadajac ich nazwy.
Je?li masz wszystkie przedmioty, o kt?re poprosi? NPC, przedmioty zostan? usuni?te, otrzymasz nagrod?, a NPC da ci kolejn? misj?.
Je?li uko?czy?e? ostatni? misj?, NPC podzi?kuje ci, da ci nagrod? za ostatni? misj?, usunie przedmioty i tyle.
Je?li u?ywasz TFS 0.2 (Mystic Spirit), zmie? script="itemsmissions.lua" na script="data/npc/scripts/itemsmissions.lua" i dodaj to w global.lua.
Pozdrawiam.
Autor: Limos
Mitrox.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Mitrox" script="itemsmissions.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="130" head="57" body="114" legs="95" feet="119" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|."/>
</parameters>
</npc>
itemsmissions.lua
PHP:
-- Collecting items missions by Limos
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 missions = {
[1] = {items = {
{id = 5890, count = 12},
{id = 5878, count = 20},
{id = 5896, count = 15},
{id = 5902, count = 21},
{id = 5897, count = 35},
{id = 5894, count = 8}
},
message = "Great, I need alot of items, but you can start with",
level = 15, -- minimum level voor this mission
rewarditem = {id = 2160, count = 1},
rewardexp = 15000
},
[2] = {items = {
{id = 5898, count = 20},
{id = 5921, count = 28},
{id = 5899, count = 15},
{id = 5905, count = 25},
{id = 6097, count = 35},
{id = 6098, count = 26}
},
message = "Thank you, the next items are",
level = 30,
rewarditem = {id = 2160, count = 5},
rewardexp = 40000
},
[3] = {items = {
{id = 5920, count = 45},
{id = 5879, count = 30},
{id = 5881, count = 15},
{id = 5876, count = 18},
{id = 5877, count = 22}
},
message = "Awesome, now get",
level = 50,
rewarditem = {id = 2160, count = 15},
rewardexp = 100000
},
[4] = {items = {
{id = 5913, count = 20},
{id = 5909, count = 42},
{id = 5914, count = 38},
{id = 5911, count = 25},
{id = 5912, count = 10},
{id = 5910, count = 10}
},
message = "Thanks, now I need",
level = 70,
rewarditem = {id = 2160, count = 25},
rewardexp = 200000
},
[5] = {items = {
{id = 5906, count = 35},
{id = 5882, count = 42},
{id = 5893, count = 28},
{id = 5948, count = 32},
{id = 5954, count = 22},
{id = 4850, count = 1}
},
message = "Good, only a few items left,",
level = 100,
rewarditem = {id = 2160, count = 50},
rewardexp = 450000
}
}
local storage = 45550
local function getItemsFromTable(itemtable)
local text = ""
for v = 1, #itemtable do
count, info = itemtable[v].count, getItemInfo(itemtable[v].id)
local ret = ", "
if v == 1 then
ret = ""
elseif v == #itemtable then
ret = " and "
end
text = text .. ret
text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
end
return text
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local xstorage = getPlayerStorageValue(cid, storage)
local x = missions[xstorage]
if not npcHandler:isFocused(cid) then
return false
end
if msgcontains(msg, 'mission') then
if xstorage == -1 then
selfSay("I am a scientist and I am currently doing some research, do you think you can help me out?", cid)
talkState[talkUser] = 1
elseif x then
if getPlayerLevel(cid) >= x.level then
selfSay("Did you get the {items} I asked you?", cid)
talkState[talkUser] = 1
else
selfSay("The mission I gave you is for level "..x.level..", come back later.", cid)
end
else
selfSay("Thanks again for all your items, it helped me alot.", cid)
npcHandler:releaseFocus(cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if xstorage == -1 then
setPlayerStorageValue(cid, storage, 1)
local x = missions[getPlayerStorageValue(cid, storage)]
selfSay(x.message.." "..getItemsFromTable(x.items)..".", cid)
elseif x then
local amount = 0
for i = 1, #x.items do
if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
amount = amount + 1
end
end
if amount == #x.items then
for i = 1, #x.items do
doPlayerRemoveItem(cid, x.items[i].id, x.items[i].count)
end
if x.rewarditem then
local count, info = x.rewarditem.count, getItemInfo(x.rewarditem.id)
doPlayerAddItem(cid, x.rewarditem.id, count)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You received "..(count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)..".")
end
if x.rewardexp then
doPlayerAddExp(cid, x.rewardexp)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You received "..x.rewardexp.." experience.")
end
setPlayerStorageValue(cid, storage, xstorage + 1)
local x = missions[getPlayerStorageValue(cid, storage)]
if x then
selfSay(x.message.." "..getItemsFromTable(x.items)..".", cid)
else
selfSay("Thanks alot! I can finish my research now.", cid)
end
else
local n = 0
for i = 1, #x.items do
if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
n = n + 1
end
end
local text = ""
local c = 0
for v = 1, #x.items do
count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
if getPlayerItemCount(cid, x.items[v].id) < x.items[v].count then
c = c + 1
local ret = ", "
if c == 1 then
ret = ""
elseif c == n then
ret = " and "
end
text = text .. ret
text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
end
end
selfSay("You don't have all items, you still need to get "..text..".", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'items') and x then
selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", cid)
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
selfSay("Oh well, I guess not then.", cid)
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye? I guess...")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Mo?esz usun?? t? linijke, je?li nie chcesz nagrody lub expu za okre?lon? misj?.
PHP:
rewarditem = {id = 2160, count = 1}
rewardexp = 15000
Jak to dzia?a:
NPC daje misje do zbierania przedmiot?w, kt?ra rozpoczyna sie od pierwszej misji.
NPC powie ci, kt?re przedmioty wci?? Ci brakuje.
Je?li chcesz dowiedziec sie wiecej na temat przedmiotow z bie??cej misji, mo?esz zapyta? NPC, wypowiadajac ich nazwy.
Je?li masz wszystkie przedmioty, o kt?re poprosi? NPC, przedmioty zostan? usuni?te, otrzymasz nagrod?, a NPC da ci kolejn? misj?.
Je?li uko?czy?e? ostatni? misj?, NPC podzi?kuje ci, da ci nagrod? za ostatni? misj?, usunie przedmioty i tyle.
Je?li u?ywasz TFS 0.2 (Mystic Spirit), zmie? script="itemsmissions.lua" na script="data/npc/scripts/itemsmissions.lua" i dodaj to w global.lua.
PHP:
getItemInfo = getItemDescriptions
Pozdrawiam.
Autor: Limos