mysql loading
#6

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;
}
Reply


Messages In This Thread
mysql loading - by Karolukas123 - 02.11.2015, 21:36
Re: mysql loading - by Karolukas123 - 02.11.2015, 22:10
Re: mysql loading - by Karolukas123 - 03.11.2015, 11:05
Re: mysql loading - by HydraHumza - 03.11.2015, 12:06
Re: mysql loading - by Karolukas123 - 03.11.2015, 14:36
Re: mysql loading - by Jefff - 03.11.2015, 15:07

Forum Jump:


Users browsing this thread: 2 Guest(s)