weapid is different in every loop.
Code:
new weapons[32], num
get_user_weapons(id, weapons, num)
now the user had 3 weapons; knife, usp and m4a1.
you check the loop if user has m4a1.
Code:
for(new i = 0; i < num; i++) {
if ( weapons[i] == CSW_M4A1 ) {
// This is called when user has m4a1
}
}
That will check first weapons[0] then weapons[1] then weapons[2]. If any of the wepons[x] is CSW_M4A1 the code will be called.
lets say array would be
Code:
weapons[0] = CSW_KNIFE
weapons[1] = CSW_USP
weapons[2] = CSW_M4A1
Then the loop would first check weapons[0] if that is CSW_M4A1. But that if statement would return false so the code will continue, when it finds CSW_M4A1 the if statement will return true and code would be called.
Then it would still continue untill the end if you don't stop it urself.
Code:
new weapons[32], num
get_user_weapons(id, weapons, num)
for(new i = 0; i < num; i++) {
weapid = weapons[i]; // This is only necessary if you use this value more than once.
if ( weapid == CSW_M4A1 ) {
// This is called when user has a m4a1
}
else if ( weapid == CSW_AK47 ) {
// This is called when user has an ak47
}
}