Re: Dynamic Objects and Properties
Quote:
|
Re: Dynamic Objects and Properties
Okay, so I get that you can store integers, floats, and strings in this thing. For someone who's first "language" is SourcePawn: When and Why should I use this?
|
Re: Dynamic Objects and Properties
Hi headline :)
Great question. The main purpose of use is when you require irregular data sets to be stored and shared between plugins. An example maybe storing times for a timer plugin. You would not be required to store arrays for level / player times and could simply use a dynamic object for storage. You could also hook member data changes which will call forwards to each plugin that has hooked the dynamic object. With this your plugins can be aware of changes in real time without constantly checking for updated data via natives or global forwards. You wouldn't use dynamic objects for plain arrays that dont need to be shared via other plugins. If you've ever had a moment where you wish you could make your own netprop. This is a viable solution that would allow such functionality without the need for you to write natives. I'm personally using this to create member sets for each player. Where one plugin can store members like a playerid and others can read them easily and or hook member changes. I also hook changes and use them to update a mysql databases to synchronise changes automatically to and from plugins with no effort at all. I have some planned changes where <dynamic>(1-maxplayers) will always relate to data for the corresponding client index that auto initialises and disposes with client connect and disconnect events. |
Re: Dynamic Objects and Properties
Got something weird.
PHP Code:
|
Re: Dynamic Objects and Properties
Quote:
Code:
Dynamic someobject = Dynamic(); Code:
Dynamic someobject = view_as<Dynamic>(Native_GetDynamicObject()); Code:
return view_as<int>(someobject); |
Re: Dynamic Objects and Properties
Quote:
Can you maybe post a basic code for one plugin that sends the value and another plugin that receives the value? Maybe thats easier to understand for me & others. |
Re: Dynamic Objects and Properties
Ok. I'll do something up on the weekend hopefully.
|
Re: Dynamic Objects and Properties
Nice, i'm learning more and more from you, keep going.
I will propably use for my next mod. |
Re: Dynamic Objects and Properties
Nice to see similar objectives like in C# and Java in SM :) I head problems with methodsmaps, now I think that u solve my problem, THX !
I always create same question in any topic of plugins, but this is my first time in lib thread: will you add dynamic to github please ? :) P.S. One more thing: Quote:
I had some errors i try to create dynamic player like: Quote:
Quote:
Next I added dynamic player to array based on client id: Quote:
Quote:
Regards, Nerus |
Re: Dynamic Objects and Properties
To check if a object is valid use...
Code:
if (player.IsValid) You also need to Dispose() your object OnClientDisconnect. These objects are not managed and will cause memory leaks if not disposed of correctly. Code:
player.Dispose(); GetInt() already supports default values as the second parameter. Code:
int defaultvalue = player.GetInt ("notset", 123); |
All times are GMT -4. The time now is 14:36. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.