SA-MP Forums Archive
їMe ayudan a convertir esto? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: їMe ayudan a convertir esto? (/showthread.php?tid=540706)



їMe ayudan con esto? - Ghost112397 - 06.10.2014

Hola, estoy haciendo un sistema de inventario para mi servidor, pero no sй como hacer para verificar si un slot del inventario esta vacнo, es decir, їexiste alguna funciуn para verificar si el texto de 'PlayerTextDraw' es 'Vacio'?


Respuesta: їMe ayudan a convertir esto? - Zume - 06.10.2014

Para eso usarнas variables no?


Respuesta: їMe ayudan a convertir esto? - aoEXE - 06.10.2014

lo que se me ocurre es algo asн, por ahн te guнas xd

pawn Код:
enum PlayerData
{
    Objeto1,
    Objeto2
};
new PlayerInfo[MAX_PLAYERS][PlayerData];

new objeto[50],string[100];
if(PlayerInfo[playerid][Objeto1] >= 1) //si Objeto1 es 1 o mayor
{
    format(objeto,sizeof(objeto),"%d",PlayerInfo[playerid][Objeto1]);
}
else //si NO es 1 o mayor
{
    objeto = "Vacio";
}
format(string,sizeof(string),"1.Slot = %s",objeto);
//mostrar que contiene 1.slot



- Ghost112397 - 06.10.2014

їPero como hago para checkear los 7 slots?

EDIT: Para aclarar, lo que quiero hacer es que al agregar un objeto al inventario, que verifique si el slot 1, 2, 3 ..., estбn libres, para asн ordenarse y no tener en el slot 1 tal cosa, el 2 vacнo, el tres vacнo, y el 4 con un arma.

Miren, me puse a pensar y con un poco de ingenio hice esto, їesta bien echo?, el compilador me indica que sн.
pawn Код:
stock ActualizarInventario(playerid, itemid)
{
    new inventario[32], text[64], objectotomado;
    switch(itemid)
    {
        case 0:
        {
            inventario = "Pizza";
            objectotomado = 1;
        }
        case 1:
        {
            inventario = "Botella de agua";
            objectotomado = 2;
        }
    }
    if(IsPlayerConnected(playerid))
    {
        if(Informacion[playerid][pSlotUsado1] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw6[playerid], text);
            Informacion[playerid][pSlotUsado1] = 1;
            Informacion[playerid][pItem1] = objectotomado;
        }
        else if(Informacion[playerid][pSlotUsado2] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw4[playerid], text);
            Informacion[playerid][pSlotUsado2] = 1;
            Informacion[playerid][pItem2] = objectotomado;
        }
        else if(Informacion[playerid][pSlotUsado3] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw5[playerid], text);
            Informacion[playerid][pSlotUsado3] = 1;
            Informacion[playerid][pItem3] = objectotomado;
        }
        else if(Informacion[playerid][pSlotUsado4] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw7[playerid], text);
            Informacion[playerid][pSlotUsado4] = 1;
            Informacion[playerid][pItem4] = objectotomado;
        }
        else if(Informacion[playerid][pSlotUsado5] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw8[playerid], text);
            Informacion[playerid][pSlotUsado5] = 1;
            Informacion[playerid][pItem5] = objectotomado;
        }
        else if(Informacion[playerid][pSlotUsado6] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw9[playerid], text);
            Informacion[playerid][pSlotUsado6] = 1;
            Informacion[playerid][pItem6] = objectotomado;
        }
        else if(Informacion[playerid][pSlotUsado7] == 0)
        {
            format(text, sizeof(text), "%s",inventario);
            PlayerTextDrawSetString(playerid, Textdraw10[playerid], text);
            Informacion[playerid][pSlotUsado7] = 1;
            Informacion[playerid][pItem7] = objectotomado;
        }
    }
    return 1;
}