"Bad Datablock from server"

Author Topic: "Bad Datablock from server"  (Read 9089 times)

I got this error testing something I've been experimenting with. Basically, it's an image that acts like a normal weapon but mounts weapons to both slots akimbo-style. Everything else is fine and there are no syntax errors but the game just tells me to forget off because the image datablock is a "bad datablock". The add-on in question is named "Weapon_BowRocket". Thanks in advance to whomever looks at it.


Loading Add-On: Weapon_BowRocket (CRC:1480223719)
Executing Add-Ons/Weapon_BowRocket/server.cs.
  Loading Add-On "Weapon_Bow"
Executing Add-Ons/Weapon_Bow/server.cs.
Executing Add-Ons/Weapon_Bow/weapon_bow.cs.
Executing Add-Ons/Weapon_Bow/server.cs.
Executing Add-Ons/Weapon_Bow/weapon_bow.cs.
Warning: DamageType "ArrowDirect" already exists.
Executing Add-Ons/Weapon_Rocket_Launcher/server.cs.
Executing Add-Ons/Weapon_Rocket_Launcher/weapon_rocket launcher.cs.
Warning: DamageType "RocketDirect" already exists.
Warning: DamageType "RocketRadius" already exists.
Executing Add-Ons/Weapon_BowRocket/Weapon_BowRocket.cs.
Add-Ons/Weapon_BowRocket/Weapon_BowRocket.cs (0): preload failed for BowRocketImage: Bad Datablock from server.
Activating package: AltFire
14 datablocks added.

you need add the image of weapon and put in the zip file then give try run test on your server.
Warning: DamageType "ArrowDirect" already exists - you has same add-ons file inside, you need rename the weapons. same for this

Warning: DamageType "ArrowDirect" already exists
Warning: DamageType "RocketDirect" already exists.
Warning: DamageType "RocketRadius" already exists.

you cannot copy the weapon from their original add-ons weapons, If you want copy the weapon then you have rename on weapon dts, image, etc..  Last thing I want you post the code script of Weapon_BowRocket.cs. I able read it.

you need add the image of weapon and put in the zip file then give try run test on your server.
Warning: DamageType "ArrowDirect" already exists - you has same add-ons file inside, you need rename the weapons. same for this

Warning: DamageType "ArrowDirect" already exists
Warning: DamageType "RocketDirect" already exists.
Warning: DamageType "RocketRadius" already exists.

you cannot copy the weapon from their original add-ons weapons, If you want copy the weapon then you have rename on weapon dts, image, etc..  Last thing I want you post the code script of Weapon_BowRocket.cs. I able read it.
Those errors about DamageType shouldn't matter because it's just from loading the Bow and Rocket Launcher in the server.cs. I load them because the addon requires those two weapons.
I attached the server.cs and the weapon's .cs below.

Don't execute the server.cs files of other add-ons. There's almost never a valid reason to do so.

Your server.cs should probably look like this:
Code: [Select]
if(forceRequiredAddOn("Weapon_Bow") == $Error::AddOn_NotFound)
{
   error("ERROR: Weapon_Bows_Akimbo - required add-on Weapon_Bow not found");
   return;
}
else if(forceRequiredAddOn("Weapon_Rocket_Launcher") == $Error::AddOn_NotFound)
{
   error("ERROR: Weapon_Bows_Akimbo - required add-on Weapon_Rocket_Launcher not found");
   return;
}
else
{
   exec("./Weapon_BowRocket.cs");
}

Notice how forceRequiredAddOn is called twice, once for each required add-on (if all goes well). There's no need to check for $Error::AddOn_Disabed as forceRequiredAddOn will load it anyway. Using forceRequiredAddOn also prevents you from re-loading an add-on that's already been loaded.
« Last Edit: December 14, 2014, 02:05:28 PM by Greek2me »

There's no need to check for $Error::AddOn_Disabed as forceRequiredAddOn will load it anyway.
Am I the only one who hates this? I don't want to force the server to load the add-on. I just want it to know that it's required.

Am I the only one who hates this? I don't want to force the server to load the add-on. I just want it to know that it's required.
You could check for isFile("add-ons/Script_Blah/server.cs") and $ADDON__Script_Blah to see if it exists and is enabled, then load it

Don't execute the server.cs files of other add-ons. There's almost never a valid reason to do so.

Your server.cs should probably look like this:
Code: [Select]
if(forceRequiredAddOn("Weapon_Bow") == $Error::AddOn_NotFound)
{
   error("ERROR: Weapon_Bows_Akimbo - required add-on Weapon_Bow not found");
   return;
}
else if(forceRequiredAddOn("Weapon_Rocket_Launcher") == $Error::AddOn_NotFound)
{
   error("ERROR: Weapon_Bows_Akimbo - required add-on Weapon_Rocket_Launcher not found");
   return;
}
else
{
   exec("./Weapon_BowRocket.cs");
}

Notice how forceRequiredAddOn is called twice, once for each required add-on (if all goes well). There's no need to check for $Error::AddOn_Disabed as forceRequiredAddOn will load it anyway. Using forceRequiredAddOn also prevents you from re-loading an add-on that's already been loaded.
This is very nice. Thank you.

Am I the only one who hates this? I don't want to force the server to load the add-on. I just want it to know that it's required.

That's how it should be, as implied by "force". Does loadRequiredAddOns work the way you want?

I forget the exact details, but there's some flaw in forceRequiredAddon which can crash the game if you call it after it loads a disabled add-on, or on some similar set of conditions.

I forget the exact details, but there's some flaw in forceRequiredAddon which can crash the game if you call it after it loads a disabled add-on, or on some similar set of conditions.
I believe if you put it as a local variable outside of a function.

I believe if you put it as a local variable outside of a function.

This will also crash dedicated servers if done in the console. Generally if you have a local variable outside of a function your add-on is broken in the first place.

Anything about the topic at hand though? Now I just really want to know why this error happened.

Anything about the topic at hand though? Now I just really want to know why this error happened.

If you cannot load the required add-ons, datablocks that you have defined that inherit the other datablocks, since they don't exist, it tries to inherit them, causing the required variables to not be inherited. When sent to the client, it realizes its broken.

Can you send us the full code?

Can you send us the full code?
Those errors about DamageType shouldn't matter because it's just from loading the Bow and Rocket Launcher in the server.cs. I load them because the addon requires those two weapons.
I attached the server.cs and the weapon's .cs below.

These are the only two .cs. Thanks.