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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Chief149
Member
Join Date: Sep 2010
Old 08-26-2016 , 21:34   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #111

I will try the WriteKeyValues thing to see what is up, but it appears to be "GetMemberType" where the failure is originating.

To be specific, it's GetMemberType which includes GetArrayCell which commits the error.
Looking more at your code here, your function Native_Dynamic_SetIntByOffset does exactly what you say.
Code:
if(!Dynamic_IsValid(index, true))
    return 0;
Your ValidateOffset function also executes successfully. This is why I thought that I was using a valid dynamic object instead of trying to operate on an invalid one.
That and I did use:
Code:
if(player != INVALID_DYNAMIC_OBJECT) //player is a dynamic BClient object
    player.UsingVendor = 0;
Ok so it's not quite the player.IsValid that you are suggesting, so an error could slip by there, but the values being sent to your functions are being checked and passing those checks that are done by your functions.

Last edited by Chief149; 08-26-2016 at 21:35.
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2016 , 21:41   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #112

Edit: Please call .IsValid instead of == INVALID_DYNAMIC_OBJECT

I'm half way through another massive refactor. When I'm done I'll post here. Could you then update and provide a full stack trace if the error continues?

In the meantime if you want to help me help you. Try and replicate the error in a really simple plugin.
__________________

Last edited by Neuro Toxin; 08-26-2016 at 21:42.
Neuro Toxin is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 08-26-2016 , 22:02   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #113

How efficient would it be to run Dynamic natives within OnPlayerRunCmd? For example 100 'get' calls per usercmd would drop the server's performance?
__________________
retired
shavit is offline
Chief149
Member
Join Date: Sep 2010
Old 08-26-2016 , 22:07   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #114

I am in the process of writing a quick script that tests every get/set of my BClient class and logs to the console.

EDIT: I guess you were right about me passing an invalid dynamic object. Odd though because I've traced my code and I can't figure out how it could be like that. Plus the error logs didn't seem like it was an invalid dynamic object either. However I was able to successfully get and set every member of my BClient class other than a couple that had additional code (for example, BClient.Speed set the clients in game speed multiplier while also storing the number in memory).

Last edited by Chief149; 08-26-2016 at 22:19.
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2016 , 22:27   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #115

Quote:
Originally Posted by shavit View Post
How efficient would it be to run Dynamic natives within OnPlayerRunCmd? For example 100 'get' calls per usercmd would drop the server's performance?
You shouldn't have a problem.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2016 , 22:39   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #116

Quote:
Originally Posted by Chief149 View Post
I am in the process of writing a quick script that tests every get/set of my BClient class and logs to the console.

EDIT: I guess you were right about me passing an invalid dynamic object. Odd though because I've traced my code and I can't figure out how it could be like that. Plus the error logs didn't seem like it was an invalid dynamic object either. However I was able to successfully get and set every member of my BClient class other than a couple that had additional code (for example, BClient.Speed set the clients in game speed multiplier while also storing the number in memory).
When using classes you HAVE to make sure each member is set in the initialiser. Failure to do this will result in the static offsets storing invalid values. Tgis would mean the object is valid while being able to generate arraylist index errors.
__________________
Neuro Toxin is offline
Chief149
Member
Join Date: Sep 2010
Old 08-26-2016 , 23:03   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #117

I do set each and every single member in the initializer.

The problem I found:
For some reason the menu system keeps calling the menu handler function twice. First with the valid client index, and again with index 0 (why, idk). By fixing the checking, it started working. Technically it was working the entire time on the first handler call, but erroring out on the second one.

I assumed that the source of my BClient instance (GetPlayerInstance(int Client) returns the BClient for that index) was returning the right value. It was. Especially for the second menu handler call (that I had no clue was happening) where the client index was 0. Sourcemod issue there? idk. Haven't looked further into it.
Chief149 is offline
Dark Athena
Member
Join Date: May 2016
Old 09-02-2016 , 02:57   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #118

Is there a way to set a collection as a property? forgive me if this has been answered before.
Dark Athena is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 09-02-2016 , 05:27   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #119

It's umpossible, two methodmaps cant reference eachother.

A collection is an ArrayList so you can use Get/SetHandle* and view_as<Collection>.
__________________
Neuro Toxin is offline
Dark Athena
Member
Join Date: May 2016
Old 09-03-2016 , 18:52   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #120

Quote:
Originally Posted by Neuro Toxin View Post
It's umpossible, two methodmaps cant reference eachother.

A collection is an ArrayList so you can use Get/SetHandle* and view_as<Collection>.

RIGHT. I have a class and I have defined the collection defined with:

Code:
return view_as<ObjectTest>(this.Items(index));
But what I wanted to do was to be able to do something like this in an existing class(where ClientFeatureList is already defined as a collection). Basically, I am treating the collection I defined as just another dynamic object I am returning. Is this allowed?

Code:
    property Dynamic ClientFeatureList
    {
        public get()
        {
            static int offset = INVALID_DYNAMIC_OFFSET;
            if (offset == INVALID_DYNAMIC_OFFSET)
            {
                offset = this.GetMemberOffset("ClientFeatureList");
                if (offset == INVALID_DYNAMIC_OFFSET)
                {
                    SetFailState("A serious error occured in Dynamic!");
                }
            }
            return this.GetObjectByOffset(offset);
        }
        public set(Dynamic value)
        {
            static int offset = INVALID_DYNAMIC_OFFSET;
            if (offset == INVALID_DYNAMIC_OFFSET)
            {
                offset = this.GetMemberOffset("ClientFeatureList");
                if (offset == INVALID_DYNAMIC_OFFSET)
                {
                    offset = this.SetDynamic("ClientFeatureList", value);
                    return;
                }
            }
            this.SetObjectByOffset(offset, value);
        }
    }
And I am setting it with:

Code:
player.SetDynamic("ClientFeatureList", view_as<Dynamic>(ClientList));

Last edited by Dark Athena; 09-03-2016 at 19:20.
Dark Athena is offline
Reply



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


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