Jump to content
  • 0

Problema salvare KM


Extremys

Question

Problema intalnita (descriere):Daca intru pe sv si merg cu o masina personala ii fac km, daca dau restart la sv nu se salveaza km la masina daca intru iar dupa restart zice ca am 0 km
Ero(area / rile) / warning-(ul / urile):-
Liniile de cod / sursa / script-ul(obligatoriu):

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 = '%d', 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 = '%d', 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 = '%d', 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 = '%d', playerCarLock4 = '%d' WHERE playerID = '%d'",playerVariables[pCarKM4],playerVariables[pCarLock4],playerVariables[pInternalID]);
                                mysql_tquery(handle,saveQuery);
                            }
                          }
                    }
                }
            }
        }
    }
}


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

giphy.gif

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Cauta in gamemode

format(query, sizeof(query), "`pWarn` = '%d',", PlayerInfo[playerid][pWarn]);

si adauga dupa:



format(query, sizeof(query), "`pOdometer1` = '%f',", PlayerInfo[playerid][pOdometer1]);
strcat(final,query);

format(query, sizeof(query), "`pOdometer2` = '%f',", PlayerInfo[playerid][pOdometer2]);
strcat(final,query);

format(query, sizeof(query), "`pOdometer3` = '%f',", PlayerInfo[playerid][pOdometer3]);
strcat(final,query);

Pentru a putea salva km la vehicule, aparent am uitat.

 

Link to comment
Share on other sites

  • 0
Acum 8 ore, iK3nnz0r[]. a spus:

Cauta in gamemode

format(query, sizeof(query), "`pWarn` = '%d',", PlayerInfo[playerid][pWarn]);

si adauga dupa:



format(query, sizeof(query), "`pOdometer1` = '%f',", PlayerInfo[playerid][pOdometer1]);
strcat(final,query);

format(query, sizeof(query), "`pOdometer2` = '%f',", PlayerInfo[playerid][pOdometer2]);
strcat(final,query);

format(query, sizeof(query), "`pOdometer3` = '%f',", PlayerInfo[playerid][pOdometer3]);
strcat(final,query);

Pentru a putea salva km la vehicule, aparent am uitat.

 

Nu am gasit nimic, si sincer nu prea am inteles nimic.

giphy.gif

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.