Gitzmo
Combat Bird
- Joined
- Apr 16, 2012
- Messages
- 199
- Reaction score
- 1
Hello I currently use a lever spawn on a project of mine but it only spawns 1 type of monster to where ever you tell them to spawn upon pulling the lever. I need one that will spawn different types of monsters depending on the players level and will spawn them at random within a certain area kind of how a raid script works where it spawns the monster fromx1 fromy1 fromz7 tox10 toy10 toz7
This is my CURRENT script that I am using.
This is my CURRENT script that I am using.
Code:
local room = { -- room with demons
fromX = 1203,
fromY = 996,
fromZ = 7,
toX = 1226,
toY = 1011,
toZ = 7
}
local monster_pos = {
[1] = {pos = {1213, 1008, 7}, monster = "hero"},
[2] = {pos = {1213, 1007, 7}, monster = "hero"},
[3] = {pos = {1210, 1008, 7}, monster = "hero"},
[4] = {pos = {1210, 1007, 7}, monster = "hero"},
[5] = {pos = {1216, 1008, 7}, monster = "hero"},
[6] = {pos = {1216, 1007, 7}, monster = "hero"},
[7] = {pos = {1219, 1008, 7}, monster = "hero"},
[8] = {pos = {1219, 1007, 7}, monster = "hero"},
[9] = {pos = {1220, 1009, 7}, monster = "hero"},
[10] = {pos = {1213, 1008, 7}, monster = "hero"},
[11] = {pos = {1213, 1007, 7}, monster = "hero"},
[12] = {pos = {1210, 1008, 7}, monster = "hero"},
[13] = {pos = {1210, 1007, 7}, monster = "hero"},
[14] = {pos = {1216, 1008, 7}, monster = "hero"},
[15] = {pos = {1216, 1007, 7}, monster = "hero"},
[16] = {pos = {1219, 1008, 7}, monster = "hero"},
[17] = {pos = {1219, 1007, 7}, monster = "hero"},
[18] = {pos = {1220, 1009, 7}, monster = "hero"},
[19] = {pos = {1213, 999, 7}, monster = "hero"},
[20] = {pos = {1213, 998, 7}, monster = "hero"},
[21] = {pos = {1210, 998, 7}, monster = "hero"},
[22] = {pos = {1210, 999, 7}, monster = "hero"},
[23] = {pos = {1216, 998, 7}, monster = "hero"},
[24] = {pos = {1216, 999, 7}, monster = "hero"},
[25] = {pos = {1219, 998, 7}, monster = "hero"},
[26] = {pos = {1219, 999, 7}, monster = "hero"},
[27] = {pos = {1220, 998, 7}, monster = "hero"},
[28] = {pos = {1213, 999, 7}, monster = "hero"},
[29] = {pos = {1213, 998, 7}, monster = "hero"},
[30] = {pos = {1210, 999, 7}, monster = "hero"},
[31] = {pos = {1210, 998, 7}, monster = "hero"},
[32] = {pos = {1216, 999, 7}, monster = "hero"},
[33] = {pos = {1216, 998, 7}, monster = "hero"},
[34] = {pos = {1219, 999, 7}, monster = "hero"},
[35] = {pos = {1219, 998, 7}, monster = "hero"},
[36] = {pos = {1220, 999, 7}, monster = "hero"}
}
local players_pos = {
{x = 1214, y =994, z = 7, stackpos = 253},
}
local new_player_pos = {
{x = 1214, y =995, z = 7},
}
local playersOnly = "no"
local questLevel = 8
function onUse(cid, item, fromPosition, itemEx, toPosition)
local all_ready, monsters, player, level = 0, 0, {}, 0
if item.itemid == 1945 then
for i = 1, #players_pos do
table.insert(player, 0)
end
for i = 1, #players_pos do
player[i] = getThingfromPos(players_pos[i])
if player[i].itemid > 0 then
if string.lower(playersOnly) == "yes" then
if isPlayer(player[i].uid) == TRUE then
all_ready = all_ready+1
else
monsters = monsters+1
end
else
all_ready = all_ready+1
end
end
end
if all_ready == #players_pos then
for i = 1, #players_pos do
player[i] = getThingfromPos(players_pos[i])
if isPlayer(player[i].uid) == TRUE then
if getPlayerLevel(player[i].uid) >= questLevel then
level = level+1
end
else
level = level+1
end
end
if level == #players_pos then
if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
for _, area in pairs(monster_pos) do
doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
end
for i = 1, #players_pos do
doSendMagicEffect(players_pos[i], CONST_ME_POFF)
doTeleportThing(player[i].uid, new_player_pos[i], FALSE)
doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
doTransformItem(item.uid,1946)
end
else
doPlayerSendTextMessage(cid,19,"Only players can use this spawn.")
end
else
doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
end
else
doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." player to use this spawn.")
end
elseif item.itemid == 1946 then
local player_room = 0
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
if isPlayer(thing.uid) == TRUE then
player_room = player_room+1
end
end
end
end
end
if player_room >= 1 then
doPlayerSendTextMessage(cid,19,"There is already someone in the spawn.")
elseif player_room == 0 then
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
doRemoveCreature(thing.uid)
end
end
end
end
doTransformItem(item.uid,1945)
end
end
return TRUE
end