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

Lua Advanced lua script

Lua:
local t =   {
	[7440] = {outfit='mew', outfitn='rat', text='Fly, mew!', dtext='Go down, mew!'}
}       
local thisCondition = createConditionObject(CONDITION_OUTFIT)
setConditionParam(thisCondition, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(thisCondition, {lookType = 354, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0})
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v, r, s = getCreaturePosition(cid), t[item.itemid], 100
	local pos = {x = v.x, y = v.y, z = 6}
	local posd = {x = v.x, y = v.y, z = 7}
	if r then
		if v.z == 7 then
			if getTileItemById(pos, 460).uid > 0 then
				if doTeleportThing(cid, pos, false) then
					doSendMagicEffect(pos, 10)
					doCreatureSay(cid, r.text, 19)
					return doAddCondition(cid, thisCondition)
				else
					return doPlayerSendCancel(cid, 'You can\'t fly here.')
				end    
			else
				return doPlayerSendCancel(cid, 'You can\'t fly here.')
			end
		elseif v.z == 6 then
			if doTeleportThing(cid, posd, false) then
				doSendMagicEffect(posd, 10)
				doCreatureSay(cid, r.dtext, 19)
				return doRemoveCondition(cid, CONDITION_OUTFIT)
			else
				return doPlayerSendCancel(cid, 'You can\'t land here.')
			end
		else
			return doPlayerSendCancel(cid, 'You can\'t fly here.')
		end
	else
		return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'There has been some error, try contacting a staff member.')
	end
end

if you are good at scriping, why dont you just try.. add a new outfit? its not to hard to add it in this script.
 
I know, but its dont work on 0.3.5

First error
Code:
[07/06/2010 20:37:49] Lua Script Error: [Action Interface] 
[07/06/2010 20:37:49] data/actions/scripts/mountsystem.lua

[07/06/2010 20:37:49] luaAddOutfitCondition(). Condition not found
[07/06/2010 20:37:50] Reloaded actions.

second error wen i try to use the item:
Code:
[07/06/2010 20:38:40] Lua Script Error: [Action Interface] 
[07/06/2010 20:38:40] data/actions/scripts/mountsystem.lua:onUse

[07/06/2010 20:38:40] data/actions/scripts/mountsystem.lua:19: attempt to index local 'r' (a nil value)
[07/06/2010 20:38:40] stack traceback:
[07/06/2010 20:38:40] 	data/actions/scripts/mountsystem.lua:19: in function <data/actions/scripts/mountsystem.lua:17>
 
Last edited:
taken from a otserv.com.br, scripted @ TFS 0.3.6
Kaotar's [Sistema] Rain System
globalevent
Lua:
local rain = Rain:new()

function onThink(interval, lastExecution)
    local minX = 0
    local minY = 0
    local maxX = 120
    local maxY = 150

    local frompos = {x=math.random(minX, maxX), y=math.random(minY, maxY), z=7}
    local topos = {x=math.random(frompos.x, maxX), y=math.random(frompos.y, maxY), z=7}

    local effects = {
        snow = {
            disteffect = CONST_ANI_SNOWBALL,
            effect = CONST_ME_ICETORNADO
        },
        rain = {
            disteffect = CONST_ANI_ICE,
            effect = CONST_ME_LOSEENERGY
        }
    }
    random = math.random(0, 10)
    if (random == 0) then
        rain.chance = math.random(10,50)
        rain:start({fromPos = frompos, toPos = topos}, effects.snow, 300, math.random(100, 500))
    else
        rain.chance = math.random(20,100)
        rain.createItem = {chance = math.random(0,10), item = {itemid = 2016, type = 1}}
        rain:start({fromPos = frompos, toPos = topos}, effects.rain, math.random(100, 1000), math.random(100, 350))
    end
    return TRUE
end

lib
Lua:
-- Features:
    -- chance = OBJECT.chance = INT
    -- createItem = OBJECT.createItem = {chance = INT, item = {itemid = INT, type = INT}}


Rain = {ignoreIds = {4526}}

function Rain:new()
    local obj = {}
    setmetatable(obj, self)
    self.__index = self
    return obj
end
function Rain:getPositionInArea(fromPos, toPos)
    self.positions = {}
    for Y = fromPos.y, toPos.y do
        for X = fromPos.x, toPos.x do
            if (getTileThingByPos({x=X, y=Y, z=7, stackpos=0}).itemid ~= 0) then
                if not (string.match(string.lower(getItemNameById(getTileThingByPos({x=X, y=Y, z=7, stackpos=0}).itemid)), "water")) then
                    table.insert(self.positions, {x=X, y=Y, z=Z})
                end
            end
        end
    end
    return true
end

function Rain:doRain(position, disteffect, effect)
    if (self.duraction ~= self.executed) then
        local chance = self.chance or 100
        if (math.random(0, 1000) <= chance) then
            for Z = 0, 7 do
                if (getTileThingByPos(({x = position.x, y = position.y, z = Z})).itemid ~= 0) then
                    doSendDistanceShoot({x = position.x - 7, y = position.y - 5, z = Z}, {x = position.x, y = position.y, z = Z}, disteffect)
                    doSendMagicEffect({x = position.x, y = position.y, z = Z}, effect)
                    if (self.createItem) then
                        if (math.random(0, 1000) <= self.createItem.chance) then
                            if (isInArray(self.ignoreIds, getTileThingByPos({x=X, y=Y, z=Z, stackpos=0}).itemid) == FALSE) then
                                local item = doCreateItem(self.createItem.item.itemid, self.createItem.item.type, {x=position.x, y=position.y, z=Z})
                                doDecayItem(item)
                            end
                        end
                    end
                    break
                end
            end
        end
        return true
    else
        return false
    end
end

function Rain:start(positions, effects, duraction, delay, var)
    self:getPositionInArea(positions.fromPos, positions.toPos)
    if not (self.positions[1]) then
        return false
    end
    self.delay = delay
    self.var = var or self
    self.effects = effects
    self.duraction = duraction
    self.executed = 0
    addEvent(doCallback, self.delay, {var=self.var})
    return true
end

function doCallback(p)
    for _, v in pairs(p.var.positions) do
        if not (p.var:doRain(v, p.var.effects.disteffect, p.var.effects.effect)) then
            return true
        end
    end
    addEvent(doCallback, p.var.delay, {var=p.var})
    p.var.executed = p.var.executed+1
end

Lua:
dofile(getDataDir() .."globalevents/lib/Rain.lua")

dofile(getDataDir() .."globalevents/lib/Rain.lua")

    local minX = 0
    local minY = 0
    local maxX = 120
    local maxY = 150

Bom essa configuração muda apenas a posição das chuvas se quiser mudar a densidade da chuva mude a linha rain.chance = math.random(20,100), lembrando não ultrapasse muito do valor 100, pois pode deixa a chuva muito feia.
Para entender melhor a função rain:start(positions, effects, duraction, delay) postarei o que cada argumento significa.
.buttonspoi2 {height: 20px; width: 60px; margin: 10px 10px 10px 10px; font-size: 10px; background-color: #F8DAB2; border: solid 1px;}
positions -> sera um tabela com 2 posições chamadas fromPos e toPos. Exemplo : {fromPos = {x=10, y=10, z=7}, toPos={x=20, y=20, z=7}
effects -> será uma tabela com os efeitos mandando no solo e de cima para baixo. Exemplo: rain = {disteffect = CONST_ANI_ICE, effect = CONST_ME_LOSEENERGY }
duraction -> será o numero de vezes que ira "chover", ou seja, cair efeitos, dando assim a duração da chuva. Exemplo: 100
delay -> será a diferença do tempo de cada pingo de chuva influencia a densidade da chuva, lembrando que também tem a variável chance


Para tornar a chuva mais intensa diminua o delay e aumente o duraction e a chance, mais fraca o inverso. Para chuvas mais duradouras aumente o delay e o duraction.
Também é possível que o script crie "poças de agua" isso é configurado na linha rain.createItem = {chance = math.random(0,10), item = {itemid = 2016, type = 1}}. Para aqueles que sabem mexer em script é possível fazer chover meteoros mudando os efeitos e varias outras coisas a sua imaginação.
Para mudar de quanto enquanto tempo a chuva ira acontecer devera mudar a tag do globalevents.xml na parte de interval.

Considerações finais: Não é aconselhável usar a snow do jeito que está configurado, pois está bem feio, também há um erro que sempre que ocorre uma nova chuva se uma antiga esta acontecendo, a velha para, e a novo começa. É fácil arrumar, porém eu só não arrumei pois isso pode acarretar novos bugs.
 
sorry, i won't edit in firefox, lua code gets messy
raind.jpg
 
Thx cybershot! i'll try it and see if it works :)

EDIT: It works almost as i want it ! :D <333

but how do i add my own effect? :p
 
Last edited:
Back
Top