• 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!

Rain Items...

Verdis

Ciekawy świata.
Joined
May 28, 2012
Messages
394
Reaction score
9
Location
Poland
Siemka, przerobiłem trochę rain items event... Lecz nie umiem sobie poradzić z tym aby nie było więcej niż jednego itema na sqm... Ma ktoś jakiś pomysł?
PHP:
local storage1 = 2113      -- the storage value here
local newPosition = {x=781, y=842, z=7}

local config = {	
	fromPosition = {x = 766, y = 832, z = 7}, -- top left cornor of the playground (random items drop)
    toPosition = {x = 796, y = 848, z = 7}, -- bottom right cornor of the playground (random items drop)
	prize = {xxxx,xxxx,xxx} -- rewards
}



function onUse(cid, item, fromPosition, itemEx, toPosition)
		pos = getPlayerPosition(cid)

		if getPlayerStorageValue(cid, storage1) == -1 then
		if(item.actionid == 8523) then
		doSendMagicEffect(pos,2)
		doTeleportThing(cid,newPosition) 
		doSendMagicEffect(newPosition,10)
		
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "xxxx")
	end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "xxxx")
end

local function senelis()
		local pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
		local randomChanceItem = math.random(1, #config.prize)		
		doCreateItem(config.prize[randomChanceItem], 1, pos)
		end
		local function seneliss()
		local pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
		local randomChance = math.random(1, #config.prize)		
		doItemSetAttribute(doCreateItem(config.prize[randomChance], 1, pos), "aid", 1905)
		end
		
		addEvent(seneliss, 500)
		
		addEvent(senelis, 50)
		
		

return TRUE
end
 
zrób sobie, np.

tbl_z = {}

table.insert(tbl_z, pozycja)

pozycja to tam gdzie pojawia się item

a przed pojawianiem się itemu to poprostu szukaj czy w tbl_z jest pozycja już taka xd
 
Może byś coś więcej podpowiedział? :) Nie to spoko. Kompletnie nie wiem, gdzie to zastosować, jakie funkcje do tego potrzebne... Nigdy tego nie używałem :)
 
Last edited:
coś w tym stylu chyba, na szybko sobie napisałem, zapewne są funkcje na szukanie elementu w tbl, ale masz

Lua:
function czy_jest_w_tbl(element, tablica)
	for t = 1, #tablica do
		if tablica[t] == element then
			return true
		end
	end
	return false
end
tbl_nowa = {}
pojawienie_sie_itema_pos = {x = , y=, z=}
if not(czy_jest_w_tbl(pojawienie_sie_itema_pos, tbl_nowa)) then
	-- stworz item
	table.insert(tbl_nowa, pojawienie_sie_itema_pos)
end


#evul mastah

zapewne się przypierdolisz znowu do mnie, ok, to jak już mnie masz cisnąć to podaj ładne rozwiązanie i co zrobiłem źle/niepotrzebnie
 
Back
Top