Guten Morgen! Fahrzeugschlüssel wird gespeichert nur das Neon nicht!
stock GetFreeKey(playerid)
{
for(new i=0; i<sizeof(Dtc_PlayerHaveCar[]); i++)
{
if(!Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]]) return i;
}
return -1;
}
Function OnPlayerBuyCar2(playerid,Model,Float:x, Float:y, Float:z, Float:a)//CARSYS
{
if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
{
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/Autos/%s%d.dtcar", name,Dtc_PlayerKey[playerid]);
PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x] = x;
PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y] = y;
PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z] = z;
PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate] = a;
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);
format(var, 32, "CarPos_x=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x]);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y]);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z]);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate]);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=0\n");fwrite(hFile, var);
format(var, 32, "CarArrest=0\n");fwrite(hFile, var);
format(var, 32, "Plate=[LiS]\n");fwrite(hFile, var);
fclose(hFile);
}
OnPlayerCarLogin(playerid);
}
}
if(dialogid == DIALOG_GUTSCHEINCARTAKE)
{
switch(random(7))
{
case 0: //Sultan 560
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 560, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
case 1: //Infernus 411
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 411, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
case 2: //Turismo 451
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 451, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
case 3: //Cheetah 415
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 415, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
case 4: //Zr350 477
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 477, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
case 5: //Bullet 541
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 541, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
case 6: //Jester 559
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
new key = GetFreeKey(playerid);
if(key == -1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Kein freier Platz.");
Dtc_PlayerKey[playerid] = key;
OnPlayerBuyCar2(playerid, 559, x, y, z, a);
GiveRandomNeon(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], playerid);
PutPlayerInVehicle(playerid, PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0);
return 1;
}
}
}