Mysql issue with number of rows (probably stupid mistake.)
#1

It might be to with the fact that it's 5am and I'm missing something aha!

I have this Under OnPlayerEnterVehicle, if the number of rows == 1 then it displays correctly, if the number of rows are above 1, it does not display at all. Why might this be?

Thanks in advance.
pawn Код:
if(VehicleSQLID[vehicleid] > 0)
    {
        if(VehOwner[vehicleid] == PlayerSQLID[playerid])
        {
            new query[256], string[256];
            format(query, sizeof(query), "SELECT * FROM `ptickets` WHERE `VehID` = %d", VehicleSQLID[vehicleid]);
            mysql_query(query);
            mysql_store_result();
            new rows = mysql_num_rows();
            printf("ROWS %d", rows);
            if(rows == 1)
            {
                format(string, sizeof(string), "This vehicle has an "COL_RED"outstanding"COL_WHITE" parking ticket to be paid, please visit a police station to view/pay your parking tickets.");
                SendClientMessage(playerid, COLOUR_WHITE, string);
            }
            if(rows > 1)
            {
                format(string, sizeof(string), "This vehicle has a total of "COL_BLUE"%d "COL_RED"outstanding"COL_WHITE" parking tickets to be paid, please visit a police station to view/pay your parking tickets.", rows);
                SendClientMessage(playerid, COLOUR_WHITE, string);
            }
        }
    }
    return 1;
}
Reply
#2

Making SQL queries in callback such as OnPlayerEnterVehicle is a bad thing.You will fetch the same information thousands of times every day.

Instead make variables to store the information and use them.You will face heavy lag if you get a large player count(Assuming that you have done this everywhere).

Are you doing some SQL queries in OnPlayerUpdate?

What did the printf tell?
Reply
#3

I considered doing that, but decided not to, you make a good point actually. I don't use any queries etc under on player update.

I will place them into variables and do the checks there although I do feel it's not going to do much if it remains.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)