• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Random item spawnpoint

Swiff

Member
Joined
Apr 6, 2009
Messages
366
Reaction score
12
Location
Sweden
Hello! I got an idea the other day, but I will need a script like this for it. Such a script may be used in alot of various ways. Anyways here goes:

Description:
Simply a few spots where there will spawn a seemingly random item.

Details:
*number of items that the "random generator" choose from may vary with each position. As in one spot there may be 3 different items that can spawn, but in another there may be 10.
*only one item may spawn, so it will have to check if there's alredy an item there before spawning a new item.
*a timer or something that checks if there's an item there alredy.


It will work quite as when killing a monster, except that only 1 item may drop and that you don't have to kill anything. As I want to create some spots wich are hard to reach with less variety and more rare items and some more common repsawns.
 
quickly made this and tested it,
it wont spawn the same item ontop of itself but it will spawn a different item ontop of that item.
Lua:
local t = {
items = {{2160,10,1},{2147,5,2}}, -- goes item, max item count, rarity (5-1. 5 being always, 1 being rare)
positions = {
{x = 1349, y = 1429, z = 7}, -- positions items can spawn, add more positions if needed
{x = 1348, y = 1429, z = 7},
{x = 1347, y = 1429, z = 7},
}
}
function onThink(cid, interval, lastExecution)
	local item = math.random(#t.items)
		for a = 1, #t.positions do
			if getTileItemById(t.positions[a], t.items[item][1]) ~= TRUE then
				local amount = math.random(t.items[item][2])
				if (math.random(5) <= t.items[item][3]) then
					doCreateItem(t.items[item][1], amount, t.positions[a])
				end
			end
		end
return true
end
 
Back
Top