Raised This Month: $12 Target: $400
 3% 

Detect when a plugin unload


Post New Thread Reply   
 
Thread Tools Display Modes
dordnung
Veteran Member
Join Date: Apr 2010
Old 01-25-2014 , 22:56   Re: Detect when a plugin unload
Reply With Quote #11

First of all you can't clone Plugin Handels

I solve this unload problem by checking every few seconds the state of all Plugins.
__________________
dordnung is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-25-2014 , 23:18   Re: Detect when a plugin unload
Reply With Quote #12

Quote:
Originally Posted by Popoklopsi View Post
First of all you can't clone Plugin Handels

I solve this unload problem by checking every few seconds the state of all Plugins.
That was one of my first idea (OnGameFrame instead and I will tell you why) but it would save so much problems if there were a simple forward OnPluginUnload(Handle:plugin) that would do some magic for us. Anyway second solution is to do an extension doing that magic forward for us but I'm not sure if there anything supporting other plugin unload in extensions.

The reason why I need it to be really accurate is because I will use many other structures to be read on game frame (yea, heard me, blame me as much as you want, reading memory is almost nothing on game frame) and I need to make sure all the others plugins memory is available before taking any action. Here is my little brainstorming for the project:

PHP Code:
-- TD ENGINE --

-- 
REGION --
enum struct_region
{
    
m_id,
    
String:m_name[32],
    
m_move_to
};

-- 
PROJECTILE --
enum struct_projectile
{
    
String:m_name[32],
    
m_model,
    
Float:m_speed
};

-- 
MODEL --
enum struct_model
{
    
m_id,
    
String:m_name[32],
    
String:m_path[PLATFORM_MAX_PATH]
};

-- 
CREEP --
enum struct_creep
{
    
String:m_name[32],
    
m_model,
    
m_life,
    
m_armor,
    
m_shield,
    
Float:m_speed,
    
Float:m_shield_aoe 
};

-- 
TOWER ATTRIBUTE --
enum DamageType
{
    
physical,
    
magical,
    
pure
};

enum struct_tower
{
    
String:m_name[32],
    
m_owner,
    
m_damage,
    
m_model,
    
DamageType:m_damage_type,
    
Float:m_rotation,
    
Float:m_speed,
    
Float:m_range,
    
Float:m_aoe
}; 
Many of those objects will be changed on game frame.
Mathias. is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 01-26-2014 , 20:14   Re: Detect when a plugin unload
Reply With Quote #13

You should monitor that bug then. It's actually really annoying to require child plugins to unregister from the core in OnPluginEnd. Bad design, if the core could clean up after the plugins itself like extensions can.

Tower Defense? I love that gameplay. Which game are you working on implementing it in?
__________________
Peace-Maker is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-26-2014 , 21:32   Re: Detect when a plugin unload
Reply With Quote #14

CS:GO, not using bot entities just to give you a taste and it only a engine, I plan to make gamemod based on it. I suppose you played warcraft 3, in this case you will be impress by the variety of my idea. Castle War (2-4 team that send wave and have to defend from other teams wave with money income) classic TD (FFA line up) TD survival (all together) and probably more.

It should works on other games since I'm not using any particular specific commands for a game.

Yes I will ask for this feature in the bug monitor and I hope this one get added for real.

EDIT: already have been request, hope we get hear.

Last edited by Mathias.; 01-26-2014 at 21:34.
Mathias. is offline
QOOOOOOOOQ
Senior Member
Join Date: Dec 2012
Old 01-26-2014 , 21:49   Re: Detect when a plugin unload
Reply With Quote #15

Why not alter the source of the plugin you want to check for, then recompile it? You add a handy forward call OnPluginEnd() and solves all your problems.
QOOOOOOOOQ is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-26-2014 , 22:48   Re: Detect when a plugin unload
Reply With Quote #16

because I want people to be able to create plugin from the engine and logically an engine does the handling, you don't need to ask the users to create forwards for you. The real question is why is this feature not implemented into sourcemod yet.

EDIT: Quote by Kyle Sanderson on the bug monitor: "An alternative would be to create hooks for RegPluginLibrary to fire functions in their parent plugins if their children die (unload). However, that's a bigger change, and not every plugin would require/follow this."

The situation is basically the same, people not following those rules will cause bad memory handling from the core and it aint the core fault since he do not have the features to accomplish the actions requires.

Last edited by Mathias.; 01-26-2014 at 22:55.
Mathias. is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-27-2014 , 02:09   Re: Detect when a plugin unload
Reply With Quote #17

Doesn't make sense what you are trying to accomplish.
You could just do away with the other plugin deps, and findstringinarray to make sure there are no duplicates.
If you are worried about models not being available on mapchange or something, you could try to preserve the model by passing a bool (download) and then a handle you clone of files to add to download table, and associate it to that model.

Else you could do things like use the caller's handle as an id/owner for the model, and on plugin unload, you call the native to clear that id/handle.. And it will rove those models from your array. Then you do not have to use libraries in your main plugin.

If you want to use libraries, you could just pass the caller's library name in your native. Store this in a dynamic array in the core plugin, and onlibraryremoved, search through your models and use the dynamic array to see if that library belongs to said model. Then remove the library name from your dynamic array.
This is probably the best choice..
In the child plugin, you reg the library, and when you call your native, just pass that library name, very easy to implement.
Onlibraryremoved isnt bad to use if you findstringinarray the libraries, though if you have a lot of models in the main array, it could take a while to parse them, but what can you do.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 01-27-2014 at 02:12.
friagram is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-27-2014 , 09:31   Re: Detect when a plugin unload
Reply With Quote #18

Quote:
Originally Posted by Black-Rabbit View Post
Castle War (2-4 team that send wave and have to defend from other teams wave with money income) classic TD (FFA line up) TD survival (all together) and probably more.
Done forget roc's Line Town Wars. or any of the WMWs lol
Mitchell is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-27-2014 , 09:36   Re: Detect when a plugin unload
Reply With Quote #19

The neat thing about Private Forwards (which I mentioned a while back) is that they remove references to the functions in them when the plugin that registered said function unloads.

Hence why I suggested them in the first place.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-27-2014 , 13:56   Re: Detect when a plugin unload
Reply With Quote #20

Quote:
Originally Posted by Powerlord View Post
The neat thing about Private Forwards (which I mentioned a while back) is that they remove references to the functions in them when the plugin that registered said function unloads.

Hence why I suggested them in the first place.
But the private forwards would have to be create by the child plugins.

Quote:
Originally Posted by Mitchell View Post
Done forget roc's Line Town Wars. or any of the WMWs lol
I will let you the pleasure to do it when I'm done with the engine and some samples

Last edited by Mathias.; 01-27-2014 at 14:46.
Mathias. is offline
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 08:57.


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