Own Your Spawn!

Como anda galerinha? Hoje tive uma ideia bem legal e vim trazer para vocês, é um sistema que inventei chamado Own your Spawn, mas como funciona?
/buyspawn Monster, Quantidade
Você paga uma certa quantia e com um comando você cria X monstros para você upar, mas não pode ter players por perto (Anti-PowersAbuse), tudo bem configurável, vamos instalar?

Vá em data/lib, copie algum arquivo desta mesma pasta e cole, renomeio-o para own_spawnlib.lua, abra-o com o bloco de notas e adicione dentro:
function getPlayersInArea(area)
local players = {}
for x = area.fromx,area.tox do
for y = area.fromy,area.toy do
for z = area.fromz,area.toz do
local m = getTopCreature({x=x, y=y, z=z}).uid
if m ~= 0 and isPlayer(m) then
table.insert(players, m)
end
end
end
end
return players
end
Muito bem, agora siga para a pasta data/talkactions/scripts, copie algum arquivo desta mesma pasta e cole, renomeie para own_spawn.lua e adicione dentro:
function onSay(cid, words, param)
local t = string.explode(param, ",")
local pos = getCreaturePosition(cid)
local cfg = {
max_summon = 9,
price = 100000,
}
if #getPlayersInArea({fromx = pos.x+4, fromy = pos.y+4, fromz = pos.z, tox = pos.x-4, toy = pos.y-4, toz = pos.z}) > 1 then
doPlayerSendTextMessage(cid, 20, "Do this in a place where no other players.") return true end
if not t[1] or not t[2] or not tonumber(t[2]) then
doPlayerSendTextMessage(cid, 20, "The command does not recognize these parameters.") return true end
if tonumber(t[2]) > cfg.max_summon then
doPlayerSendTextMessage(cid, 20, "Maximum monsters in your spawn is "..cfg.max_summon..", rushed.") return true end
if not doPlayerRemoveMoney(cid, cfg.price) then
doPlayerSendTextMessage(cid, 20, "You do not have enough money to buy their own spawn!") return true end
for i = 1, t[2] do
doCreateMonster(t[1], {x = pos.x+3, y = pos.y+3, z = pos.z})
end
doPlayerSendTextMessage(cid, 20, "His spawn was summoned, good level up for you!")
return true
end
Na pasta data/talkactions, abra com um editor de texto o arquivo talkactions.xml e adicione essa tag:
<talkaction log="yes" words="!buyspawn;/buyspawn" event="script" value="own_spawn.lua"/>
Configuração

Nesta parte do código:
local cfg = {
max_summon = 9,
price = 100000,
}
Em "max_summon", você coloca a quantia máxima de monstros que podem dar spawn. E em "price" você coloca o preço para dar o spawn, no caso coloquei 100k ![]()
Utilização
















