Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.0 kB
2
Indexable
Never
<movement type="StepIn" actionid="7001-7065" event="script">
		<![CDATA[
			domodlib("huntingConfig")

			function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				if isPlayer(cid) then
					if getPlayerItemCount(cid, configHunting.itemId) < 1 then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, '[Colloseum] Nie masz glejtu.'), doTeleportThing(cid, fromPosition)
					end

					if exhaustion.check(cid, configHunting.exhaustStorage) ~= false then
						return doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, '[Colloseum] Zwolnij.'), doTeleportThing(cid, {x=2503, y=875, z=6})
					end

					local monsters, player = {}, false
					local playerIn = nil 
						if huntingConfig[item.actionid] then
							local v = huntingConfig[item.actionid]
							for x = v.fromPos.x, v.toPos.x do
								for y = v.fromPos.y, v.toPos.y do
									doCleanTile({x=x, y=y, z=v.toPos.z})
									local t = getTopCreature({x=x, y=y, z=v.toPos.z}).uid
									if t ~= 0 then
										if isMonster(t) then
											table.insert(monsters, t)
										else
											if isPlayer(t) then
												player = true
												playerIn = getPlayerGUID(t)

											end
										end
									end
								end
							end
							
							if not player then
								doTeleportThing(cid, v.teleportPos, true)
								doPlayerRemoveItem(cid, configHunting.itemId, 1)

								local x = addEvent(removePlayerFromRoom, v.expireTime * 1000, cid, configHunting, huntingConfig)
								doCreatureSetStorage(cid, configHunting.storage, x)
								doCreatureSetStorage(cid, configHunting.RoomStorage, item.actionid)
								doCreatureSetStorage(cid, configHunting.timeStorage, os.time()+v.expireTime)

								for _, v in ipairs(monsters) do
									if isCreature(v) then
										doRemoveCreature(v)
									end
								end
							else
							doTeleportThing(cid, fromPosition, true)
							local InPlayer = getPlayerByGUID(playerIn)
							if InPlayer ~= nil then 
								local timex= getCreatureStorage(InPlayer, configHunting.timeStorage)-os.time()
								local minutes = math.floor(timex / 60)
								local seconds = timex % 60
								doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, '[Colloseum] Arena jest zajeta. Przyjdz za ' .. minutes .. ' min. i ' .. seconds .. ' sek.')
							end
						
							end
							
						end
	

					exhaustion.set(cid, configHunting.exhaustStorage, configHunting.exhaustTime)
				end
				return true
			end

			function removePlayerFromRoom(pid, configHunting, huntingConfig)
				if isPlayer(pid) then
					doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, '[Colloseum] Twoj czas skonczyl sie. Opusciles arene.')
					doCreatureSetStorage(pid, configHunting.storage, -1)
					doCreatureSetStorage(pid, configHunting.RoomStorage, -1)
				end
			end
		]]>