Didn't look at all the code, but what are you doing here?
1-
"for(i; i <= 100; i)"
...
"if (i != 0) i"
i gets incremented by 1 every loop (as scripted in the last part in your for statement). You may be skipping indexes this way
EDIT: Nvm, I see you are checking two indexes per loop.
2-
"new i = 1"
...
"if (i != 0)"
You are never setting i to 0 in this piece of code (you're only incrementing it), so this statement is pretty useless.
3-
"i;"
If you meant to increase i with the value of s, the proper way is "i = s" or "i = i s";
This would do the same thing:
Also, (point #4): GetSVarInt() is global. This seems to be a per-vehicle script so it will most likely (I don't know the rest of your script, if the global dynamic server variable has been reset after calling GetFreeTrunkID() (or before) it might not. Depends on your script.
Code:
GetFreeTrunkID(v, s) {
new i=1;
for(i; i <= 100; i)
{
//i;
if(get_vehicle_trunk[v][s][i] == 0)
if(i != 0)
{
i;
if(get_vehicle_trunk[v][s][i] == 0)
i;
1-
"for(i; i <= 100; i)"
...
"if (i != 0) i"
i gets incremented by 1 every loop (as scripted in the last part in your for statement). You may be skipping indexes this way
EDIT: Nvm, I see you are checking two indexes per loop.
2-
"new i = 1"
...
"if (i != 0)"
You are never setting i to 0 in this piece of code (you're only incrementing it), so this statement is pretty useless.
3-
"i;"
If you meant to increase i with the value of s, the proper way is "i = s" or "i = i s";
This would do the same thing:
Code:
GetFreeTrunkID(v, s)
{
for (new i = 1; i <= 100; i)
{
if (!get_vehicle_trunk[v][s][i])
{
return i GetSVarInt("SlotTrunkUsed");
}
}
return -1; //Return -1 when there is no free trunk ID
}
Also, (point #4): GetSVarInt() is global. This seems to be a per-vehicle script so it will most likely (I don't know the rest of your script, if the global dynamic server variable has been reset after calling GetFreeTrunkID() (or before) it might not. Depends on your script.