Spotlight controlled by the player

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Spotlight controlled by the player

Post by bdbodger »

Well I have written another script this one is for spotlights that are controlled by the player . To use it make script_models model miscobj/searchlightbase.tik and give them all the same targetname . Then execute the script like this .

exec global/player_spotlight.scr mytargetname

The lights starts off and while you press the use key while standing close to them they light up . It will follow your view :roll: .

player_spotlight.scr
Image
User avatar
G3mInI
First Lieutenant
Posts: 187
Joined: Sat Jun 29, 2002 3:49 am

Post by G3mInI »

Will this work in multiplayer ? Specifically using it in a server side only mod ?
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

yes serverside mod . You can spawn the base . Key your finger on the use button while standing close to it or the light goes out .
Image
User avatar
G3mInI
First Lieutenant
Posts: 187
Joined: Sat Jun 29, 2002 3:49 am

Post by G3mInI »

Sweet! Great job bdbodger. Keep em coming! I have learned a great deal from your scripts, as well as others here. Best place to get information for the game as far as I am concerened.

G3mInI
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

working on version 2 with keys you can set like color of the light and I am going to make it on off . For example but an mg gun beside it and the use key will turn on the light as well as letting you use the gun . Also a key to set health of the light and if it will be destoyable or not . Right now it is so it will just be shot out right away and it won't be useable anymore . Any other suggestions are welcome .
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

light

Post by tltrude »

Your mod is very cool!!! It would be nice if the light at the end of the beam stayed on all the time and not just when it hits somthing.

Image

In the above screenshot it is hitting a small object on a pole. But, if I move it slightly off the object, only the hedge behind is lit up.
Last edited by tltrude on Sun Aug 01, 2004 6:57 pm, edited 2 times in total.
Tom Trude,

Image
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

that looks cool, but for a flashlight mod, you might want to make the spotlight scale smaller.
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
SolidScope
Lance Corporal
Posts: 19
Joined: Tue Jul 13, 2004 1:24 am

Post by SolidScope »

I did what he said to do and mine didn't work. All it did was make the base of the light. The little half circle thing. Any ideas?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

targetname

Post by tltrude »

You have to put the targetname you gave to the base at the end of the line, like this.

level waittill prespawn

exec global/player_spotlight.scr
mytargetname

And, that script has to be in main/global.
Tom Trude,

Image
User avatar
G3mInI
First Lieutenant
Posts: 187
Joined: Sat Jun 29, 2002 3:49 am

Post by G3mInI »

Master-Of-Fungus-Foo-D wrote:that looks cool, but for a flashlight mod, you might want to make the spotlight scale smaller.
umm all i got to say to that is :lol:

If you look closely I believe he is standing next to a spotlight he spawned. It is not mounted to the top of his weapon.

bdbodger I have implemented this script of yours into a server side mod of snow park, I put a spotlight at the top of each sniper stand on one of the railings.. great script... works and looks pretty cool.

Peace,
G3mInI
User avatar
SolidScope
Lance Corporal
Posts: 19
Joined: Tue Jul 13, 2004 1:24 am

Re: targetname

Post by SolidScope »

tltrude wrote:You have to put the targetname you gave to the base at the end of the line, like this.

level waittill prespawn

exec global/player_spotlight.scr
mytargetname

And, that script has to be in main/global.
Did that, nothing happened.

I spawned a script_model in my map. Gave it the key model and value of the .tik thing like I should. Gave it the targetname of flashlight. Then went into the maps .scr file, and after waittill prespawn put exec global/player_spotlight.scr flashlight
Image
User avatar
G3mInI
First Lieutenant
Posts: 187
Joined: Sat Jun 29, 2002 3:49 am

Post by G3mInI »

Well it worked fine for me... did u actually put player_spotlight.scr into a folder called global and add it to the .pk3 file ?

My code ended up looking like this.. of course you would have a different origin and a different targetname....

First I created a thread after level waittill prespawn like so"

thread spawn_the_lights:

right after that statement I have:
exec global/snowy1_spotlight.scr sniper_spot // I renamed player_spotlight.scr to snowy1_spotlight.scr


then further down at the bottom of my script I have this thread:

spawn_the_lights:

local.spotty1 = spawn script_model
local.spotty1 model "miscobj/searchlightbase.tik"
local.spotty1.targetname = sniper_spot
local.spotty1.origin = ( 3885.64 -5395.82 570.00 )
local.spotty1.angles = (0.00 90.00 0.00 )
end


Now that works just fine for me and for the other 3 lights I have in the spawn_the_lights thread. All have the same targetname of sniper_spot.

G3mInI
User avatar
SolidScope
Lance Corporal
Posts: 19
Joined: Tue Jul 13, 2004 1:24 am

Post by SolidScope »

When I sayid "spawn" I meant go to my new bot map in radient, make a script_model, and give it the key model and value of the .tik. And also give it the targetname that I put after I exec the file in the maps .scr. Yes I did put it in the global folder. I'm not some n00b. But I'll try it again.
Image
Splaetos
Major General
Posts: 730
Joined: Tue Jan 20, 2004 2:55 pm
Contact:

Post by Splaetos »

that looks great BD =)
When I am king, you will be first against the wall~
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Well tom with a real searchlight if it does not hit anything you don't see the light at the end of the beam either .
Image
Post Reply