forward OnPlayerBuyCar(playerid, Model, Preis, cAutohaus, tank);
for(new a=0;a<sizeof(Kaufliste);a++)
{
Kaufliste[a][Carid]=CreateVehicle(Kaufliste[a][Modelid],Kaufliste[a][CarPos_x], Kaufliste[a][CarPos_y], Kaufliste[a][CarPos_z], Kaufliste[a[CarRotate]1,1,20);
}
new typ, string[128];
typ=IsAutohausCar(vehicleid);
if(typ!=-1)
{
FreezePlayer(playerid);
Spectating[playerid][0]=typ;
format(string, sizeof(string), "{40A5FE}Fahrzeug:{FFFFFF}\t %s\n{40A5FE}Preis:{FFFFFF}\t\t $%d\n{40A5FE}Tank:{FFFFFF}\t\t %d", Kaufliste[typ] [Name], Kaufliste[typ][aPreis],Kaufliste[typ][Tank]);
ShowPlayerDialog(playerid, DIALOG_SELLCAR, DIALOG_STYLE_MSGBOX, "{FFFFFF}Autohaus", string, "Kaufen", "Abbrechen");
}
if(dialogid==DIALOG_SELLCAR)
{
if(response)
{
print("D1");
if(Spectating[playerid][0]!=-1)
{
print("D2");
if(!PlayerHaveCar[playerid][PlayerKey[playerid]])
{
print("D3");
new preis = Kaufliste[Spectating[playerid][0]][aPreis];
print("D4");
if(GetPlayerMoney(playerid) > preis)
{
print("D5");
//new autohaus=Kaufliste[Spectating[playerid][0]][Autohaus];
GivePlayerCash(playerid, -preis);
print("D6");
new prname[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, prname, sizeof name);
format(str, sizeof str, "/Autos/%s_Car_%d.ini", prname,PlayerKey[playerid]);
new File: hFile = fopen(str, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarId=%d\n", PlayerCar[playerid][PlayerKey[playerid]][CarId]=Spectating[playerid][0]);fwrite(hFile, var);
format(var, 32, "CarModel=%d\n",PlayerCar[playerid][PlayerKey[playerid]][CarModel]=Kaufliste[Spectating[playerid][0]][Modelid]);fwrite(hFile, var);
format(var, 32, "CarNitro=0\n");fwrite(hFile, var);
format(var, 32, "CarHyd=0\n");fwrite(hFile, var);
format(var, 32, "CarWheel=0\n");fwrite(hFile, var);
format(var, 32, "CarAusp=0\n");fwrite(hFile, var);
format(var, 32, "CarSideL=0\n");fwrite(hFile, var);
format(var, 32, "CarSideR=0\n");fwrite(hFile, var);
format(var, 32, "CarFB=0\n");fwrite(hFile, var);
format(var, 32, "CarRB=0\n");fwrite(hFile, var);
format(var, 32, "CarSpoiler=0\n");fwrite(hFile, var);
format(var, 32, "CarRoof=0\n");fwrite(hFile, var);
format(var, 32, "CarHood=0\n");fwrite(hFile, var);
format(var, 32, "CarVents=0\n");fwrite(hFile, var);
format(var, 32, "CarLamps=0\n");fwrite(hFile, var);
format(var, 32, "CarPJ=-1\n");fwrite(hFile, var);
format(var, 32, "CarC1=-1\n");fwrite(hFile, var);
format(var, 32, "CarC2=-1\n");fwrite(hFile, var);
format(var, 32, "Preis=%d\n",PlayerCar[playerid][PlayerKey[playerid]][CarPreis]=preis/2);fwrite(hFile, var);
format(var, 32, "Tank=%d\n", Kaufliste[Spectating[playerid][0]][Tank]); fwrite(hFile, var);
format(var, 32, "MaxTank=%d\n", Kaufliste[Spectating[playerid][0]][Tank]); fwrite(hFile, var);
format(var, 32, "CarState=%d\n", PlayerCar[playerid][PlayerKey[playerid]][CarState]);fwrite(hFile, var);
fclose(hFile);
}
PlayerCar[playerid][PlayerKey[playerid]][CarId]=Spectating[playerid][0];
PlayerCar[playerid][PlayerKey[playerid]][CarModel]=Kaufliste[Spectating[playerid][0]][Modelid];
PlayerCar[playerid][PlayerKey[playerid]][CarNitro]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarHyd]=0;
print("D7");
PlayerCar[playerid][PlayerKey[playerid]][CarWheel]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarAusp]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarSideL]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarSideR]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarFB]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarRB]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarSpoiler]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarRoof]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarHood]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarVents]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarLamps]=0;
PlayerCar[playerid][PlayerKey[playerid]][CarPJ]=-1;
PlayerCar[playerid][PlayerKey[playerid]][CarC1]=1;
PlayerCar[playerid][PlayerKey[playerid]][CarC2]=1;
print("D8");
PlayerCar[playerid][PlayerKey[playerid]][CarPreis]=preis/2;
PlayerCar[playerid][PlayerKey[playerid]][CarTank]=Kaufliste[Spectating[playerid][0]][Tank];
PlayerCar[playerid][PlayerKey[playerid]][CarMaxTank]=Kaufliste[Spectating[playerid][0]][Tank];
PlayerCar[playerid][PlayerKey[playerid]][CarState]=0;
print("D9");
PlayerCar[playerid][PlayerKey[playerid]][CarId] = CreateVehicle(PlayerCar[playerid][PlayerKey[playerid]][CarModel],PlayerCar[playerid] [PlayerKey[playerid]][CarPos_x],PlayerCar[playerid][PlayerKey[playerid]][CarPos_y],PlayerCar[playerid][PlayerKey[playerid]] [CarPos_z],PlayerCar[playerid][PlayerKey[playerid]][CarRotate],PlayerCar[playerid][PlayerKey[playerid]][CarC1],PlayerCar[playerid] [PlayerKey[playerid]][CarC2], -1);/*vehicle spawn*/
SetVehicleNumberPlate(PlayerCar[playerid][PlayerKey[playerid]][CarId], SpielerName(playerid));
RemovePlayerFromVehicle(playerid);
print("D10");
FreezePlayer(playerid);
print("D11");
UnfreezePlayer(playerid);
print("D12");
PlayerHaveCar[playerid][PlayerKey[playerid]] = 1;
}
else
{
SendClientMessage(playerid, COLOR_WEISS, "Du hast nicht genügend Geld dabei!");
FreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
UnfreezePlayer(playerid);
return 1;
}
}
else
{
FreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_WEISS, "Auf diesem Schlüssel ist bereits ein Fahrzeug!");
UnfreezePlayer(playerid);
return 1;
}
}
}
if(!response)
{
FreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
UnfreezePlayer(playerid);
return 1;
}
}
/*public OnPlayerBuyCar(playerid, Model, Preis, cAutohaus, tank)
{
if(IsPlayerConnected(playerid))
{
GivePlayerCash(playerid, -Preis);
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "/Autos/%s_Car_%d.ini", name, PlayerKey[playerid]);
new File: hFile = fopen(str, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarId=0\n");fwrite(hFile, var);
format(var, 32, "CarModel=%d\n",Model);fwrite(hFile, var);
if(cAutohaus == 0)//Intercars
{
format(var, 32, "CarPos_x=%.3f\n",744.7441);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",-1345.2749);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",13.2438);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",271.8782);fwrite(hFile, var);
}
else if(cAutohaus == 1)//Grottis
{
format(var, 32, "CarPos_x=%.3f\n",550.6537);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",-1264.4824);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",16.9693);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",135.6086);fwrite(hFile, var);
}
format(var, 32, "CarNitro=0\n");fwrite(hFile, var);
format(var, 32, "CarHyd=0\n");fwrite(hFile, var);
format(var, 32, "CarWheel=0\n");fwrite(hFile, var);
format(var, 32, "CarAusp=0\n");fwrite(hFile, var);
format(var, 32, "CarSideL=0\n");fwrite(hFile, var);
format(var, 32, "CarSideR=0\n");fwrite(hFile, var);
format(var, 32, "CarFB=0\n");fwrite(hFile, var);
format(var, 32, "CarRB=0\n");fwrite(hFile, var);
format(var, 32, "CarSpoiler=0\n");fwrite(hFile, var);
format(var, 32, "CarRoof=0\n");fwrite(hFile, var);
format(var, 32, "CarHood=0\n");fwrite(hFile, var);
format(var, 32, "CarVents=0\n");fwrite(hFile, var);
format(var, 32, "CarLamps=0\n");fwrite(hFile, var);
format(var, 32, "CarPJ=-1\n");fwrite(hFile, var);
format(var, 32, "CarC1=-1\n");fwrite(hFile, var);
format(var, 32, "CarC2=-1\n");fwrite(hFile, var);
format(var, 32, "Preis=%d\n",Preis);fwrite(hFile, var);
format(var, 32, "Tank=%d\n", tank);fwrite(hFile, var);
format(var, 32, "MaxTank=%d\n", tank);fwrite(hFile, var);
fclose(hFile);
}
OnPlayerCarLogin(playerid);
}
}*/