• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

Potiony skrypty

Status
Zamknięty.

Tis27

User
Dołączył
Kwiecień 5, 2008
Posty
10
Liczba reakcji
0
wchodzimy w silnik/data/actions/script i dodajemy potions.lua

Kod:

local greatHealthPot = 7591
local greatManaPot = 7590
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636
local knightsandpaladins = {3, 4, 7, 8}
local druidsandsorcerers = {1, 2, 5, 6}
local druidspaladinsandsorcerers = {1, 2, 3, 5, 6, 7}
local knights = {4, 8}

function onUse(cid, item, frompos, item2, topos)
if(item.itemid == healthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 170, 230, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, emptyPot)
elseif(item.itemid == manaPot) then
if(doTargetCombatMana(0, cid, 170, 230, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, emptyPot)
elseif(item.itemid == strongHealthPot) then
if getPlayerLevel(cid) >= 50 and isInArray(knightsandpaladins, getPlayerVocation(cid)) == TRUE then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 300, 500, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, strongEmptyPot)
else
doCreatureSay(cid, "Only knights and paladins of level 50 or above may drink this fluid.", TALKTYPE_ORANGE_1)
end
elseif(item.itemid == strongManaPot) then
if getPlayerLevel(cid) >= 50 and isInArray(druidspaladinsandsorcerers, getPlayerVocation(cid)) == TRUE then
if(doTargetCombatMana(0, cid, 300, 500, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, strongEmptyPot)
else
doCreatureSay(cid, "Only druids, sorcerers and paladins of level 50 or above may drink this fluid.", TALKTYPE_ORANGE_1)
end
elseif(item.itemid == greatHealthPot) then
if getPlayerLevel(cid) >= 80 and isInArray(knights, getPlayerVocation(cid)) == TRUE then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 500, 800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, greatEmptyPot)
else
doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
end
elseif(item.itemid == greatManaPot) then
if getPlayerLevel(cid) >= 80 and isInArray(druidsandsorcerers, getPlayerVocation(cid)) == TRUE then
if(doTargetCombatMana(0, cid, 500, 800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, greatEmptyPot)
else
doCreatureSay(cid, "Only druids and sorcerers of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
end
end

return TRUE
end

potem wchodzimy w actions.xml i dodajemy


Kod:

<action itemid="7591" script="potions.lua" />
<action itemid="7588" script="potions.lua" />
<action itemid="7590" script="potions.lua" />
<action itemid="7618" script="potions.lua" />
<action itemid="7620" script="potions.lua" />
<action itemid="7635" script="potions.lua" />
<action itemid="7634" script="potions.lua" />
<action itemid="7636" script="potions.lua" />

nastepnie w npc/scripts dodajemy potions.lua

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('Hello ' .. creatureGetName(cid) .. '! I sell great mana potion, great health potion, strong mana potion, strong health potion, health potion, mana potion.')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'great mana potion') or msgcontains(msg, 'great mana potions')then
count = getCount(msg)
price = count*150
buy(cid,7590,count,price)
elseif msgcontains(msg, 'great health potion') or msgcontains(msg, 'great health potions')then
count = getCount(msg)
price = count*150
buy(cid,7591,count,price)
elseif msgcontains(msg, 'strong mana potion') or msgcontains(msg, 'strong mana potions') then
count = getCount(msg)
price = count*100
buy(cid,7589,count,price)
elseif msgcontains(msg, 'strong health potion') or msgcontains(msg, 'strong health potions')then
count = getCount(msg)
price = count*100
buy(cid,7588,count,price)
elseif msgcontains(msg, 'health potion') or msgcontains(msg, 'health potions')then
count = getCount(msg)
price = count*50
buy(cid,7618,count,price)
elseif msgcontains(msg, 'mana potion') or msgcontains(msg, 'mana potions')then
count = getCount(msg)
price = count*50
buy(cid,7620,count,price)

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end


function onCreatureChangeOutfit(creature)

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) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end


nastepnie w data/npc dodajemy npc zeby sprzedawal te potiony:

Kod:

<?xml version="1.0"?>

<npc name="Rashid" script="data/npc/scripts/potions.lua" access="6" lookdir="7">
<health now="1000" max="1000"/>
<look type="146" head="132" body="116" legs="116" feet="76"/>
</npc>





Mysle ze moze sie przydac
 
Status
Zamknięty.
Do góry