Save vehicle by vehicleid.
#1

Hi people.I need some help.I have All save and load scripts,but i don't know how to save player car by vehicle id?I want to do that when player disconnect.
Reply
#2

Use this:

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
Reply
#3

How i can use that?I talk about OnPlayerDisconnect,how can i get player vehicle id if player out?

PlayerData[playerid][pcar] with this i check is player have he own car,ten i try check:

new vehicleid = GetPlayerVehicleID(PlayerData[playerid][pcar]); i try to get vehicle id he own car,but don't work...
Reply
#4

Past your code on how to save your vehicle.
Reply
#5

stock SaveCar(playerid,vehicleid)
{
if(PlayerData[ playerid ][ pcar ] == -1) return;//if player don't have he own car for him don't save car.
print("Car successfully save");
new files[ 128 ];
format( files, 60, "saves/cars/%d.ini",vehicleid);
if(!fexist(files)){dini_Create(files);}
Reply
#6

When you buy a car, how do you create the vehicle?
Can I see that part of the code?
Reply
#7

new iRandom = random(sizeof(TurgausSpawn));
new TempVeh = CreateVehicle(534,TurgausSpawn[iRandom][0], TurgausSpawn[iRandom][1], TurgausSpawn[iRandom][2], TurgausSpawn[iRandom][3], -1, -1, -1);
PlayerData[playerid][pcar]=TempVeh;
vehicleDB[TempVeh][Lock]=true;
vehicleDB[vehicleid][sell]=true;
vehicleDB[TempVeh][gas]=40;
GetPlayerName(playerid,vehicleDB[TempVeh][owner_name],MAX_PLAYER_NAME);
SendClientMessage(playerid, COLOR_GREEN, " Your car succefull have made.You can found it: /carmapp");
SendClientMessage(playerid, COLOR_RED, " Don't forget lock your car!");
GivePlayerMoneyA(playerid, -9000);
SetVehicleToRespawn(vehicleid);
Reply
#8

Keep in mind, vehicle ID's will never be the same. You can save vehicle ID 3, remove vehicle ID 3, spawn another vehicle- which would take ID 3, then spawn the saved vehicle, it will end up screwing up the server. It would be better to write your own type of vehicle ID system.
Reply
#9

Ok.

PlayerData[playerid][pcar] is your vehicle id.

If you check your code it says:
pawn Код:
new TempVeh = CreateVehicle(534,TurgausSpawn[iRandom][0], TurgausSpawn[iRandom][1], TurgausSpawn[iRandom][2], TurgausSpawn[iRandom][3], -1, -1, -1);
This code means that the id of the vehicle is TempVeh.

A few lines later you say that PlayerData[playerid][pcar]=TempVeh. So you store the vehicle's id into the PlayerData variable.
This means that the PlayerData[playerid][pcar] is your vehicle's id.

So your new code would be:

pawn Код:
stock SaveCar(playerid,vehicleid)
{
if(PlayerData[ playerid ][ pcar ] == -1) return;//if player don't have he own car for him don't save car.
print("Car successfully save");
new files[ 128 ];
format( files, 60, "saves/cars/%d.ini", PlayerData[playerid][pcar]);
if(!fexist(files)){dini_Create(files);}
Reply
#10

Thanks i try,please reply to me another thread "anti-car stealing"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)