UWAGA! Zaznaczam że nie jestem autorem danego skryptu, skrypt znaleziony w datapacku Podhalanskiego OTS (Edycja już niedostępna - Moon OTS 3.0), autor nie jest znany.
I. Folder Creaturescripts:
1. Tworzymy plik counter.lua w data/creaturescripts/scripts. A w nim:
local monsters = {
--name = storage
["mouse"] = 35001,
["rat"] = 35002,
["giant manta"] = 35003,
["fly"] = 35076,
}
function onKill(cid, target)
if(isPlayer(target) ~= TRUE) then
local name = getCreatureName(target)
local monster = monsters[string.lower(name)]
if(monster) then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed for now " .. killedMonsters .. " " .. name .. "'s.")
setPlayerStorageValue(cid, monster, killedMonsters + 1)
end
end
return TRUE
end
--name = storage
["mouse"] = 35001,
["rat"] = 35002,
["giant manta"] = 35003,
["fly"] = 35076,
}
function onKill(cid, target)
if(isPlayer(target) ~= TRUE) then
local name = getCreatureName(target)
local monster = monsters[string.lower(name)]
if(monster) then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed for now " .. killedMonsters .. " " .. name .. "'s.")
setPlayerStorageValue(cid, monster, killedMonsters + 1)
end
end
return TRUE
end
<event type="kill" name="KilledMonstersCounter" event="script" value="counter.lua"/>
registerCreatureEvent(cid, "KilledMonstersCounter")
II. Folder NPCs:
1. W data/npc/ tworzymy plik Guard.xml, a w nim:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Guard" script="data/npc/scripts/shiptasker.lua" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="134" head="95" body="94" legs="92" feet="93" addons="2" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hi! Welcome to our ship! We are sailing a lot of time, and have never meet the pirate bay. All in all we are sailing the same way, and its safe. If you search {work}? I think I can help you." />
<parameter key="message_farewall" value="Bye bye!"/>
<parameter key="message_walkaway" value="Cya!"/>
</parameters>
</npc>
<npc name="Guard" script="data/npc/scripts/shiptasker.lua" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="134" head="95" body="94" legs="92" feet="93" addons="2" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hi! Welcome to our ship! We are sailing a lot of time, and have never meet the pirate bay. All in all we are sailing the same way, and its safe. If you search {work}? I think I can help you." />
<parameter key="message_farewall" value="Bye bye!"/>
<parameter key="message_walkaway" value="Cya!"/>
</parameters>
</npc>
2. Tworzymy plik w data/npc/scripts/ o nazwie: shiptasker.lua, i tworzymy przykładowy skrypt:
------STORAGE-------
------100 do 104-------
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
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, 'work')) then
setPlayerStorageValue(cid,39002,1)
selfSay('I have a good job for you. You must {clean} up my room. A lot of flies fly in my room. Please kill for me 5 flies.', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'clean')) then
selfSay('You must have some experience to kill these small ugly monsters. If you end your cleaning please say me you have {done}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'done') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,800) > 0) then
selfSay('You already help me, thank you so much.', cid)
else
if (getPlayerStorageValue(cid,35076) > 4) then
setPlayerStorageValue(cid,800,1)
doPlayerAddExperience(cid,1000)
selfSay('Thanks! For now you can go to the Ship Guard. Its all I can you give. {(given 1000 experience points)}', cid)
else
selfSay('You forget make your work? I remember everything boy, you should clean my room from flies, if you have done say {done}.', cid)
end
end
return true
end
----------------------------------------------------------
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
------100 do 104-------
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
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, 'work')) then
setPlayerStorageValue(cid,39002,1)
selfSay('I have a good job for you. You must {clean} up my room. A lot of flies fly in my room. Please kill for me 5 flies.', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'clean')) then
selfSay('You must have some experience to kill these small ugly monsters. If you end your cleaning please say me you have {done}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'done') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,800) > 0) then
selfSay('You already help me, thank you so much.', cid)
else
if (getPlayerStorageValue(cid,35076) > 4) then
setPlayerStorageValue(cid,800,1)
doPlayerAddExperience(cid,1000)
selfSay('Thanks! For now you can go to the Ship Guard. Its all I can you give. {(given 1000 experience points)}', cid)
else
selfSay('You forget make your work? I remember everything boy, you should clean my room from flies, if you have done say {done}.', cid)
end
end
return true
end
----------------------------------------------------------
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
if(msgcontains(msg, 'work')) then
setPlayerStorageValue(cid,39002,1)
selfSay('I have a good job for you. You must {clean} up my room. A lot of flies fly in my room. Please kill for me 5 flies.', cid)
end
setPlayerStorageValue(cid,39002,1)
selfSay('I have a good job for you. You must {clean} up my room. A lot of flies fly in my room. Please kill for me 5 flies.', cid)
end
Jeżeli napiszemy "WORK" napisze wiadomość kluczową dla misji, przypisując storage -> 39002, co jest storage globalnym dla danego skryptu.
Następnie:
if(msgcontains(msg, 'clean')) then
selfSay('You must have some experience to kill these small ugly monsters. If you end your cleaning please say me you have {done}.', cid)
talkState[talkUser] = 1
selfSay('You must have some experience to kill these small ugly monsters. If you end your cleaning please say me you have {done}.', cid)
talkState[talkUser] = 1
Później:
elseif(msgcontains(msg, 'done') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,800) > 0) then
selfSay('You already help me, thank you so much.', cid)
if (getPlayerStorageValue(cid,800) > 0) then
selfSay('You already help me, thank you so much.', cid)
Następnie:
if (getPlayerStorageValue(cid,35076) > 4) then
setPlayerStorageValue(cid,800,1)
doPlayerAddExperience(cid,1000)
selfSay('Thanks! For now you can go to the Ship Guard. Its all I can you give. {(given 1000 experience points)}', cid)
else
selfSay('You forget make your work? I remember everything boy, you should clean my room from flies, if you have done say {done}.', cid)
end
end
setPlayerStorageValue(cid,800,1)
doPlayerAddExperience(cid,1000)
selfSay('Thanks! For now you can go to the Ship Guard. Its all I can you give. {(given 1000 experience points)}', cid)
else
selfSay('You forget make your work? I remember everything boy, you should clean my room from flies, if you have done say {done}.', cid)
end
end
W przeciwnym wypadku kończy rozmowę i wraca do poprzedniej wersji rozmowy.
Przypisaliśmy storage dla potwora o nazwie "FLY" - (getPlayerStorageValue(cid,35076) > 4) , POWYŻEJ 4 CZYLI 5 SZTUK. TYLE MUSIMY ZABIĆ WAŻEK.
III. ZASTOSOWANIE W QUEST LOGU LUB NA STRONIE WWW:
1. W pliku quests.xml w folderze data/XML :
<quest name="In the swimming ship" startstorageid="39002" startstoragevalue="1">
<mission name="Cleaning up sailing team helper room" storageid="800" startvalue="1" endvalue="1">
<missionstate id="1" description="You gained now your first task on this sailing ship. You stand up with good dream, and you are exhaused and feel terrible."/>
</mission>
</quest>
<mission name="Cleaning up sailing team helper room" storageid="800" startvalue="1" endvalue="1">
<missionstate id="1" description="You gained now your first task on this sailing ship. You stand up with good dream, and you are exhaused and feel terrible."/>
</mission>
</quest>
storageid="800" --> ustalamy storage wewnętrzny
startstorageid="39002" --> ustalamy storage z pliku NPC dającego misje (global storage dla pliku)
questname / missionname --> nazwa nagłówka misji oraz misji
2. Analogicznie na stronce WWW w accmakerze podajemy storage 39002
--- PORADNIK Z DEDYKACJĄ DLA PXGAME & 4 FAME. ---
IV. Filmik instruktażowy:
Zachęcam do subskrypcji powiązanego kanału na YT!
https://www.youtube.com/user/TibiaOTS2014/videos
Zakładki