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

TalkAction [EVENT - SURPRISE PACKAGE] - easy configurable

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
Actions
Lua:
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local q = {
				a = {1111, 2222, 3333, 4444, 5555, 6666, 0}, -- Id of items which surprise package can create (0 means nothing).
				b = {1, 2} -- Amount of create items (random).
			}
			local r, s, t, u = q.a[math.random(1, #q.a)], getItemNameById(r), amount[math.random(1, #q.b)], getCreaturePosition(cid)

			if(r == 0) then
				doCreatureAddHealth(cid, -(math.random(20,100)))
				doSendMagicEffect(u, CONST_ME_EXPLOSIONHIT)
				doPlayerSendTextMessage(cid, 4, "It was a trap! Surprise package burned you!")
			else
				doPlayerAddItem(cid, r, t)
				doSendMagicEffect(u, CONST_ME_GIFT_WRAPS)
				doPlayerSendTextMessage(cid, 4, "Surprise package gave you ".. t .."x of ".. s ..".")
			end
			return true
		end


Talkactions
Lua:
		local q = {
			a = 9999, -- Global Storage which take amount of created presents.
			b = 5, -- Maximum amount of present which system will create.
			c = {x = 1104, y = 1188, z = 7}, -- Top left cornor of the playground.
			d = {x = 1104, y = 1188, z = 7}, -- Bottom right cornor of the playground.
			e = 9074, -- Id of suprise package.
			f = "Suprise package fell from the sky!", -- Message which shows up to all players when item will be created on the map.
			g = 2, -- Seconds between each present.
			h = 30 -- Seconds, after these seconds surprise package event will start.
		}
		
		function onSay(cid, words, param, channel)
			if getPlayerGroupId(cid) > 3 then
				if(param == '') then
					doPlayerSendTextMessage(cid, "You have started surprise package event. ".. q.b .." surprise packages will be created on the map on each ".. q.g .." seconds.")
					setGlobalStorageValue(q.a, q.b)
					addEvent(start, 1)
					return true
				end
				local t = string.explode(param, ",")
				t[1] = tonumber(t[1])
				if(not t[1]) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
					return true
				end
				doPlayerSendTextMessage(cid, "You have started surprise package event. ".. t[1] .." surprise packages will be created on the map on each ".. q.g .." seconds.")
				setGlobalStorageValue(q.a, t[1])
				addEvent(start, 1)
				return true
			end
			return true
		end
		
		function start()
			doBroadcastMessage("[EVENT - SURPRISE PACKAGE]\nEvent will start for " .. q.h .. " seconds. Free surprise packages fall from the sky!")
			addEvent(postawPrezent, q.h * 1000)
			return true
		end

		function postawPrezent()
			local r = {x = math.random(q.c.x, q.d.x), y = math.random(q.c.y, q.d.y), z = math.random(q.c.z, q.d.z), stackrandom = 253}
			if getGlobalStorageValue(q.a) < q.b then
				doSendDistanceShoot({x = r.x - 7, y = r.y - 5, z = r.z}, {x = r.x, y = r.y, z = r.z}, 35)
				addEvent(function()
					doSendMagicEffect({x = r.x, y = r.y, z = r.z}, 11)
					doCreateItem(q.e, 1, {x = r.x, y = r.y, z = r.z})
				end, 150)
				for _, pid in ipairs(getPlayersOnline()) do
					doPlayerSendTextMessage(pid, 4, q.f)
				end
				setGlobalStorageValue(q.a, (getGlobalStorageValue(q.a) + 1))
				addEvent(postawPrezent, g * 1000)
				return true
			end
		end

Not tested. Yours GarQet.
 
Hmmm it reminds me ammo/health/weapon packages from oldschool game - Worms :D
 
Back
Top