Jump to content
  • 0

[sscript support] array in array


Kurofly

Question


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Hello rA world !

 

I'm working on a script in which it would be very useful to have an array in another array.

Is it possible?

 

Thanks in advance  /thx

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Example?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

I tried something like 

setarray .array[0][0] , 1;

Doesn't work.

 

I'm doing an autoshop which sells items instead of players so that they can play while selling.

A shop must be able to keep trace of what its owners sold so that if they log out before the shop closes it can give them back their items and money$$

 

To do so I need to have an array with all the items sold for each player who didn't login back yet

So the best way would have to set an array in another array.

 

I already changed everything using getd instead but this is something I will want to do in the future for sure so that's why I wanted to know.

 

Thank you for your time . /thx

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Hmm unfortunately a multi-dimension array is impossible to use in rA /hmm

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Too bad  :P

 

At least I know for sure it's impossible.

 

TY

Edited by Kurofly
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

You can do a trick

setarray .@array_acid[0], 2000000, 2000001;
setarray getd( ".@array_item"+ .@array_acid[0] ), 501, 502, 503;

.@array_item2000000[0] == 501

.@array_item2000000[1] == 502

.@array_item2000000[2] == 503

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Don't worry, that's exactly what I did  ;)

function	SetShop	{
	attachrid(getarg(1));
	if (getarg(0) == 0) { mes "Sorry but the last shop has been taken during your set up" ; close; }
	//creates the items in the shop
	npcshopitem "Subshop"+getarg(0),@sold_nameid[0],@price[0];
	delitem @sold_nameid[0],@sold_quantity[0];
	for(@i = 1 ; @i < getarraysize(@sold_nameid) ; @i++) { delitem @sold_nameid[@i],@sold_quantity[@i] ; npcshopadditem "Subshop"+getarg(0),@sold_nameid[@i],@price[@i]; }
	//set the shop and player variables
	for (@i = 0 ; @i < getarraysize(@sold_nameid) ; @i++) {
		setarray getd("$Shop"+getarg(0)+"itemid"+getarraysize(getd("$Shop"+getarg(0)+"rid"))+"["+@i+"]") , @sold_nameid[@i];
		setarray getd("$Shop"+getarg(0)+"amount"+getarraysize(getd("$Shop"+getarg(0)+"rid"))+"["+@i+"]") , @sold_quantity[@i];
		setarray getd("$Shop"+getarg(0)+"price"+getarraysize(getd("$Shop"+getarg(0)+"rid"))+"["+@i+"]") , @price[@i];
		setarray getd("$"+strcharinfo(0)+"amount["+@i+"]") , @sold_quantity[@i];
	}
	setarray getvariableofnpc(.shopname$,"Shop#"+getarg(0)) , @shopname$;
	setd "$Shop"+getarg(0)+"rid["+getarraysize(getd("$Shop"+getarg(0)+"rid"))+"]" , getarg(1);
	//setarray getvariableofnpc(.itemidcount[getarraysize(getd("$Shop"+getarg(0)+"rid"))],"Shop#"+getarg(0)) , @i+1;
	getmapxy @map$,@x,@y,0;
	set getvariableofnpc(.map$,"Shop#"+getarg(0)) , @map$;
	set getvariableofnpc(.x,"Shop#"+getarg(0)) , @x;
	set getvariableofnpc(.y,"Shop#"+getarg(0)) , @y;
	//enable shop
	donpcevent "Shop#"+getarg(0)+"::OnEnable";
	return;
}

But of course it's god damn unreadable  :P

Too bad though ^^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...