AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Light an area (How to ?) (https://forums.alliedmods.net/showthread.php?t=56243)

ConnorMcLeod 06-09-2007 16:43

Light an area (How to ?)
 
Hi,

Is it possible to light a closed area (like a room) during a certain time, like for 30 seconds, or waiting some one switch of this light ?

Rolnaaba 06-09-2007 17:35

Re: Light an area (How to ?)
 
http://www.amxmodx.org/funcwiki.php?go=func&id=371
i.e.:
for pitchblack:
Code:
set_lights("a");

for as bright as you can get it:
Code:
seta_lights("z");

to return to normal:
Code:
set_lights("#OFF");
have fun

FYI:
Code:
#include <engine>

regalis 06-09-2007 17:40

Re: Light an area (How to ?)
 
@rolnaaba: set_lights() is for the whole map ;)

Code:

spawn_light(origin[3])
{
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY, origin)
    write_byte(TE_DLIGHT);// 27
    write_coord(origin[0]);  // x
    write_coord(origin[1]);  // y
    write_coord(origin[2]);  // z
    write_byte(100); // radius in 10's
    write_byte(255); // r
    write_byte(255); // g
    write_byte(255); // b
    write_byte(8);    // life in 10's
    write_byte(60);  // decay rate in 10's
    message_end();
}

Just set the origin where the light should be...and maybe the color and radius...don't ask me what decay is..0o

greetz regalis

Zenith77 06-10-2007 09:37

Re: Light an area (How to ?)
 
Please note I don't understand the measurements, or how to correctly set the life for 30 seconds but you will see that decay affects how fast the light withdraws over its lifespan, i.e "shrinking".

Rolnaaba 06-10-2007 10:49

Re: Light an area (How to ?)
 
I know set_lights is for whole map, thought thats what he wanted O.o but I was wrong

ShTaM 06-10-2007 11:34

Re: Light an area (How to ?)
 
But how to let during 30 secondes and get a very nice light ?

regalis 06-10-2007 12:24

Re: Light an area (How to ?)
 
I Think this:
Code:

write_byte(8);    // life in 10's
means the light stays 8/10 seconds...

Now use this
Code:

write_byte(10);    // life in 10's
and do a set_task(1.0, ....)
and the task should repeat 30 times..0o
Maybe add a second dlight at the half time to prevent flickering..
It should then pulse or something...
Or maybe adjust the "decay" thingy ;)

greetz regalis

ShTaM 06-10-2007 13:54

Re: Light an area (How to ?)
 
Code:


public Light()
{
 message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
 write_byte(27);
 write_coord(0);
 write_coord(0); // y
 write_coord(0); // z
 write_byte(50); // radius
 write_byte(255); // red
 write_byte(255); // green
 write_byte(255); // blue
 write_byte(10); // life in 10's
 write_byte(30); // decay rate in 10's
 message_end();
 if ( AddLum < 500 )
 {
  AddLum++
  set_task(0.01,"Light")
 }
 else if ( AddLum == 500 )
 {
  AddLum = 0
 }
}

I can't get a constant light, it's boring :cry:.

regalis 06-10-2007 14:21

Re: Light an area (How to ?)
 
Quote:

Originally Posted by ShTaM (Post 487760)
Code:


public Light()
{
 message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
 write_byte(27);
 write_coord(0);
 write_coord(0); // y
 write_coord(0); // z
 write_byte(50); // radius
 write_byte(255); // red
 write_byte(255); // green
 write_byte(255); // blue
 write_byte(10); // life in 10's
 write_byte(30); // decay rate in 10's
 message_end();
 if ( AddLum < 500 )
 {
  AddLum++
  set_task(0.01,"Light")
 }
 else if ( AddLum == 500 )
 {
  AddLum = 0
 }
}

I can't get a constant light, it's boring :cry:.

Do you set the origin of the light?
This is a local dynamic light not for the whole map...
You have to set a specific location for this ;)
If you want to set the light for the whole map use what rolnaaba postet (set_lights() )...
Btw.: This --> set_task(0.01,"Light") will be set_task(0.1,"Light")
Shorter periods than 0.1 aren't supported..
But that seems ok...

greetz regalis

mogel 06-10-2007 14:46

Re: Light an area (How to ?)
 
Hi,

Quote:

Originally Posted by ShTaM (Post 487760)
I can't get a constant light, it's boring :cry:.

no possible with TE_DLIGHT ... max. constant view ist 25.5 seconds (life -> 255) ... the timing (hl1-engine problem?) is very bad to start a 2nd TE_DLIGHT on the same position without jitter :|

hand, mogel


All times are GMT -4. The time now is 10:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.