• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action The Colours of Magic (Only powders, letters script) (Mystic Spirit 0.2.10)

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
here i'm releasing the script for the Colours Of Magic Event (Just powders, tomorrow i'll post rewards and script to end the event)

First, execute this on phpMyAdmin
SQL:
CREATE TABLE `colourofmagic`
(
	`colorid` int not null default 0,
	`count` int not null default 0
) ENGINE = InnoDB;

insert into colourofmagic (colorid, count) values (1, 0);
insert into colourofmagic (colorid, count) values (2, 0);
insert into colourofmagic (colorid, count) values (3, 0);

Paste this on items.xml
XML:
	<item id="13191" name="envelope from the wizards">
		<attribute key="description" value="The sender on this letter reads: 'The Three Wizards, Skyward Lane 33 in 82335 Cloudstream.'" />
		<attribute key="weight" value="50" />
	</item>
	<item id="13192" name="letter from the wizards">
		<attribute key="description" value="A letter from the three wizards." />
		<attribute key="weight" value="50" />
	</item>
	<item id="13193" name="strange red powder">
		<attribute key="weight" value="50" />
	</item>
	<item id="13194" name="strange yellow powder">
		<attribute key="weight" value="50" />
	</item>
	<item id="13195" name="strange blue powder">
		<attribute key="weight" value="50" />
	</item>
	<item id="13196" name="strange green powder">
		<attribute key="weight" value="50" />
	</item>
	<item id="13197" name="strange violet powder">
		<attribute key="weight" value="50" />
	</item>
	<item id="13198" name="strange orange powder">
		<attribute key="weight" value="50" />
	</item>

Create a file on data/actions/scripts called colourofmagic.lua and paste:
LUA:
dofile("./config.lua")

local powders = {13193, 13194, 13195}
local join = 63533
local pcolor = 63534
local storage = 63535

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 13191 then
		local random = math.random(3)
		doRemoveItem(item.uid, 1)
		doPlayerAddItem(cid, 13192 + random, 1)
		doPlayerAddItem(cid, 13192, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You open the envelope very carefully. A " .. (random == 1 and "red" or random == 2 and "yellow" or "blue") .. " powder in a small pouch and a letter are waiting inside.")
		return TRUE
	
	elseif item.itemid == 13192 then
		doShowTextDialog(cid, item.itemid, "* Be careful adventurer as you can use the magic powder in this envelope on your self only once!\n\n* Use this coloured powder if you made your decision and you will be marked with the colour you have chosen.\n\n* Then use the remaining powder on another player who marked himself with a different colour to join one of the three wizards.\n\n* You can join the orange wizard Furb of Fun, the violet wizard Feiz of Power or the green wizard Fern of Nature.")
		return TRUE 
	
	elseif isInArray(powders, item.itemid) == TRUE then
		if getPlayerStorageValue(cid, storage) > 0 then
			doPlayerSendCancel(cid, "You already marked a player.")
			return TRUE
		end
		if isPlayer(itemEx.uid) == TRUE then
			_s = getPlayerStorageValue(itemEx.uid, pcolor)
			_p = getPlayerStorageValue(cid, pcolor)
			if itemEx.uid == cid then
				if getPlayerStorageValue(cid, pcolor) < 1 then
					local color = item.itemid - 13192
					setPlayerStorageValue(cid, pcolor, color)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You marked yourself with the " .. (color == 1 and "red" or color == 2 and "yellow" or "blue") .. " color.")
					return TRUE
				end
			else
				if _p > 0 and _p ~= item.itemid - 13192 then
					doPlayerSendCancel(cid, "You cannot use this powder.")
					return TRUE
				end
				if _s < 1 then
					doPlayerSendCancel(cid, "That player does not have a color yet.")
					return TRUE
				end
				if _s == _p then
					doPlayerSendCancel(cid, "You cannot make combinations with a player that has the same color as you.")
					return TRUE
				end

				local color = (_s == 1 and _p == 2 and "orange" or _s == 1 and _p == 3 and "purple" or _s == 2 and _p == 1 and "orange" or _s == 2 and _p == 3 and "green" or _s == 3 and _p == 1 and "violet" or _s == 3 and _p == 2 and "green" or "")
				local colorid = (_s == 1 and _p == 2 and 1 or _s == 1 and _p == 3 and 2 or _s == 2 and _p == 1 and 1 or _s == 2 and _p == 3 and 3 or _s == 3 and _p == 1 and 2 or _s == 3 and _p == 2 and 3 or -1)
				if sqlType == "mysql" then
					env = luasql.mysql()
					sql = env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort)
				else -- sqlite
					env = luasql.sqlite3()
					sql = env:connect(sqliteDatabase)
				end
				local t = 2
				sql:execute("UPDATE colourofmagic SET count = count + 1 WHERE colorid = " .. colorid .. ";")
				sql:close()
				env:close()
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You made " .. color .. " powder.")
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You joined to " .. (color == "orange" and "Furb of Fun" or color == "violet" and "Feiz of Power" or color == "green" and "Fern of Nature" or "") .. ".")
				setPlayerStorageValue(cid, join, (color == "orange" and 1 or color == "violet" and 2 or color == "green" and 3 or 4))
				setPlayerStorageValue(cid, storage, 1)
				doRemoveItem(item.uid, 1)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
				return TRUE
			end
		end
	end
	return TRUE
end

And this on actions.xml:
XML:
<action fromid="13191" toid="13195" script="colourofmagic.lua"/>

And that's all for now :D
 
Last edited:
very nice release i wont be using it at least not right now. great scripts you keep making and releasing rep++
 
Back
Top