Ir para conteúdo

Npc Pokemoncollector Funcionando


Vodkart

Posts Recomendados

Explicação:

 

é dada uma lista na ordem alfabética com os pokemons que esse NPC compra,depois disso há 2 versões

V 1.0 --[[ PokeServer ]] -- : basta dizer o nome do pokemon que você quer vender e colocar o mesmo no slot da pokebola...

V 2.0 --[[ Pokemon Dash --]] : a pokebola tem que estar dentro da backpack,com a função "sellPokemon(cid, name, price)" que não é minha

pokeot.png

 

 

 

NPC/SCRIPT

 

buy_pokemons.lua

V 1.0

 

 

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 

   function pairsByKeys (t, f) -- function for alphabetical order in list
     local a = {}
     for n in pairs(t) do table.insert(a, n) end
     table.sort(a, f)
     local i = 0
     local iter = function ()
       i = i + 1
       if a[i] == nil then return nil
       else return a[i], t[a[i]]
       end
     end
     return iter
   end


local Pokemons = {
["gloom"] = {price = 150000},
["kakuna"] = {price = 25000},
["sandshrew"] = {price = 85000},
["pidgeot"] = {price = 550000},
["rattata"] = {price = 130000},
["pidgeotto"] = {price = 120000},
["poliwag"] = {price = 11000},
["horsea"] = {price = 20000},
["oddish"] = {price = 8000},
["bellsprout"] = {price = 10000},
["pidgey"] = {price = 5000},
["beedrill"] = {price = 120000},
["magnemite"] = {price = 60000},
["magneton"] = {price = 250000},
["raticate"] = {price = 85000},
["seadra"] = {price = 250000},
["doduo"] = {price = 65000},
["dodrio"] = {price = 300000},
["golbat"] = {price = 120000},
["graveler"] = {price = 160000},
["electrode"] = {price = 200000},
["victreebel"] = {price = 500000},
["poliwhirl"] = {price = 220000},
["bulbasaur"] = {price = 300000}
}


local idballs = {
[2532] = {2531},
[2653] = {2557},
[2654] = {2525},
[2652] = {2524},
[2195] = {2523},
[2531] = {2532},
[2557] = {2653},
[2525] = {2654},
[2524] = {2652},
[2523] = {2195},
}
local balls = idballs[getPlayerSlotItem(cid,8).itemid]



if(msgcontains(msg, "pokemon") or msgcontains(msg, "pokemon")) then
selfSay("Qual o pokemon que você quer me vender? quer olhar a {list} ?", cid) 
talkState[talkUser] = 1
elseif (msgcontains(msg, "list") or msgcontains(msg, "LIST")) and talkState[talkUser] == 1 then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. "" 
doShowTextDialog(cid, 6579, str) 
elseif Pokemons[msg]  and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 25000) == 5 then       
return selfSay('Você está montando.',cid)
elseif getPlayerStorageValue(cid, 23000) == 5 then
return selfSay('Você está voando.',cid)
elseif #getCreatureSummons(cid) >= 1 then
return selfSay('Voce precisa botar seus pokemons dentro da pokebola.',cid)
elseif balls == nil then
return selfSay('Coloque seu pokemon slot da Pokeball para que eu possar examinar!!',cid)
end
local a = getItemAttribute(getPlayerSlotItem(cid,8).uid,"name")
if string.find(tostring(a),msg) then
doRemoveItem(getPlayerSlotItem(cid,8).uid, 1)
doPlayerAddMoney(cid, Pokemons[msg].price) 
selfSay('Obrigado por vender o pokemon '..msg..' por '..Pokemons[msg].price..' meu amigo!', cid)
else
selfSay('vc n tem o pokemon '..msg..' para vender!', cid)
end
elseif msg == "no" and talkState[talkUser] >= 1 then 
selfSay("Then not", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end 
return TRUE 
end 


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

 

 

V 2.0

 

 

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

   function pairsByKeys (t, f) -- function for alphabetical order in list
     local a = {}
     for n in pairs(t) do table.insert(a, n) end
     table.sort(a, f)
     local i = 0
     local iter = function ()
       i = i + 1
       if a[i] == nil then return nil
       else return a[i], t[a[i]]
       end
     end
     return iter
   end


function sellPokemon(cid, name, price) -- n sei de quem é essa função
local pokename = name
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local itemsball = getItemsInContainerById(bp.uid, 2222)
local itemsultra = getItemsInContainerById(bp.uid, 2220)
for _, pok in pairs(itemsball) do
if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, price)
selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)
return true
end
break
end
for _, pok in pairs(itemsultra) do
if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, price)
selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)
return true
end
break
end
selfSay("Hey, you dont have this pokemon("..pokename..")! Make sure if its not fainted and it is inside your backpack!",cid)
end

local Pokemons = {
["gloom"] = {price = 150000},
["kakuna"] = {price = 25000},
["sandshrew"] = {price = 85000},
["pidgeot"] = {price = 550000},
["rattata"] = {price = 130000},
["pidgeotto"] = {price = 120000},
["poliwag"] = {price = 11000},
["horsea"] = {price = 20000},
["oddish"] = {price = 8000},
["bellsprout"] = {price = 10000},
["pidgey"] = {price = 5000},
["beedrill"] = {price = 120000},
["magnemite"] = {price = 60000},
["magneton"] = {price = 250000},
["raticate"] = {price = 85000},
["seadra"] = {price = 250000},
["doduo"] = {price = 65000},
["dodrio"] = {price = 300000},
["golbat"] = {price = 120000},
["graveler"] = {price = 160000},
["electrode"] = {price = 200000},
["victreebel"] = {price = 500000},
["poliwhirl"] = {price = 220000},
["bulbasaur"] = {price = 300000}
}

if(msgcontains(msg, "pokemon") or msgcontains(msg, "pokemon")) then
selfSay("has some pokemon you want sell me? or you can look at the {list}!", cid) 
talkState[talkUser] = 1
elseif (msgcontains(msg, "list") or msgcontains(msg, "LIST")) and talkState[talkUser] == 1 then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. "" 
doShowTextDialog(cid, 6579, str) 
elseif Pokemons[msg]  and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 25000) == 5 then       
return selfSay("Você está montando.",cid)
elseif getPlayerStorageValue(cid, 23000) == 5 then
return selfSay("Você está voando.",cid)
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Voce precisa botar seus pokemons dentro da pokebola.",cid)
end
sellPokemon(cid, msg, Pokemons[msg].price)
elseif msg == "no" and talkState[talkUser] >= 1 then 
selfSay("Then not", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end 
return TRUE 
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

 

 

 

 

NPC

 

Comprador.xml

<?xml version="1.0"?>
<npc name="Comprador" script="data/npc/scripts/buy_pokemons.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|. quer me vender alguns {pokemon}? " />
</parameters>
</npc>

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

[06/02/2011 23:29:04] [Error - Npc interface]

[06/02/2011 23:29:04] data/npc/scripts/buypoks.lua:onCreatureSay

[06/02/2011 23:29:04] Description:

[06/02/2011 23:29:04] data/npc/scripts/buypoks.lua:74: bad argument #1 to 'pairs' (table expected, got nil)

[06/02/2011 23:29:04] stack traceback:

[06/02/2011 23:29:04] [C]: in function 'pairs'

[06/02/2011 23:29:04] data/npc/scripts/buypoks.lua:74: in function 'callback'

[06/02/2011 23:29:04] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'

[06/02/2011 23:29:04] data/npc/scripts/buypoks.lua:8: in function <data/npc/scripts/buypoks.lua:8>

 

 

v2 ? not work

Link para o comentário
Compartilhar em outros sites

what version u use?

u edited your script? give me your script edited...

because i tested script and worked

 

 

 

21:15 Comprador: Ola Khfgev. u sell me pokemon?

21:15 Khfgev: pokemon

21:15 Comprador: has some pokemon you want sell me?

21:16 Khfgev [8]: rattata

21:16 Comprador: Wow! Thanks for this wonderful pokemon! Take your money.

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

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

 

function sellPokemon(cid, name, price) -- n sei de quem é essa funçao

local pokename = name

local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

local itemsball = getItemsInContainerById(bp.uid, 2222)

local itemsultra = getItemsInContainerById(bp.uid, 2220)

for _, pok in pairs(itemsball) do

if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then

doRemoveItem(pok, 1)

doPlayerAddMoney(cid, price)

selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)

return true

end

break

end

for _, pok in pairs(itemsultra) do

if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then

doRemoveItem(pok, 1)

doPlayerAddMoney(cid, price)

selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)

return true

end

break

end

selfSay("Hey, you dont have this pokemon("..pokename..")! Make sure if its not fainted and it is inside your backpack!",cid)

end

 

local pokemons = {

["gloom"] = {price = 150000},

["kakuna"] = {price = 25000},

["sandshrew"] = {price = 85000},

["pidgeot"] = {price = 550000},

["rattata"] = {price = 130000},

["pidgeotto"] = {price = 120000},

["poliwag"] = {price = 11000},

["horsea"] = {price = 20000},

["oddish"] = {price = 8000},

["bellsprout"] = {price = 10000},

["pidgey"] = {price = 5000},

["beedrill"] = {price = 120000},

["magnemite"] = {price = 60000},

["magneton"] = {price = 250000},

["raticate"] = {price = 85000},

["seadra"] = {price = 250000},

["doduo"] = {price = 65000},

["dodrio"] = {price = 300000},

["golbat"] = {price = 120000},

["graveler"] = {price = 160000},

["electrode"] = {price = 200000},

["victreebel"] = {price = 500000},

["poliwhirl"] = {price = 220000},

["bulbasaur"] = {price = 300000}

}

 

if(msgcontains(msg, "pokemon") or msgcontains(msg, "pokemon")) then

local str = ""

str = str .. "Pokemon Prices :\n\n"

for name, pos in pairs(Pokemons) do

str = str..name.." = "..pos.price.."\n"

end

str = str .. ""

doShowTextDialog(cid, 6579, str)

selfSay("has some pokemon you want sell me?", cid)

talkState[talkUser] = 1

elseif pokemons[msg] and talkState[talkUser] == 1 then

if getPlayerStorageValue(cid, 25000) == 5 then

return selfSay("Voce está montando.",cid)

elseif getPlayerStorageValue(cid, 23000) == 5 then

return selfSay("Voce está voando.",cid)

elseif #getCreatureSummons(cid) >= 1 then

return selfSay("Voce precisa botar seus pokemons dentro da pokebola.",cid)

end

sellPokemon(cid, msg, pokemons[msg].price)

elseif msg == "no" and talkState[talkUser] >= 1 then

selfSay("Then not", cid)

talkState[talkUser] = 0

npcHandler:releaseFocus(cid)

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

 

 

[07/02/2011 13:24:50] [Error - Npc interface]

[07/02/2011 13:24:50] data/npc/scripts/pokemon.lua:onCreatureSay

[07/02/2011 13:24:50] Description:

[07/02/2011 13:24:50] data/npc/scripts/pokemon.lua:73: bad argument #1 to 'pairs' (table expected, got nil)

[07/02/2011 13:24:50] stack traceback:

[07/02/2011 13:24:50] [C]: in function 'pairs'

[07/02/2011 13:24:50] data/npc/scripts/pokemon.lua:73: in function 'callback'

[07/02/2011 13:24:50] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'

[07/02/2011 13:24:50] data/npc/scripts/pokemon.lua:8: in function <data/npc/scripts/pokemon.lua:8>

Link para o comentário
Compartilhar em outros sites

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

 

function pairsByKeys (t, f) -- function for alphabetical order in list

local a = {}

for n in pairs(t) do table.insert(a, n) end

table.sort(a, f)

local i = 0

local iter = function ()

i = i + 1

if a == nil then return nil

else return a, t[a]

end

end

return iter

end

 

 

function sellPokemon(cid, name, price) -- n sei de quem é essa função

local pokename = name

local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

local itemsball = getItemsInContainerById(bp.uid, 2222)

local itemsultra = getItemsInContainerById(bp.uid, 2220)

for _, pok in pairs(itemsball) do

if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then

doRemoveItem(pok, 1)

doPlayerAddMoney(cid, price)

selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)

return true

end

break

end

for _, pok in pairs(itemsultra) do

if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then

doRemoveItem(pok, 1)

doPlayerAddMoney(cid, price)

selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)

return true

end

break

end

selfSay("Hey, you dont have this pokemon("..pokename..")! Make sure if its not fainted and it is inside your backpack!",cid)

end

 

local Pokemons = {

["gloom"] = {price = 150000},

["kakuna"] = {price = 25000},

["sandshrew"] = {price = 85000},

["pidgeot"] = {price = 550000},

["rattata"] = {price = 130000},

["pidgeotto"] = {price = 120000},

["poliwag"] = {price = 11000},

["horsea"] = {price = 20000},

["oddish"] = {price = 8000},

["bellsprout"] = {price = 10000},

["pidgey"] = {price = 5000},

["beedrill"] = {price = 120000},

["magnemite"] = {price = 60000},

["magneton"] = {price = 250000},

["raticate"] = {price = 85000},

["seadra"] = {price = 250000},

["doduo"] = {price = 65000},

["dodrio"] = {price = 300000},

["golbat"] = {price = 120000},

["graveler"] = {price = 160000},

["electrode"] = {price = 200000},

["victreebel"] = {price = 500000},

["poliwhirl"] = {price = 220000},

["bulbasaur"] = {price = 300000}

}

 

if(msgcontains(msg, "pokemon") or msgcontains(msg, "pokemon")) then

selfSay("has some pokemon you want sell me? or you can look at the {list}!", cid)

talkState[talkUser] = 1

elseif (msgcontains(msg, "list") or msgcontains(msg, "LIST")) and talkState[talkUser] == 1 then

local str = ""

str = str .. "Pokemon Prices :\n\n"

for name, pos in pairsByKeys(Pokemons) do

str = str..name.." = "..pos.price.."\n"

end

str = str .. ""

doShowTextDialog(cid, 6579, str)

elseif Pokemons[msg] and talkState[talkUser] == 1 then

if getPlayerStorageValue(cid, 25000) == 5 then

return selfSay("Você está montando.",cid)

elseif getPlayerStorageValue(cid, 23000) == 5 then

return selfSay("Você está voando.",cid)

elseif #getCreatureSummons(cid) >= 1 then

return selfSay("Voce precisa botar seus pokemons dentro da pokebola.",cid)

end

sellPokemon(cid, msg, Pokemons[msg].price)

elseif msg == "no" and talkState[talkUser] >= 1 then

selfSay("Then not", cid)

talkState[talkUser] = 0

npcHandler:releaseFocus(cid)

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

Cara usei a versão 2.0 e não da pra vender aqui não :neutral:

Eu falo o nome do pokemon (exemplo: bulbasaur) e o npc não fala nada ._.

Eu falei hi,pokemon,list.. tentei de tudo e não consegui, Se me puder ajudar

Ja garante SEU REP++

 

 

E..

Como faço pra adiciona mais poke pra vende ae?

Vale REP++ tbm :smile_positivo:

Link para o comentário
Compartilhar em outros sites

Meu deus,me ajude.

 

eu fiz tudo como ta ai,e aqui não vai!,de jeito nenhum!

 

To lá de player com um kakuna no slot da ball.

 

07:29 Buy pokes: Ola Mlk da Zika. quer me vender alguns pokemon?

07:29 Mlk da Zika [1]: pokemon

07:29 Buy pokes: has some pokemon you want sell me? or you can look at the list!

07:29 Mlk da Zika [1]: list

07:30 Mlk da Zika [1]: kakuna

 

ele não compra ;x

pela mor me ajuda!

 

 

[15/02/2011 08:50:24] [Error - Npc interface]

[15/02/2011 08:50:24] data/npc/scripts/venda.lua:onCreatureSay

[15/02/2011 08:50:24] Description:

[15/02/2011 08:50:24] data/npc/scripts/venda.lua:36: attempt to call global 'getItemsInContainerById' (a nil value)

[15/02/2011 08:50:24] stack traceback:

[15/02/2011 08:50:24] data/npc/scripts/venda.lua:36: in function 'sellPokemon'

[15/02/2011 08:50:24] data/npc/scripts/venda.lua:105: in function 'callback'

[15/02/2011 08:50:24] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'

[15/02/2011 08:50:24] data/npc/scripts/venda.lua:8: in function <data/npc/scripts/venda.lua:8>

 

Editado por molizok
Link para o comentário
Compartilhar em outros sites

você não tem a função na lib :X

 

vai em lib e cria um arquivo.lua e renomeie para :

 

 

pokeLib

pokein, pokeout = 2222,2223
ultrapokein, ultrapokeout = 2220, 2221
aguinha = {'4820', '4821', '4822', '4823', '4824', '4825'}

function doRemoveTile(pos)-- Script by mock
pos.stackpos = 0
local sqm = getTileThingByPos(pos)
doRemoveItem(sqm.uid,1)
end


function doCreateTile(id,pos) -- By mock
doAreaCombatHealth(0,0,pos,0,0,0,CONST_ME_NONE)
doCreateItem(id,1,pos)
end

function hasSqm(pos)
local f = getTileThingByPos(pos)
if f.itemid ~= 0 and f.itemid ~= 1 then
return true
end
return false
end

function getPosDirs(p, dir) -- By MatheusMkalo
return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z}
end

function doItem(pos,a,d)-- Script by mock
doCreateTile(460,pos)
pos.stackpos = 0
local c = getTileThingByPos(pos)
doItemSetAttribute(c.uid, "aid", a)
end

function getDescription(uid)
for i,x in pairs(getItemDescriptions(uid)) do
if i == "special" then
return x
end
end
end

function findLetter(string, letter)
for i = 1, #string do
if string:sub(i, i) == letter then
return i
end
end
end

function isWalkable(pos, creature, proj, pz)-- by Nord
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return false
end
end
end
return true
end

function getPosDirs(p, dir)
return dir == 1 and {x=p.x-1, y=p.y, z=p.z} or dir == 2 and {x=p.x-1, y=p.y+1, z=p.z} or dir == 3 and {x=p.x, y=p.y+1, z=p.z} or dir == 4 and {x=p.x+1, y=p.y+1, z=p.z} or dir == 5 and {x=p.x+1, y=p.y, z=p.z} or dir == 6 and {x=p.x+1, y=p.y-1, z=p.z} or dir == 7 and {x=p.x, y=p.y-1, z=p.z} or dir == 8 and {x=p.x-1, y=p.y-1, z=p.z}
end

function canSummon(cid)
local pos = getCreaturePosition(cid)
local state = false
for i = 1, 8 do
if isWalkable(getPosDirs(getCreaturePosition(cid), i)) then
state = true
end
end
return state
end

function isPlayerSummon(cid, uid)
if getCreatureMaster(uid) == cid then
return TRUE
end
return FALSE
end

function getSummonLifes(cid)
for _,x in pairs(getCreatureSummons(cid)) do
return getCreatureHealth(x), getCreatureMaxHealth(x)
end
end

function isSummon(sid)
   for i, pid in ipairs(getPlayersOnline()) do
       for c, cid in pairs(getCreatureSummons(pid)) do
           if (cid == sid) then
               return true
           end
       end 
   end
   return false
end 

function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag[i])
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end

Editado por Vodkart
Link para o comentário
Compartilhar em outros sites

  • 4 weeks later...
×
×
  • Criar Novo...