06.02.2015, 18:38
for(new i = 0; i <= i; i++)
warning 219: local variable "i" shadows a variable at a preceding level
warning 219: local variable "i" shadows a variable at a preceding level
for(new j = 0 j <= j; j++)
for(new j = 0 j <= j; j++) // <<<<<<<<<<<
{
GetPlayerWeaponData(playerid, j, weapons[j][0], weapons[j][1]);
}
for(new j = 0; j <= j; j++)
for(new j = 0; j <= 12; j++) // j <= j means infinite loop, that's why i changed it into j <= 12 since there are only 12 weapon slots
{
GetPlayerWeaponData(playerid, j, weapons[j][0], weapons[j][1]);
}
- Hey, let's set j to 0. - Is j less or equal to j? Well, yes it is, because 0 is less or equal to 0. Good, then call GetPlayerWeaponData. - We called GetPlayerWeaponData, now let's increase j by 1. j is 1 now. - Is j less or equal to j? Well, yes it is, because 1 is less or equal to 1. Good, then call GetPlayerWeaponData. - We called GetPlayerWeaponData, now let's increase j by 1. j is 2 now. [...] TO INFINITY AND BEYOND. Never do this, you'll crash your server due to a huge CPU consumption.
for(new qzh = 0; qzh <= 12; qzh ++) // j <= j means infinite loop, that's why i changed it into qzh <= 12 since there are only 12 weapon slots
{
GetPlayerWeaponData(playerid, qzh, weapons[qzh][0], weapons[qzh][1]);
}