02.07.2014, 12:51
I want to make a system that once you hit a certain dialogue on the car will function checks whether there is enough money, the car will add MySQL, and finally load the car.
It makes everything but she is not charging correctly the data.
Function what i use:
LoadCarID(CarID) function:
Debug.txt show that:
It makes everything but she is not charging correctly the data.
Function what i use:
PHP код:
function AddCar(omanik, Desc[], model, price, id)
{
new query[512], amswer;
if(PlayerInfo[id][pCash] < hind) return SendClientMessage(id, -1, "You don't have enough money!");
format(query, sizeof(query), "INSERT INTO `Cars` (Owned, Owner, Model, Value, Locationx, Locationy, Locationz, Angle, Parked, Stock) VALUES (1, %d, %d, %d, 763.7009, -1016.5224, 23.9668, 0, 0, %d)", KasutajaInfo[id][pSQLID], model, price, price);
mysql_query(query);
mysql_query(query);
answer = mysql_insert_id();
SFM(id, -1, "DEBUG: sql last insert id %d", answer);
LoadCarID(answer);
SetPlayerCheckpoint( id, 763.7009, -1016.5224, 23.9668, 3.0 );
GivePlayerMoneyEx( id, -(price) );
SFM( id, COLOR_LIGHTBLUE, "Car: %s Price: %d euro. (( Car id %d ))", Desc, hind, answer );
return 1;
}
PHP код:
funktsioon LoadCarID(z)
{
mysql_debug(1);
new result[128], sql[256];
format(sql, sizeof(sql), "SELECT * FROM `Cars` WHERE `CarId` = '%d'", z);
mysql_query(sql);
mysql_store_result();
if(mysql_fetch_row_format(sql,"|"))
{
mysql_fetch_field_row(result,"Owned"); AutoInfo[z][cOwned] = strval(result);
mysql_fetch_field_row(result,"Owner"); AutoInfo[z][cOwner] = strval(result);
mysql_fetch_field_row(result,"Description"); strmid(AutoInfo[z][cDescription], result, 0, strlen(result), 255);//
mysql_fetch_field_row(result,"Model"); AutoInfo[z][cModel] = strval(result);
mysql_fetch_field_row(result,"Value"); AutoInfo[z][cValue] = strval(result);
mysql_fetch_field_row(result,"Lock"); AutoInfo[z][cLock] = strval(result);
mysql_fetch_field_row(result,"Locationx"); AutoInfo[z][cLocationx] = floatstr(result);
mysql_fetch_field_row(result,"Locationy"); AutoInfo[z][cLocationy] = floatstr(result);
mysql_fetch_field_row(result,"Locationz"); AutoInfo[z][cLocationz] = floatstr(result);
mysql_fetch_field_row(result,"Angle"); AutoInfo[z][cAngle] = floatstr(result);
mysql_fetch_field_row(result,"Parked"); AutoInfo[z][cParked] = strval(result);
mysql_fetch_field_row(result,"ParkLocationx"); AutoInfo[z][cParkLocationx] = floatstr(result);
mysql_fetch_field_row(result,"ParkLocationy"); AutoInfo[z][cParkLocationy] = floatstr(result);
mysql_fetch_field_row(result,"ParkLocationz"); AutoInfo[z][cParkLocationz] = floatstr(result);
mysql_fetch_field_row(result,"ParkAngle"); AutoInfo[z][cParkAngle] = floatstr(result);
mysql_fetch_field_row(result,"Narkot"); AutoInfo[z][cNarkot] = strval(result);
mysql_fetch_field_row(result,"AMaterjale"); AutoInfo[z][cMaterjale][0] = strval(result);
mysql_fetch_field_row(result,"BMaterjale"); AutoInfo[z][cMaterjale][1] = strval(result);
mysql_fetch_field_row(result,"CMaterjale"); AutoInfo[z][cMaterjale][2] = strval(result);
mysql_fetch_field_row(result,"Nitro"); AutoInfo[z][cNitro] = strval(result);
mysql_fetch_field_row(result,"GPS"); AutoInfo[z][cGPS] = strval(result);
mysql_fetch_field_row(result,"Raadio"); AutoInfo[z][cRaadio] = strval(result);
mysql_fetch_field_row(result,"Comp1"); AutoInfo[z][cComp1] = strval(result);
mysql_fetch_field_row(result,"Comp2"); AutoInfo[z][cComp2] = strval(result);
mysql_fetch_field_row(result,"Comp3"); AutoInfo[z][cComp3] = strval(result);
mysql_fetch_field_row(result,"Comp4"); AutoInfo[z][cComp4] = strval(result);
mysql_fetch_field_row(result,"Comp5"); AutoInfo[z][cComp5] = strval(result);
mysql_fetch_field_row(result,"Comp6"); AutoInfo[z][cComp6] = strval(result);
mysql_fetch_field_row(result,"Comp7"); AutoInfo[z][cComp7] = strval(result);
mysql_fetch_field_row(result,"Comp8"); AutoInfo[z][cComp8] = strval(result);
mysql_fetch_field_row(result,"Comp9"); AutoInfo[z][cComp9] = strval(result);
mysql_fetch_field_row(result,"Comp10"); AutoInfo[z][cComp10] = strval(result);
mysql_fetch_field_row(result,"Color1"); AutoInfo[z][cColor1] = strval(result);
mysql_fetch_field_row(result,"Color2"); AutoInfo[z][cColor2] = strval(result);
mysql_fetch_field_row(result,"Stock"); AutoInfo[z][cStock] = strval(result);
mysql_fetch_field_row(result,"CarKeyGiven"); AutoInfo[z][cCarKeyGiven] = strval(result);
//mysql_fetch_field_row(result,"Number"); AutoInfo[z][cRegistration] = result;
Car[z] = AddStaticVehicleEx(AutoInfo[z][cModel],AutoInfo[z][cLocationx],AutoInfo[z][cLocationy],AutoInfo[z][cLocationz]+0.1, AutoInfo[z][cAngle],AutoInfo[z][cColor1],AutoInfo[z][cColor2],60000);
OnCarUpdate(z);
}
mysql_free_result();
mysql_debug(0);
}
PHP код:
[14:03:26] >> mysql_query( Connection handle: 1 )
[14:03:26] CMySQLHandler::Query(SELECT * FROM `Cars` WHERE `CarId` = '6') - Successfully executed.
[14:03:26] >> mysql_store_result( Connection handle: 1 )
[14:03:26] CMySQLHandler::StoreResult() - Result was stored.
[14:03:26] >> mysql_fetch_row_format( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchRow() - Return: 6|1|126||426|90000|0|None|763.701|-1016.52|23.9668|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|90000|0|sarmo
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Owned") - 1
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Owner") - 126
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Description") -
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Model") - 426
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Value") - 90000
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Lock") -
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Locationx") - 763.701
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Locationy") - -1016.52
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Locationz") - 23.9668
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Angle") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Parked") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("ParkLocationx") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("ParkLocationy") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("ParkLocationz") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("ParkAngle") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Narkot") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("AMaterjale") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("BMaterjale") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("CMaterjale") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Nitro") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("GPS") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Radio") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp1") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp2") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp3") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp4") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp5") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp6") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp7") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp8") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp9") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Comp10") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Color1") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Color2") - 0
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("Stock") - 90000
[14:03:26] >> mysql_fetch_field_row( Connection handle: 1 )
[14:03:26] CMySQLHandler::FetchField("CarKeyGiven") - 0
[14:03:26] >> mysql_query( Connection handle: 1 )
[14:03:26] CMySQLHandler::Query(UPDATE Cars SET Owned = '1', Owner = '126', Parked = '0', ParkLocationx = '0.000000', ParkLocationy = '0.000000', ParkLocationz = '0.000000', ParkAngle = '0.000000', Narkot = '0', AMaterjale = '0', BMaterjale = '0', CMaterjale = '0', Nitro = '0', GPS = '0', CarKeyGiven = '0', Raadio = '0' WHERE CarId = '6') - Successfully executed.
[14:03:26] >> mysql_free_result( Connection handle: 1 )
[14:03:26] CMySQLHandler::FreeResult() - Result was successfully free'd.