1 - Colt 45 2 - Didlo 3 - AK47 4 - Empty .... 10 - Empty Equipped: Right hand: Nothing Left hand: Nothing
1 - Colt 45 2 - Empty 3 - AK47 .... 10 - Empty Equipped: Right hand: Dildo Left hand: Nothing
for(new i = 0; i < 10; i++) { if(pItems[playerid][iID][i] > 0 && pItems[playerid][iUsed][i] == 0) { slot += 1; format(string,sizeof(string), "%s[%i]\t%s\t[%i]\n", string, slot, NObject(pItems[playerid][iType][i]), pItems[playerid][iAmmo][i]); } else { slot += 1; format(string,sizeof(string), "%s[%i]\tEmpty space\n", string, slot); } }
new count;
for(new i = 0; i < 10; i ++)
{
if(pItems[playerid][iID][i] > 0 && pItems[playerid][iUsed][i] == 0)
{
count ++;
format(string, sizeof(string), "%s[%i]\t%s\t[%i]\n", string, count, NObject(pItems[playerid][iType][i]), pItems[playerid][iAmmo][i]);
}
}
for(new i = count; i < 10; i ++)
{
format(string, sizeof(string), "%s[%i]\tEmpty space\n", string, i);
}
Do something like this:
PHP код:
|
new count;
for(new i; i < 10; i ++)
{
if(pItems[playerid][iID][i] > 0 && pItems[playerid][iUsed][i] == 0)
{
count ++;
format(string, sizeof(string), "%s[%i]\t%s\t[%i]\n", string, count, NObject(pItems[playerid][iType][i]), pItems[playerid][iAmmo][i]);
}
}
if(count < 10)
{
for(new i; i < 10-count; i++)
{
count++;
format(string, sizeof(string), "%s[%i]\tEmpty space\n", string, count);
}
}
That's going to show the same number twice. Preferably:
PHP код:
|
....... if(count < 10) { new rest; rest = 10-count; for(new i; i < rest; i++) { ...
Thanks, but there's a problem.
When the player has no items, show 10 slots. When the player has 1 item it shows 9 slots (1 occuped 8 empty), if 2, shows 8 slots, etc. |
new count;
for(new i; i < 10; i ++)
{
if(pItems[playerid][iID][i] > 0 && pItems[playerid][iUsed][i] == 0)
{
count ++;
format(string, sizeof(string), "%s[%i]\t%s\t[%i]\n", string, count, NObject(pItems[playerid][iType][i]), pItems[playerid][iAmmo][i]);
}
}
if(count < 10)
{
for(new i = count; i < 10; i++)
{
count++;
format(string, sizeof(string), "%s[%i]\tEmpty space\n", string, count);
}
}