SanninStory
https://www.twitch.tv/sdrn
- Joined
- Oct 13, 2012
- Messages
- 1,778
- Reaction score
- 119
Witam.
Ostatnio na brazylijskim forum znalaz?em fajny skrypt na Pet System, wi?c postanowi?em go nieco urozmaici?.
Doda?em do niego funkcje takie jak informacja o nie z?apanym Pecie, czy zabieraniu przedmiotu i znikaniu potworka po nieudanej pr?bie.
Dzia?a to jak system w Pokemonach.
Wi?c przejd?my do rzeczy, tworzymy plik catchPet.lua w data/actions/scripts i wklejamy to:
[lua]-- Script edited by Sedron
local mtrs = {
["Rat"] = {hp = 1000, maxhp = 1000, corpse = 3073, chance = 1},
["Skeleton"] = {hp = 1000, maxhp = 1000, corpse = 5972, chance = 100},
["Dragon"] = {hp = 1000, maxhp = 1000, corpse = 3104, chance = 100},
-- ["Nazwa Potwora"] = {hp = Ile hp ma miec po zlapaniu, maxhp = Maksymalna ilosc hp, corpse = dead potworka tzw. Corpse, chance = Szansa na zlapanie},
}
function onUse(cid, item, frompos, item2, topos)
for pet_name, v in pairs(mtrs) do
if item2.itemid == v.corpse then
if math.random(0,100) <= v.chance then
doPlayerSendTextMessage(cid, 27, "Udalo ci sie zlapac ".. pet_name .. "'a.")
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
local itemcatch = doPlayerAddItem(cid, 7632, 1)
doItemSetAttribute(itemcatch, "namepet", pet_name)
doItemSetAttribute(itemcatch, "description", "Mozesz tym przywolac ".. pet_name .."'a.")
doItemSetAttribute(itemcatch, "lifepet", v.hp)
doItemSetAttribute(itemcatch, "maxlifepet", v.maxhp)
else
doPlayerSendTextMessage(cid, 27, "Nie udalo ci sie zlapac ".. pet_name .."'a.")
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
end
end
end
return true
end
[/lua]
Nast?pnie tworzymy kolejny plik lua w tej samej lokalizacji tym razem o nazwie startPet.lua i dajemy to:
[lua]-- Script edited by Sedron
function onUse(cid, item, frompos, item2, topos)
local health = tonumber(getItemAttribute(item.uid, "lifepet"))
local mhp = tonumber(getItemAttribute(item.uid, "maxlifepet"))
if health <= 0 then
return doPlayerSendCancel(cid, "Twoj pomocnik polegl.")
end
local pet_name = getItemAttribute(item.uid, "namepet")
if item.itemid == 7632 then
if not getTilePzInfo(getPlayerPosition(cid)) then
if #getCreatureSummons(cid) < 1 then
doTransformItem(item.uid, 7633)
local summon = doSummonCreature(pet_name, getThingPos(cid))
doConvinceCreature(cid, summon)
setCreatureMaxHealth(summon, mhp)
doCreatureAddHealth(summon, mhp)
doCreatureAddHealth(summon, health - mhp)
doSendMagicEffect(getCreaturePosition(summon), 67)
doCreatureSay(cid, "Pomoz mi, ".. pet_name .. "!", TALKTYPE_SAY)
else
doPlayerSendCancel(cid, "Mozesz przywolac tylko jednego pomocnika na raz.")
end
else
doPlayerSendCancel(cid, "Nie mozesz przywolac pomocnika w strefie bezpiecznej.")
end
elseif item.itemid == 7633 then
local hp, maxhp = getCreatureHealth(getCreatureSummons(cid)[1]), getCreatureMaxHealth(getCreatureSummons(cid)[1])
if #getCreatureSummons(cid) >= 1 then
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 67)
doRemoveCreature(getCreatureSummons(cid)[1])
doTransformItem(item.uid, 7632)
doItemSetAttribute(item.uid, "lifepet", hp)
doItemSetAttribute(item.uid, "maxlifepet", maxhp)
doCreatureSay(cid, "Dzieki za pomoc, " .. pet_name .. ".", TALKTYPE_SAY)
end
end
return true
end
[/lua]
Natomiast, do Actions.xml doklejamy w linijki o nast?puj?cej tre?ci:
[xml]<action itemid="2149" event="script" value="catchPet.lua"/>
<action itemid="7632;7633" event="script" value="startPet.lua"/>
[/xml]
Gotowe, mamy system Pet i mo?emy si? nim cieszy? do woli !
Screen przedmiotu ze z?apanym Petem:
Pozdrawiam i licz?, ?e si? przyda.
Ostatnio na brazylijskim forum znalaz?em fajny skrypt na Pet System, wi?c postanowi?em go nieco urozmaici?.
Doda?em do niego funkcje takie jak informacja o nie z?apanym Pecie, czy zabieraniu przedmiotu i znikaniu potworka po nieudanej pr?bie.
Dzia?a to jak system w Pokemonach.
Wi?c przejd?my do rzeczy, tworzymy plik catchPet.lua w data/actions/scripts i wklejamy to:
[lua]-- Script edited by Sedron
local mtrs = {
["Rat"] = {hp = 1000, maxhp = 1000, corpse = 3073, chance = 1},
["Skeleton"] = {hp = 1000, maxhp = 1000, corpse = 5972, chance = 100},
["Dragon"] = {hp = 1000, maxhp = 1000, corpse = 3104, chance = 100},
-- ["Nazwa Potwora"] = {hp = Ile hp ma miec po zlapaniu, maxhp = Maksymalna ilosc hp, corpse = dead potworka tzw. Corpse, chance = Szansa na zlapanie},
}
function onUse(cid, item, frompos, item2, topos)
for pet_name, v in pairs(mtrs) do
if item2.itemid == v.corpse then
if math.random(0,100) <= v.chance then
doPlayerSendTextMessage(cid, 27, "Udalo ci sie zlapac ".. pet_name .. "'a.")
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
local itemcatch = doPlayerAddItem(cid, 7632, 1)
doItemSetAttribute(itemcatch, "namepet", pet_name)
doItemSetAttribute(itemcatch, "description", "Mozesz tym przywolac ".. pet_name .."'a.")
doItemSetAttribute(itemcatch, "lifepet", v.hp)
doItemSetAttribute(itemcatch, "maxlifepet", v.maxhp)
else
doPlayerSendTextMessage(cid, 27, "Nie udalo ci sie zlapac ".. pet_name .."'a.")
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
end
end
end
return true
end
[/lua]
Nast?pnie tworzymy kolejny plik lua w tej samej lokalizacji tym razem o nazwie startPet.lua i dajemy to:
[lua]-- Script edited by Sedron
function onUse(cid, item, frompos, item2, topos)
local health = tonumber(getItemAttribute(item.uid, "lifepet"))
local mhp = tonumber(getItemAttribute(item.uid, "maxlifepet"))
if health <= 0 then
return doPlayerSendCancel(cid, "Twoj pomocnik polegl.")
end
local pet_name = getItemAttribute(item.uid, "namepet")
if item.itemid == 7632 then
if not getTilePzInfo(getPlayerPosition(cid)) then
if #getCreatureSummons(cid) < 1 then
doTransformItem(item.uid, 7633)
local summon = doSummonCreature(pet_name, getThingPos(cid))
doConvinceCreature(cid, summon)
setCreatureMaxHealth(summon, mhp)
doCreatureAddHealth(summon, mhp)
doCreatureAddHealth(summon, health - mhp)
doSendMagicEffect(getCreaturePosition(summon), 67)
doCreatureSay(cid, "Pomoz mi, ".. pet_name .. "!", TALKTYPE_SAY)
else
doPlayerSendCancel(cid, "Mozesz przywolac tylko jednego pomocnika na raz.")
end
else
doPlayerSendCancel(cid, "Nie mozesz przywolac pomocnika w strefie bezpiecznej.")
end
elseif item.itemid == 7633 then
local hp, maxhp = getCreatureHealth(getCreatureSummons(cid)[1]), getCreatureMaxHealth(getCreatureSummons(cid)[1])
if #getCreatureSummons(cid) >= 1 then
doSendMagicEffect(getCreaturePosition(getCreatureSummons(cid)[1]), 67)
doRemoveCreature(getCreatureSummons(cid)[1])
doTransformItem(item.uid, 7632)
doItemSetAttribute(item.uid, "lifepet", hp)
doItemSetAttribute(item.uid, "maxlifepet", maxhp)
doCreatureSay(cid, "Dzieki za pomoc, " .. pet_name .. ".", TALKTYPE_SAY)
end
end
return true
end
[/lua]
Natomiast, do Actions.xml doklejamy w linijki o nast?puj?cej tre?ci:
[xml]<action itemid="2149" event="script" value="catchPet.lua"/>
<action itemid="7632;7633" event="script" value="startPet.lua"/>
[/xml]
Gotowe, mamy system Pet i mo?emy si? nim cieszy? do woli !
Screen przedmiotu ze z?apanym Petem:
Pozdrawiam i licz?, ?e si? przyda.