MA
pedido

Script de alavanca onde apareça monstro e gaste dinheiro

Por markim1986, 07 de jan. de 2013 em Scripts

script
24
2.2k
markim1986M
08 de janeiro de 2013 às 16:30

local config = {
money_requires = 1,
monsters = {["Rat"] = 3, ["Tiger"] = 2}, -- Nomde do montros e quantidade
pos = {{x=990,y=1048,z=7}, {x=995,y=1049,z=7}},
}
function onUse(cid, item)
if exhaustion.get(cid, 1734) > 0 then
doPlayerSendCancel(cid, "Sorry, you need waint a 5 minuts.")
return true
end
if doPlayerRemoveMoney(cid, config.money_requires) then
for k, v in pairs(config.monsters) do
for i=1, v do
  local monster = doSummonCreature(k, config.pos[1])				
  doSendMagicEffect(getThingPos(monster), 10)
  exhaustion.set(cid, 1734, 5)
end
end
else
doPlayerSendTextMessage(cid, 27, "Sorry, you need a "..config.money_requires.." for summon monster.")
return true
end
end

 

 

Agora tem que espera 5 segundos pra poder usar denovo..... ta foda esse pedido em ¬¬'

 

 

KKKKKKKKKKKKKKKKKK

Verdade cara, olha ta dando esse erro agora ;)

 

[08/01/2013 16:30:43] [Error - Action Interface]
[08/01/2013 16:30:43] data/actions/scripts/a.lua:onUse
[08/01/2013 16:30:43] Description:
[08/01/2013 16:30:43] data/actions/scripts/a.lua:7: attempt to compare number with boolean
[08/01/2013 16:30:43] stack traceback:
[08/01/2013 16:30:43]  data/actions/scripts/a.lua:7: in function <data/actions/scripts/a.lua:6>

 

Vlw pelo seu tempo

brun123B
08 de janeiro de 2013 às 16:36

Use essa script:

Fiz o mesmo esquema de como sumona criaturas, basta editar a tabela monsters.

Se quiser algo do tipo monstro de acordo com level do player etc, só pedir

 

local delay = {}

function onUse(cid, item, frompos, item2, topos)

   local maxSummons = 8   -- máximo de summons permitidos por player
   local timeForReuse = 5 -- segundos para usar novamente
   local cost = 1500	 -- gold para sumonar
   local monsters = {	   -- tabela com monstros, e a quantidade que vai sumonar
   ["Rat"] = 3,
   ["Tiger"] = 2,
   }

   if delay[0] and delay[0] - os.time() > 0 then
    return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.")
   end

   local monsterCount = 0
   local guid = getPlayerGUID(cid)

   if delay[guid] then
    for _, mid in pairs(delay[guid]) do
	    if isCreature(mid) then
		    monsterCount = monsterCount + 1
	    else
		    delay[guid][_] = nil
	    end
    end
   end

   if monsterCount >= maxSummons then
    return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!")
   end

   if not doPlayerRemoveMoney(cid, cost) then
    return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!")
   end

   delay[0] = os.time() + timeForReuse
   monsterCount = 0

   for monsterName, number in pairs(monsters) do
    for _ = 1, number do
	    local newMonster = doCreateMonster(monsterName, getClosestFreeTile(cid, getThingPos(cid), true), false)
	    if isCreature(newMonster) then
		    monsterCount = monsterCount + 1
		    table.insert(delay[guid], newMonster)
		    doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT)
		    if monsterCount >= maxSummons then
			    return true
		    end
	    end
    end
   end

return true
end

Editado Janeiro 8 por brun123

markim1986M
08 de janeiro de 2013 às 19:28

Use essa script:

Fiz o mesmo esquema de como sumona criaturas, basta editar a tabela monsters.

Se quiser algo do tipo monstro de acordo com level do player etc, só pedir

 

local delay = {}

function onUse(cid, item, frompos, item2, topos)

local maxSummons = 8   -- máximo de summons permitidos por player
local timeForReuse = 5 -- segundos para usar novamente
local cost = 1500	 -- gold para sumonar
local monsters = {	   -- tabela com monstros, e a quantidade que vai sumonar
["Rat"] = 3,
["Tiger"] = 2,
}

if delay[0] and delay[0] - os.time() > 0 then
	return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.")
end

local monsterCount = 0
local guid = getPlayerGUID(cid)

if delay[guid] then
	for _, mid in pairs(delay[guid]) do
		if isCreature(mid) then
			monsterCount = monsterCount + 1
		else
			delay[guid][_] = nil
		end
	end
end

if monsterCount >= maxSummons then
	return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!")
end

if not doPlayerRemoveMoney(cid, cost) then
	return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!")
end

delay[0] = os.time() + timeForReuse
monsterCount = 0

for monsterName, number in pairs(monsters) do
	for _ = 1, number do
		local newMonster = doCreateMonster(monsterName, getClosestFreeTile(cid, getThingPos(cid), true), false)
		if isCreature(newMonster) then
			monsterCount = monsterCount + 1
			table.insert(delay[guid], newMonster)
			doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT)
			if monsterCount >= maxSummons then
				return true
			end
		end
	end
end

return true
end

 

Amigo so esta sumonando 1 bixo e esta dando este erro :

 

[17/01/2013 19:28:18] [Error - Action Interface]
[17/01/2013 19:28:18] data/actions/scripts/summonMonster.lua:onUse
[17/01/2013 19:28:18] Description:
[17/01/2013 19:28:18] data/actions/scripts/summonMonster.lua:46: bad argument #1 to 'insert' (table expected, got nil)
[17/01/2013 19:28:18] stack traceback:
[17/01/2013 19:28:18]  [C]: in function 'insert'
[17/01/2013 19:28:18]  data/actions/scripts/summonMonster.lua:46: in function <data/actions/scripts/summonMonster.lua:3>

 

Vlw tbm por esta ajudando

brun123B
08 de janeiro de 2013 às 19:36

Assim:

 

local delay = {}

function onUse(cid, item, frompos, item2, topos)

   local maxSummons = 8   -- máximo de summons permitidos por player
   local timeForReuse = 5 -- segundos para usar novamente
   local cost = 1500    -- gold para sumonar
   local monsters = {	 -- tabela com monstros, e a quantidade que vai sumonar
   ["Rat"] = 3,
   ["Tiger"] = 2,
   }

   if delay[0] and delay[0] - os.time() > 0 then
    return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.")
   end

   local monsterCount = 0
   local guid = getPlayerGUID(cid)

   if delay[guid] then
    for _, mid in pairs(delay[guid]) do
	    if isCreature(mid) then
		    monsterCount = monsterCount + 1
	    else
		    delay[guid][_] = nil
	    end
    end
   else
    delay[guid] = {}
   end

   if monsterCount >= maxSummons then
    return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!")
   end

   if not doPlayerRemoveMoney(cid, cost) then
    return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!")
   end

   delay[0] = os.time() + timeForReuse
   monsterCount = 0

   for monsterName, number in pairs(monsters) do
    for _ = 1, number do
	    local newMonster = doCreateMonster(monsterName, getClosestFreeTile(cid, getThingPos(cid), true), false)
	    if isCreature(newMonster) then
		    monsterCount = monsterCount + 1
		    table.insert(delay[guid], newMonster)
		    doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT)
		    if monsterCount >= maxSummons then
			    return true
		    end
	    end
    end
   end

return true
end

markim1986M
08 de janeiro de 2013 às 19:44

Assim:

 

local delay = {}

function onUse(cid, item, frompos, item2, topos)

local maxSummons = 8   -- máximo de summons permitidos por player
local timeForReuse = 5 -- segundos para usar novamente
local cost = 1500	-- gold para sumonar
local monsters = {	 -- tabela com monstros, e a quantidade que vai sumonar
["Rat"] = 3,
["Tiger"] = 2,
}

if delay[0] and delay[0] - os.time() > 0 then
	return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.")
end

local monsterCount = 0
local guid = getPlayerGUID(cid)

if delay[guid] then
	for _, mid in pairs(delay[guid]) do
		if isCreature(mid) then
			monsterCount = monsterCount + 1
		else
			delay[guid][_] = nil
		end
	end
else
	delay[guid] = {}
end

if monsterCount >= maxSummons then
	return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!")
end

if not doPlayerRemoveMoney(cid, cost) then
	return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!")
end

delay[0] = os.time() + timeForReuse
monsterCount = 0

for monsterName, number in pairs(monsters) do
	for _ = 1, number do
		local newMonster = doCreateMonster(monsterName, getClosestFreeTile(cid, getThingPos(cid), true), false)
		if isCreature(newMonster) then
			monsterCount = monsterCount + 1
			table.insert(delay[guid], newMonster)
			doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT)
			if monsterCount >= maxSummons then
				return true
			end
		end
	end
end

return true
end

 

Perfeito, so gotaria que direcionase os bixos por ex:

Nascer 1 numa ponta e outro na outra (configuravel XYZ)

Obrigado!

brun123B
08 de janeiro de 2013 às 20:33

Fiz por direção, basta configurar a tabela "dirPref" e ver quais direções você quer dar prioridade pra sumonar:

 

local delay = {}

function onUse(cid, item, frompos, item2, topos)

   local maxSummons = 8   -- máximo de summons permitidos por player
   local timeForReuse = 5 -- segundos para usar novamente
   local cost = 1500    -- gold para sumonar
   local dirPref = {NORTHWEST, SOUTHEAST, NORTHEAST, SOUTHWEST, NORTH, SOUTH, EAST, WEST}
   local monsters = {   -- tabela com monstros, e a quantidade que vai sumonar
   ["Rat"] = 3,
   ["Tiger"] = 2,
   }

   if delay[0] and delay[0] - os.time() > 0 then
    return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.")
   end

   local monsterCount = 0
   local guid = getPlayerGUID(cid)

   if delay[guid] then
    for _, mid in pairs(delay[guid]) do
	    if isCreature(mid) then
		    monsterCount = monsterCount + 1
	    else
		    delay[guid][_] = nil
	    end
    end
   else
    delay[guid] = {}
   end

   if monsterCount >= maxSummons then
    return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!")
   end

   if not doPlayerRemoveMoney(cid, cost) then
    return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!")
   end

   delay[0] = os.time() + timeForReuse
   monsterCount = 0
   local dir = 1

   for monsterName, number in pairs(monsters) do
    for _ = 1, number do
	    local range = 1
	    local pos = getPosByDir(getThingPos(cid), dirPref[dir], range)
	    local loops = 0
	    while doTileQueryAdd(cid, pos, 0, false) ~= 1 and loops <= #dirPref * 2 do
		    dir = (dir + 1) > #dirPref and 1 or dir + 1
		    if dir == 1 then
			   range = range + 1
		    end
		    pos = getPosByDir(getThingPos(cid), dirPref[dir], range)
		    loops = loops + 1
	    end
	    if doTileQueryAdd(cid, pos, 0, false) ~= 1 then
		    pos = getClosestFreeTile(cid, getThingPos(cid), true)
	    end
	    local newMonster = doCreateMonster(monsterName, pos, false)
	    if isCreature(newMonster) then
		    monsterCount = monsterCount + 1
		    table.insert(delay[guid], newMonster)
		    doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT)
		    if monsterCount >= maxSummons then
			    return true
		    end
	    end
    end
   end

return true
end

markim1986M
11 de janeiro de 2013 às 13:06

Muito obrigado pessoal.

Script Pefeito podem fechar o topic!

 

Brun123, You have reached your quota of positive votes for the day

Amanha lhe dou REP+

SlicerS
11 de janeiro de 2013 às 13:10

sanado, movido

1 ano depois...
10 de abril de 2014 às 15:54

Deu esse erro

 

 

[10/04/2014 15:53:12] [Error - LuaScriptInterface::loadFile] data/actions/scripts/summonMonster.lua:73: 'end' expected (to close 'function' at line 2) near 'en'
[10/04/2014 15:53:12] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/summonMonster.lua)
[10/04/2014 15:53:12] data/actions/scripts/summonMonster.lua:73: 'end' expected (to close 'function' at line 2) near 'en'