Jump to content
  • 0

Problema salvare/incarcare KM


Extremys

Question

Problema intalnita (descriere): Pai intru pe server cumpar masina si fac km, daca ies si intru iar km raman, dar daca ies dau restart la server km nu mai raman

Ero(area / rile) / warning-(ul / urile): Nu imi da
Liniile de cod / sursa / script-ul(obligatoriu): Ce imi veti cere aia o sa va dau


Imagini / Video (optional):-
Ati incercat sa rezolvati singur?: Da am incercat, nustiu ce sa fac sunt nou in mysql

 

giphy.gif

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0
Acum 1 oră, Mister a spus:

Arata functia loadcar si arata si functia cum salvezi km cum ii contorizezi

Nu gasesc nici o functie care sa incarce masinile

Citat

forward DistanceCheck();
public DistanceCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        new saveQuery[369];
        new Float:d;
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new Float:dist, Float:X, Float:Y, Float:Z;
                if(IsPlayerInAnyVehicle(i))
                {
                    GetVehiclePos(GetPlayerVehicleID(i),X,Y,Z);
                }
                else
                {
                    GetPlayerPos(i,X,Y,Z);
                }
                dist = floatsqroot(floatpower(floatabs(floatsub(PosX,X)),2)+floatpower(floatabs(floatsub(PosY,Y)),2)+floatpower(floatabs(floatsub(PosZ,Z)),2));
                 if(CheckDelay >= 1)
                {
                    CheckDelay--;
                }
                else
                {
                    if(floatround(dist) < 1000) Distance += floatround(dist);
                }
                GetPlayerPos(i,d,PosY,PosZ);
                GetPlayerPos(i,PosX,PosY,PosZ);
                new dist2;
                dist2 = Distance / 1000;
                if(dist2 >= 1)
                {
                    if(!IsPlayerPaused(i))
                       {
                        new vehicleid = GetPlayerVehicleID(i);
                        if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
                        {
                            if(playerVariables[pCarID] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM = '%f', playerCarLock = '%d' WHERE playerID = '%d'",playerVariables[pCarKM],playerVariables[pCarLock],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                            else if(playerVariables[pCarID2] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM2] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM2 = '%f', playerCarLock2 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM2],playerVariables[pCarLock2],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                            else if(playerVariables[pCarID3] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM3] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM3 = '%f', playerCarLock3 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM3],playerVariables[pCarLock3],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                            else if(playerVariables[pCarID4] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM4] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM4 = '%f', playerCarLock4 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM4],playerVariables[pCarLock4],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                          }
                    }
                }
            }
        }
    }
}

 

@Mister asta am gasit despre vehicule

Citat

public IniVehs()
{
    new Cache: result5 = mysql_query (handle, "SELECT * FROM `vehicles` ORDER BY `vehicles`.`vehicleID` ASC");
    new x;
    new success = 1;

     for ( new i, j = cache_get_row_count ( ); i != j; ++i )
    {
        //cache_get_field_content(i, "vehicleID", result); x = strval(result);
          x++;
        if(systemVariables[vehicleCounts][0] + systemVariables[vehicleCounts][1] + systemVariables[vehicleCounts][2] < MAX_VEHICLES)
        {
            cache_get_field_content(i, "vehicleModelID", result); vehicleVariables[x][vVehicleModelID] = strval(result);
            cache_get_field_content(i, "vehiclePosX", result); vehicleVariables[x][vVehiclePosition][0] = floatstr(result);
            cache_get_field_content(i, "vehiclePosY", result); vehicleVariables[x][vVehiclePosition][1] = floatstr(result);
            cache_get_field_content(i, "vehiclePosZ", result); vehicleVariables[x][vVehiclePosition][2] = floatstr(result);
            cache_get_field_content(i, "vehiclePosRotation", result); vehicleVariables[x][vVehicleRotation] = floatstr(result);
            cache_get_field_content(i, "vehicleGroup", result); vehicleVariables[x][vVehicleGroup] = strval(result);
            cache_get_field_content(i, "vehicleDMV", result); vehicleVariables[x][vVehicleDMV] = strval(result);
            cache_get_field_content(i, "vehicleJob", result); vehicleVariables[x][vVehicleJob] = strval(result);
            cache_get_field_content(i, "vehicleRank", result); vehicleVariables[x][vVehicleRank] = strval(result);
            cache_get_field_content(i, "vehicleDS", result); vehicleVariables[x][vVehicleDS] = strval(result);
            cache_get_field_content(i, "vehicleCol1", result); vehicleVariables[x][vVehicleColour][0] = strval(result);
            cache_get_field_content(i, "vehicleCol2", result); vehicleVariables[x][vVehicleColour][1] = strval(result);

            if(vehicleVariables[x][vVehicleColour][0] < 0) {
                vehicleVariables[x][vVehicleColour][0] = random(126);
            }
            if(vehicleVariables[x][vVehicleColour][1] < 0) {
                vehicleVariables[x][vVehicleColour][1] = random(126);
            }


            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);

            switch(vehicleVariables[x][vVehicleModelID])
            { // OnVehicleSpawn has some annoying glitches with this!1. Should fix.
                case 427, 428, 432, 601, 528: SetVehicleHealth(vehicleVariables[x][vVehicleScriptID], 5000.0);
            }
            systemVariables[vehicleCounts][0]++;

            new stringcar[256];
            format(stringcar, 256, "%s",groupVariables[vehicleVariables[x][vVehicleGroup]][gGroupName]);
            if(vehicleVariables[x][vVehicleGroup] >= 1)
            {
                 SetVehicleNumberPlate(x, stringcar);
            }

            format(stringcar, 256, "%s",jobVariables[vehicleVariables[x][vVehicleJob]][jJobName]);
            if(vehicleVariables[x][vVehicleJob] >= 1)
            {
                 SetVehicleNumberPlate(x, stringcar);
            }

            if(vehicleVariables[x][vVehicleDMV] == 1)
            {
                dmv[x] = CreateObject(19309,0,0,0,0,0,0,100.0);
                SetObjectMaterialText(dmv[x], "DMV", 0, 50, "Times New Roman", 27, 1, COLOR_YELLOW, 0xFF000000, 1);
                AttachObjectToVehicle(dmv[x], x, 0.0, -0.5, 0.9, 0.0, 0.0, 0.0);
            }

            if((vehicleVariables[x][vVehicleGroup] == 1 || vehicleVariables[x][vVehicleGroup] == 10) && vehicleVariables[x][vVehicleModelID] == 411)
            {
                sirena[x] = CreateObject(19419, 0, 0, 0, 0, 0, 0, 0);
                AttachObjectToVehicle(sirena[x], x, 0.0, 0.0, 0.7, 0.0, 0.0, 0.0);
            }

            if(vehicleVariables[x][vVehicleGroup] == 7 && vehicleVariables[x][vVehicleModelID] == 560)
            {
                taxiobj[x] = CreateObject(19308, 0, 0, 0, 0, 0, 0, 0);
                AttachObjectToVehicle(taxiobj[x], x, 0.0, 0.0, 0.92, 0.0, 0.0, 0.0);
            }
        }
        else
        {
            success = 0;
            printf("ERROR: Vehicle limit reached (MODEL %d, VEHICLEID %d, MAXIMUM %d, TYPE STATIC) [01x08]", vehicleVariables[x][vVehicleModelID], x, MAX_VEHICLES);
        }
    }
    cache_delete(result5);
    if(success) printf("[script] %d vehicles loaded.", systemVariables[vehicleCounts][0]);
    return 1;
}

vehiculele personale se salveaza in tabelul cu conturi

Edited by Extremys

giphy.gif

Link to comment
Share on other sites

  • 0
6 hours ago, Extremys said:

Nu gasesc nici o functie care sa incarce masinile

 

@Mister asta am gasit despre vehicule

vehiculele personale se salveaza in tabelul cu conturi

Daca e gm Bladex iti spun clar abandoneaza edit-ul ai prea mult de munca pe el si nu se merita.

Si aici i lipseste o functie care sa salveze in baza de date Km ca Hurdrock = n00b a uitat sa salveze Km am avut un Notepad cu rezolvarea o sa il caut si revin cu edit daca gasesc.

Link to comment
Share on other sites

  • 0
Acum 35 minute, SoNNy.sys a spus:

GM praf oricum, faci un query la fiecare modificare de distanta la masini?...

Citat

forward DistanceCheck();
public DistanceCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        new saveQuery[369];
        new Float:d;
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new Float:dist, Float:X, Float:Y, Float:Z;
                if(IsPlayerInAnyVehicle(i))
                {
                    GetVehiclePos(GetPlayerVehicleID(i),X,Y,Z);
                }
                else
                {
                    GetPlayerPos(i,X,Y,Z);
                }
                dist = floatsqroot(floatpower(floatabs(floatsub(PosX,X)),2)+floatpower(floatabs(floatsub(PosY,Y)),2)+floatpower(floatabs(floatsub(PosZ,Z)),2));
                 if(CheckDelay >= 1)
                {
                    CheckDelay--;
                }
                else
                {
                    if(floatround(dist) < 1000) Distance += floatround(dist);
                }
                GetPlayerPos(i,d,PosY,PosZ);
                GetPlayerPos(i,PosX,PosY,PosZ);
                new dist2;
                dist2 = Distance / 1000;
                if(dist2 >= 1)
                {
                    if(!IsPlayerPaused(i))
                       {
                        new vehicleid = GetPlayerVehicleID(i);
                        if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
                        {
                            if(playerVariables[pCarID] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM = '%f', playerCarLock = '%d' WHERE playerID = '%d'",playerVariables[pCarKM],playerVariables[pCarLock],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                            else if(playerVariables[pCarID2] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM2] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM2 = '%f', playerCarLock2 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM2],playerVariables[pCarLock2],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                            else if(playerVariables[pCarID3] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM3] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM3 = '%f', playerCarLock3 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM3],playerVariables[pCarLock3],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                            else if(playerVariables[pCarID4] == vehicleid)
                            {
                                Distance = 0;
                                playerVariables[pCarKM4] += 1;
                                format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarKM4 = '%f', playerCarLock4 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM4],playerVariables[pCarLock4],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                          }
                    }
                }
            }
        }
    }
}

 

giphy.gif

Link to comment
Share on other sites

  • 0

Era doar o concluzie, o intrebare ironica. Nu te mai chinui cu script-uri de ca*** :) Nu poti sa-ti faci server si sa folosesti un query la fiecare 2 secunde pentru fiecare masina personala de pe server.

Sinner.png

Link to comment
Share on other sites

  • 0
Acum 5 minute, SoNNy.sys a spus:

Era doar o concluzie, o intrebare ironica. Nu te mai chinui cu script-uri de ca*** :) Nu poti sa-ti faci server si sa folosesti un query la fiecare 2 secunde pentru fiecare masina personala de pe server.

Nu vreau sa imi fac server, vreau sa invat sa creez unu in viitor pe alt gamemode intelegi?

giphy.gif

Link to comment
Share on other sites

  • 0

nu stiu daca e corect, dar nu e mai simplu sa stochezi intr-o variabila cati km face si sa  faca update doar cand masina este distrusa si primeste spawn ?:) ?

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.