public LoadAirline(airlineid)
{
new query[650];
format(query, sizeof(query), "SELECT * FROM `airlines` WHERE `ID` = '%d'", airlineid);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() > 0)
{ // airline exists
new line[1250];
if(mysql_fetch_row(line)) //Fetches the line
{
new string2[200];
new data[10][128]; //The data strings
new data2[17]; //The data variables
new Float:data3[4]; //The data floats
sscanf(line, "p<|>s[128]s[https://sampforum.blast.hk/showthread.php?tid=606814]dddds[128]s[128]s[128]s[128]s[128]s[128]dddddffffs[128]s[128]dddddddd", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2], data[3], data[4], data[5], data[6], data[7], data2[4], data2[5], data2[6], data2[7], data2[8], data3[0],data3[1],data3[2],data3[3],data[8],data[9],data2[9],data2[10],data2[11],data2[12],data2[13],data2[14],data2[15],data2[16]);
format(string2, sizeof(string2), "%s", data[0]);
strmid(AInfo[airlineid][aName], string2, 0, strlen(string2), 128);
format(string2, sizeof(string2), "%s", data[1]);
strmid(AInfo[airlineid][aOwner], string2, 0, strlen(string2), 128);
AInfo[airlineid][aFlights] = data2[0];
AInfo[airlineid][aPayrate] = data2[1];
AInfo[airlineid][aBalance] = data2[2];
AInfo[airlineid][aID] = data2[3];
format(string2, sizeof(string2), "%s", data[2]);
strmid(AInfo[airlineid][aRank1], string2, 0, strlen(string2), 128);
format(string2, sizeof(string2), "%s", data[3]);
strmid(AInfo[airlineid][aRank2], string2, 0, strlen(string2), 128);
format(string2, sizeof(string2), "%s", data[4]);
strmid(AInfo[airlineid][aRank3], string2, 0, strlen(string2), 128);
format(string2, sizeof(string2), "%s", data[5]);
strmid(AInfo[airlineid][aRank4], string2, 0, strlen(string2), 128);
format(string2, sizeof(string2), "%s", data[6]);
strmid(AInfo[airlineid][aRank5], string2, 0, strlen(string2), 128);
format(string2, sizeof(string2), "%s", data[7]);
strmid(AInfo[airlineid][aRank6], string2, 0, strlen(string2), 128);
AInfo[airlineid][aTotalEarnt] = data2[4];
AInfo[airlineid][aTotalPaid] = data2[5];
AInfo[airlineid][aFleetSlots] = data2[6];
//AInfo[airlineid][aFleetTotal] = data2[7]; - We don't need to load it, as it's created upon the airline vehicle spawn.
AInfo[airlineid][aUniform] = data2[8];
AInfo[airlineid][aPos1] = data3[0];
AInfo[airlineid][aPos2] = data3[1];
AInfo[airlineid][aPos3] = data3[2];
AInfo[airlineid][aPos4] = data3[3];
format(string2, sizeof(string2), "%s", data[8]);
strmid(AInfo[airlineid][aMotd], string2, 0, strlen(string2), 200);
format(string2, sizeof(string2), "%s", data[9]);
strmid(AInfo[airlineid][aMotdSetBy], string2, 0, strlen(string2), 128);
AInfo[airlineid][pInvMembers] = data2[9];
AInfo[airlineid][pRmvMembers] = data2[10];
AInfo[airlineid][pPrmMembers] = data2[11];
AInfo[airlineid][pPrkFleet] = data2[12];
AInfo[airlineid][pClrFleet] = data2[13];
AInfo[airlineid][pBnkPerm] = data2[14];
AInfo[airlineid][pRspFleet] = data2[15];
AInfo[airlineid][aDistance] = data2[16];
if(AInfo[airlineid][aMapIcon] == 0) { AInfo[airlineid][aMapIcon] = CreateDynamicMapIcon(data3[0], data3[1], data3[2], 5, 0); }
mysql_free_result();
}
mysql_free_result();
//Admin loaded the airline ID: airlineid
}
else
{
mysql_free_result();
print("Failed to load airline.");
}
}
You just have to follow the instructions.
I think the main problem for you is that mysql now uses a callback which means that you need two functions. One function "LoadAirline" to setup the SQL Query but you also need a new callback to fetch the data. Once the callback is called you usually use cache_get_field etc. I think it becomes more clear to you if you read example codes like the login/register mysql tutorial which is on this forum. |
False. Only threaded queries have a callback. If you want to do a non-threaded query then you will need to save the cache and get the stuff from it then delete the cache and you won't need a callback, but it will freeze the server until it finishes that MySQL stuff, but if you use threaded queries then the server will keep going while that MySQL stuff is happening. You can make threaded queries look better by using y_inline though. Also in R40+ it's cache_get_value_name.
|