Raised This Month: $170 Target: $400
 42% 

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-07-2018 , 20:24   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #271

I've completed updating Dynamic instances.

Code:
	char error[128];
	Database db = SQLite_UseDatabase("dynamictest", error, sizeof(error));

	test.SetString("stringvalue", "a string value 'which needs to be escaped'.", 64);
	test.SetInt("intvalue", 666);
	test.SetFloat("floatvalue", 666.666666666);
	test.SetBool("boolvalue", true);
	test.SetString("ID", "STEAMID:1234567890", 24);

	PreparedQuery query = PreparedQuery();
	query.Compile("UPDATE `table` SET `stringvalue`=?, `intvalue`=?, `floatvalue`=?, `boolvalue`=? WHERE `ID`=?");
	query.Execute(db, test);
	query.Dispose();


	db = null;
	return true;
Here is the .Execute prototype.

Code:
public bool Execute(Database db, Dynamic parameters, SQLQueryCallback callback=INVALID_FUNCTION, any data=0, int buffersize=512)
Callback is the 3rd parameter. When left as INVALID_FUNCTION Dynamic calls an internal callback to keep it threaded.
__________________

Last edited by Neuro Toxin; 07-07-2018 at 20:25.
Neuro Toxin is offline
popey456963
Member
Join Date: Mar 2016
Old 07-22-2018 , 17:49   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #272

In the Methodmap example (2.0 on the Wiki), would you have to destroy the Dynamic object when the methodmap is no longer intended to be removed? Or, since it's attached to that object, do you no longer have to destroy it?
popey456963 is offline
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 #273

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 #274

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 #275

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 #276

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
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:55.


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