loop problem
#1

Im having problems with this code i made it myself but there is one problem the loop sends the message 10 times that is the max cars that a player can own and is buged -.- how i can make it send only one message for each vehicle get from the db? I really need help with it =|


pawn Код:
if(strcmp(x_v,"list",true) == 0)
        {
            new query[256];
            for(new i; i < MAX_PLAYER_CARS; i ++)
            {
                format(query, sizeof(query)," SELECT * FROM vehicles WHERE Owner= '%s' LIMIT 1",playerinfo[playerid][Name]);
                mysql_query(query);
                mysql_store_result();
                if(mysql_num_rows())
                if(mysql_fetch_row(query,"|"))
                {
                    sscanf(query, "p<|>e<iiiifffs[25]iii>", vehicleinfo[i]);
                    format(string, sizeof(string),"Owner: %s || Car id : %d || Model id : %d", vehicleinfo[i][Owner], vehicleinfo[i][id],vehicleinfo[i][Model]);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                }
            }
            return 1;
        }
Reply
#2

pawn Код:
if(strcmp(x_v,"list",true) == 0)
        {
            new query[256];
            format(query, sizeof(query),"SELECT * FROM vehicles WHERE Owner='%s'",playerinfo[playerid][Name]);
            mysql_query(query);
            mysql_store_result();
            if(mysql_num_rows())
            {
                for(new i; i < MAX_PLAYER_CARS; i++)
                {
                    if(mysql_fetch_row(query,"|"))
                    {
                        sscanf(query, "p<|>e<iiiifffs[25]iii>", vehicleinfo[i]);
                        format(string, sizeof(string),"Owner: %s || Car id : %d || Model id : %d", vehicleinfo[i][Owner], vehicleinfo[i][id],vehicleinfo[i][Model]);
                        SendClientMessage(playerid, COLOR_GREEN, string);
                    }
                }
            }
            mysql_free_result();
            return 1;
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)