And again i need some help
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.
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:
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
If i try your code i get "an error occured" php side...
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
Hi, PM sent.
FRANCESCO CROCETTI @ SKARED CREATIONS
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.
That's good, may be I remembered a fix that was already included in the current release.
FRANCESCO CROCETTI @ SKARED CREATIONS