Carownership /park problem +REP
#1

I have the standard carownership from Los Angeles Roleplay

The problem is this -

When i buy a car and park it somewhere, everything is alright, it respawns one time but everything is alright.
Now if i restart the server and go to the car where i parked it, it is for sale. But my car that i parked is at the carownership house, i dont know whats wrong

The park command

pawn Код:
else if(strcmp(x_nr,"parken",true) == 0)
            {
                new Float:x,Float:y,Float:z;
                new Float:a;
                new carid;
                new getcarid;
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
                else { return 1; }
                getcarid = GetPlayerVehicleID(playerid);
                GetPlayerName(playerid, playername, sizeof(playername));
                GetVehiclePos(carid, x, y, z);
                GetVehicleZAngle(carid, a);
                if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
                {
                    if(PlayerInfo[playerid][pPcarkey] == 999 && PlayerInfo[playerid][pPcarkey2] == 999 & PlayerInfo[playerid][pPcarkey3])
                    {
                        SendClientMessage(playerid, COLOR_CRVENA, "[ERROR]:Du besitzt kein Fahrzeug.");
                        return 1;
                    }
                    if(getcarid == carid)
                    {
                        CarInfo[carid][cLocationx] = x;
                        CarInfo[carid][cLocationy] = y;
                        CarInfo[carid][cLocationz] = z;
                        CarInfo[carid][cAngle] = a;
                        format(string, sizeof(string), "~n~ Fahrzeug geparkt. ~n~");
                        GameTextForPlayer(playerid, "Dein Fahrzeug wird ab nun hier spawnen.", 10000, 3);
                        OnPropUpdate();
                        OnPlayerUpdate(playerid);
                        DestroyVehicle(carid);
                        CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                        TogglePlayerControllable(playerid, 1);
                        return 1;
                    }
                }
            }
Reply
#2

well how was the car created before it was parked?(like AddStaticVehicle ect..)
that is the code you'll have to interrupt when the server is loading,
you'll have to set the vehicles position to the new parked position,


so it has nothing to do with the code you posted,
Reply
#3

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
well how was the car created before it was parked?(like AddStaticVehicle ect..)
that is the code you'll have to interrupt when the server is loading,
you'll have to set the vehicles position to the new parked position,


so it has nothing to do with the code you posted,
The cars are created under OnGameModeInit, they are loading all from a .cfg file

pawn Код:
for(new h = 538; h < sizeof(CarInfo); h++)
    {
        AddStaticVehicleEx(CarInfo[h][cModel],CarInfo[h][cLocationx],CarInfo[h][cLocationy],CarInfo[h][cLocationz]+1.0,CarInfo[h][cAngle],CarInfo[h][cColorOne],CarInfo[h][cColorTwo],60000);
    }
And there is also a function to load them

pawn Код:
public LoadCar()
{
    new arrCoords[13][64];
    new strFromFile2[256];
    new File: file = fopen("/cfg/cars.cfg", io_read);
    if (file)
    {
        new idx = 538;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            CarInfo[idx][cModel] = strval(arrCoords[0]);
            CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][cColorOne] = strval(arrCoords[5]);
            CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][cValue] = strval(arrCoords[9]);
            CarInfo[idx][cLicense] = strval(arrCoords[10]);
            CarInfo[idx][cOwned] = strval(arrCoords[11]);
            CarInfo[idx][cLock] = strval(arrCoords[12]);
            printf("CarInfo: %d Owner:%s Kennzeichen: %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
            idx++;
        }
    }
    return 1;
}
Reply
#4

Have you made sure you set the variable you use to store the 'for sale' value inside be it cForSale or w/e, OnPlayerConnect it sets the variables to 0 then when the player logs in it can load the 1 value if it does?

If you didn't understand that i'll reword it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)