Array Help ?
Sorry if I explain this bad.
I have this array Code:
And I use it like so: Code:
All that works just fine. And I have a task to remove messages in the array every so often. (RefreshMessages) But I want a better way to remove a message. This is my problem: Code:
Obviously, since i use "contain" it would remove all those messages. Is there any way i can maybe make "AddMessage" return something, to remove my exactly message I added? I can return the position where the string is, but "RefreshMessages" bumps it around. Any ideas? This is what I was hoping for: Code:
|
Re: Array Help ?
RemoveMessage(id,Msg[id]); ?!
|
Re: Array Help ?
Quote:
|
Re: Array Help ?
You could get where the message goes by returning it from the refreshmessages to addmessage and from there to the variable and use it with removemessage or make them to same function etc... Still you'r saying that it removes all because you are using contain. How about using equal, or is there some reason why you wouldn't? You could actually make two funcs, one with containi and one with equal check.
|
Re: Array Help ?
You could do this:
Code:
Code:
|
Re: Array Help ?
That. Is. Perfect.
Thank you! |
Re: Array Help ?
This would be better for AddMessage() so it replaces the slots that have deleted messages.
Code:
|
Re: Array Help ?
To retrieve i efficiently, use ArraySize instead of loop + if( !IsValidMessage(client, i) )
Of course this assumes you delete array item if you delete a message. |
Re: Array Help ?
Quote:
Therefore, the index returned from AddMessage() will be wrong if a message before it was deleted. |
Re: Array Help ?
Quote:
|
| All times are GMT -4. The time now is 01:32. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.