Save vehicle's parked position after restart?
#1

Hi there,

The problem is, that i want to make some kind of auto-parking system by using dini saving and probably OnPlayerExitVehicle function. I searched forum and founded this code:

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    format(CarFile, sizeof(CarFile), "vehicle%d.txt", vehicleid);
    if(!dini_Exists(CarFile)) dini_Create(CarFile);
    GetVehiclePos(vehicleid, posx, posy, posz);
    GetVehicleZAngle(vehicleid, posa);
    dini_FloatSet(CarFile, "x", posx);
    dini_FloatSet(CarFile, "y", posy);
    dini_FloatSet(CarFile, "z", posz);
    dini_FloatSet(CarFile, "a", posa);
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    format(CarFile, sizeof(CarFile), "vehicle%d.txt", vehicleid);
    if(!dini_Exists(CarFile)) { dini_Create(CarFile);
    } else {
    posx = dini_Float(CarFile, "x");
    posy = dini_Float(CarFile, "y");
    posz = dini_Float(CarFile, "z");
    posa = dini_Float(CarFile, "a");
    SetVehiclePos(vehicleid, posx, posy, posz);
    SetVehicleZAngle(vehicleid, posa);
    }
    return 1;
}
It works, but it only saves the position and angle, and the problem is - the vehicle does not spawn after server is restarted. I also tried saving vehicle's ID into the file, but it don't work ether.

So I searched again and founded this tutorial: http://forum.sa-mp.com/showthread.ph...hlight=vehicle
I tried doing something with that, but I don't really understand what's there and how to use it properly or even can it solve my problem?

So can anyone give some ides how to fix the code above or even post some examples?

Thanks.
Reply
#2

Tried to save vehicle in OnGameModeExit and then spawn?
Reply
#3

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Tried to save vehicle in OnGameModeExit and then spawn?
No idea how to do that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)