So I've been having an issue with setting some properties. dynamic.smx throws an exception basically.
The relevant part of my object's constructor:
Code:
public BClient(char steamid[64], int Client, bool loadFromDB = true)
{
if(g_iLaser == -1)
g_iLaser = PrecacheModel("materials/sprites/laserbeam.vmt", true);
//the backing data structure
Dynamic bc = Dynamic(256, 0);
//one of the fields that wont work
bc.SetInt("usingvendor", 0);
//these lines only occur after EVERY field has been setup in the constructor
if(loadFromDB)
CreateTimer(3.0, LoadClient, bc);
return view_as<BClient>(bc);
}
Here is the property code:
Code:
property int UsingVendor
{
public get()
{
static int offset = INVALID_DYNAMIC_OFFSET;
if(offset == INVALID_DYNAMIC_OFFSET)
{
offset = this.GetMemberOffset("usingvendor");
if(offset == INVALID_DYNAMIC_OFFSET)
ThrowError("A serious error has occurred in Dynamic!");
}
return this.GetIntByOffset(offset);
}
public set(int i)
{
static int offset = INVALID_DYNAMIC_OFFSET;
if(offset == INVALID_DYNAMIC_OFFSET)
{
offset = this.GetMemberOffset("usingvendor");
if(offset == INVALID_DYNAMIC_OFFSET)
{
offset = this.SetInt("usingvendor", i);
return;
}
}
this.SetIntByOffset(offset, i);
}
}
The code that triggers the error:
Code:
player.UsingVendor = 0;
//The error thrown to the console
Code:
L 08/26/2016 - 21:15:25: [SM] Exception reported: Invalid index 1 (count: 0)
L 08/26/2016 - 21:15:25: [SM] Blaming: dynamic.smx()
L 08/26/2016 - 21:15:25: [SM] Call stack trace:
L 08/26/2016 - 21:15:25: [SM] [0] GetArrayCell
L 08/26/2016 - 21:15:25: [SM] [1] Line 1199, C:\Users\Clayton\Dropbox\BluRP Dev\dynamic.sp::GetMemberType()
L 08/26/2016 - 21:15:25: [SM] [2] Line 1527, C:\Users\Clayton\Dropbox\BluRP Dev\dynamic.sp::Native_Dynamic_SetIntByOffset()
L 08/26/2016 - 21:15:25: [SM] [4] Dynamic_SetIntByOffset
L 08/26/2016 - 21:15:25: [SM] [5] Line 201, C:\Users\Clayton\Dropbox\BluRP Dev\include\dynamic.inc::Dynamic.SetIntByOffset()
L 08/26/2016 - 21:15:25: [SM] [6] Line 1166, C:\Users\Clayton\Dropbox\BluRP Dev\include\bluerp/classes/BClient.inc::BClient.UsingVendor.set()
L 08/26/2016 - 21:15:25: [SM] [7] Line 1502, C:\Users\Clayton\Dropbox\BluRP Dev\include\bluerp/classes/BNpc.inc::JobHandle()
Is this an error on my end or with your plugin? I seem to be following everything correctly as far as I can tell. Judging by the error, I am pretty sure I am NOT trying to access a property of an invalid dynamic object.