Jump to content
The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades. ×
  • 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:   594
  • Joined:  10/26/11
  • Last Seen:  

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

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

  1. for(i=0;i<MAX_PARTY;i++){
  2. if(p->party.member[i].account_id){
  3. switch (type) {
  4. case 2:
  5. mapreg_setreg(reference_uid(add_str("$@partymemberaid"), j),p->party.member[i].account_id);
  6. break;
  7. case 1:
  8. mapreg_setreg(reference_uid(add_str("$@partymembercid"), j),p->party.member[i].char_id);
  9. break;
  10. default:
  11. mapreg_setregstr(reference_uid(add_str("$@partymembername$"), j),p->party.member[i].name);
  12. }
  13. j++;
  14. }
  15. }
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:   594
  • 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...