mysql loading - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql loading (
/showthread.php?tid=593213)
mysql loading -
Karolukas123 - 02.11.2015
Hey.. i making tuning system.. and i dont know why tune not load.. Its save normal ( in mysql its save )..
but if i relog my tune gone...
Code:
}
stock LoadPlayerVehicle(playerid)
{
if(!IsPlayerConnected(playerid)) return 1;
new Vardas[MAX_PLAYER_NAME];
GetPlayerName(playerid, Vardas, sizeof(Vardas));
new Query[500], String[500], Modelis, Float: Health, Float: vPos[4], Color[2];
format(Query, sizeof(Query), "SELECT * FROM `vehicles` WHERE `Transportas` = '%s'", Vardas);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_fetch_row(String);
mysql_fetch_field_row(Query, "Model"); Modelis = strval(Query);
mysql_fetch_field_row(Query, "Pos_X"); vPos[0] = floatstr(Query);
mysql_fetch_field_row(Query, "Pos_Y"); vPos[1] = floatstr(Query);
mysql_fetch_field_row(Query, "Pos_Z"); vPos[2] = floatstr(Query);
mysql_fetch_field_row(Query, "Pos_A"); vPos[3] = floatstr(Query);
mysql_fetch_field_row(Query, "Color1"); Color[0] = strval(Query);
mysql_fetch_field_row(Query, "Color2"); Color[1] = strval(Query);
mysql_fetch_field_row(Query, "Health"); Health = floatstr(Query);
new vehicleid = CreateVehicle(Modelis, vPos[0], vPos[1], vPos[2] + 3, vPos[3], Color[0], Color[1], -1);
SetVehicleHealth(vehicleid, Health);
mysql_fetch_field_row(Query, "Pos_X"); vehicleDB[vehicleid][vLastPos][0] = floatstr(Query);
mysql_fetch_field_row(Query, "Pos_Y"); vehicleDB[vehicleid][vLastPos][1] = floatstr(Query);
mysql_fetch_field_row(Query, "Pos_Z"); vehicleDB[vehicleid][vLastPos][2] = floatstr(Query);
mysql_fetch_field_row(Query, "Pos_A"); vehicleDB[vehicleid][vLastPos][3] = floatstr(Query);
mysql_fetch_field_row(Query, "Rida"); vehicleDB[vehicleid][Rida] = floatstr(Query);
mysql_fetch_field_row(Query, "Fuel"); vehicleDB[vehicleid][gas] = strval(Query);
mysql_fetch_field_row(Query, "Paintjob"); vehicleDB[vehicleid][vPaintjob] = strval(Query);
mysql_fetch_field_row(Query, "Tune0"); vehicleDB[vehicleid][vTune][0] = strval(Query);
mysql_fetch_field_row(Query, "Tune1"); vehicleDB[vehicleid][vTune][1] = strval(Query);
mysql_fetch_field_row(Query, "Tune2"); vehicleDB[vehicleid][vTune][2] = strval(Query);
mysql_fetch_field_row(Query, "Tune3"); vehicleDB[vehicleid][vTune][3] = strval(Query);
mysql_fetch_field_row(Query, "Tune4"); vehicleDB[vehicleid][vTune][4] = strval(Query);
mysql_fetch_field_row(Query, "Tune5"); vehicleDB[vehicleid][vTune][5] = strval(Query);
mysql_fetch_field_row(Query, "Tune6"); vehicleDB[vehicleid][vTune][6] = strval(Query);
mysql_fetch_field_row(Query, "Tune7"); vehicleDB[vehicleid][vTune][7] = strval(Query);
mysql_fetch_field_row(Query, "Tune8"); vehicleDB[vehicleid][vTune][8] = strval(Query);
mysql_fetch_field_row(Query, "Tune9"); vehicleDB[vehicleid][vTune][9] = strval(Query);
mysql_fetch_field_row(Query, "Tune10"); vehicleDB[vehicleid][vTune][10] = strval(Query);
mysql_fetch_field_row(Query, "Tune11"); vehicleDB[vehicleid][vTune][11] = strval(Query);
mysql_fetch_field_row(Query, "Tune12"); vehicleDB[vehicleid][vTune][12] = strval(Query);
mysql_fetch_field_row(Query, "Locked"); vehicleDB[vehicleid][vLocked] = !!strval(Query);
mysql_fetch_field_row(Query, "NumberPlate"); format(vehicleDB[vehicleid][vNumberPlate], 8, "%s", Query);
format(vehicleDB[vehicleid][vOwner], 21, "%s", GetPlayerNameEx(playerid));
SetVehicleNumberPlate(vehicleid, vehicleDB[vehicleid][vNumberPlate]);
vehicleDB[vehicleid][vOwned] = true;
playerData[playerid][vCarID] = vehicleid;
SetVehicleToRespawn(vehicleid);
}
mysql_free_result();
return 1;
Re: mysql loading -
Karolukas123 - 02.11.2015
Ups guys still need help..
Re: mysql loading -
Karolukas123 - 03.11.2015
up up
Re: mysql loading -
HydraHumza - 03.11.2015
Why you are using MySQL old version you should try new version which you can find
here.
Re: mysql loading -
Karolukas123 - 03.11.2015
Humza because i dont know code and how to use new version.. and i like this version
Re: mysql loading -
Jefff - 03.11.2015
pawn Code:
stock LoadPlayerVehicle(playerid)
{
if(!IsPlayerConnected(playerid)) return 1;
new Vardas[MAX_PLAYER_NAME];
GetPlayerName(playerid, Vardas, sizeof(Vardas));
new Query[85], String[500];
format(Query, sizeof(Query), "SELECT * FROM `vehicles` WHERE `Transportas` = '%s' LIMIT 1", Vardas);
mysql_query(Query);
mysql_store_result();
if(mysql_fetch_row(String))
{
printf("String: %s",String);
new Modelis,Float:vPos[4],Color[2],Float:Health,Float:Rida,a[16],Plate[8];
sscanf(String,"p<|>ia<f>[4]iiffa<i>[16]s[8]",Modelis, vPos, Color[0], Color[1], Health, Rida, a, Plate);
new vehicleid = CreateVehicle(Modelis, vPos[0], vPos[1], vPos[2] + 3.0, vPos[3], Color[0], Color[1], -1);
SetVehicleHealth(vehicleid, Health);
for(new i=0; i < sizeof(vPos); i++)
vehicleDB[vehicleid][vLastPos][i] = vPos[i];
vehicleDB[vehicleid][gas] = a[0];
vehicleDB[vehicleid][vPaintjob] = a[1];
for(new i=0; i < 13; i++)
vehicleDB[vehicleid][vTune][i] = a[i + 2];
vehicleDB[vehicleid][vLocked] = !!a[15];
vehicleDB[vehicleid][vNumberPlate][0] = EOS;
strcat(vehicleDB[vehicleid][vNumberPlate], Plate, 8);
strcat(vehicleDB[vehicleid][vOwner], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
vehicleDB[vehicleid][vOwned] = true;
playerData[playerid][vCarID] = vehicleid;
SetVehicleToRespawn(vehicleid);
}
mysql_free_result();
return 1;
}