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

Raibow Outfit

Renusek

beton beton beton punk!
Joined
Jul 24, 2008
Messages
1,047
Reaction score
9
Location
Poland - Katowice/Ruda Śląska
Is that possible to do in lua 'rainbow outfits' ?
I mean random colors outfit like this(global tibia xD):
YouTube - Rainbow Outfit

Only colors changing, not addons, not outfit.
Is that possible? Would be great. :p.
Or in c++, to config.lua line:
randomOutfitColors = "yes"
then talkactions !rainbow "start, !rainbow "stop.
Or something like this :D:D.
 
:)

Code:
<talkaction words="!rainbow" event="script" value="rainbow.lua"/>

Code:
local function outfit(params)
	local _outfit = {
		lookType = getCreatureOutfit(params.player).lookType,
		lookHead = math.random(1, 115),
		lookBody = math.random(1, 115),
		lookLegs = math.random(1, 115),
		lookFeet = math.random(1, 115)
	}
	doSetCreatureOutfit(params.player, _outfit, -1)
	addEvent(outfit, 200, params)
end

function onSay(cid, words, param, channel)
	local params = {}
	params.player = cid
	addEvent(outfit, 200, params)
	return FALSE
end
 
@up
;<.

OMG. Chojrak! :D So fast, so great.
You are great ;* !
But.. xD. If I say !rainbow x2, I have 2x faster rainbow :D. Can you add to script command !rainbowstop ? Please? :p. Giving rep++ ofc. ;).

Please, do the stop command, when I relog I get error:
Code:
[11/06/2009 16:48:10] Lua Script Error: [TalkAction Interface] 
[11/06/2009 16:48:10] in a timer event called from: 
[11/06/2009 16:48:10] data/talkactions/scripts/rainbow_outfit.lua:onSay

[11/06/2009 16:48:10] luaGetCreatureOutfit(). Creature not found

[11/06/2009 16:48:10] Lua Script Error: [TalkAction Interface] 
[11/06/2009 16:48:10] in a timer event called from: 
[11/06/2009 16:48:10] data/talkactions/scripts/rainbow_outfit.lua:onSay

[11/06/2009 16:48:11] data/talkactions/scripts/rainbow_outfit.lua:3: attempt to index a boolean value
[11/06/2009 16:48:11] stack traceback:
[11/06/2009 16:48:11] 	data/talkactions/scripts/rainbow_outfit.lua:3: in function <data/talkactions/scripts/rainbow_outfit.lua:1>
 
Last edited:
Code:
local function outfit(params)
	local _outfit = {
		lookType = getCreatureOutfit(params.player).lookType,
		lookHead = math.random(1, 115),
		lookBody = math.random(1, 115),
		lookLegs = math.random(1, 115),
		lookFeet = math.random(1, 115)
	}
	doSetCreatureOutfit(params.player, _outfit, -1)
	if (getPlayerStorageValue(params.player, 77889) == 1) then
		addEvent(outfit, 200, params)
	end
end

function onSay(cid, words, param, channel)
	if (param == "stop") then
		setPlayerStorageValue(cid, 77889, 0)
	else
		local params = {}
		params.player = cid
		addEvent(outfit, 200, params)
		setPlayerStorageValue(cid, 77889, 1)
	end
	return FALSE
end

Start: !rainbow
Stop: !rainbow stop

@UP:
When i've added stopEvent(outfit) it didn't stop doing event.
 
This is my version

Lua:
local colors = {94, 81, 79, 88, 18, 11, 92, 128}
local storage = 65535

function onSay(cid, words, param, channel)

	if(param == "on") then
		if getPlayerStorageValue(cid, storage) < 1 then
			if doPlayerRemoveMoney(cid, 5000) == TRUE then
				local event = addEvent(changeOutfit, 10, cid)
				setPlayerStorageValue(cid, storage, 1)
				return TRUE
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough money.")
				return TRUE
			end
		else
			return TRUE
		end
	elseif(param == "off") then
		if getPlayerStorageValue(cid, storage) > 0 then
			setPlayerStorageValue(cid, storage, 0)
			return TRUE
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have rainbow outfit on.")
			return TRUE
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Use !rainbow on-off.")
		return TRUE
	end
	return TRUE
end

function changeOutfit(cid)

local randomHead = colors[math.random(#colors)]
local randomLegs = colors[math.random(#colors)]
local randomBody = colors[math.random(#colors)]
local randomFeet = colors[math.random(#colors)]

local outfit = getCreatureOutfit(cid)
local tmp = {}

	if getPlayerStorageValue(cid, storage) > 0 then
		tmp = outfit
		tmp.lookType = outfit.lookType
		tmp.lookHead = randomHead
		tmp.lookLegs = randomLegs
		tmp.lookBody = randomBody
		tmp.lookFeet = randomFeet
		tmp.lookAddons = outfit.lookAddons

		doCreatureChangeOutfit(cid, tmp)
		local event = addEvent(repeatChangeOutfit, 10, cid)
		return TRUE
	else
		stopEvent(event)
		return TRUE
	end
end

function repeatChangeOutfit(cid)

local randomHead = colors[math.random(#colors)]
local randomLegs = colors[math.random(#colors)]
local randomBody = colors[math.random(#colors)]
local randomFeet = colors[math.random(#colors)]

local outfit = getCreatureOutfit(cid)
local tmp = {}

	if getPlayerStorageValue(cid, storage) > 0 then
		tmp = outfit
		tmp.lookType = outfit.lookType
		tmp.lookHead = randomHead
		tmp.lookLegs = randomLegs
		tmp.lookBody = randomBody
		tmp.lookFeet = randomFeet
		tmp.lookAddons = outfit.lookAddons

		doCreatureChangeOutfit(cid, tmp)
		local event = addEvent(changeOutfit, 10, cid)
		return TRUE
	else
		stopEvent(event)
		return TRUE
	end
end

You can add/remove colors.

Use !rainbow on-off to start or stop.
 
Last edited:
@up
Your is little bit better ;). Thanks all :*. Rep++ added to both.
But is there any faster way to add all color numbers? :p.
And when player have rainbow on, when he log out, I've got error in console. :p. Any way to auto switch off when player logout? ;>.
 
Last edited:
@colors

Changing "colors[math.random(#colors)]" to "math.random(1, last color number)" Ex: math.random(1, 118)

@error, i forget post this script:

go to data/creaturescripts, create a file and add this:
Lua:
local storage = 65535

function onLogout(cid)
	setPlayerStorageValue(cid, storage, 0)
	return TRUE
end

Add this to login.lua
Lua:
	registerCreatureEvent(cid, "RainbowOutfit")

Put this in creaturescripts.xml
Lua:
	<event type="logout" name="RainbowOutfit" event="script" value="SCRIPT_NAME.lua"/>
 
Back
Top