Need help, check for a location ID. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help, check for a location ID. (
/showthread.php?tid=610695)
Need help, check for a location ID. -
Sjn - 27.06.2016
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.
Re: Need help, check for a location ID. -
Matz - 27.06.2016
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;
Re: Need help, check for a location ID. -
F1N4L - 27.06.2016
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]);
}
Re: Need help, check for a location ID. -
Stinged - 27.06.2016
You can also use foreach/y_iterate.