Forum poświęcone powstawaniu Belxena OTS
Witam Mam dzis do oddania npc dajacy misje By proxer.
opisze to tutaj tez:
otoz tak trzeba sobie zrobic plik o nazwie tiles.lua i wkleic do niego to:
Kod:
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)
local player_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_money = player_gold + player_plat + player_crys
local playerCap = getPlayerFreeCap(cid)
local item = 2160 --Crystal Coin
local itemweight = getItemWeight(item, 1)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hi.Im old traveler i can give you mission.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('You must wait second, ' .. getPlayerName(cid) .. '.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'mission') then
setPlayerStorageValue(cid,400006)
else
selfSay('Go to 2 npcs.')
end
end
if msgcontains(msg, 'award') then
if getPlayerStorageValue(cid,400006) == 3 then
selfSay('Good Job, Take This')
doPlayerAddItem(cid,item,1)
else
selfSay('go to other npcs!.')
end
end
if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
focus = 0
end
end
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 2 then
selfSay('Good bye then.')
focus = 0
end
end
end
potem zrobic Old Traveler.xml i wkleic do niego to:
Kod:
<npc name="Old Traveler" script="data/npc/scripts/tiles.lua" walkinterval="2000" floorchange="0" access="3" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="57" head="115" body="113" legs="31" feet="38" addons="3" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hello, |PLAYERNAME|!" />
<parameter key="message_needmoremoney" value="Try again when you found tiles."/>
<parameter key="message_decline" value="Why would you tease me like that?"/>
</parameters>
</npc>
Teraz tworzymy npc o swojej nazwie niewiem np:
mission1.lua i wklejamy do niego:
Kod:
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('Hi.Im old traveler i can give you mission.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('You must wait second, ' .. getPlayerName(cid) .. '.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'mission') then
selfSay('ok now go to 2 npc!')
getPlayerStorageValue(cid,400006) == 1
setPlayerStorageValue(cid,400006,2)
else
selfSay('You must go to other npcs!')
end
end
if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
focus = 0
end
end
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 2 then
selfSay('Good bye then.')
focus = 0
end
end
end
i oczywiscie plik npc /xml ktory to bedzie czytac czyli w moim przypadku:
Kod:
<npc name="Wlasna Nazwa" script="data/npc/scripts/mission1.lua" walkinterval="2000" floorchange="0" access="3" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="57" head="115" body="113" legs="31" feet="38" addons="3" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hello, |PLAYERNAME|!" />
<parameter key="message_needmoremoney" value="Try again when you have missions."/>
<parameter key="message_decline" value="Why would you tease me like that?"/>
</parameters>
</npc>
teraz tworzymy 2 plik lua o nazwie np:
mission2.lua i wklejamy to:
Kod:
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('Hi.Im old traveler i can give you mission.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('You must wait second, ' .. getPlayerName(cid) .. '.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'mission') then
selfSay('ok now go to missioner npc!')
getPlayerStorageValue(cid,400006) == 2
setPlayerStorageValue(cid,400006,3)
else
selfSay('You must go to other npcs!')
end
end
if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
focus = 0
end
end
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 2 then
selfSay('Good bye then.')
focus = 0
end
end
end
i oczywiscie plik npc/ xml ktory bedzie go czytac:
Kod:
<npc name="Wlasna nazwa" script="data/npc/scripts/mission2.lua" walkinterval="2000" floorchange="0" access="3" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="57" head="115" body="113" legs="31" feet="38" addons="3" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hello, |PLAYERNAME|!" />
<parameter key="message_needmoremoney" value="Try again when you have mission."/>
<parameter key="message_decline" value="Why would you tease me like that?"/>
</parameters>
</npc>
pliki tworzone w 100% by proxer!
wszystkie problemy prosze zglaszac tutaj
Offline