Jump to content
  • 0

Deleting char_id on an array


pajodex

Question


  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

Hi,

So I tested out a lot of things but this part seemed to be not working.

for(.@i=0; .@i < .@size; .@i++) {
        if (.char_id[.@i] == getcharid(0))
            cleararray .char_id[.@i],0,getcharid(0);
}

This supposed to delete char_id to the array.

Is there an alternative where I can retrieve the char_id list so I can remove the specific char_id listed? To explain futher:

array .char_id:
.char_id[0] = 150001
.char_id[1] = 150002
.char_id[2] = 150003
.char_id[3] = 150004

I want to remove .char_id[2] from the list. using:

deletearray .char_id[2],1;

so results will be:

.char_id[0] = 150001
.char_id[1] = 150002
.char_id[2] = 150004

I also tried this:

for(.@i=0; .@i < .@size; .@i++) {
        if (.char_id[.@i] == getcharid(0))
            deletearray .char_id[.@i],1;
}

but I figured that .@i is not = 2... I know you get what I mean xD 

 

Thanks for anybody interested in helping.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  161
  • Reputation:   31
  • Joined:  12/06/11
  • Last Seen:  

Is .@size defined? 
try
 

for(.@i=0; .@i < getarraysize(.char_id); .@i++) {
        if (.char_id[.@i] == getcharid(0))
            deletearray .char_id[.@i],1;
}

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

1 minute ago, Jeroen said:

Is .@size defined? 
try
 


for(.@i=0; .@i < getarraysize(.char_id); .@i++) {
        if (.char_id[.@i] == getcharid(0))
            deletearray .char_id[.@i],1;
}

 

Will this part of the code ".@i"

deletearray .char_id[.@i],1;

locate the char_id of the invoking character?

Edited by pajodex
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

.@aid = getcharid(0);
for(.@i = getarraysize(.char_id) - 1; .@i >= 0; .@i--) {
	if (.char_id[.@i] == .@aid)
		deletearray .char_id[.@i],1;
}

you could do it this way as well, loop from the end to the start...

this way you wont need to worry to recalculate the index in case you're intend to continue removing all the duplicates data in the array.

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