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) == 0 || strcmp(cmd, "/checara", true) == 0)
    {
        if (
IsPlayerConnected(playerid))
        {
            if (
PlayerInfo[playerid][pAdmin] < 0) return SendClientMessage(playerid, COLOR_GRAD1, "ERRO: Vocк nгo tem nнvel administrativo suficiente.");
            if (
PlayerInfo[playerid][pAdminStats] != 0 && PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playerid, COLOR_GRAD1, "ERRO: Vocк nгo estб no modo admin! (/trabalhar)");
            
temp2 = strtok(cmdtext, idx);
            if (!
strlen(temp2)) return SendClientMessage(playerid, -1, "USE: (/ChecarA)rmas [ID/Nome]");
            new 
targetid = ReturnUser(temp2), TW, msg1[250];
            if (
targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAD1, "ERRO: ID/Nome Invбlido.");
            for (new 
a = 0; a <= 9; a++)
            {
                new 
weapon, ammo;
                
GetPlayerWeaponData(targetid, a, weapon, ammo);
                if (
ammo != 0 && weapon != 0)
                {
                    new 
WeaponName[50], Ammo;
                    if (
ammo == -1) Ammo = 1;
                    else 
Ammo = ammo;
                    if (
weapon == 18) WeaponName = "Molotov";
                    else 
GetWeaponName(weapon, WeaponName, 64);
                    
format(string, sizeof(string), "Armas de %s(%d):\n\n%s (ID:%d) - Ammo: %d\n", GetPlayerNameRP(targetid), targetid, WeaponName, weapon, Ammo);
                    
TW++;
                }
            }
            if (
TW == 0)
            {
                
format(string, sizeof(string), "Armas de %s(%d):\n\nNenhuma (ID:0) - Ammo: 0\n", GetPlayerNameRP(targetid), targetid);
            }
            else
            {
                
format(msg1, 128, "<!> Total: %d", TW);
                
SendClientMessage(playerid, COLOR_ADMIN_INFO, msg1);
            }
            
ShowPlayerDialog(playerid, 0, DIALOG_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) == 0 || strcmp(cmd, "/checara", true) == 0)
{
    if (
IsPlayerConnected(playerid))
    {
        if (
PlayerInfo[playerid][pAdmin] < 0) return SendClientMessage(playerid, COLOR_GRAD1, "ERRO: Vocк nгo tem nнvel administrativo suficiente.");
        if (
PlayerInfo[playerid][pAdminStats] != 0 && PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playerid, COLOR_GRAD1, "ERRO: Vocк nгo estб no modo admin! (/trabalhar)");
        
temp2 = strtok(cmdtext, idx);
        if (!
strlen(temp2)) return SendClientMessage(playerid, -1, "USE: (/ChecarA)rmas [ID/Nome]");
        new 
targetid = ReturnUser(temp2), TW, msg1[250];
        if (
targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAD1, "ERRO: ID/Nome Invбlido.");
        for (new 
a = 0; a <= 9; a++)
        {
            new 
weapon, ammo;
            
GetPlayerWeaponData(targetid, a, weapon, ammo);
            if (
ammo != 0 && weapon != 0)
            {
                new 
WeaponName[50], Ammo;
                if (
ammo == -1) Ammo = 1;
                else 
Ammo = ammo;
                if (
weapon == 18) WeaponName = "Molotov";
                else 
GetWeaponName(weapon, WeaponName, 64);
                
format(string, sizeof(string), "%sArmas de %s(%d):\n\n%s (ID:%d) - Ammo: %d\n", string,GetPlayerNameRP(targetid), targetid, WeaponName, weapon, Ammo);
                
TW++;
            }
        }
        if (
TW == 0)
        {
            
format(string, sizeof(string), "Armas de %s(%d):\n\nNenhuma (ID:0) - Ammo: 0\n", GetPlayerNameRP(targetid), targetid);
        }
        else
        {
            
format(msg1, 128, "<!> Total: %d", TW);
            
SendClientMessage(playerid, COLOR_ADMIN_INFO, msg1);
        }
        
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Armas", string, "Fechar", "");
    }
    return 
1;
} 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)