Jump to content
  • 0

Dublare masini server


Question

Posted

Salut sunt nou pe aici si vin si eu cu o problema 

Daca mut o masina de pe server cu comanda /vmove dupa dau restart masina se dubleaza si nu stiu de ce , ce as putea face

Multumesc

8 answers to this question

Recommended Posts

  • 0
Posted
Acum 11 minute, Cata12X a spus:

ca mut o masina de pe server cu comanda /vmove dupa dau restart masina se dubleaza si nu stiu de ce , ce as putea face

Multumesc

PS. Nu toate masinile le dubleaza doar cele care le-am adaugat ultima data pe baza de date

CMD:vmuta(playerid, params[]) {
    if(playerVariables[playerid][pAdminLevel] >= 4) {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must be inside the vehicle that you wish to move.");

        new
            string[42];

        for(new x = 0; x < MAX_VEHICLES; x++) {
            if(vehicleVariables[x][vVehicleScriptID] == GetPlayerVehicleID(playerid)) {

                GetVehiclePos(x, vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2]);
                GetVehicleZAngle(x, vehicleVariables[x][vVehicleRotation]);

                DestroyVehicle(vehicleVariables[x][vVehicleScriptID]);
                vehicleVariables[x][vVehicleScriptID] = CreateVehicle(vehicleVariables[x][vVehicleModelID], vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2], vehicleVariables[x][vVehicleRotation], vehicleVariables[x][vVehicleColour][0], vehicleVariables[x][vVehicleColour][1], -1);
                PutPlayerInVehicle(playerid, vehicleVariables[x][vVehicleScriptID], 0);
                LinkVehicleToInterior(x, GetPlayerInterior(x));
                SetVehicleVirtualWorld(x, 0);

                saveVehicle(x);
                Fuel[x] = 100;

                format(string, sizeof(string), "You have successfully moved vehicle %d.", x);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
        }
    }
    return 1;
}

  • 0
Posted
Just now, Cata12X said:

PS. Nu toate masinile le dubleaza doar cele care le-am adaugat ultima data pe baza de date

CMD:vmuta(playerid, params[]) {
    if(playerVariables[playerid][pAdminLevel] >= 4) {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must be inside the vehicle that you wish to move.");

        new
            string[42];

        for(new x = 0; x < MAX_VEHICLES; x++) {
            if(vehicleVariables[x][vVehicleScriptID] == GetPlayerVehicleID(playerid)) {

                GetVehiclePos(x, vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2]);
                GetVehicleZAngle(x, vehicleVariables[x][vVehicleRotation]);

                DestroyVehicle(vehicleVariables[x][vVehicleScriptID]);
                vehicleVariables[x][vVehicleScriptID] = CreateVehicle(vehicleVariables[x][vVehicleModelID], vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2], vehicleVariables[x][vVehicleRotation], vehicleVariables[x][vVehicleColour][0], vehicleVariables[x][vVehicleColour][1], -1);
                PutPlayerInVehicle(playerid, vehicleVariables[x][vVehicleScriptID], 0);
                LinkVehicleToInterior(x, GetPlayerInterior(x));
                SetVehicleVirtualWorld(x, 0);

                saveVehicle(x);
                Fuel[x] = 100;

                format(string, sizeof(string), "You have successfully moved vehicle %d.", x);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
        }
    }
    return 1;
}

Cand folosesti comanda /vmove trebuie sa faci un query in care sa stergi masina din baza de date, pe urma sa o salvezi pe asta care o muti in baza de date!

350x20_FFFFFF_FFFFFF_000000_000000.png

  • 0
Posted (edited)
Acum 39 minute, Cata12X a spus:

 

Ce este acela un  query   si cum pot sa il fac, daca ai putea sa-mi spui

 

Edited by Cata12X
  • 0
Posted
Just now, Cata12X said:

Ce este acela un  query   si cum pot sa il fac, daca ai putea sa-mi spui

 

Pune aici functia SaveVehicle din comanda /vmove!

350x20_FFFFFF_FFFFFF_000000_000000.png

  • 0
Posted
Chiar acum, Voller. a spus:

Pune aici functia SaveVehicle din comanda /vmove!

CMD:saveveh(playerid, params[])
{
    if(playerVariables[playerid][pAdminLevel] >= 4) {
        if(!IsPlayerInAnyVehicle(playerid))
            return SCM(playerid, COLOR_GREY, "You need to be in a vehicle to save it.");

        if(GetPVarInt(playerid, "sCc") == 1) {

            new
                i,
                queryString[255],
                Float: vPos[4]; // x, y, z + z angle

            GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);

            format(queryString, sizeof(queryString), "INSERT INTO vehicles (vehicleModelID, vehiclePosX, vehiclePosY, vehiclePosZ, vehiclePosRotation) VALUES('%d', '%f', '%f', '%f', '%f')", GetVehicleModel(GetPlayerVehicleID(playerid)), vPos[0], vPos[1], vPos[2], vPos[3]);
            new Cache: resultxx = mysql_query(handle, queryString);

            i = cache_insert_id();
            cache_delete(resultxx);

            SCM(playerid, COLOR_WHITE, "Vehicle saved!");

            vehicleVariables[vVehicleModelID] = GetVehicleModel(GetPlayerVehicleID(playerid));
            vehicleVariables[vVehiclePosition][0] = vPos[0];
            vehicleVariables[vVehiclePosition][1] = vPos[1];
            vehicleVariables[vVehiclePosition][2] = vPos[2];

            vehicleVariables[vVehicleRotation] = vPos[3];
            vehicleVariables[vVehicleGroup] = 0;

            vehicleVariables[vVehicleScriptID] = GetPlayerVehicleID(playerid);

            for(new x = 0; x < MAX_VEHICLES; x++) {
                if(AdminSpawnedVehicles[x] == GetPlayerVehicleID(playerid)) {
                    AdminSpawnedVehicles[x] = 0; // If the vehicle is admin-spawned, we can remove it from the array and move it to the vehicle script enum/arrays.
                }
            }

            systemVariables[vehicleCounts][2]--;
            systemVariables[vehicleCounts][0]++;
            DeletePVar(playerid, "sCc");
        }
        else {
            SetPVarInt(playerid, "sCc", 1);
            return SCM(playerid, COLOR_GREY, "Daca esti sigur ca vrei sa salvezi vehiculul, tasteaza din nou /saveveh.");
        }
    }
    return 1;
}

  • 0
Posted
Just now, Cata12X said:

CMD:saveveh(playerid, params[])
{
    if(playerVariables[playerid][pAdminLevel] >= 4) {
        if(!IsPlayerInAnyVehicle(playerid))
            return SCM(playerid, COLOR_GREY, "You need to be in a vehicle to save it.");

        if(GetPVarInt(playerid, "sCc") == 1) {

            new
                i,
                queryString[255],
                Float: vPos[4]; // x, y, z + z angle

            GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);

            format(queryString, sizeof(queryString), "INSERT INTO vehicles (vehicleModelID, vehiclePosX, vehiclePosY, vehiclePosZ, vehiclePosRotation) VALUES('%d', '%f', '%f', '%f', '%f')", GetVehicleModel(GetPlayerVehicleID(playerid)), vPos[0], vPos[1], vPos[2], vPos[3]);
            new Cache: resultxx = mysql_query(handle, queryString);

            i = cache_insert_id();
            cache_delete(resultxx);

            SCM(playerid, COLOR_WHITE, "Vehicle saved!");

            vehicleVariables[vVehicleModelID] = GetVehicleModel(GetPlayerVehicleID(playerid));
            vehicleVariables[vVehiclePosition][0] = vPos[0];
            vehicleVariables[vVehiclePosition][1] = vPos[1];
            vehicleVariables[vVehiclePosition][2] = vPos[2];

            vehicleVariables[vVehicleRotation] = vPos[3];
            vehicleVariables[vVehicleGroup] = 0;

            vehicleVariables[vVehicleScriptID] = GetPlayerVehicleID(playerid);

            for(new x = 0; x < MAX_VEHICLES; x++) {
                if(AdminSpawnedVehicles[x] == GetPlayerVehicleID(playerid)) {
                    AdminSpawnedVehicles[x] = 0; // If the vehicle is admin-spawned, we can remove it from the array and move it to the vehicle script enum/arrays.
                }
            }

            systemVariables[vehicleCounts][2]--;
            systemVariables[vehicleCounts][0]++;
            DeletePVar(playerid, "sCc");
        }
        else {
            SetPVarInt(playerid, "sCc", 1);
            return SCM(playerid, COLOR_GREY, "Daca esti sigur ca vrei sa salvezi vehiculul, tasteaza din nou /saveveh.");
        }
    }
    return 1;
}

Pai... comanda Saveveh pare a fi in regula de ce nu folosesti /saveveh si nu mai folosesti /vmove ? intri in ce masina vrei sa o muti o duci unde vrei sa o pui si dupa da-i /saveveh.

format(queryString, sizeof(queryString), "INSERT INTO vehicles (vehicleModelID, vehiclePosX, vehiclePosY, vehiclePosZ, vehiclePosRotation) VALUES('%d', '%f', '%f', '%f', '%f')", GetVehicleModel(GetPlayerVehicleID(playerid)), vPos[0], vPos[1], vPos[2], vPos[3]);

Asta e un query.

  • Upvote 1

350x20_FFFFFF_FFFFFF_000000_000000.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.