GTA Suchtis Roleplay Auto in DB abspeichern

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Die Funktionen zum Speichern und laden sehen so aus:


    Spoiler anzeigen
    forward SaveServerCar(idx);
    public SaveServerCar(idx)
    {
    if(idx > sizeof(Vehicle)) return 1;
    if (IsANeewbieBike(idx)) return 1;
    new string[10], Float:X, Float:Y, Float: Z, Float: A, query[300];
    GetVehiclePos(idx, X,Y,Z);
    GetVehicleZAngle(idx, A);
    if(IsVehicleInRangeOfPoint(idx, 10.0, Vehicle[idx][v_X] ,Vehicle[idx][v_Y], Vehicle[idx][v_Z])) {
    Vehicle[idx][v_use_new]=0;
    format(string, sizeof(string), "%s",Vehicle[idx][vPlate]);
    } else {
    Vehicle[idx][v_use_new] = 1;
    format(string, sizeof(string), "%s",Vehicle[idx][vPlate]);
    format(query, sizeof(query), "UPDATE samp_vehicle SET x_new=%f WHERE plate='%s'",X,string);
    mysql_query(query);
    format(query, sizeof(query), "UPDATE samp_vehicle SET y_new=%f WHERE plate='%s'",Y,string);
    mysql_query(query);
    format(query, sizeof(query), "UPDATE samp_vehicle SET z_new=%f WHERE plate='%s'",Z,string);
    mysql_query(query);
    format(query, sizeof(query), "UPDATE samp_vehicle SET a_new=%f WHERE plate='%s'",A,string);
    mysql_query(query);
    }
    format(query, sizeof(query), "UPDATE samp_vehicle SET tank_now=%f WHERE plate='%s'",spawncar_gas[idx],string);
    mysql_query(query);
    format(query, sizeof(query), "UPDATE samp_vehicle SET use_new=%d WHERE plate='%s'",Vehicle[idx][v_use_new],string);
    mysql_query(query);
    format(query, sizeof(query), "UPDATE samp_vehicle SET v_Towed=%d WHERE plate='%s'",Vehicle[idx][v_Towed],string);
    mysql_query(query);
    Vehicle[idx][v_GasNow] = spawncar_gas[idx];
    format(query, sizeof(query), "UPDATE samp_vehicle SET tank_now=%.1f WHERE plate='%s'",Vehicle[idx][v_GasNow],string);
    mysql_query(query);
    return mysql_free_result();
    }

    Spoiler anzeigen
    forward LoadServerCars();
    stock LoadServerCars() {
    new string[10];
    for (new idx = 1; idx < sizeof(Vehicle); idx ++) {
    format(string, sizeof(string),"%d",idx);
    Vehicle[idx][v_use_new] = mysql_GetIntByString("samp_vehicle","use_new","id",string);
    Vehicle[idx][vID] = mysql_GetIntByString("samp_vehicle","id","id",string);
    Vehicle[idx][vModel] = mysql_GetIntByString("samp_vehicle","model","id",string);
    Vehicle[idx][v_X] = mysql_GetFloatByString("samp_vehicle","x","id",string);
    Vehicle[idx][v_Y] = mysql_GetFloatByString("samp_vehicle","y","id",string);
    Vehicle[idx][v_Z] = mysql_GetFloatByString("samp_vehicle","z","id",string);
    Vehicle[idx][v_A] = mysql_GetFloatByString("samp_vehicle","a","id",string);
    strmid(Vehicle[idx][vPlate], mysql_GetStringByString("samp_vehicle","plate","id",string), 0, strlen(mysql_GetStringByString("samp_vehicle","plate","id",string)), 255);
    Vehicle[idx][vC1] = mysql_GetIntByString("samp_vehicle","color1","id",string);
    Vehicle[idx][vC2] = mysql_GetIntByString("samp_vehicle","color2","id",string);
    Vehicle[idx][v_GasNow] = mysql_GetIntByString("samp_vehicle","tank_now","id",string);
    Vehicle[idx][v_GasMax] = mysql_GetIntByString("samp_vehicle","tank_max","id",string);
    Vehicle[idx][vJob] = mysql_GetIntByString("samp_vehicle","job","id",string);
    Vehicle[idx][vRank] = mysql_GetIntByString("samp_vehicle","rank","id",string);
    Vehicle[idx][vLicense] = mysql_GetIntByString("samp_vehicle","license","id",string);
    Vehicle[idx][vInterior] = mysql_GetIntByString("samp_vehicle","interior","id",string);
    Vehicle[idx][v_X_new] = mysql_GetFloatByString("samp_vehicle","x_new","id",string);
    Vehicle[idx][v_Y_new] = mysql_GetFloatByString("samp_vehicle","y_new","id",string);
    Vehicle[idx][v_Z_new] = mysql_GetFloatByString("samp_vehicle","z_new","id",string);
    Vehicle[idx][v_A_new] = mysql_GetFloatByString("samp_vehicle","a_new","id",string);
    Vehicle[idx][v_use_new] = mysql_GetIntByString("samp_vehicle","use_new","id",string);
    Vehicle[idx][v_Towed] = mysql_GetIntByString("samp_vehicle","use_new","id",string);

    //printf("ID: %d, Model: %d, Plate: %s", Vehicle[idx][vID], Vehicle[idx][vModel], Vehicle[idx][vPlate]);
    CreateVehicleForServer(
    Vehicle[idx][vModel],
    Vehicle[idx][v_X],
    Vehicle[idx][v_Y],
    Vehicle[idx][v_Z],
    Vehicle[idx][v_A],
    Vehicle[idx][vC1],
    Vehicle[idx][vC2],
    Vehicle[idx][vInterior],
    Vehicle[idx][vJob],
    Vehicle[idx][vLicense],
    Vehicle[idx][vRank]);

    }
    printf("* Server vehicles sucessfully loaded. *");
    }