Need help, check for a location ID.
#1

Hello people!

I need a small help to check if a location ID has already been added.

Let me elaborate more; I have a /addload [loadid] [start] [end] command which imports the start point's location ID and end point's location ID to the selected load's row. The location IDs in the field are formatted and imported in the following way

Код:
10|20|30|40|50|60|70
And split up with sscanf to store in the array. So far, everything works fine. Now, my problem here is; the command user can import the same location ID twice or more. How can I check if the location ID the command user put has already been added?

I tried fetching the result in a local array then looped through it and compared the IDs with the desired one but didn't work.

Any help?

If any code is required, let me know.
Reply
#2

I didn't really understand that command but you may add:

Код:
#define MAX_LOADS somenumberhere
new bool:IsLoadUsed[MAX_LOADS];
So if it used you add there:

Код:
IsLoadUsed[id] = true; or false;
Reply
#3

Quote:
Originally Posted by Matz
Посмотреть сообщение
I didn't really understand that command but you may add:

Код:
#define MAX_LOADS somenumberhere
new bool:IsLoadUsed[MAX_LOADS];
So if it used you add there:

Код:
IsLoadUsed[id] = true; or false;
Exactly!

Код:
for(new i = 0; i < MAX_LOADS; i ++)
{
    if(IsLoadUsed[i] == false) continue;

    printf("ID %i already been added", IsLoadUsed[i]);
}
Reply
#4

You can also use foreach/y_iterate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)