• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [Global Events], [Creature Script], [TFS 0.2.10] strange issu :D

Tymofek

New Member
Joined
May 12, 2011
Messages
86
Reaction score
3
Location
Santiago - CHILE
Hello!, i made a tiny script so if a player has cetain storage value == 1 then an animated text should come over in a 5 seconds interval.

but... looks like the interval its not working, when i reload global events, the animated text appears, but not anymore. (it should appear on 5 secs and on five secs again for ever!.)

[global events.xml]
PHP:
<globalevent name="animatedtext" interval="5" script="animated.lua"/>

[animated.lua]
PHP:
function onThink(interval, lastExecution)

for _, name in ipairs(getOnlinePlayers()) do
local cid = getPlayerByName(name)
if getPlayerStorageValue(cid, 4545) == 1 then
doSendMagicEffect(getPlayerPosition(cid),12)
doSendAnimatedText(getPlayerPosition(cid), "LOL!", TEXTCOLOR_BLUE)
end
end
end

looks fine but only works when i reload then never.

so i tought i could use the onthing function on creaturescript, but... i dont know how to set up an interval xD.

Thx in advance :)
 
Code:
function onThink(interval, lastExecution, thinkInterval)
for _, pid in ipairs(getPlayersOnline()) do
    if getPlayerStorageValue(pid, 4545) == 1 then
         doSendAnimatedText(getCreaturePosition(pid), "LOL!", math.random(1,255))
    end
end
return TRUE
end

Try that.
 
Thx for your comment i did try it but that didnt work in 3 attemps the first: is getOnlinePlayers. fixed it
second: player not found
thirth: storage problem.

well, i fixed all but doesnt work.

my script the one i posted at the top works as i sayed, but am sure there is a problem with the global events on the TFS 0.2.10 because it doesnt repeat the script as it should. only works one time just when i reload but doesnt keep on doing it!.

there must be some fix to help it :S, then i tought that in creaturescript the function on think exists too! so maybe there is a way to repeat the script in certain interval.

well i hope someone can help!
 
SOLVED MY SELF :D (as almost always :S)

as i sayed before my script works only once so i created a loop like this.

in the global events

PHP:
function onThink(interval, lastExecution, thinkInterval)
for _, name in ipairs(getOnlinePlayers()) do
local cid = getPlayerByName(name)


function animated ()
doSendMagicEffect(getPlayerPosition(cid),12)
doSendAnimatedText(getPlayerPosition(cid), "LOL!", TEXTCOLOR_BLUE)
addEvent(animated,5000)
end

if isPlayer(cid) then
addEvent(animated, 5000)
end
end


this will do the animated text function in a loop for ever. but it was only executed once.

:S

sadly i found this solution without being helped :S

SOLVED!
 
Back
Top