04.09.2013, 11:35
Ok, Some success has been made now. The vehicle belongs to me but only after server restart. Which means that it does not change the owner right away. I need to gmx the server each time... Please help me with this last part now.
pawn Код:
else if(strcmp(x_nr,"buy",true) == 0)
{
if(IsASalesVehicle(idcar))
{
if(PlayerInfo[playerid][pLevel] < 2)
{
SendClientMessage(playerid, COLOR_GREY, "You need to be level 2 to buy a vehicle!");
return 1;
}
new sellstring[24];
if(PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999 || PlayerInfo[playerid][pPcarkey3] == 9999) { }
else return SendClientMessage(playerid, COLOR_GREY,"* You already own three cars!");
if(GetPlayerMoney(playerid) >= CarInfo[idcar][cPrice])
{
if(PlayerInfo[playerid][pCarLic] == 1)
{
for(new h = GetPlayerVehicleID(playerid); h < sizeof(CarInfo); h++)
{
if(CarInfo[h][cOwned] == 0)
{
idcar = h;
h = 9999;
}
}
if(PlayerInfo[playerid][pPcarkey] == 9999) { PlayerInfo[playerid][pPcarkey] = idcar; }
else if(PlayerInfo[playerid][pPcarkey2] == 9999) { PlayerInfo[playerid][pPcarkey2] = idcar; }
else if(PlayerInfo[playerid][pPcarkey3] == 9999) { PlayerInfo[playerid][pPcarkey3] = idcar; }
else { PlayerInfo[playerid][pPcarkey] = idcar; }
CarInfo[idcar][cOwned] = 1;
strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
SafeGivePlayerMoney(playerid,-CarInfo[idcar][cPrice]);
PlayerPlayMusic(playerid);
format(sellstring, sizeof(sellstring),"LARP/Vehicles/%d.ini",idcar)
dini_Create(sellstring);
dini_IntSet(sellstring,"Model",CarInfo[idcar][cModel]);
dini_FloatSet(sellstring,"Location_X",CarInfo[idcar][cLocationx]);
dini_FloatSet(sellstring,"Location_Y",CarInfo[idcar][cLocationy]);
dini_FloatSet(sellstring,"Location_Z",CarInfo[idcar][cLocationz]);
dini_FloatSet(sellstring,"Angle",CarInfo[idcar][cAngle]);
dini_IntSet(sellstring,"Color_1",CarInfo[idcar][cColorOne]);
dini_IntSet(sellstring,"Color_2",CarInfo[idcar][cColorTwo]);
dini_IntSet(sellstring,"Component0",CarInfo[idcar][cComponent0]);
dini_IntSet(sellstring,"Component1",CarInfo[idcar][cComponent1]);
dini_IntSet(sellstring,"Component2",CarInfo[idcar][cComponent2]);
dini_IntSet(sellstring,"Component3",CarInfo[idcar][cComponent3]);
dini_IntSet(sellstring,"Component4",CarInfo[idcar][cComponent4]);
dini_IntSet(sellstring,"Component5",CarInfo[idcar][cComponent5]);
dini_IntSet(sellstring,"Component6",CarInfo[idcar][cComponent6]);
dini_IntSet(sellstring,"Component7",CarInfo[idcar][cComponent7]);
dini_IntSet(sellstring,"Component8",CarInfo[idcar][cComponent8]);
dini_IntSet(sellstring,"Component9",CarInfo[idcar][cComponent9]);
dini_IntSet(sellstring,"Component10",CarInfo[idcar][cComponent10]);
dini_IntSet(sellstring,"Component11",CarInfo[idcar][cComponent11]);
dini_IntSet(sellstring,"Component12",CarInfo[idcar][cComponent12]);
dini_IntSet(sellstring,"Component13",CarInfo[idcar][cComponent13]);
format(string, sizeof(string),"LARP/Vehicles/SalesCarID%d.ini",idcar);
fremove(string);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /vehiclehelp to view the vehicle manual!");
gEngine[playerid] = 0;
engineOn[GetPlayerVehicleID(playerid)] = false;
CuvajVozilo(idcar);
OnPropUpdate(4,idcar);
OnPlayerUpdateEx(playerid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "* For security reasons, a Driving License is needed to buy a car!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have enough cash with you ! ");
return 1;
}
}
}