Raised This Month: $94 Target: $400
 23% 

WeaponBox FadeOut


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Fun Stuff        Approver:   HamletEagle (32)
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 07-31-2012 , 05:26   WeaponBox FadeOut
Reply With Quote #1



WeaponBox FadeOut Effects
Version: 0.2

Description:
The beautiful effect for weaponbox disappearance. Now they are slowly taking off and dissolved in the air. So as you can configure the time of disappearance and the glow of weaponbox.
Cvars:
  • wpnbox_fadeout_lifetime - 30.0 - weaponbox life time
  • wpnbox_fadeout_rgb - 255 255 000 - weaponbox glow color [RGB]

Screenshot



idea from CTF by Hunter_Digital
Attached Files
File Type: sma Get Plugin or Get Source (wpnbox_fadeout.sma - 768 views - 1.9 KB)
__________________
The functional way is the right way

Last edited by GordonFreeman (RU); 04-21-2016 at 15:45.
GordonFreeman (RU) is offline
terro
Junior Member
Join Date: Jun 2012
Location: Tunisia
Old 08-09-2012 , 07:45   Re: [HL] WeaponBox FadeOut
Reply With Quote #2

What 's the map !!
__________________
88.198.143.7:27021
BEST server
terro is offline
Send a message via Skype™ to terro
SPT1
Senior Member
Join Date: Aug 2012
Old 08-09-2012 , 08:57   Re: [HL] WeaponBox FadeOut
Reply With Quote #3

nice
SPT1 is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 08-09-2012 , 09:21   Re: [HL] WeaponBox FadeOut
Reply With Quote #4

Quote:
Originally Posted by terro View Post
What 's the map !!
are you kidding me? It's crossfire, either one of its mods.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-21-2016 , 11:11   Re: [HL] WeaponBox FadeOut
Reply With Quote #5

1.Setting pev_nextthink on Spawn() is not reliable. Due to this, your plugin is working only if a player dropped a weapon by drop command, but fails when he is killed and game drop the weapon.

Why? Usually, when a weaponbox is created game sets the think to CWeaponBox::Kill and nextthink to gametime() + 120 in HL and to gametime() + 300 in CS. This happens AFTER spawn is called, so it overrides what you set in fw_WeaponBoxSpawn.
But, when you manually drop the weapon the piece of code I'm talking about is missing(probably wanted?), so you are lucky and it somehow works.

To understand better, look at HL code:

1. https://github.com/ValveSoftware/hal...ayer.cpp#L4566 this happens when you drop manually the weapon. See, nextthink is not changed.
2. https://github.com/ValveSoftware/hal...layer.cpp#L780 this is executed when you die and game drop the active item. Here nextthink is changed.

What you should do to make it work in both cases is to hook Touch instead of Spawn()
PHP Code:
register_touch("worldspawn""weaponbox""CWeaponBox_Touch"
In CWeaponBox_Touch alter pev_nextthink.

If you still don't get it, here is the order of calls.

When you drop a weapon:

1."drop" command is send.
2.DropPlayerItem() is called.
3.weaponbox entity is created.
4.Spawn is called.
5.SetModel() set the entity model to models/w_weaponbox.mdl
6.Touch() is called -> here you should set the new weaponbox life.

When game drop a weapon:

1.PackDeadPlayerItems is called.
2.weaponbox entity is created.
3.Spawn is called.
4.SetModel() set the entity model to models/w_weaponbox.mdl
5.Think is set to CWeaponBox::Kill, so it will later remove the entity.
6.pev_nextthink is set to gametime() + 120
7.Touch() is called -> here you should set the new weaponbox life.

If you do it like that then it will work also in CS and probably other mods.

Short story: Set nextthink in Touch, not Spawn so game won't override your value.

2.In fw_WeaponBoxThink use charsmax() to retrieve a string size.
3.In fw_FadeOut also check if entity is valid. Some other plugins may remove it while the task is running.
You could retrieve pev_renderamt inside fw_FadeOut, instead of passing it in set_task(so you will pass only entity index) and you won't need to convert the value to integer anymore. Anyway, your way is ok too I guess.
4.Don't remove weaponbox entities like you do. That way you only remove the box and not the weapon that is inside it.
The correct way to remove it is to call think on the entity. Since your superceded Think(), you could set a custom value in a unused field, like pev_iuser3. In fw_WeaponBoxThink, check pev_iuser3. If it holds your custom value, then do nothing. Else, set the properties(as you already do) and supercede.

Something like:
Spoiler
__________________
HamletEagle is offline
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 04-21-2016 , 15:06   Re: WeaponBox FadeOut
Reply With Quote #6

Updated!
__________________
The functional way is the right way
GordonFreeman (RU) is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-21-2016 , 15:30   Re: WeaponBox FadeOut
Reply With Quote #7

You forgot to use charsmax() in parse(), please fix. Other than that, code looks good now.

Approved.
__________________
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-21-2016 , 15:40   Re: WeaponBox FadeOut
Reply With Quote #8

nice.
__________________
EFFx is offline
Send a message via Skype™ to EFFx
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode