• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] How to save the position of a car?
#2
In the most basic explanation possible: create the variable to save the vehicle's position, when the player disconnects you set the vehicle's position in these variables and save it in the database. Then when the player logs in you create the vehicle with the coordinates retrieved from the database.

Basically, the logic would start like this:

PHP Code:
new playerVehicle[MAX_PLAYERS]; new Float:carPos[MAX_PLAYERS][3]; public OnPlayerLogin(playerid) { // Retrieves the coordinates saved in the database .... carPos[playerid][0] = X; carPos[playerid][1] = Y; carPos[playerid][2] = Z; // Creates the vehicle with the coordinates retrieved playerVehicle[playerid] = CreateVehicle(modelid, carPos[playerid][0], carPos[playerid][1], carPos[playerid][2]); } public OnPlayerDisconnect(playerid, reason) { // Sets the vehicle's position in the variable GetVehiclePos(playerVehicle[playerid], carPos[playerid][0], carPos[playerid][1], carPos[playerid][2]); // Saves the position of the variable in the database Save System... }
  Reply


Messages In This Thread
How to save the position of a car? - by Boxi - 2021-03-21, 11:45 AM
RE: How to save the position of a car? - by RhaegarX - 2021-03-21, 12:08 PM