VehicleID:1------------VehicleID:2 |||||||||||------------||||||||||| Owner:Justin-----------Owner:Bruno
----<_____________________< ----\/--------------------/\ ----||--------------------|| VehicleID:1------------VehicleID:2 |||||||||||------------||||||||||| Owner:Justin-----------Owner:Bruno
VehicleID:1(bruno's vehicle)-------------Wrong Vehicle |||||||||||------------------------------||||||||||| Owner:Noone------------------------------Owner:Bruno
if(!strcmp(cmdtext, "/asellcar", true))
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "Login first!");
return 1;
}
if(PlayerInfo[playerid][pAdmin] >= 5)
{
new vehid = GetPlayerVehicleID(playerid);
CarInfo[vehid][cOwned] = 0;
new ye,m,d;
new h,mi,s;
getdate(ye,m,d);
gettime(h,mi,s);
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pPcarkey] == vehid || PlayerInfo[i][pPcarkey2] == vehid)
{
if(PlayerInfo[i][pPcarkey] == vehid) PlayerInfo[i][pPcarkey] = 999;
else if(PlayerInfo[i][pPcarkey2] == vehid) PlayerInfo[i][pPcarkey2] = 9999;
GivePlayerMoney(i, GetVehiclePrice(vehid) / 2);
}
else
{
format(string, sizeof(string),"INTELRP/Accounts/%s.ini",CarInfo[vehid][cOwner]);
new totalcash = dini_Int(string,"Money") + GetVehiclePrice(vehid);
dini_IntSet(string,"Money",totalcash);
if(dini_Int(string,"CarKey") == vehid)
{
dini_IntSet(string,"CarKey",9999);
}
else if(dini_Int(string,"CarKey2") == vehid)
{
dini_IntSet(string,"CarKey2",9999);
}
}
}
}
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
DestroyVehicle(vehid);
format(string, sizeof(string),"INTELRP/Vehicles/%d.ini",vehid);
fremove(string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "INTEL:Not authorized.");
return 1;
}
}
return 1;
}
format(file,sizeo(file),"INTELRP/Accounts/%s.ini");
dini_IntSet(file,"CarKey",dini_Int(file,"CarKey")-1);
Ahh, you're complaining about after a restart - that's different. In that case why are you storing the ID in the first place? As you've seen IDs are meaningless over server restarts. Just store the data on the vehicle such as model, colour etc and recreate the vehicle every mode start, saving the returned ID in a global for that run only.
|
/* PS: every vehicle has a file [1.ini;2.ini;3.ini...].*/
new veh;
for(new h = 1; h < sizeof(CarInfo); h++)//This will count the last vehicle created
{
if(CarInfo[h][cOwned] == 1)
{
veh = h + 1;
}
}
CarInfo[veh][vID] = veh;
PlayerInfo[playerid][pckey] = veh;