a Inventory load er...
 
Notifications
Clear all

a Inventory load error

8 Posts
2 Users
0 Reactions
792 Views
(@unicorn)
Posts: 11
Active Member
Topic starter
 

HI guys! combu is very convenience for me,like it very much, here I have two questions:

question 1:

i configure the php,mysql, then run the admin/index.php, it's all ok.

When i run the unity demo, it's connected correctly too,then i create a user, add a "sword" item to Inventory,then the unity demo get wrong message:

"NullReferenceException: Object reference not set to an instance of an object
DemoGUI.DisplayInventory () (at Assets/combu/Demo/DemoGUI.cs:1123)"

the "item.customData" is null in  line 1123 of DemoGUI.cs:

if (item.customData.Count > 0) {
foreach (string key in item.customData.Keys) {
GUILayout.Label(key + "=" + item.customData[key].ToString());
break;
}
}

Though it occur error, the mysql table: cb_inventory has been written correctly.

question 2:

when i click the button:"Take Screenshot and Send" in "Files" Menu of unity demo, it's appear red info: "File not uploaded".

i wonder if i need to set a ftp? or just some other reason?

 

thank you!

 

 laugh

 
Posted : 11/06/2014 5:54 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Quite strange, I tried right now the Demo scene and haven't this issues. The null reference exception is what I wonder (I will send you a private email to make some tests together on your server and catch it), while about the upload issue I think it's more likely the folder "upload" hasn't the correct "read&write" permissions set on your webserver (usually you can check and change the permissions on files and folders on your favorite FTP client) because Combu doesn't handle FTP.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 11/06/2014 6:09 pm
(@unicorn)
Posts: 11
Active Member
Topic starter
 

thank you very much!

i found the Inventory in unity demo, need to fill the "Name", "Quantity","Custom key(1 as example)", and the last one: "Custom value".

I Fill the "Custom value" with some string like:"sadasdad", or leave it blank, the error will occur.

I look back to Custom menu, it's a dictionary like "<dataKey, DataValue>":

-id : 1

-Username : a

-[Custom] aa : AA

-[Custom] Coins : 0

...

-[Custom] Position:

Is the "Custom value" of inventory need to be some kind of special format? not a simple string or leave blank? I think...

smile

 
Posted : 11/06/2014 6:44 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

In Inventory you don't need to set all the fields, the only required field is the "Name" of the item, everything else is optional (but if you set the "Custom Value" then of course you need to specify also a "Custom Name", because CBInventory.customData like CBUser.customData is an hashtable so it needs both a key and a value and not only a value).

I probably found the issue you're having, I think you set Custom Name or Custom Value enclosed within quotes ("asdasd" instead of asdasd). I fixed this issue now and will include it in the next update that I'm preparing to send next in the few hours/day, meanwhile you can fix yourself by adding the following line in the file /inventory.php at line 83 (right after the assignment of Quantity and before the if statement in the function wsSave):

$rec->CustomData = $_REQUEST["CustomData"];

About your question on the account's Custom Data (menu "CUSTOM" in the demo), the Custom Value is a string and you can leave it blank, but as inventory's custom data you shouldn't enclose in quotes neither the Name nor the Value.

The use of Custom Data are there so you can customize the items and accounts with your own parameters without adding new fields in the database tables, for example you can use the inventory custom data to store specific parameters of your item (e.g. durability of your weapon, quality, etc).

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 11/06/2014 7:00 pm
(@unicorn)
Posts: 11
Active Member
Topic starter
 

When i add a new item to inventory in unity demo,i input value to all four slot [Name],[Quanity],[Custom key(1 as example)],[Custom value],like this:

sword

10

heavy

22

then i check the cb_inventory show like this:

Id     IdAccount    Name    Quantity   CustomData

5            1          sword        10       {"heavy":"22"}

then, in DisplayInventory () in DemoGUI():

if (item.customData.Count > 0)
{
foreach (string key in item.customData.Keys) {
GUILayout.Label(key + "=" + item.customData[key].ToString());
break;
}
}'

the item.customData is null, so it will error: NullReferenceException

when i modify cb_inventory to this:

Id     IdAccount    Name    Quantity   CustomData

5            1          sword        10       {"heavy":"10"}

It will be correct get the item.customData.

I track it to CBInventory.cs:

public virtual void fromHashtable (Hashtable hash) {
...
if (hash.ContainsKey("CustomData") && hash["CustomData"] != null)
{
   if (hash["CustomData"] is Hashtable)
   {
      customData = (Hashtable)hash["CustomData"];
   }
   else
   {
      customData = hash["CustomData"].ToString().hashtableFromJson();
   }
}

It will go to line "customData = hash["CustomData"].ToString().hashtableFromJson();"

Debug.Log(hash["CustomData"].ToString()) show like this:

{"heavy":"22"}  

so it failed.

if change cb_inventory to  {"heavy":"10"}, Debug.Log(hash["CustomData"].ToString()) show like this:

{"heavy":"10"}

it will work correctly.

Then i track to CBManager.cs, here update a inventoryItem:

public virtual void UpdateInventory (CBInventory inventoryItem)

so it's something wrong in saving format?smile

 

thank you!

 
Posted : 12/06/2014 4:11 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I don't know what's going with your installation, I'm not having your issue and in my table it's not saving with slash+double quotes. I sent you an email with the latest package that I'm going to upload sooner, please replace all your combu files and database with that and let me know.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 12/06/2014 5:22 am
(@unicorn)
Posts: 11
Active Member
Topic starter
 

I tried and the slash+double quotes stay the same.

I using mysql-essential-5.1.71-win32,php-5.2.17-Win32-VC6-x86,and a chinese version of SQLyog11.42,window7 32bit_chinese_version.

I will try it in another computer,then tell you the result,it's will be more accurate.

thank you very much!

smile

 
Posted : 13/06/2014 12:40 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Maybe I understood the issue you're having with double quote slashes, I see you're using PHP 5.2 and it probably has enabled magic_quotes by default. I'm away for the weekend but at Monday I'll send a version to you and see if it fixes the issue, in case positive I'll integrate the changes on the official version too.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 05/07/2014 8:58 pm
Share: