Change inventory va...
 
Notifications
Clear all

Change inventory values....

7 Posts
2 Users
0 Likes
563 Views
(@maroku)
Posts: 7
Active Member
Topic starter
 

And again i need some help :D

Im just not able to change the inventory values in the sql database. I tryed much but the most time the code just created a new item in the database instead of changing a value of the item.

So my question is how do i change inventory values in Unity with Javascript.

 
Posted : 12/05/2013 12:28 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Upon loading inventory it should set the property id of the item, so you store the entire object and change its values. Are you reusing the same object returned by the load event? Without passing the id it will add new objects.

Here is an example:

#pragma strict

var updated : boolean = false;

function Start () {
var cbManager : CBManager = FindObjectOfType(CBManager);
cbManager.OnLogin = OnUserLogin;
cbManager.OnInventoryLoaded = OnInventoryLoaded;
cbManager.Login("aa", "aa");
}

function OnUserLogin (user : CBUser, error : String) {
if (user)
CBManager.instance.LoadInventory(user);
}

function OnInventoryLoaded (inventoryItems : CBInventory[]) {
if (!updated) {
updated = true;
inventoryItems[0].quantity = 3;
inventoryItems[0].Update();
}
}

function OnInventoryUpdated (success : boolean, error : String) {
print("Item updated: " + success);
}

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 12/05/2013 1:37 pm
(@maroku)
Posts: 7
Active Member
Topic starter
 

If i try your code i get "an error occured" php side...

 
Posted : 12/05/2013 3:41 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I'm sorry, may be I fixed it in my local version. I will send you the updated web services later today.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 12/05/2013 4:21 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Hi, PM sent.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 13/05/2013 1:04 am
(@maroku)
Posts: 7
Active Member
Topic starter
 

Well i am sorry aswell.
It was my fault that this did not work correctly. Everything works fine now.
There is no need to fix anything about the CBInventory or Webservice.

 
Posted : 13/05/2013 2:48 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

That's good, may be I remembered a fix that was already included in the current release.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 13/05/2013 2:55 am
Share: