AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Weapon Lights * Update 0.7.1 Beta (26-Feb-2009) (https://forums.alliedmods.net/showthread.php?t=84077)

HiSS 01-20-2009 05:56

Weapon Lights * Update 0.7.1 Beta (26-Feb-2009)
 
4 Attachment(s)
New version 0.7.1 beta, attached donwload at the top of this post.

Hi, I was too busy sorry I can't add it before. New version done by Arkshine available.

* Changes:

- Fixed bug when using pistols.
- Now uses VEN's method.

* Download here v.0.6 (old bugged):


Get Plugin
Get Source


* See here changes in new version:

http://forums.alliedmods.net/showthr...676#post754676

- Features:

This plungin just adds small dyanmic lights when a player shoot.
You can also change the color and the radius of the lights.

- Cvars:

weapon_lights 0 -> disable 1 = enable, default 1
weapon_lights_radius -> the size of light, default 18
weapon_lights_color -> color of the light RGB 0-255, default 255 150 15
weapon_lights_silenced -> 0 = disable lights | 1 = normal light | 2 = 50% of a normal light, default 2

- Installation:

Put .amxx file into your "./addons/amxx/plugins/" folder.
Add "weapon_lights" into your "plugins.ini" file. ("./addons/configs/")

- Credits:

> Arkshine - adapted for using hamsandwich, VEN's method, silenced weapons option, code optimization and helped me a lot, thank you.
> Avalanche (I learn there how to make a dynamic light, in his plugin "Flashbang Dynamic Light", used in first release).
> HiSS - Original idea. It's me!

- Modules recquired:

* fakemeta
* hamsandwich

Tested in Counter-Strike 1.6 AMXX 1.8.1 and works fine.
No reported issues with another plugin yet.
Compiled with 0 errors | 0 warnings.

Sorry for my bad english, I hope you enjoy the plugin.
Greetings.

Arkshine 01-20-2009 06:23

Re: Weapon Lights (Beta) for Counter-Strike
 
As suggestions :

- Here it's more appropriate to use a command to retrieve the value or caching the value from cvar on a specific event ( like new_round ) ; because each time a player fires you retrieve the string and parse it when it needs to be done one time. ( one time when the value is changed )
- Since this function will be called very often, you should use static for light_origin.
- MSG_BROADCAST -> You should use MSG_PVS ; no need to send the message to players who don't look the origin.
- 27 -> Juste write directly TE_DLIGHT ; the define name is here for that.
- Instead of using floatround(), use EngFunc_WriteCoord, it's for float. Better and you don't need to call 3 natives in more.
- You include cstrike and fakemeta_util, no need here.

Owyn 01-20-2009 06:57

Re: Weapon Lights (Beta) for Counter-Strike
 
screens?

Mini_Midget 01-20-2009 09:43

Re: Weapon Lights (Beta) for Counter-Strike
 
Tested and works but still room for improvements.
http://forums.alliedmods.net/showthread.php?t=54887
You should read that so you can catch exactly when a shot is made. The way you have it is bad and sometimes plays when switching weapons.

Anyway... Heres some screen shots

[IMG]http://img88.**************/img88/6510/dedust20085vw7.jpg[/IMG]


[IMG]http://img161.**************/img161/3557/dedust20088bb6.jpg[/IMG]

[IMG]http://img440.**************/img440/6702/dedust20090me0.jpg[/IMG]

HiSS 01-20-2009 10:01

Re: Weapon Lights (Beta) for Counter-Strike
 
Quote:

- Here it's more appropriate to use a command to retrieve the value or caching the value from cvar on a specific event ( like new_round ) ; because each time a player fires you retrieve the string and parse it when it needs to be done one time. ( one time when the value is changed )
I dunno what you mean with this, sorry my english is very bad, if you can explaind me please.
Quote:

- Since this function will be called very often, you should use static for light_origin.
I fixed it thank you.

Quote:

- MSG_BROADCAST -> You should use MSG_PVS ; no need to send the message to players who don't look the origin.
I prefer MSG_BROADCAST, if a player is around a corner you still can view the light, it's the point. Thanks anyway.
Quote:

- 27 -> Juste write directly TE_DLIGHT ; the define name is here for that.
I try this but get some strange error, it works fine with 27.
Quote:

- Instead of using floatround(), use EngFunc_WriteCoord, it's for float. Better and you don't need to call 3 natives in more.
Done, it works fine, thanks.
Quote:

- You include cstrike and fakemeta_util, no need here.
Removed, thank you very much I credit you in the first post.

I still trying to find the way how to detected if a weapon is silenced and make a cvar to turn on/off, żany suggestions?

Thank you all for reply, and thank Mini_Midget for screenshots :)
Greetings.

bomnacama 01-20-2009 11:48

Re: Weapon Lights (Beta) * Updated v0.2
 
seems fun. nive ak skins :D

Stixsmaster 01-20-2009 12:28

Re: Weapon Lights (Beta) * Updated v0.2
 
I think you should make it so that when a silencer is used...have it so the light is not as bright when there is no silencer...

---Stixsmaster

Arkshine 01-20-2009 16:20

Re: Weapon Lights (Beta) * Updated v0.2
 
Quote:

I dunno what you mean with this, sorry my english is very bad, if you can explaind me please.
Do you understand that you parse each time the cvar, when you need to do one time at least ? Just cache the value.

If you want to keep the use of cvars :

- Hook NewRound event ( or others, like RoundStart or RoundEnd )
- Retrieve cvar value, and parse it
- Save in global vars.

You can create a command acting as cvar, too. When someone change the value, it will save immediately one time in the global vars. Using Cvars, you will have to wait the next event.

Do you see what I was meant now ?

Quote:

I prefer MSG_BROADCAST, if a player is around a corner you still can view the light, it's the point. Thanks anyway.
If player is around a corner, he should see the light. PVS means potentially. If player is enough near, it will works in such situation. Try it and you will see.
It will be better to not send a lot of messages when the player is not around.

Quote:

I try this but get some strange error, it works fine with 27.
Try again, no way that it generates an error ; write_byte ( TE_DLIGHT ); works perfectly fine and more readable.

Quote:

Done, it works fine, thanks.
Btw, if interested, to keep the same "design", I'm using a macro, like that :

Code:
#define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) ) #define write_coord_f(%1)         ( engfunc ( EngFunc_WriteCoord, %1 ) )
Code:
write_coord_f( light_origin[0] ); write_coord_f( light_origin[1] ); write_coord_f( light_origin[2] );

Quote:

I still trying to find the way how to detected if a weapon is silenced and make a cvar to turn on/off, żany suggestions?
See cs_get_weapon_silen() ; if you don't want to use cstrike, use the offset 88. ( see cstrike.cpp + cstrike.h for more details )


And Mini_Midget is right, you should use the VEN's method.

HiSS 01-22-2009 11:48

I see code around me in the darkest nights
 
Hi, I try to implement VEN's method but I can't get it to work.
I'll go insane, I try thousands of ways but it still doesn't work.

I tried to implement a way to find if a weapon si silenced with cs_get_weapon_silen() (I don't know how to use offsets), and make a new cvar for it with 3 options:

0 - disable if is silenced
1 - make the light as a normal weapon
2 - make 50% of radius light if is silenced

But it fails CATASTROPHiCALLY.

If anyone can help me plz, I leave you the code attached (without the silenced option attempts).

Thanks and sorry my bad english.
Greetings.

Arkshine 01-22-2009 12:23

Re: Weapon Lights (Beta) * Updated v0.2
 
Wait a bit. I will send you by PM the corrected plugin with both cvars and command as examples, so to see the difference. Then, feel free to use or not some code with your own style. ( I don't attach here because some people seem to not like when I rewrite a plugin... -_- )

[Edit] Message sent. I have included your "silenced" cvar too. Hope it will help you.


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

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