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

[TFS 1.0] Changing Lights Within An Area

Jaed Le Raep

★Gaeming★
Joined
Sep 3, 2007
Messages
1,295
Reaction score
441
Hey guys, I've been really into thinking of what are some original, or at least rare, scripting ideas I could request, so that they'd at least be able to the public (quickly relearning scripting in the process).

Anyway, this idea would basically make is so that the designated area would have it's light settings constantly changing, in random intervals and colors, as if it were a nightclub or bar. I believe this would be accomplished via LUA. For the config, it would be nice if the color range, the area dimensions, and intervals would be easily changeable.
 
Well, you may swap floor ids. I know it's not exact thing you expected, but I can't think of any better solution. You may also assign light flags to creatures, but for items, I think it's otb-sided.
 
Code:
local pos = {x=1594, y=1602, z=8}
local disco = getSpectators(pos, 4, 4, false)

if disco then
    for _, cid in ipairs(disco) do
        if isPlayer(cid) then
            doSetCreatureLight(cid, 11, math.random(0,120), 30000)
        end
    end
end

That should work I guess...
 
Code:
local pos = {x=1594, y=1602, z=8}
local disco = getSpectators(pos, 4, 4, false)

if disco then
    for _, cid in ipairs(disco) do
        if isPlayer(cid) then
            doSetCreatureLight(cid, 11, math.random(0,120), 30000)
        end
    end
end

That should work I guess...

What function would that be? onThink or a movement?
 
onThink didn't work, unfortunately..

7GfP7.png


Code:
<globalevent name="Creston Bar" interval="100000" script="creston bar.lua" />

Code:
local pos = {x=994, y=1075, z=7}
local disco = getSpectators(pos, 4, 4, false)

function onThink(interval)
if disco then
    for _, cid in ipairs(disco) do
        if isPlayer(cid) then
            doSetCreatureLight(cid, 11, math.random(0,120), 30000)
        end
    end
end
end
 
Last edited:
It will be easier if you make NPCs and set them an item outfit, so they'd be the one with the color stuff
Then it's just making an onThink event in their .lua
 
It will be easier if you make NPCs and set them an item outfit, so they'd be the one with the color stuff
Then it's just making an onThink event in their .lua

Don't mean to be one to request hand-holding, but since I honestly have no idea what route to go down to do this, would you be able to?
 
I just tested the script and works fine, but I don't know why the console is showing that error.

@EDIT: Lol, just add a return true before the last end.
 
Last edited:
Code:
local pos = {x=994, y=1075, z=7}
local disco = getSpectators(pos, 4, 4, false)

function onThink(interval)
if disco then
for _, cid in ipairs(disco) do
if isPlayer(cid) then
doSetCreatureLight(cid, 11, math.random(0,120), 30000)
end
end
end
return true
end
 
Yeah.. it's still not working for me. There's no console error as I can tell, and I have 1 character in the bar, in the position in the script. For the record, this is my XML.

Code:
<globalevent name="Creston Bar" interval="30000" script="creston bar.lua" />

Eidt: I'm just feeling really inept, especially with @Colors stating that it's working on your end. I just don't get how it is, because I've had it scripted for a couple days and it doesn't work on my end. The current version of my script can be seen below.

Code:
local pos = {x=994, y=1075, z=7}
local disco = getSpectators(pos, 5, 4, false)

function onThink(interval)
if disco then
    for _, cid in ipairs(disco) do
        if isPlayer(cid) then
            doSetCreatureLight(cid, 9, math.random(0,120), 1000)
        end
    end
end
return true
end
 
Last edited:
It finally worked on my end o.o But only on my GM character and only after I've reloaded global events.. I tried to do some login registration but it totally didn't work out. I then tried to make it a creaturescript, with login registration, that also didn't work. It's a really awesome script and pretty much what I envisioned, so thank you so much for getting this much accomplished for me.
 
make it a creatureevent, Register it at Login.lua and it should work for every character.
wild guess :D

EDIT:
If you do a globalevent then you have to execute the Event AND stand in the area for it to work.
if you want to let it happen as soon as a Player walks into the bar, then its a creatuerevent
 
make it a creatureevent, Register it at Login.lua and it should work for every character.
wild guess :D

EDIT:
If you do a globalevent then you have to execute the Event AND stand in the area for it to work.
if you want to let it happen as soon as a Player walks into the bar, then its a creatuerevent

I already tried the creatureevent method, it really did not work.. in creatureevent.xml I registered it as a think event... but maybe I did that wrong.
 
@Zyntax here here :)

Code:
<event type="login" name="CrestonBar" script="creston bar.lua"/>

Code:
local pos = {x=999, y=1079, z=8}
local disco = getSpectators(pos, 3, 3, true)

function onLogin(cid)
if disco then
    for _, cid in ipairs(disco) do
            doSetCreatureLight(cid, 11, math.random(0,120), 10)
        end
end
return true
end

And in login.lua

Code:
player:registerEvent("CrestonBar")
 
Last edited:
change your lines to this:
Code:
<event type="think" name="CrestonBar" script="creston bar.lua"/>
and us onThink instead of onLogin
Code:
function onThink(cid)
and it will work :D
 
Last edited:
Back
Top