Break; function error -
NealPeteros - 09.09.2018
I have this script where the system gives items, and here's how i planned it to work
Код:
- The system searches the inventory for a vacant slot. if found, the player receives level 1 version of the item and its placed on that slot, then it ends the operation.
- If every slot is occupied by level 1 versions of the item, then the system will go to the first slot and "upgrade" that item to a level 2 version, then it ends the operation.
- if every slot is occupied by level 2 versions of the item, then the system will go to the first slot and "upgrade" that item to a level 3 version, then it ends the operation.
I thought I got it, but when I tested it, the break; function doesn't work. It continues to the very last slot.
Re: Break; function error -
NealPeteros - 09.09.2018
Oh shoot, forgot to paste that, sorry.
Pastebin
Re: Break; function error -
Infin1ty - 09.09.2018
why not just use
Код:
PlayerInfo[id][Item][i]++;
and if u want ur highest upgrade to be '3' then put in a if statement and return 1; once it reaches 3 . . .
Re: Break; function error -
NealPeteros - 09.09.2018
Quote:
Originally Posted by Infin1ty
why not just use
Код:
PlayerInfo[id][Item][i]++;
and if u want ur highest upgrade to be '3' then put in a if statement and return 1; once it reaches 3 . . .
|
Something like this?
Pastebin
EDIT: That doesn't work either.
Re: Break; function error -
Infin1ty - 09.09.2018
Код:
for(new i = 0; i < 10; i++)
{
if(HealthInfo[id][HealthLevel][i] == 3) break;
else HealthInfo[id][HealthLevel][i]++, break;
}
See if that works for ya. Its much more efficient as well. I've basically done what you did in like 10+ lines but in 4 lines instead.
Another Edit: To the best of my knowledge, I'm not so sure you understand what '++' does, at least according to the second pastebin you sent. This increments the number of 'HealthInfo[id][HealthLevel][i]' up by 1 each time. If you happen to know SQL I'm sure it would remind you of 'AUTO_INCREMENT', it works the same way.
Re: Break; function error -
NealPeteros - 09.09.2018
Quote:
Originally Posted by Infin1ty
Код:
for(new i = 0; i < 10; i++)
{
if(HealthInfo[id][HealthLevel][i] == 3) break;
else HealthInfo[id][HealthLevel][i]++, break;
}
See if that works for ya. Its much more efficient as well. I've basically done what you did in like 10+ lines but in 4 lines instead.
Another Edit: To the best of my knowledge, I'm not so sure you understand what '++' does, at least according to the second pastebin you sent. This increments the number of 'HealthInfo[id][HealthLevel][i]' up by 1 each time. If you happen to know SQL I'm sure it would remind you of 'AUTO_INCREMENT', it works the same way.
|
Still doesn't work somehow...
Re: Break; function error -
Shinja - 09.09.2018
Show us how you are defining PlayerInfo and the enum inside it aswell
Re: Break; function error -
NealPeteros - 09.09.2018
Quote:
Originally Posted by Shinja
Show us how you are defining PlayerInfo and the enum inside it aswell
|
Код:
enum hInfo
{
HealthLevel[10]
};
new HealthInfo[MAX_PLAYERS][hInfo];
Re: Break; function error -
Shinja - 09.09.2018
Are you sure the variable is working like it suppose to, in that way HealthInfo[id][HealthLevel] might me considered as a string
Re: Break; function error -
NealPeteros - 09.09.2018
Quote:
Originally Posted by Shinja
Are you sure the variable is working like it suppose to, in that way HealthInfo[id][HealthLevel] might me considered as a string
|
It's an array; used it as an array.