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

Problem with random interval

phern

alysiaots.com
Joined
Nov 2, 2008
Messages
195
Reaction score
2
Location
Poland
Hi there.
I am trying to do a script that every random ammount of time (3 to 4 secs) repeats some effect.
I've found something like that:

l
PHP:
ocal config = {
positions = {
["1"] = { x = 1074, y = 1059, z = 8 },


},


}


function onThink(cid, interval, lastExecution)
for text, pos in pairs(config.positions) do
doSendMagicEffect(pos, 5)


end

return TRUE
end

and

PHP:
<globalevent name="EffectTiles" interval="2000" event="script" value="effect.lua"/>

But i want the interval to be random. Tried with

PHP:
<globalevent name="EffectTiles" interval="math.random(3000, 4000)" event="script" value="effect.lua"/>
and also to delete interval from globalexents.xml and change
function onThink(cid, interval, lastExecution) to function onThink(cid, math.random(3000, 4000), lastExecution)

also not working.

Could someone help me, please?
 
maybe that works:
Lua:
local config = { 
	positions = { 
		["1"] = { x = 1074, y = 1059, z = 8 }, 
	} 
} 

local function effects()
for text, pos in pairs(config.positions) do 
doSendMagicEffect(pos, 5)
end

function onThink(cid, interval, lastExecution) 
	addEvent(effects, math.random(3,4)*1000) 
return TRUE 
end
 
Very bad.. never use in .xml math randoms, never works o.o!
Lua:
<globalevent name="EffectTiles" interval="math.random(3000, 4000)" event="script" value="effect.lua"/>
FAIL!!

take loot:
globalevents.xml
Lua:
<globalevent name="EffectTile" interval="3000" script="effectile.lua"/>

script:

Lua:
local config = {
positions = {
["1"] = { x = 1074, y = 1059, z = 8 },

},

effects = {
CONDITION_PARAM_DELAYED

}
}


function onThink(cid, interval, lastExecution)
for text, pos in pairs(config.positions) do
doSendMagicEffect(pos, math.random(1, #config.effects))
doSendAnimatedText(pos, text, math.random(1, 255))

end

return TRUE
end
 
@up yee saw this script, and not really randomizing anything but the type of effects. It don't have to be on global events. I just wanted to make a script that is repeating the effect every random ammount of time. Is this really impossible to do?
 
Back
Top Bottom