Jump to content
  • 0

Build an array from source and pass to script


Moriarty

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

The title says it all, I'm making a function to return char_ids from everybody on the player screen, so I need to build an array from source, so I can use it on my script, but I have no idea how to do it 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

For examples, look at script commands that set global arrays.

getpartymember() - src/map/script.c#L7142

		for(i=0;i<MAX_PARTY;i++){
			if(p->party.member[i].account_id){
				switch (type) {
				case 2:
					mapreg_setreg(reference_uid(add_str("$@partymemberaid"), j),p->party.member[i].account_id);
					break;
				case 1:
					mapreg_setreg(reference_uid(add_str("$@partymembercid"), j),p->party.member[i].char_id);
					break;
				default:
					mapreg_setregstr(reference_uid(add_str("$@partymembername$"), j),p->party.member[i].name);
				}
				j++;
			}
		}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

Thanks, I did it before looking here, this was a silly post, I should have searched :P

 

Anyway, I have a new problem now.
How do I delete all elements of this array before build it?



I was using mapreg, now i'm using pc_setreg and deleting the array with the npc.. It works, but it would be nice to know how to do it from source :\

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Looking at src/map/mapreg_sql.c#L36, it automatically removes/deletes the variable if you are setting it to 0 or "".

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

Thanks a lot for you attetion.

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...