Raised This Month: $101 Target: $400
 25% 

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 , 21: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 21:25.
Neuro Toxin is offline
popey456963
Member
Join Date: Mar 2016
Old 07-22-2018 , 18: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 , 01: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 , 23: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 , 07: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 07:03.
oeN. is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-29-2018 , 08: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
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 11-12-2018 , 01:20   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #277

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 05:54.
ThatOneGuy is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-12-2018 , 16:43   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #278

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 , 17:23   Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
Reply With Quote #279

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
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 22:23.


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