Raised This Month: $7 Target: $400
 1% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-23-2018 , 00:20   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #271

You always need to call .Dispose when you're done with them
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-28-2018 , 22:57   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #272

Quote:
Originally Posted by oeN.
Hey,

Basically I'm working on Clan System. And Dynamic looks promising.
I need to store Clans names and array of members (strings).
Let's say there are 5 Clans. Indexed 1, 2, 3, 4. Each Clan has unique name and array of members that are in that clan. Is it possible to store these data using Dynamic?

In AmxX I would just do that:
Code:
enum _:ClanData {
	CLAN_ID,
	CLAN_NAME[32],
	CLAN_MEMBERS[MAX_MEMBERS][64]
}
new g_aClans = CreateArray(ClanData);

new clan[ClanData];
clan[CLAN_ID] = 1;
clan[CLAN_NAME] = "My Clan";
clan[CLAN_MEMBERS] = { "Player 1", "Player 2", "Player 3" }
ArrayPushArray(g_aClans, clan);
And done. So easy and so readable. Without dozens of global variables.

Am I doing bad trying to use Dynamic for that?
I would start of by using the Class Builder to build your base class ClanData.

clandata.inc


As per your code example:

Code:
Dynamic Clans = Dynamic();

ClanData Clan = ClanData();
Clan.SetName("My Clan");

Dynamic ClanMembers = ClanData.Members;
ClanMembers.PushString("Player 1");
ClanMembers.PushString("Player 2");
ClanMembers.PushString("Player 3");

Clans.PushDynamic(Clan);
You could then access a ClanData methodmap like so:

Code:
ClanData Clan = Clans.GetDynamicByIndex(0);
__________________
Neuro Toxin is offline
oeN.
Junior Member
Join Date: Apr 2018
Old 07-29-2018 , 06:01   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #273

Yeah, I got that class done before, forgot to send it too.
But thanks for that example, appreciate it.

P.S. Class Builder needs update. SetObjectByOffset and GetObjectByOffset should be changed to SetDynamicByOffset and GetDynamicByOffset, SetObject to SetDynamic.

Last edited by oeN.; 07-29-2018 at 06:03.
oeN. is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-29-2018 , 07:16   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #274

I actually updated it after replying to your pm in this thread.

- Dynamic type now uses Get/SetDynamic
- Dynamic types initialise as Dynamic() instead of INVALID_DYNAMIC_OBJECT
- Serious error msgs (offset issue) now print methodmap name and member
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 11-12-2018 , 00:20   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #275

Using the latest version (0.0.32), I'm getting the following errors:

Code:
my\path\include\dynamic/methodmaps/preparedquery.inc(34) : error 017: undefined symbol "_Dynamic_PreparedQuery_Compile"
my\path\include\dynamic/methodmaps/preparedquery.inc(34) : error 092: number of arguments does not match definition
my\path\include\dynamic/methodmaps/preparedquery.inc(34) : warning 213: tag mismatch
my\path\include\dynamic/methodmaps/preparedquery.inc(39) : error 017: undefined symbol "_Dynamic_PreparedQuery_Prepare"
my\path\include\dynamic/methodmaps/preparedquery.inc(39) : error 092: number of arguments does not match definition
my\path\include\dynamic/methodmaps/preparedquery.inc(39) : warning 213: tag mismatch
my\path\include\dynamic/methodmaps/preparedquery.inc(44) : error 017: undefined symbol "_Dynamic_PreparedQuery_Execute"
my\path\include\dynamic/methodmaps/preparedquery.inc(44) : error 092: number of arguments does not match definition
my\path\include\dynamic/methodmaps/preparedquery.inc(44) : warning 213: tag mismatch
I'm not using dynamic for queries/databases and am wondering if this is a newly introduced bug (the content was added in July). It seems if you arent compiling dynamic itself, the include isnt loading the functions in scripting/dynamic/system/preparedquery.sp that are required for the above. Can you take a look into this, please?
__________________

Last edited by ThatOneGuy; 11-12-2018 at 04:54.
ThatOneGuy is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-12-2018 , 15:43   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #276

Ill have a look into this in the next week. For now please use v0031 of the include isn't compiling with your plugin
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 11-12-2018 , 16:23   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #277

Quote:
Originally Posted by Neuro Toxin View Post
Ill have a look into this in the next week. For now please use v0031 of the include isn't compiling with your plugin
I just commented out that include in the main include to compile, then undid the edit.
__________________
ThatOneGuy is offline
cristi_ip
Senior Member
Join Date: Dec 2010
Location: Bucharest
Old 12-14-2018 , 23:45   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #278

Hello, using the last version (0.0.32), i have the following error:

Code:
L 12/15/2018 - 00:24:58: [SM] Exception reported: Tried to access disposed dynamic handle 0
L 12/15/2018 - 00:24:58: [SM] Blaming: dynamic.smx
L 12/15/2018 - 00:24:58: [SM] Call stack trace:
L 12/15/2018 - 00:24:58: [SM]   [0] ThrowNativeError
L 12/15/2018 - 00:24:58: [SM]   [1] Line 371, ..\dynamic.sp::_Dynamic_IsValid
L 12/15/2018 - 00:24:58: [SM]   [2] Line 117, ..\dynamic/system/methodmaps/dynamicobject.sp::DynamicObject.IsValid
L 12/15/2018 - 00:24:58: [SM]   [3] Line 152, ..\dynamic/system/datatypes/string.sp::_Dynamic_GetStringByOffset
L 12/15/2018 - 00:24:58: [SM]   [4] Line 369, ..\dynamic/system/natives.sp::Native_Dynamic_GetStringByOffset
L 12/15/2018 - 00:24:58: [SM]   [6] Dynamic_GetStringByOffset
L 12/15/2018 - 00:24:58: [SM]   [7] Line 240, D:\Coding\SM_Scripting\scripting1_8\include\dynamic/methodmaps/dynamic.inc::Dynamic.GetStringByOffset
L 12/15/2018 - 00:24:58: [SM]   [8] Line 67, D:\Coding\SM_Scripting\scripting1_8\include\togdmginfo.inc::EventInfo.GetWeapon
L 12/15/2018 - 00:24:58: [SM]   [9] Line 373, D:\Coding\SM_Scripting\scripting1_8\togdmginfo.sp::ShowStats
L 12/15/2018 - 00:24:58: [SM]   [10] Line 350, D:\Coding\SM_Scripting\scripting1_8\togdmginfo.sp::Event_PlayerDeath
Any fix ?

Thank you!
cristi_ip is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-15-2018 , 01:43   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #279

Looks like a plugin is trying to access an object that is alreasy dusposed.

Can you provide the code in the Event_PlayerDeath event callback?
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 12-23-2018 , 23:55   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #280

Quote:
Originally Posted by Neuro Toxin View Post
Looks like a plugin is trying to access an object that is alreasy dusposed.

Can you provide the code in the Event_PlayerDeath event callback?
They PM'd me. I believe it may be an error on my end.

In Event_PlayerDeath (and round end for those still alive), I was combining stats from multiple dynamic objects held in an ArrayList, I was removing/disposing one each time they were combined. In doing so, I didnt have the .IsValid check and thought I was fine without it by tracking how many cells the array had, using the .Erase function (shifting it), and going in reverse order. Somewhere, my logic has a scenario the leads to an invalid object. My fix for now is the .IsValid check. Am waiting to hear back from the poster regarding whether or not the issue is resolved, but I dont believe the error involves dynamic.

To make it more confusing for me, I had a memory leak (now patched) in that I forgot to dispose the objects being removed from the arraylist when they were combined. I was only disposing dynamic objects on next round start. That said, it is strange that an object was already disposed if there was no disposing until after all the processing was done...Is there not multiple seconds between round end/start events (during which all processing should be complete, so all objects should have still been valid)? I suppose I should test that assumption. That said, assuming there is time between those events, I dont understand how any dynamic object being processed could be already disposed. I can send you my code if needed. The .inc file was auto-generated from your tool.

EDIT: .IsValid causes other errors. Plugin is now recoded without Dynamic and all errors are gone.
__________________

Last edited by ThatOneGuy; 12-25-2018 at 12:20.
ThatOneGuy 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 02:30.


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