Guten Tag
Ich arbeite grade an einem system für das Oamt womit sie die autos sperren. Ich habe den Befehl so gemacht das man den über das Kennzeichen am Auto sperrt. Doch nun ist das problem das überall das gleiche kennzeichen ist es seit den man fährt zu den punkt und gibt dort /kennzeichen ein. Nun möchte ich aber ein random autokennzeichen system haben. Also zufällige zahlen nach dem autokauf.
Ich benutze das Dt_car System. (ältere Version)
/kennzeichen Befehl
if(strcmp(cmd,"/kennzeichen",true)==0)
{
if(IsPlayerInRangeOfPoint(playerid,2.5,1658.3011,-1698.5973,20.4719))
{
if(IsPlayerInAnyVehicle(playerid))
{
new car = GetPlayerVehicleID(playerid);
if(IsADtCar(car))
{
if(Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
{
if(car == PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId])
{
new rndzahl, stringg[32];
rndzahl = random(8999)+1000;
format(stringg,sizeof(stringg),"%d",rndzahl);
if(KZExistiert(stringg))
{
rndzahl = rndzahl-1;
format(stringg,sizeof(stringg),"%d",rndzahl);
}
PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPlate] = 1;
//format(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarNumber],sizeof(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarNumber]),"%d",rndzahl);
PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarNumber] = stringg;
format(string,sizeof(string),"Dein neues Kennzeichen ist: %d",rndzahl);
SendClientMessage(playerid,0x00FFFFFF,string);
new Float:CarX,Float:CarY,Float:CarZ,Float:CarA;
GetVehiclePos(car,CarX,CarY,CarZ);
GetVehicleZAngle(car,CarA);
DestroyVehicle(car);
PlayerCarSpawn(playerid,Dtc_PlayerKey[playerid]);
SetVehiclePos(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId],CarX,CarY,CarZ);
SetVehicleZAngle(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId],CarA);
PutPlayerInVehicle(playerid,PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId],0);
return 1;
}
else
{
SendClientMessage(playerid,0xFF0000FF,"Das ist nicht dein Fahrzeug!");
return 1;
}
}
else
{
SendClientMessage(playerid,0xFF0000FF,"Du musst den richtigen Schlüssel ausgewählt haben!");
return 1;
}
}
}
else
{
SendClientMessage(playerid,0xFF0000FF,"Du bist in keinem Fahrzeug!");
return 1;
}
}
else
{
SendClientMessage(playerid,0xFF0000FF,"Du bist nicht am /kennzeichen-Punkt.");
return 1;
}
}
Das Kauf system
if(newkeys == 16)//Enter
{
new carid = dtc_AutohausCar[playerid];
new car,preis,counter;
for(new ah = 0; ah < sizeof(dtcKaufliste);ah++)
{
if(dtcKaufliste[ah][dtc_Autohaus] == autohaus)
{
if( counter == carid)
{
car = dtcKaufliste[ah][dtc_CarModel];
preis = dtcKaufliste[ah][dtc_CarPreis];
}
counter ++;
}
}
if(GetPlayerMoney(playerid) < preis){SendClientMessage(playerid,COLOR_GREY,"Du hast nicht genug Geld um dieses Fahrzeug zu kaufen!");} else {OnPlayerBuyCar(playerid,car,preis,autohaus);}
//ResetPlayer
DestroyVehicle(dtc_AutohausSCar[playerid]);
SetPlayerPos(playerid, DtcSonstiges[autohaus][4][0],DtcSonstiges[autohaus][4][1],DtcSonstiges[autohaus][4][2]);
SetPlayerFacingAngle(playerid,DtcSonstiges[autohaus][4][3]);
dtc_AutohausCar[playerid] = 0;
dtc_AutohausCat[playerid] = 2000;
SetPlayerVirtualWorld(playerid,0);
TextDrawHideForPlayer(playerid,CarKauf[playerid]);
TextDrawDestroy(CarKauf[playerid]);
TogglePlayerControllable(playerid,1);
SetCameraBehindPlayer(playerid);
}
public OnPlayerBuyCar(playerid,Model,Preis,Autohaus)//CARSYS
{
if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
{
CallRemoteFunction("M_GivePlayerMoney","id",playerid,-Preis);
if(Autohaus == 0)
{
AddToBizzTill(14,Preis);
}
else if(Autohaus == 1)
{
AddToBizzTill(12,Preis);
}
else if(Autohaus == 2)
{
AddToBizzTill(21,Preis);
}
else if(Autohaus == 3)
{
AddToBizzTill(15,Preis);
}
else if(Autohaus == 4)
{
AddToBizzTill(13,Preis);
}
SetParkPlatz(playerid,Autohaus);
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/Autos/%s%d.dtcar", name,Dtc_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);
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=%d\n",Preis);fwrite(hFile, var);
format(var, 32, "CarPlate=0\n");fwrite(hFile, var);
format(var, 32, "CarGesperrt=0\n");fwrite(hFile, var);
format(var, 32, "CarSperrpreis=0\n");fwrite(hFile, var);
fclose(hFile);
}
OnPlayerCarLogin(playerid);
}
}
public OnPlayerCarLogin(playerid)
{
for(new x = 0; x < MaxVeh; x++)
{
if(!Dtc_PlayerHaveCar[playerid][x])
{
new string2[128];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "/Autos/%s%d.dtcar", playername2,x);
new File: UserFile = fopen(string2, io_read);
if (UserFile)
{
Dtc_PlayerHaveCar[playerid][x] = 1;
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "CarId" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarId] = strval( val ); }
if( strcmp( key , "CarModel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarModel] = strval( val ); }
if( strcmp( key , "CarPos_x" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_x] = floatstr( val ); }
if( strcmp( key , "CarPos_y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_y] = floatstr( val ); }
if( strcmp( key , "CarPos_z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_z] = floatstr( val ); }
if( strcmp( key , "CarRotate" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRotate] = floatstr( val ); }
if( strcmp( key , "CarNitro" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarNitro] = strval( val ); }
if( strcmp( key , "CarHyd" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarHyd] = strval( val ); }
if( strcmp( key , "CarWheel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarWheel] = strval( val ); }
if( strcmp( key , "CarAusp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarAusp] = strval( val ); }
if( strcmp( key , "CarSideL" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSideL] = strval( val ); }
if( strcmp( key , "CarSideR" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSideR] = strval( val ); }
if( strcmp( key , "CarFB" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarFB] = strval( val ); }
if( strcmp( key , "CarRB" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRB] = strval( val ); }
if( strcmp( key , "CarSpoiler" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSpoiler] = strval( val ); }
if( strcmp( key , "CarRoof" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRoof] = strval( val ); }
if( strcmp( key , "CarHood" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarHood] = strval( val ); }
if( strcmp( key , "CarVents" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarVents] = strval( val ); }
if( strcmp( key , "CarLamps" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarLamps] = strval( val ); }
if( strcmp( key , "CarPJ" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPJ] = strval( val ); }
if( strcmp( key , "CarC1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarC1] = strval( val ); }
if( strcmp( key , "CarC2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarC2] = strval( val ); }
if( strcmp( key , "Preis" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPreis] = strval( val ); }
if( strcmp( key , "CarNumber" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayerCar[playerid][x][CarNumber], val, 0, strlen(val)-1, 255); }
if( strcmp( key , "CarPlate" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPlate] = strval( val ); }
if( strcmp( key , "CarGesperrt" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarGesperrt] = strval( val ); }
if( strcmp( key , "CarSperrpreis" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSperrpreis] = strval( val ); }
}
fclose(UserFile);
PlayerCarSpawn(playerid,x);
}
}
}
}
public PlayerCarSpawn(playerid,Slot)
{
if(IsPlayerConnected(playerid))
{
if(Dtc_PlayerHaveCar[playerid][Slot])
{
PlayerCar[playerid][Slot][CarId] = CreateVehicle(PlayerCar[playerid][Slot][CarModel],PlayerCar[playerid][Slot][CarPos_x],PlayerCar[playerid][Slot][CarPos_y],PlayerCar[playerid][Slot][CarPos_z],PlayerCar[playerid][Slot][CarRotate],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2], 60000);/*vehicle spawn*/
ChangeVehicleColor(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2]);
if(PlayerCar[playerid][Slot][CarPJ] >= 0) {ChangeVehiclePaintjob(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarPJ]);}
if(PlayerCar[playerid][Slot][CarNitro] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarNitro]);}
if(PlayerCar[playerid][Slot][CarHyd] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHyd]);}
if(PlayerCar[playerid][Slot][CarWheel] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarWheel]);}
if(PlayerCar[playerid][Slot][CarAusp] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarAusp]);}
if(PlayerCar[playerid][Slot][CarSideL] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideL]);}
if(PlayerCar[playerid][Slot][CarSideR] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideR]);}
if(PlayerCar[playerid][Slot][CarFB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarFB]);}
if(PlayerCar[playerid][Slot][CarRB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRB]);}
if(PlayerCar[playerid][Slot][CarSpoiler] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSpoiler]);}
if(PlayerCar[playerid][Slot][CarRoof] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRoof]);}
if(PlayerCar[playerid][Slot][CarHood] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHood]);}
if(PlayerCar[playerid][Slot][CarVents] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarVents]);}
if(PlayerCar[playerid][Slot][CarLamps] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarLamps]);}
if(PlayerCar[playerid][Slot][CarPlate] != 0) {SetVehicleNumberPlate(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarNumber]);}
if(Dtc_LockOnSpawn)
{
Dtc_Carlock[PlayerCar[playerid][Slot][CarId]] = 1;
Dtc_LockCar(PlayerCar[playerid][Slot][CarId]);
}
}
}
}
Also das man ein Kennzeichen direkt bekommt nach dem man das Auto gekauft hat.
Außerdem speichert er das Kennzeichen icht wäre echt nett wenn mir jemand helfen könnte da ich echt nicht mehr weiter komme.
MFg
Troniix