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

TalkAction New! RAINBOW SYSTEM with config by Dubler :D

Dubler

PHP, LUA, C++
Joined
Aug 3, 2009
Messages
268
Reaction score
11
Location
Poland
Hi,
i'm greenhorn in lua (3 days of learning). I decided to post my first script - 100% by me.
[video=youtube;4QA8ot6jIYo]http://www.youtube.com/watch?feature=player_profilepage&v=4QA8ot6jIYo[/video]
Step 1

YourOTS\data\lib\050-function.lua | At the end, add this:
Code:
czekaj = coroutine.yield
function czekanie(c)
    if(coroutine.status(c) ~= 'dead') then
        local _, czas = coroutine.resume(c)
        addEvent(czekanie, czas, c)
    end
end
function zacznijCzekac(f)
    if(type(f) == 'function') then
        local c = coroutine.create(f)
        czekanie(c)
    end
end
function timeString(timeDiff)
    local dateFormat = { 
        {"day", timeDiff / 60 / 60 / 24},
        {"hour", timeDiff / 60 / 60 % 24},
        {"minute", timeDiff / 60 % 60},
        {"second", timeDiff % 60}
    }
    local out = {}
    for k, t in ipairs(dateFormat) do
        local v = math.floor(t[2])
        if(v > 0) then
            table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
        end
    end
    return table.concat(out)
end

Step 2

YourOTS\data\talkactions\scripts\rainbowsys.lua | create and add this:
Code:
function onSay(cid, words, param)
--config ## Script By Dubler from otland.net ##
local t = 5 -- time in seconds
local fr = 4 -- frequency, changes per second
--endconfig ## Script By Dubler from otland.net ##
local frequency = (1000 / fr)
local timevar = (fr * t)
 zacznijCzekac(function()
	for i = 1, timevar do
		cc(cid)
		czekaj(frequency)
		local i = (i + 1)
	end
end)
return true
end
function cc(cid)
local head = math.random(133)
local body = math.random(133)
local legs = math.random(133)
local feet = math.random(133)
local myOutfit = getCreatureOutfit(cid)
local outfit = {lookType = myOutfit.lookType, lookHead = head, lookAddons = myOutfit.lookAddons, lookLegs = legs, lookBody = body, lookFeet = feet}
doSetCreatureOutfit(cid, outfit, (frequency +5))
end --## Script By Dubler from otland.net ##

Step 3

YourOTS\data\talkactions\talkactions.xml | At the end, add this:
Code:
	<talkaction words="/rainbow" event="script" value="rainbowsys.lua"/>

Plz, don't delete my footer. I'm sorry for my bad english ;s
Enjoy and rep me ++!

@down
yep, that's true. This script is only for very good dedicated servers... or acces only god/any support
 
Last edited:
script looks nice - but I think, that it can make ots slower if a lot of players will use it (maybe not, i'm not sure)
 
oh holy shit, it's so gay.

But is nice. haha'
funny.

Nice job
 
Shorter version. You don't need anything in 'data/lib'. Only this script:
Lua:
--config ## Script By Dubler from otland.net , update by P~ ##
local t = 5 -- time in seconds
local fr = 4 -- frequency, changes per second
--endconfig ## Script By Dubler from otland.net , update by P~ ##

local frequency = (1000 / fr)
local rainbowEvents = {}

function rainbowOutfit(cid, count)
	local newOutfit = getCreatureOutfit(cid)
	newOutfit.lookHead = math.random(133)
	newOutfit.lookBody = math.random(133)
	newOutfit.lookLegs = math.random(133)
	newOutfit.lookFeet = math.random(133)
	doSetCreatureOutfit(cid, newOutfit, frequency + 5)
	if(count >= 1) then
		rainbowEvents[getPlayerGUID(cid)] = addEvent(rainbowOutfit, frequency, cid, count - 1)
	end
end --## Script By Dubler from otland.net , update by P~ ##

function onSay(cid, words, param)
	if(rainbowEvents[getPlayerGUID(cid)] ~= nil) then
		stopEvent(rainbowEvents[getPlayerGUID(cid)])
	end
	rainbowOutfit(cid, t * fr)
	
	return true
end
It also block possibility to start more then 1 event for 1 player.
 
Back
Top