
ahoy
Members-
Content Count
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Staff Applications
Calendar
Everything posted by ahoy
-
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.
-
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 [email protected] = getarg(0); [email protected]_id = getarg(1); freeloop(1); [email protected] = getd("$global_storage_keys" + ":" + [email protected]_id); [email protected] = callfunc("array_exists", [email protected], [email protected]); if ([email protected]) { freeloop(0); return; } // The new ID was not in the global store, so add it. callfunc("array_pad", [email protected], getarraysize([email protected]) + 1, [email protected]); setd("$global_storage_keys" + ":" + [email protected]_id, [email protected]); freeloop(0); return; } From this snippet, after I call `setd` with value `[email protected]`, the length of `$global_storage_keys:<guild_id>` is always zero.
-
prontera,133,217,5 script Item Test 4_M_MANAGER,{ getinventorylist; for ([email protected] = 0; [email protected] < @inventorylist_count; [email protected]++) { [email protected] = @inventorylist_id[[email protected]]; [email protected]_amount = @inventorylist_amount[[email protected]]; [email protected]_equipped = @inventorylist_equip[[email protected]]; [email protected]_refined = @inventorylist_refine[[email protected]]; [email protected]_carded = @inventorylist_card1[[email protected]]; mes getitemname([email protected]) + ": ID=" + [email protected] + ", equipped=" + [email protected]_equipped + ", refined=" + [email protected]_refined + ", carded=" + [email protected]_carded; [email protected]_count = getd("$global_storage" + [email protected]); if ([email protected]_equipped) { setd("$global_storage" + [email protected], [email protected]_count + [email protected]_amount); } mes [email protected]_count + " -> " + getd("$global_storage" + [email protected]); } 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 ([email protected] = 0; i < @inventorylist_count; i++)