Dialogue with loop
#1

I want to make a dialog loop, but I can not, I wanted to show all the weapons the player, with this command to check weapons, when I type this command, shows an incomplete dialogue, example, it has two guns in dialogue shows only one, and when it is to show that he has no weapon.

PHP код:
    if (strcmp(cmd"/checararmas"true) == || strcmp(cmd"/checara"true) == 0)
    {
        if (
IsPlayerConnected(playerid))
        {
            if (
PlayerInfo[playerid][pAdmin] < 0) return SendClientMessage(playeridCOLOR_GRAD1"ERRO: Vocк nгo tem nнvel administrativo suficiente.");
            if (
PlayerInfo[playerid][pAdminStats] != && PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playeridCOLOR_GRAD1"ERRO: Vocк nгo estб no modo admin! (/trabalhar)");
            
temp2 strtok(cmdtextidx);
            if (!
strlen(temp2)) return SendClientMessage(playerid, -1"USE: (/ChecarA)rmas [ID/Nome]");
            new 
targetid ReturnUser(temp2), TWmsg1[250];
            if (
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GRAD1"ERRO: ID/Nome Invбlido.");
            for (new 
0<= 9a++)
            {
                new 
weaponammo;
                
GetPlayerWeaponData(targetidaweaponammo);
                if (
ammo != && weapon != 0)
                {
                    new 
WeaponName[50], Ammo;
                    if (
ammo == -1Ammo 1;
                    else 
Ammo ammo;
                    if (
weapon == 18WeaponName "Molotov";
                    else 
GetWeaponName(weaponWeaponName64);
                    
format(stringsizeof(string), "Armas de %s(%d):\n\n%s (ID:%d) - Ammo: %d\n"GetPlayerNameRP(targetid), targetidWeaponNameweaponAmmo);
                    
TW++;
                }
            }
            if (
TW == 0)
            {
                
format(stringsizeof(string), "Armas de %s(%d):\n\nNenhuma (ID:0) - Ammo: 0\n"GetPlayerNameRP(targetid), targetid);
            }
            else
            {
                
format(msg1128"<!> Total: %d"TW);
                
SendClientMessage(playeridCOLOR_ADMIN_INFOmsg1);
            }
            
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Armas"string"Fechar""");
        }
        return 
1;
    } 
Reply
#2

UP? Please..
Reply
#3

This below should work.
Just keep formatting the string in a way it'll add on everytime the loop "loops"
PHP код:
if (strcmp(cmd"/checararmas"true) == || strcmp(cmd"/checara"true) == 0)
{
    if (
IsPlayerConnected(playerid))
    {
        if (
PlayerInfo[playerid][pAdmin] < 0) return SendClientMessage(playeridCOLOR_GRAD1"ERRO: Vocк nгo tem nнvel administrativo suficiente.");
        if (
PlayerInfo[playerid][pAdminStats] != && PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playeridCOLOR_GRAD1"ERRO: Vocк nгo estб no modo admin! (/trabalhar)");
        
temp2 strtok(cmdtextidx);
        if (!
strlen(temp2)) return SendClientMessage(playerid, -1"USE: (/ChecarA)rmas [ID/Nome]");
        new 
targetid ReturnUser(temp2), TWmsg1[250];
        if (
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GRAD1"ERRO: ID/Nome Invбlido.");
        for (new 
0<= 9a++)
        {
            new 
weaponammo;
            
GetPlayerWeaponData(targetidaweaponammo);
            if (
ammo != && weapon != 0)
            {
                new 
WeaponName[50], Ammo;
                if (
ammo == -1Ammo 1;
                else 
Ammo ammo;
                if (
weapon == 18WeaponName "Molotov";
                else 
GetWeaponName(weaponWeaponName64);
                
format(stringsizeof(string), "%sArmas de %s(%d):\n\n%s (ID:%d) - Ammo: %d\n"string,GetPlayerNameRP(targetid), targetidWeaponNameweaponAmmo);
                
TW++;
            }
        }
        if (
TW == 0)
        {
            
format(stringsizeof(string), "Armas de %s(%d):\n\nNenhuma (ID:0) - Ammo: 0\n"GetPlayerNameRP(targetid), targetid);
        }
        else
        {
            
format(msg1128"<!> Total: %d"TW);
            
SendClientMessage(playeridCOLOR_ADMIN_INFOmsg1);
        }
        
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Armas"string"Fechar""");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)