AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Custom Flashlight v0.5.4 (10/20/09) (https://forums.alliedmods.net/showthread.php?t=72143)

ConnorMcLeod 06-01-2008 06:50

Custom Flashlight v0.5.4 (10/20/09)
 
10 Attachment(s)
Custom Flashlight




.: Description :.

This plugin lets you customize flashlight with those features :
  • Set the drain frequency
  • Set the charge frequency
  • Choose the radius of flashlight
  • New! Unlimited flashlight (no drain)
  • New! Choose the color according to players team, or randomly
  • New! Show the flashlight to all players or only to the player who is using it (this can be usefull on kz servers)
  • New! Set a max distance after with the flashlight won't display
  • New! Set the light attenuation according to distance
  • New! Set flashlight sounds
  • Supports simon logic Blinding Flashlight plugin



.: Commands :.

  • flashlight_set custom < 0|1 >
    Turn the plugin on/off
  • flashlight_set show < 0|1 >
    Show flashlight to all players or only to the player who is using it
  • flashlight_set drain < value > default cs value is 120
    Time in seconds it will take to flashlight to be fully drained
  • flashlight_set charge < value > default cs value is 20
    Time in seconds it will take to flashlight to be fully charged
  • flashlight_set colortype < 0|1 >
    0:random (predifined) colors
    1:team colors
  • flashlight_set colorct < RRRGGGBBB >
    Flashlight color for CTs if flashlight_color_type is set to 1
  • flashlight_set colorte < RRRGGGBBB >
    Flashlight color for Ts if flashlight_color_type is set to 1
  • flashlight_set radius < 0-255 >
    Flashlight radius :P
  • flashlight_set distance < value >
    Max distance in units where you can see the flashlight
  • flashlight_set attenuation < value >
    Attenuation light factor according to distance between player and flashlight



.: Modules/Requirements :.

  • AMXX1.8+
  • Engine
  • $CONFIGSDIR/flashlight_colors.ini (see attachment)
    (plugin will automatically use per team colors if this file doesn't exist)


.: Credits :.


XxAvalanchexX for the previous plugin version witch gave me this idea and in witch i took the TE_DLIGHT message
HLSDK
Salamon for some ideas



.: Colors examples :.


http://en.wikipedia.org/wiki/List_of_colors



.: Config example :.


Put this code in amxx.cfg (or maps/de_dust2.cfg, maps/prefix_de.cfg etc..) -> default amxx .cfg files system.
Code:

// Custom Flashlight Settings
flashlight_set custom 1
flashlight_set show 1

flashlight_set drain 120
flashlight_set charge 20

flashlight_set colortype 0
flashlight_set colorte 255000000
flashlight_set colorct 000000255

flashlight_set radius 9
flashlight_set distance 2000
flashlight_set attenuation 5

To use per maps .ini file, do as for per maps plugins.ini file but instead of using maps/ folder, use flashlight/ one.
Examples :
Code:

addons\amxmodx\configs\flashlight\de_dust.ini
addons\amxmodx\configs\flashlight\prefix_cs.ini

.: Changelog :.
Code:

* v0.5.4 (10.20.09)
* attempt to fix the bug when you can re-activate fl when empty
*
* v0.5.3 (09/01/09)
* -fixed little errors due to version change
* -added player range check in death event
** v0.5.2 (07/23/09)
* -fixed inverted teams colors
*
* v0.5.1 (04/04/09)
* -haven't realised i can remove FM include
*
* v0.5.0 (04/03/09)
* - use register_think instead of FM_CmdStart
* - use client_PreThink instead of FM_PlayerPreThink
* - use get_user_origin mode 1 and 3 instead of fakemeta stock
* - replaced some FM natives+enums with amxx natives (emit_sound, write_coord)
*
* v0.4.0 (07/27/08)
* - replaced cvars with commands
* - .ini file now supports prefix/per map configs
*
* v0.3.1 (06/29/08)
* - fixed bug when you could have seen normal flashlight
*
* v0.3.0 (06/21/08)
*
* - some code optimizations (thanks to simon logic and jim_yang)
* - changes cvars flashlight_drainfreq and flashlight_chargefreq to
*  flashlight_fulldrain_time and flashlight_fullcharge_time
*  (simon logic suggestion)
* - moved random colors into $CONFIGSDIR/flashlight_colors.ini
*
* v0.2.0
* First public release


Alka 06-01-2008 06:59

Re: Custom Flashlight (New)
 
Just tested, and works great! Gj :mrgreen:

Fry! 06-01-2008 08:38

Re: Custom Flashlight (New)
 
wow , something new . =)

Fan of Da!!! 06-01-2008 09:28

Re: Custom Flashlight (New)
 
Will this work with zombie infection ? :)

Fry! 06-01-2008 09:45

Re: Custom Flashlight (New)
 
Why You don't try ?

Fan of Da!!! 06-01-2008 10:20

Re: Custom Flashlight (New)
 
Because i have Sparta mod server the plugin is for one friend :D

ConnorMcLeod 06-01-2008 10:31

Re: Custom Flashlight (New)
 
Quote:

Originally Posted by Fan of Da!!! (Post 633065)
Will this work with zombie infection ? :)

Should work.

Zul Rivers 06-04-2008 04:13

Re: Custom Flashlight (New)
 
Good Job, this plugin doesn't seem to lag me in my server.

ConnorMcLeod 06-04-2008 12:34

Re: Custom Flashlight (New)
 
Players can have low fps if you set radius too high.

AntiBots 06-04-2008 13:03

Re: Custom Flashlight (New)
 
I donīt have any problem with FPS.

anakin_cstrike 06-04-2008 14:11

Re: Custom Flashlight (New)
 
Very nice...gj:up:

soccdoodcss 06-04-2008 22:47

Re: Custom Flashlight (New)
 
I loved the original, nice job. I like the new features.

dekken 06-05-2008 15:14

Re: Custom Flashlight (New)
 
i found a bug..or its supposed to be like that..(DONT THINK SO :P)
it will only light in the Shadows and Dark Places

Here i light the Ground:
Nothing Happens.
http://img227.**************/img227/5...st20000an1.jpg

Here i light Dark Spot:
and it does Light It.
http://img519.**************/img519/6...st20001ms3.jpg

ConnorMcLeod 06-05-2008 16:48

Re: Custom Flashlight (New)
 
Quote:

Originally Posted by dekken (Post 635049)
its supposed to be like that


dekken 06-05-2008 17:51

Re: Custom Flashlight (New)
 
well then thats stupid...on dark Maps..with custom lights? like in zombie mod...that wouldnt be effective(?).

ConnorMcLeod 06-06-2008 17:33

Re: Custom Flashlight (New)
 
That's the purpose of a light, make you see in dark places.

Salamon 06-07-2008 09:52

Re: Custom Flashlight (New)
 
oh my god! thats what im talking about !! :D at last, this is so good, i was waiting for this, big + for you man ^^

works very well but i have one question, with normal flashlight i can hook when someone have turned on or off flashlight by using pev_effects, when 8 is on, 0 off, what is the value in this plugin when flashlight is on / off ?

ConnorMcLeod 06-07-2008 10:05

Re: Custom Flashlight (New)
 
Hook Flashlight event :

PHP Code:

register_event("Flashlight""Event_Flashlight""be")


public 
Event_Flashlight(id)
{
    
client_print(idprint_chat"You have just turned %s your flashlight"read_data(1) ? "on" "off")


Make sure that cvar flashlight_show_all is 1, or your plugin won't be able to catch the event.

Salamon 06-07-2008 10:47

Re: Custom Flashlight (New)
 
if i could i would give you 1000 karma for this ^^ event of course working ;]

anyway flashlight_show_all is better to turn 1, more realistic ;]

i think we have one small problem, this plugin doesnt work with forward client_impulse, i mean with this plugin on we cant block anyway impulse 100

any suggestions ?

ConnorMcLeod 06-07-2008 12:03

Re: Custom Flashlight (New)
 
Quote:

Originally Posted by Salamon (Post 635821)
if i could i would give you 1000 karma for this ^^ event of course working ;]

Give me a kiss and it's fine.

Quote:

Originally Posted by Salamon (Post 635821)
anyway flashlight_show_all is better to turn 1, more realistic ;]

I use this on my kz server, so players don't annoy other players with their light.


Quote:

Originally Posted by Salamon (Post 635821)
i think we have one small problem, this plugin doesnt work with forward client_impulse, i mean with this plugin on we cant block anyway impulse 100

any suggestions ?

Impulse 100 is already blocked with this plugin.

Salamon 06-07-2008 19:51

Re: Custom Flashlight (New)
 
ahh i understand it now ^^ :P

;* friend kiss haha xD

Simon Logic 06-18-2008 11:10

Re: Custom Flashlight (New)
 
Interesting one. Pity i have no time to play with amx/x more.

I suggest converting flashlight_drainfreq & flashlight_chargefreq into cvars called e.g. flashlight_deplete_secs & flashlight_fullcharge_secs (if possible of course) which will stand for number of seconds fully charged flashlight can emit light until is depleted & number of secs an exhausted flashlight have to be charged respectively. This is more user-friendly.

Also you can optimize calculations within Make_FlashLight(id) (looks like it can be called rather often):

iAttn = 256 + iDecay * get_pcvar_num(g_pcvarFlashAttn) // barney/dontaskme
-->
fTemp = 256 / (256 + iDecay * get_pcvar_num(g_pcvarFlashAttn))
...
write_byte((g_iColor[id][Red] * fTemp)

Also this one
Code:
#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" #define SOUND_FLASHLIGHT_OFF    "items/flashlight1.wav"
theoretically makes resource duplication (depends of number of macro entries in the code) in compiled plugin. I would rather use new const instead of #DEFINE for string constants especially when they occure twice or more in the source code.

Again, pity i could not test it in-game. As i remember Avalanche's plugin did not feed my needs in conjunction with Blinding Flashlight.

ConnorMcLeod 06-21-2008 04:08

Re: Custom Flashlight (New)
 
Thanks for suggestions.
I've changed cvars and #define thing.


I'm still confused on what is better for the attenuation thing as you may have missed that i need to have an integer/byte, so if i use floats i need to round them.
So what is optimized :
Code:
    static iDecay, iAttn     iDecay = floatround( flDist * 255.0 / flMaxDist )     iAttn = 256 + iDecay * get_pcvar_num(g_pcvarFlashAttn) // barney/dontaskme     // [..]     write_byte((g_iColor[id][Red] * 256) / iAttn)     write_byte((g_iColor[id][Green] * 256) / iAttn)     write_byte((g_iColor[id][Blue] * 256) / iAttn)

or

Code:
    static iDecay, Float:flAttn     iDecay = floatround( flDist * 255.0 / flMaxDist )     flAttn = 256.0 / (256 + iDecay * get_pcvar_num(g_pcvarFlashAttn))     // [..]     write_byte( floatround( g_iColor[id][Red] * flAttn ) )     write_byte( floatround( g_iColor[id][Green] * flAttn ) )     write_byte( floatround( g_iColor[id][Blue] * flAttn ) )

??

jim_yang 06-21-2008 05:04

Re: Custom Flashlight (New)
 
I still preferred the first one, obviously call triple floatround is not wise here. but I don't know if the pawn compiler has optimization about multiplying like this: (my guess is yes)
somevalue * 256 => somevalue<<8

also arrayset nonzero value is not so fast as your imagination.
so just set a loop

ConnorMcLeod 06-21-2008 05:48

Re: Custom Flashlight (New)
 
Updated to v0.3.0, thanks to both of you :)

Son 06-21-2008 06:38

Re: Custom Flashlight (New)
 
Not bad. ;) Karma.

warzarmz 06-23-2008 20:50

Re: Custom Flashlight (New)
 
theres a bug in your plugin i'm not sure your aware of.

Lets say my server is running Biohazard, and its also running this plugin. If a human has the flashlight on when he gets infected, the zombie can't turn off the light, it always stays on.

ConnorMcLeod 06-24-2008 00:27

Re: Custom Flashlight (New)
 
This is related to Biohazard plugin, ask author for modifications if you want, i can't do nothing about it.

-edit-
If Zombies are in fact terrorists, you can set per team color and T color to 000000000.

luffy67 06-24-2008 02:24

Re: Custom Flashlight (New)
 
Nice Job Connorr , +karma :up:

ConnorMcLeod 06-24-2008 12:27

Re: Custom Flashlight (New)
 
Quote:

Originally Posted by luffy67 (Post 642988)
Nice Job Connorr , +karma :up:

Merci mec ;)

AcidoX 06-25-2008 05:24

Re: Custom Flashlight (New)
 
Verry nice plugin! Must be aproved! :)

Zul Rivers 06-29-2008 11:06

Re: Custom Flashlight (New)
 
Yeah should be approved!
But how do i make it unlimited? no drain?

Arkshine 06-29-2008 11:14

Re: Custom Flashlight (New)
 
flashlight_fulldrain_time 0

Salamon 06-29-2008 16:13

Re: Custom Flashlight (New)
 
i said before that i love this plugin but found a bug ;/

bug only with mp_flashlight 1 but without it i dont see flashlight drain

when i have mp_flashlight on 1 to see how much battery i have left, when turn on customflashlight, die, and before respawn click 1 time "f" (impulse 100) on spawn normal flashlight is turning ON to me ;/ and dont turn off alone, i can normal shut off and turn on customflashlight but the normal flashlight stay ;/

ConnorMcLeod 06-29-2008 16:26

Re: Custom Flashlight v0.3.1 (06/29/08)
 
Ty for the feed back, fixed in v0.3.1

Iswa! 06-30-2008 09:37

Re: Custom Flashlight v0.3.1 (06/29/08)
 
Very Nice !! Good Job

Salamon 07-01-2008 16:35

Re: Custom Flashlight v0.3.1 (06/29/08)
 
yea!!! working excellent

i dunno 1 thing, why it isnt approved yet? im confirming, its WORKING in 100% good now ^^

Mini_Midget 07-16-2008 10:58

Re: Custom Flashlight v0.3.1 (06/29/08)
 
Found a small glitch.

When your flashlight is still on.
I set flashlight_custom to 0.
The custom flashlight is still there and I can use the default CS flashlight.
It only goes away once I die or when the round is over.

Other than that.

This plugin rocks!!

ConnorMcLeod 07-30-2008 07:07

Re: Custom Flashlight v0.4.0 (07/30/08)
 
Updated to v0.4.0

- changed cvars into commands
- now fully supports per maps/prefixes configs.

danielkza 08-02-2008 05:20

Re: Custom Flashlight v0.4.0 (07/30/08)
 
Great plugin, will use this idea for my KZ plugin (will not copy your code,don't worry).

+karma


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

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