Portal SAMP
[Ajuda] Fazer com que inves de abrir meu inventario, abrir do ID mencionado - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Fazer com que inves de abrir meu inventario, abrir do ID mencionado (/showthread.php?tid=3708)



Fazer com que inves de abrir meu inventario, abrir do ID mencionado - RosaScripter - 22/06/2023

Fazer com que inves de abrir meu inventario, abrir do ID mencionado. Fiz algumas formas mas estou errado as var (coisa de iniciante) mas todo mundo tem uma dificuldade. xD

codigo padrão
Código:
CMD:inventario(playerid)
{
    new str[64];
    if(InventarioAberto[playerid])
    {
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawHide(playerid, DrawInv[playerid][i]);
        }
        InventarioAberto[playerid] = 0;
        CancelSelectTextDraw(playerid);
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}cerro su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
        return 1;
    }
    else
    {
        format(str, sizeof(str), "Inventario: %s", Name(playerid));
        PlayerTextDrawSetString(playerid, DrawInv[playerid][34], str);
        PlayerTextDrawSetString(playerid, DrawInv[playerid][38], "");
        for(new i = 1; i < 33; ++i)
        {
            PlayerTextDrawSetPreviewModel(playerid, DrawInv[playerid][i], PlayerInventario[playerid][i][Slot]);
            if(PlayerInventario[playerid][i][Slot] == -1)
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 999);
            }
            else
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 1);
            }
        }
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawShow(playerid, DrawInv[playerid][i]);
        }
        SelectTextDraw(playerid, 0xC4C4C4AA);
        InventarioAberto[playerid] = 1;
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}abrio su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
    }
    return 1;
}

codigo para ver inv de outro jogador
Código:
CMD:mirainv(playerid, params[])
{
    new str[64];
    if(!IsPolicial(playerid))        return notification.Show(playerid, "ERRO", "No tienes permision.", ICONE_ERRO);
    if(Patrulha[playerid] == false)                 return notification.Show(playerid, "ERRO", "No estas en patrulla.", ICONE_ERRO);
    if(sscanf(params, "d", ID))                        return SendClientMessage(playerid, CorErroNeutro, "USE: /mirainv [ID]");
    if(!IsPlayerConnected(ID))                                    return notification.Show(playerid, "ERRO", "Jugador no estas en linea.", ICONE_ERRO);
    if(!IsPerto(playerid,ID))return notification.Show(playerid, "ERRO", "No estas cerca de este jugador.", ICONE_ERRO);
    if(InventarioAberto[playerid])
    {
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawHide(playerid, DrawInv[playerid][i]);
        }
        InventarioAberto[playerid] = 0;
        CancelSelectTextDraw(playerid);
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}cerro su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
        return 1;
    }
    else
    {
        format(str, sizeof(str), "Inventario: %s", Name(playerid));
        PlayerTextDrawSetString(playerid, DrawInv[playerid][34], str);
        PlayerTextDrawSetString(playerid, DrawInv[playerid][38], "");
        for(new i = 1; i < 33; ++i)
        {
            PlayerTextDrawSetPreviewModel(playerid, DrawInv[playerid][i], PlayerInventario[playerid][i][Slot]);
            if(PlayerInventario[playerid][i][Slot] == -1)
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 999);
            }
            else
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 1);
            }
        }
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawShow(playerid, DrawInv[playerid][i]);
        }
        SelectTextDraw(playerid, 0xC4C4C4AA);
        InventarioAberto[playerid] = 1;
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}abrio su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
    }
    return 1;
}

inv q eu uso https://pastebin.com/N5iSuQYg


RE: Fazer com que inves de abrir meu inventario, abrir do ID mencionado - xbruno1000x - 22/06/2023

Tenta dessa maneira:
Código:
CMD:mirainv(playerid, params[])
{
    new str[64];
    if(!IsPolicial(playerid))        return notification.Show(playerid, "ERRO", "No tienes permision.", ICONE_ERRO);
    if(Patrulha[playerid] == false)                 return notification.Show(playerid, "ERRO", "No estas en patrulla.", ICONE_ERRO);
    if(sscanf(params, "d", ID))                        return SendClientMessage(playerid, CorErroNeutro, "USE: /mirainv [ID]");
    if(!IsPlayerConnected(ID))                                    return notification.Show(playerid, "ERRO", "Jugador no estas en linea.", ICONE_ERRO);
    if(!IsPerto(playerid,ID))return notification.Show(playerid, "ERRO", "No estas cerca de este jugador.", ICONE_ERRO);
    if(InventarioAberto[playerid])
    {
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawHide(playerid, DrawInv[playerid][i]);
        }
        InventarioAberto[playerid] = 0;
        CancelSelectTextDraw(playerid);
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}cerro su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
        return 1;
    }
    else
    {
        format(str, sizeof(str), "Inventario: %s", Name(playerid));
        PlayerTextDrawSetString(playerid, DrawInv[playerid][34], str);
        PlayerTextDrawSetString(playerid, DrawInv[playerid][38], "");
        for(new i = 1; i < 33; ++i)
        {
            PlayerTextDrawSetPreviewModel(playerid, DrawInv[playerid][i], PlayerInventario[ID][i][Slot]);
            if(PlayerInventario[ID][i][Slot] == -1)
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 999);
            }
            else
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 1);
            }
        }
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawShow(playerid, DrawInv[playerid][i]);
        }
        SelectTextDraw(playerid, 0xC4C4C4AA);
        InventarioAberto[playerid] = 1;
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}abrio su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
    }
    return 1;
}

Você precisa getar os dados da variável ID ao invés de playerid. playerid vai getar do próprio jogador.


RE: Fazer com que inves de abrir meu inventario, abrir do ID mencionado - RosaScripter - 22/06/2023

(22/06/2023 00:47)xbruno1000x Escreveu:
Código:
CMD:mirainv(playerid, params[])
{
    new str[64];
    if(!IsPolicial(playerid))        return notification.Show(playerid, "ERRO", "No tienes permision.", ICONE_ERRO);
    if(Patrulha[playerid] == false)                 return notification.Show(playerid, "ERRO", "No estas en patrulla.", ICONE_ERRO);
    if(sscanf(params, "d", ID))                        return SendClientMessage(playerid, CorErroNeutro, "USE: /mirainv [ID]");
    if(!IsPlayerConnected(ID))                                    return notification.Show(playerid, "ERRO", "Jugador no estas en linea.", ICONE_ERRO);
    if(!IsPerto(playerid,ID))return notification.Show(playerid, "ERRO", "No estas cerca de este jugador.", ICONE_ERRO);
    if(InventarioAberto[playerid])
    {
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawHide(playerid, DrawInv[playerid][i]);
        }
        InventarioAberto[playerid] = 0;
        CancelSelectTextDraw(playerid);
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}cerro su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
        return 1;
    }
    else
    {
        format(str, sizeof(str), "Inventario: %s", Name(playerid));
        PlayerTextDrawSetString(playerid, DrawInv[playerid][34], str);
        PlayerTextDrawSetString(playerid, DrawInv[playerid][38], "");
        for(new i = 1; i < 33; ++i)
        {
            PlayerTextDrawSetPreviewModel(playerid, DrawInv[playerid][i], PlayerInventario[ID][i][Slot]);
            if(PlayerInventario[ID][i][Slot] == -1)
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 999);
            }
            else
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 1);
            }
        }
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawShow(playerid, DrawInv[playerid][i]);
        }
        SelectTextDraw(playerid, 0xC4C4C4AA);
        InventarioAberto[playerid] = 1;
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}abrio su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
    }
    return 1;
}

Eu aqui alterando um monte de var e tu só mexeu no PlayerInventario praticamente kaka +REP


RE: Fazer com que inves de abrir meu inventario, abrir do ID mencionado - xbruno1000x - 22/06/2023

(22/06/2023 00:51)RosaScripter Escreveu:
(22/06/2023 00:47)xbruno1000x Escreveu:
Código:
CMD:mirainv(playerid, params[])
{
    new str[64];
    if(!IsPolicial(playerid))        return notification.Show(playerid, "ERRO", "No tienes permision.", ICONE_ERRO);
    if(Patrulha[playerid] == false)                 return notification.Show(playerid, "ERRO", "No estas en patrulla.", ICONE_ERRO);
    if(sscanf(params, "d", ID))                        return SendClientMessage(playerid, CorErroNeutro, "USE: /mirainv [ID]");
    if(!IsPlayerConnected(ID))                                    return notification.Show(playerid, "ERRO", "Jugador no estas en linea.", ICONE_ERRO);
    if(!IsPerto(playerid,ID))return notification.Show(playerid, "ERRO", "No estas cerca de este jugador.", ICONE_ERRO);
    if(InventarioAberto[playerid])
    {
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawHide(playerid, DrawInv[playerid][i]);
        }
        InventarioAberto[playerid] = 0;
        CancelSelectTextDraw(playerid);
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}cerro su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
        return 1;
    }
    else
    {
        format(str, sizeof(str), "Inventario: %s", Name(playerid));
        PlayerTextDrawSetString(playerid, DrawInv[playerid][34], str);
        PlayerTextDrawSetString(playerid, DrawInv[playerid][38], "");
        for(new i = 1; i < 33; ++i)
        {
            PlayerTextDrawSetPreviewModel(playerid, DrawInv[playerid][i], PlayerInventario[ID][i][Slot]);
            if(PlayerInventario[ID][i][Slot] == -1)
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 999);
            }
            else
            {
                PlayerTextDrawSetPreviewRot(playerid, DrawInv[playerid][i], 0.000000, 0.000000, 0.000000, 1);
            }
        }
        for(new i = 0; i < 40; ++i)
        {
            PlayerTextDrawShow(playerid, DrawInv[playerid][i]);
        }
        SelectTextDraw(playerid, 0xC4C4C4AA);
        InventarioAberto[playerid] = 1;
        format(str, sizeof(str), "{FFFFFF}*{FF0000}%s {FFFFFF}abrio su inventario.", Name(playerid));
        SendClientMessageInRange(10, playerid, str, 0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA,0xB384FFAA);
    }
    return 1;
}

Eu aqui alterando um monte de var e tu só mexeu no PlayerInventario praticamente kaka +REP

Fico feliz que tenha ajudado. O erro era apenas que você estava usando playerid ao invés de ID(variável que armazena o ID desejado). Devia estar exibindo o inventário do próprio jogador.