GetFreeVehicleSlot
#10

Quote:
Originally Posted by Stefand
Посмотреть сообщение
This is what I had when I used Dini files, is there a way to do the same with Mysql?
pawn Код:
stock GetFreeVehicleSlot()
{
    new string[40];
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        format(string, sizeof(string), "Vehicles/Vehicle_%d.ini", i); //format the file
        if(fexist(string)) continue; //If the file exists, go to the next file
        return i; //If the file doesn't exist, then we have an available slot, and we return the number/value of 'i'
    }
    return -1; //return -1 or INVALID_VEHICLE_ID for no available files
}
Would this work?
pawn Код:
stock GetFreeVehicleSlot()
{
    new query[200];
    for(new v = 0; v < MAX_VEHICLES; v ++)
    {
        format(query, sizeof(query), "SELECT * FROM `Vehicles` WHERE CarFileID = %d");
        mysql_function_query(g_connectionHandle, query, false, "DefaultCallback", "");
        mysql_store_result(g_connectionHandle);
        if(mysql_num_rows(g_connectionHandle) > 0) continue;
        return v;
    }
    return -1;
}
Reply


Messages In This Thread
GetFreeVehicleSlot - by Stefand - 04.06.2013, 15:39
Re: GetFreeVehicleSlot - by nmader - 04.06.2013, 16:52
Re: GetFreeVehicleSlot - by Stefand - 04.06.2013, 16:57
Re: GetFreeVehicleSlot - by Pooh7 - 04.06.2013, 17:08
Re: GetFreeVehicleSlot - by Stefand - 04.06.2013, 17:09
Re: GetFreeVehicleSlot - by Stefand - 04.06.2013, 17:16
Re: GetFreeVehicleSlot - by nmader - 04.06.2013, 17:27
Re: GetFreeVehicleSlot - by Stefand - 04.06.2013, 17:44
Re: GetFreeVehicleSlot - by Stefand - 04.06.2013, 18:23
Re: GetFreeVehicleSlot - by Stefand - 04.06.2013, 18:34

Forum Jump:


Users browsing this thread: 2 Guest(s)