MySQL value takes other place
#1

Hey,
I have a problem with MySQL data.
I have a function to show bag content to a player:
pawn Код:
stock ShowBag(playerid, bagid, bagmodel)
{
    new requete[82], rows;
    mysql_format(MySQLConnect, requete, sizeof(requete),  "SELECT Modele, Info FROM serveur_sacs WHERE SacID = %d ORDER BY Modele ASC", bagid);
    new Cache:sac = mysql_query(MySQLConnect, requete);
    cache_get_row_count(rows);
    if(rows)
    {
        new menu[1024] = "{FFFFFF}", objet[64], mobjet, Float:minfo, Float:poids;
        for(new i = 0; i < rows; i++)
        {
            cache_get_value_name_int(i, "Modele", mobjet);
            cache_get_value_name_float(i, "Info", minfo);

            format(objet, sizeof(objet), "• %s\n", GetObjectName(mobjet, minfo));
            SendClientMessage(playerid, -1, "i: %d (rows: %d) - SACID: %d - mobjet: %d, minfo: %0.1f, %s", i, rows, bagid, mobjet, minfo, GetObjectName(mobjet, minfo));

            if(!IsABag(mobjet)) poids += GetObjectWeight(mobjet);
            else poids += GetBagWeight(floatround(minfo));

            // poids += GetObjectWeight(mobjet);


            strcat(menu, objet);
        }
        format(requete, sizeof(requete), "%s - Capacitй: %.1f/%.1f", GetObjectName(bagmodel), poids, GetBagMaxWeight(bagmodel));
        Dialog_Show(playerid, SAC_MENU, DIALOG_STYLE_LIST, requete, menu, "Ok", "Quitter");
        SetPVarInt(playerid, "BagID_Menu", bagid);
    }
    else SendClientMessage(playerid, COULEUR_ROUGE, "Ce sac est vide.");
    cache_delete(sac);
    return 1;
}
In-game, the script give me:
Код:
[14:57:45] i: 0 (rows: 4) - SACID: 1 - mobjet: 356, minfo: 1.0, M4A1 avec 1 munitions
[14:57:45] i: 1 (rows: 4) - SACID: 1 - mobjet: 372, minfo: 1.0, Tec-9 avec 1 munitions
[14:57:45] i: 2 (rows: 4) - SACID: 1 - mobjet: 1575, minfo: 3.0, Sacoche
[14:57:45] i: 3 (rows: 4) - SACID: 1 - mobjet: 1575, minfo: 3.0, Sacoche
Instead of:


I know that the problem comes from this function GetBagWeight because when I let just poids += GetObjectWeight(mobjet) that works perfectly but I don't want to ignore the bag weight.
This function calls a mysql query:
pawn Код:
forward Float:GetBagWeight(bagid);
stock Float:GetBagWeight(bagid)
{
    new requete[82], rows, Float:poids = 0.0;
    mysql_format(MySQLConnect, requete, sizeof(requete),  "SELECT Modele, Info FROM serveur_sacs WHERE SacID = %d ORDER BY Modele ASC", bagid);
    new Cache:sac = mysql_query(MySQLConnect, requete);
    cache_get_row_count(rows);
    if(rows)
    {
        new mobjet;
        for(new i = 0; i < rows; i++)
        {
            cache_get_value_name_int(i, "Modele", mobjet);
            poids += GetObjectWeight(mobjet);
        }
    }
    cache_delete(sac);
    return poids;
}
Can some help me ?
Thanks.
Reply
#2

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)