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

Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]


Post New Thread Reply   
 
Thread Tools Display Modes
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 03-18-2016 , 08:37   Re: Dynamic Objects and Properties - v006 - [2016.03.15]
Reply With Quote #31

Dynamic someobj = Dynamic();
someobj.SetBool("somebool", true);


-> error 105: cannot find method or property Dynamic.SetBool
__________________
ImACow is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-18-2016 , 09:18   Re: Dynamic Objects and Properties - v006 - [2016.03.15]
Reply With Quote #32

Quote:
Originally Posted by ImACow View Post
Dynamic someobj = Dynamic();
someobj.SetBool("somebool", true);


-> error 105: cannot find method or property Dynamic.SetBool
Quote:
Originally Posted by Neuro Toxin View Post
Just realised I need to add support for boolean types.

I'll do this soon...
(relevant part bolded)
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 03-18-2016 , 09:44   Re: Dynamic Objects and Properties - v006 - [2016.03.15]
Reply With Quote #33

My bad, did not read through pages.

Btw I want to make data persistent when a plugin reloads, is this the correct way ?

Offload.smx -> getDyn & setDyn.

Mainplugin.smx
-> OnPluginStart
-> Create Dynamic object.

-> OnPluginEnd
-> Use SetDyn from Offload.smx to set the reference of the dynamic.



then in main plugin on a plugin start check if the getDyn is a valid dynamic?

__________________

Last edited by ImACow; 03-18-2016 at 10:10.
ImACow is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-18-2016 , 20:23   Re: Dynamic Objects and Properties - v006 - [2016.03.15]
Reply With Quote #34

After some head scratching this is what im thinking.

Code:
Dynamic someobj = Dynamic.GetByName("pluginname_settings");
Code:
If (!someobj.IsValid)
Code:
someobj = Dynamic();
someobj.SetName("pluginname_settings");
This would enable you to set a unique name for any dynamic object. Any other plugins can then Dynamic.GetByName without having to parse the obj index through natives.

In the sanerio above. Moomoo could try find a dynamic object by name on plugin start.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-19-2016 , 00:31   Re: Dynamic Objects and Properties - v007 - [2016.03.19]
Reply With Quote #35

Version 0.0.7 released
- Added support for boolean datatypes
- Updated example plugin to include bool usage
- Updated test plugin to verify bool usage and conversion between datatypes
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-19-2016 , 02:39   Re: Dynamic Objects and Properties - v007 - [2016.03.19]
Reply With Quote #36

Version 0.0.8 released
- Added support for naming dynamic objects
- Updated example plugin to show usage of naming objects
- Dispose now supports automatic disposing of disposable members

Code:
public bool SetName(const char[] objectname, bool replace=false)
public static Dynamic FindByName(const char[] objectname)
Code:
// You can name a dynamic object
someobj.SetName("someobj");

// So another plugin can access it like so
someobj = Dynamic.FindByName("someobj");
Github Changes
__________________
Neuro Toxin is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 03-19-2016 , 10:37   Re: Dynamic Objects and Properties - v008 - [2016.03.19]
Reply With Quote #37

Awesome dude!
__________________
ImACow is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 03-19-2016 , 10:38   Re: Dynamic Objects and Properties - v008 - [2016.03.19]
Reply With Quote #38

I'm using this now to offload all my plugin data on PluginEnd, and recover it on PluginStart
__________________
ImACow is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-19-2016 , 20:28   Re: Dynamic Objects and Properties - v008 - [2016.03.19]
Reply With Quote #39

An example of the changes around .Dispose.

Code:
Dynamic someobj = Dynamic();
Dynamic anotherobj = Dynamic();
someobj.SetObject("anotherobj", anotherobj);

// This dispose call will also call dispose on anotherobj
someobj.Dispose();

// If you dont want anotherobj to be disposed you can use this instead
someobj.Dispose(false);

// And then you can dispose anotherobj later
anotherobj.Dispose();
__________________
Neuro Toxin is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 03-19-2016 , 21:37   Re: Dynamic Objects and Properties - v008 - [2016.03.19]
Reply With Quote #40

Some ideas:

can FindByName be used to search children?

.FindParent()
.FindChild()
.DisposeParent()
.DisposeChildren()
.CountChildren()

Cow.
__________________
ImACow 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 11:52.


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