Jump to content
  • 0

Build an array from source and pass to script


Question

Posted

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 

4 answers to this question

Recommended Posts

Posted

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++;
			}
		}
Posted

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 :\

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...