Jump to content

ahoy

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Hi, thanks for your reply. I think this case is a little different as `copyarray` requires a reference to an array. Unless I am misunderstanding something, in your example, you are getting a reference to your global array and are then copying it to an array that you are passing as your first argument. But in my case, I need to update a global array. I use `getd` to get a reference to my global array, but the destination array in `copyarray` cannot accept a string reference. When I follow your pattern, I am copying the contents of an array into itself without updating the global array.
  2. I'm creating a storage system which allows users to join a group and share a storage between them. When a group is created, it is assigned an ID. When a player joins the group, they are associated with the group with a permanent account variable. If Alice is in group 0 and she deposits some items 50 items with ID 10 and 7 items with ID 21, the array `$global_storage_keys:0` should be set to `[10, 21]` and the variable `$global_storage:0:10` and `$global_storage:0:21` should be set to 50 and 7 respectively. However, when I try to update the keys variable with `setd`, only the first value of the array is preserved. How do I manipulate an array which I need to `setd` to access? Thanks. function script add_id_to_global_store { // Adds the ID an an item to the key store. // arg0: the integer ID of an item // arg1: the integer ID of the guild .@id = getarg(0); .@guild_id = getarg(1); freeloop(1); .@keys = getd("$global_storage_keys" + ":" + .@guild_id); .@found = callfunc("array_exists", .@keys, .@id); if (.@found) { freeloop(0); return; } // The new ID was not in the global store, so add it. callfunc("array_pad", .@keys, getarraysize(.@keys) + 1, .@id); setd("$global_storage_keys" + ":" + .@guild_id, .@keys); freeloop(0); return; } From this snippet, after I call `setd` with value `.@keys`, the length of `$global_storage_keys:<guild_id>` is always zero.
  3. prontera,133,217,5 script Item Test 4_M_MANAGER,{ getinventorylist; for (.@i = 0; .@i < @inventorylist_count; .@i++) { .@id = @inventorylist_id[.@i]; .@inventory_amount = @inventorylist_amount[.@i]; .@is_equipped = @inventorylist_equip[.@i]; .@is_refined = @inventorylist_refine[.@i]; .@is_carded = @inventorylist_card1[.@i]; mes getitemname(.@id) + ": ID=" + .@id + ", equipped=" + .@is_equipped + ", refined=" + .@is_refined + ", carded=" + .@is_carded; .@storage_count = getd("$global_storage" + .@id); if (!.@is_equipped) { setd("$global_storage" + .@id, .@storage_count + .@inventory_amount); } mes .@storage_count + " -> " + getd("$global_storage" + .@id); } close; } I wrote a small script to see the contents of the arrays that are populated by getinventorylist. The first time I speak to the NPC on a character, I get the output that I expect. However, every subsequent attempt to speak to the NPC, nothing happens. A dialogue box doesn't open, and no errors are logged in the console. If I restart the server, the NPC still won't talk to me. If I make a new character, then the NPC will talk to me exactly one time again. Does anyone know why this might be? EDIT: You can remove this thread, in my loop header I had a typo: for (.@i = 0; i < @inventorylist_count; i++)
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.