Scripts / [SOLVED] adding flashlight to a specific wepaon/object..is possible?

Author
Message
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 18th Sep 2019 16:49
Hi I dont know if this is the right board to post this discussi by since i think is a scripting question i'll try..

i would to know if the flashlgiht "light" can be associated to a specific obejct/weapon to that it can be used only when a specifc weapon is equipped..

my player has a flashlight hand model in place and i would to know if i can do that player uses flashlight only when the hand+flashlight hud is active
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB

The author of this post has marked a post as an answer.

Go to answer
PM
Belidos
3D Media Maker
3
Years of Service
User Offline
Joined: 23rd Nov 2015
Location: Hertfordshire
Posted: 18th Sep 2019 17:47 Edited at: 18th Sep 2019 17:47
I'm pretty sure there is, and it should be simple.

You would need:

1. A way to identify the weapon slot .....
2. A way to disable the flashlight ......
3. A way to enable the flashlight .....
4. a way to toggle the flashlight when it's enabled .....

I know we have all these commands, not sure which or how to use them though.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 18th Sep 2019 18:38
yes i know commands are here .. the problem is that i dont know how figure them right now.. lol
i came form c# and i'm learning lua atm so i was thinking someone did thi on the past so i could have a starting point to work on
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th Sep 2019 22:19
This post has been marked by the post author as the answer.
attach it to an always active object somewhere and fill in your flashlights "weapon name" the system has for it - details in the script
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 18th Sep 2019 23:43 Edited at: 19th Sep 2019 07:16
Quote: "attach it to an always active object somewhere and fill in your flashlights "weapon name" the system has for it - details in the script"


great Master ..you're a life saver...mant thanks ....works great but there a little bug since player can use flashlight "before" flashlight/item(colt1911 in this case) item is picked up and is not inteded to work this way...like if the F keyis enabled

but after player pickup flashlight for the first time script correclty works and if flashlight/items is not equipped player correcly cant use flashlight and F key is correcly disabled

plus i noticed that changing the default colt1911 with other weapon names (tried Magnum357,RPG,Shotgun to test) scritp dont work..
if i leave
local weapon_name = "modern\\colt1911"
all works fine..why? I'm missing something?

Edit solved the flashlight active at start issue adding


i dont know if is it the best ways since i'm learning lua so maybe it's a wrong trick...LOL

solved all my bad wrong weapon name selected.. all works great.. now need to add some cool stuffs to my flshlight system like battery picup and drain and so on... thanks smallg.. great as usually

PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
Belidos
3D Media Maker
3
Years of Service
User Offline
Joined: 23rd Nov 2015
Location: Hertfordshire
Posted: 19th Sep 2019 08:04
You should already know and have the resources to add batteries and such, i seem to remember you and me collaborating to round off one of smallg's script to include pickupable flashlights and batteries quite some time ago

https://forum.game-guru.com/thread/214886

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 19th Sep 2019 10:03 Edited at: 19th Sep 2019 10:54
Quote: "You should already know and have the resources to add batteries and such, i seem to remember you and me collaborating to round off one of smallg's script to include pickupable flashlights and batteries quite some time ago "


yes my friend I remember.. that was about 3 years ago(( time flies).. hope my memory and my rusty and noobs lua skills could help me to figure it.. but i'm fiducios......

and is possible to make the flashlight light intensity to be less intense and the color to be changed and the radious reduced?.. in the apst i remember it was all hardcoded but now?
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
thughto
1
Years of Service
User Offline
Joined: 7th Mar 2018
Location:
Posted: 19th Sep 2019 17:19
Thank you so much guys!!
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 13th Oct 2019 23:11 Edited at: 13th Oct 2019 23:20
Hi again guys.,.. i integrated my system with battery flashlight system me smallg and belidos worked some time ago.. i managed to make light to be played only when flashlight is selected (weapon) but i have a issue related to the fact if i switch the flashlight with another weapon even if the light is correcly disabled and flashlight is deactivated when i re.switch to the flashlight battery drain start automatically even if i dont pressed f to startthe flashlight

PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
GubbyBlips
User Offline
Joined: 14th Jan 2019
Location:
Posted: 14th Oct 2019 04:39
If you supply a script, some of these guru's could probably help
you figure it out. I haven't a clue about animation sequences
or weapon scripts. Nice job so far.
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 14th Oct 2019 07:37 Edited at: 14th Oct 2019 07:37
thisi is the flashlight script


this is the flashlight equipped script


and this is the flashlight pickup script


smallg knows all of them LOL
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Oct 2019 17:20 Edited at: 14th Oct 2019 17:25
untested but this should fix it (also fixed the horrible lack of indentation )
edit; needed to also fix/allow for the "auto on" in the weapon attachment script
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 14th Oct 2019 18:43
hi smallg and thanks for your reply and scritps.. but before i go i would to ask waht did you do specifically

did you added the flstate on and off to the flashlight .lua functions and called the state in the flashlight_equipped script or did you add something else i missed?
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 14th Oct 2019 18:45
Quote: "also fixed the horrible lack of indentation "


what??
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
GubbyBlips
User Offline
Joined: 14th Jan 2019
Location:
Posted: 14th Oct 2019 20:20
Indentation?
.......Oh, I see
..............what you
.....................did there
..............Do you
.......mean like
this?
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Oct 2019 20:33 Edited at: 14th Oct 2019 20:34
Quote: "did you added the flstate on and off to the flashlight .lua functions and called the state in the flashlight_equipped script or did you add something else i missed?"

yes changed the state to flstate so it's less likely to get confused as i needed to make it a global so you can pass it between the 2 scripts, also fixed is_flashlight_active to be a global variable
then basically i just edited flashlight.lua to check and exit the script if is_flashlight_active = 0
and edited flashlight_equipped to update the 2 new global variables based on the weapon's equipped state
in short, just added a way to make the 2 scripts talk to each other
Quote: "Indentation?
.......Oh, I see
..............what you
.....................did there
..............Do you
.......mean like
this?"

yes
..just
....like
......that
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 14th Oct 2019 21:00
ok many thanks i'll try them now and see if it works ...thanks again...
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 14th Oct 2019 21:15 Edited at: 14th Oct 2019 21:16
i got 2 errors



PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Oct 2019 00:07
looks like you posted an extra 'end' right at the bottom of flashlight.lua, remove that and it should be fine
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
3
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Oct 2019 00:10
Glad to see proper indentation of scripts is catching on at last.
Been there, done that, got all the T-Shirts!
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 15th Oct 2019 06:25
Quote: "looks like you posted an extra 'end' right at the bottom of flashlight.lua, remove that and it should be fine"


nope

i removed the last "end"at the bottom of the flashlight script by myself before you posted it ( trying to fix by myself) and the first error obviously get fixed but the second one related to the flashlight_battery script remains
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
3com
5
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 15th Oct 2019 07:52

Add this piece of code at the bottom of the flashlight_battery.lua script.

Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 15th Oct 2019 10:06
thanks i'll try tonight asap when at home ..
PC Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA NVDIA 1660GTX 6GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 16th Oct 2019 19:23
all done and works perfectly mant many thanks smallg an 3com..

@3com.. i would to purchase your animated paper v2 on the store but didnt see the script to to animated it on the form page you linked
PC 2 Specs:
AMD RYZEN 2600 SIX CORE @3,70, 64GB RAM DDR4 2400, M/B GIGABYTE AX370
SVGA NVDIA 1660GTX 6GB , SSD M.2 TRANSCEND S110 1TB, 1X HDD SEAGATE BARRACUDA 4TB, 1X HDD TOSHIBA 2TB


PC 2 Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA RADEON R9 380 4GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
3com
5
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Oct 2019 19:30
@ JC LEON
Can you give me the store link please?
Don't know whats paper are you talking about.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 16th Oct 2019 20:54 Edited at: 16th Oct 2019 20:54
Quote: "Can you give me the store link please?
Don't know whats paper are you talking about. "



Sorry the asset if form Oldpam.. but he wrote about you since you wrote the scirpt for it

here the link

https://www.tgcstore.net/product/27811

and what about your horror pack_?
PC 2 Specs:
AMD RYZEN 2600 SIX CORE @3,70, 64GB RAM DDR4 2400, M/B GIGABYTE AX370
SVGA NVDIA 1660GTX 6GB , SSD M.2 TRANSCEND S110 1TB, 1X HDD SEAGATE BARRACUDA 4TB, 1X HDD TOSHIBA 2TB


PC 2 Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA RADEON R9 380 4GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 19th Oct 2019 14:20 Edited at: 20th Oct 2019 00:18
ALL WORKS fine ..now i manage to have a simple reload anim for flashlight and set it to alf fire button (default left alt key)
how can i manage to make anim plays when player reload flashlight ..namely when player holds Fkey for 3 seconds to relload battery?



i managed to play reload anim with the command



and put it in this part of the code



but this way i have anim plays after the flashlight batteries are changed and animation is not syncro with events..

can someone could try to tell me how can i to set the codeto make the anim plays accordong woth reload??

thanks
PC 2 Specs:
AMD RYZEN 2600 SIX CORE @3,70, 64GB RAM DDR4 2400, M/B GIGABYTE AX370
SVGA NVDIA 1660GTX 6GB , SSD M.2 TRANSCEND S110 1TB, 1X HDD SEAGATE BARRACUDA 4TB, 1X HDD TOSHIBA 2TB


PC 2 Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA RADEON R9 380 4GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 20th Oct 2019 16:13
itried several ways to set the

SetGamePlayerStateIsMelee(1)

inside the scirpt but i got always the anims plays when player flashlight reload in done.. and it's not what iìn looking for

any hel p would be greatly appreacited
PC 2 Specs:
AMD RYZEN 2600 SIX CORE @3,70, 64GB RAM DDR4 2400, M/B GIGABYTE AX370
SVGA NVDIA 1660GTX 6GB , SSD M.2 TRANSCEND S110 1TB, 1X HDD SEAGATE BARRACUDA 4TB, 1X HDD TOSHIBA 2TB


PC 2 Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA RADEON R9 380 4GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM
smallg
Community Leader
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Oct 2019 17:27 Edited at: 20th Oct 2019 17:31
probably constantly calling the animation
try something like


i think this will just cause a graphical glitch if the player holds the F key for a while but doesn't completely hold it long enough to complete the reload as it will still play the animation so you will want to add a way to check for that and stop the animation if so..
something like
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
JC LEON
9
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 20th Oct 2019 21:17 Edited at: 20th Oct 2019 21:20
thanks smallg ..system works fine

honestly even with the liens of code you wrote to me


the glitch you wrote about remains but i sorted it not using these lines and simply set the


insted 0.35 and player plays anims only when the batteries are changed...

the only issue i have is that the flashlight light itself is active and can be started even before player finish reload anims and the flashlight is again on screen.. is there a way to make light to be started only when plashlight animation is completely played?? i tried several solutions but without great results

here a video

https://www.youtube.com/watch?v=eGR58Qk0Co8&feature=youtu.be

can please someone could correclty ebmed the video ...thanks i tried but not sorted it...

as you can se when player reload anims plays even if flashlight is not onscreen player is able to start flashlight.. and it's not great.. LOL
PC 2 Specs:
AMD RYZEN 2600 SIX CORE @3,70, 64GB RAM DDR4 2400, M/B GIGABYTE AX370
SVGA NVDIA 1660GTX 6GB , SSD M.2 TRANSCEND S110 1TB, 1X HDD SEAGATE BARRACUDA 4TB, 1X HDD TOSHIBA 2TB


PC 2 Specs:
AMD QUADCORE 880K @4.5GHZ, 32GB RAM DDR3 1600, M/B ASUS A88XM-PLUS
SVGA RADEON R9 380 4GB , SSD KINGSTON A400 1TB, 2X HHD SEAGATE BARRACUDA 4TB
PM

Login to post a reply

Server time is: 2019-10-23 23:52:59
Your offset time is: 2019-10-23 23:52:59