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

GlobalEvent Rain System [HOT]!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,286
Location
Sweden?
Hiho Everyone,

I was bored this morning and just scripted something for fun.

Desc: Its simple to install. Well there is other rain systems which is more advanced than mine. But well its in beta phase and i need bit help. This rain system should not cause any laggs i think! Since it only rains around your player and not over the whole map! Where you go, the rain will follow you!
You can configure: When should i start rain, From drops to rain storm!
And also when it hits water tiles it make splashes on the water!
Also it will only rain on ground and floor up. Not under 7!

Missing:
If player is under a itemid, it should hit over that itemid. Such as roof, inside a building, under a big tree and etc..
Well, that is the only problem, its raining inside the buildings!


Tested on 0.3.6 & 0.4

LrRwhb.png


At globalevents/globalevents.xml
XML:
<globalevent name="Rain" interval="1" event="script" value="rain.lua"/>
For 0.4:
XML:
<globalevent name="Rain" interval="1000" event="script" value="rain.lua"/>
XML:
<globalevent name="RainTime" interval="36000" event="script" value="raintime.lua"/>
For 0.4:
XML:
<globalevent name="RainTime" interval="3600000" event="script" value="raintime.lua"/>

At globalevents/scripts create new lua and name it "rain.lua" and paste the code below:
Lua:
local Cyko = {
	interval = 1000, --1000Recommended. But here you decide until it starts raining as hell!
	waterid = {4608, 4609, 4610, 4611, 4612}
}
 
 
function Rain(cid)
if getStorage(3000) == 1 then
for _, cid in ipairs(getPlayersOnline()) do
	if isCreature(cid) then
		if getThingPos(cid).z <= 7 then
		local pos = getThingPos(cid) 
		local frompos = getThingPos(cid)
		pos.x = pos.x + math.random(-9,9)
		pos.y = pos.y + math.random(-9,9)
		frompos.x = pos.x - 9
		frompos.y = pos.y - 9  
			for i = 1,#Cyko.waterid do
				if getTileItemById(pos, Cyko.waterid[i]).uid > 0 then
					doSendMagicEffect(pos,CONST_ME_WATERSPLASH)
				else
                                       doSendDistanceShoot(frompos, pos, CONST_ANI_ICE)
			               doSendMagicEffect(pos,CONST_ME_LOSEENERGY)
                           end
					end
				end
			end
		end
	end
end
 
function isUnderRoof(cid)
	--We need to figure this out!
end
 
 
function onThink(interval, lastExecution)
	if getStorage(3000) == 1 then
		for _, cid in ipairs(getPlayersOnline()) do
				if getThingPos(cid).z <= 7 then
					for i = 1, 5 do
						addEvent(Rain, i*Cyko.interval, cid)
						end
					end
				end
			end
	return true
end

At globalevents/scripts create new lua and name it "raintime.lua" and paste the code below:
Lua:
function onThink(interval, lastExecution)
	if getStorage(3000) == -1 then
		doSetStorage(3000, 1)
	else
		doSetStorage(3000, -1)
		end
	return true
end

Enjoy!
 
Last edited:
You sure :/? Well, i tried on real tibia map it didnt gave any laggs. Even i had 4gb ram on my home computer.

- - - Updated - - -

Well, now i figure out what caused lagg. Hopefully this will help a bit. Until i find a way to optimize it more.
 
maybe something that if some players are close enough just a rain is created, for no make a lot of rains in a small place
 
maybe something that if some players are close enough just a rain is created, for no make a lot of rains in a small place
Well, its open-source on the script xD If someone want to help. Go ahead.
 
If you fix so it rain over whole map without laggs, it will be nice ^_^
 
^ i think that that is impossible, this script can be improved with if you are in X area just rain in your visible area, and if 2 players are close enough, don't make 2 rains because if there are 20 chars it will be a super spam, make just one for all the chars , and you dont need to make things were nobody will see it, that is just lag
 
Well i will improve what tibiamakers said. But im to bussy now.
 
Not only spam, but the overall performance is really poor.
You are getting online players every second more than once.
 
Not only spam, but the overall performance is really poor.
You are getting online players every second more than once.

Well, i dont know what to say :/
Someone have to try with alot of players. If it cause lagg or not :/ Mcs would be fine.

- - - Updated - - -

Well, now i made it check radius around the player, if there is more than 1. It stops raining. Now need to figure out how to make 1 of them rain. Any suggestions?
 
It is by player pos.
 
You should loop from z 0 t z 7 and check if there is a tile, so it doesn't rain inside buildings.
But that will cost even more performance..
 
Why not simply do it client sided?..
You got OTClient which allows you to modify that.

otherwise you got something called the "Island" approach

which basically groups multiple groups of players into one area, meaning it would only need to send 1 effect. for 1 person.
Yet. if you send 1 magic effect and 20 people are on screen it still needs to send packets to 20 people.
 
Back
Top