Jump to content
  • 0

Dublare masini server


Cata12X

Question

8 answers to this question

Recommended Posts

  • 0
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;
}

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0
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;
}

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.