Jump to content
  • 0

Deleting char_id on an array


Question

Posted

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.

3 answers to this question

Recommended Posts

  • 0
Posted (edited)
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
  • 0
Posted
.@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.

  • Upvote 1

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