Hallöchen Community,
Ich habe ein Problem, wenn ich ein zweites Auto kaufe, dann ist das nicht meins und gehört auch niemanden aber die datei wird unter meinem namen gespeichert. Wenn ich ein relogg mache ist es auch dann nicht mehr da. Woran kann das liegen? Ich schicke anbei alles was mit dem Autokauf/speicher/ladesystem zutun hat:
enum AHInfo
{
Name[50],
Float:posxx,
Float:posyy,
Float:poszz,
Float:spawnx,
Float:spawny,
Float:spawnz,
Float:spawna,
Kasse,
Besitzer[MAX_PLAYER_NAME]
}
enum AKInfo
{
modelid,
Name[35],
Autohausname[50],
Preis,
Float:posxx,
Float:posyy,
Float:poszz,
Float:posaa
}
enum Ainfo
{
Name[35],
modelid,
Float:HP,
Kaputt,
Nummernschild[20],
Float:posxx,
Float:posyy,
Float:poszz,
Float:posaa,
Abgeschlossen,
Farbe1,
Farbe2,
Paintjob,
Spoiler,
Hood,
Roof,
Sideskirt,
Lamps,
Nitro,
Exhaust,
Wheels,
Stereo,
Hydraulics,
FrontBumper,
RearBumper,
VentRight,
VentLeft
}
new Autohaus[2][AHInfo] = {
{"Mittelklassewagen", 753.6300, -1357.7891, 13.5000, 737.6641,-1343.2924,13.2495,271.4967, 0, "Staat"},
{"Sportwagen", 563.4568,-1292.7025,17.2482, 566.0915,-1280.0604,16.9498,33.4480, 0, "Staat"}
};
new Buycars[25][AKInfo] = {
{401, "Bravura", "Mittelklassewagen", 25000, 766.7662,-1334.1815,13.2480,210.7874},
{405, "Sentinel", "Mittelklassewagen", 25000, 761.2087,-1333.8333,13.2328,206.9077},
{418, "Moonbeam", "Mittelklassewagen", 30000, 755.4553,-1333.3359,13.2852,214.0488},
{422, "Bobcat", "Mittelklassewagen", 35000, 749.9855,-1333.5839,13.2508,217.2708},
{426, "Premier", "Mittelklassewagen", 30000, 743.5275,-1333.6078,13.2670,210.7271},
{458, "Solair", "Mittelklassewagen", 28000, 762.8854,-1379.3729,13.3188,299.0174},
{604, "Glendale Shit", "Mittelklassewagen", 10000, 761.7148,-1373.2991,13.2637,299.2405},
{475, "Sabre", "Mittelklassewagen", 35000, 761.5200,-1366.9171,13.2169,299.7655},
{500, "Mesa", "Mittelklassewagen", 38000, 760.8416,-1360.9537,13.2255,304.4968},
{507, "Elegant", "Mittelklassewagen", 28000, 783.9602,-1374.3782,13.2769,124.6623},
{526, "Fortune", "Mittelklassewagen", 20000, 784.1906,-1367.5514,13.1670,124.2438},
{533, "Feltzer", "Mittelklassewagen", 35000, 784.1780,-1360.2250,13.1719,122.4979},
{536, "Blade", "Mittelklassewagen", 27000, 783.9187,-1353.3546,13.1739,121.8231},
{549, "Tampa", "Mittelklassewagen", 35000, 784.1418,-1346.8944,13.1674,121.2379},
{555, "Windsor", "Mittelklassewagen", 38000, 784.1707,-1341.1776,13.2767,119.7063},
{579, "Huntley", "Mittelklassewagen", 50000, 783.9836,-1380.7814,13.4114,116.2054},
{587, "Euros", "Mittelklassewagen", 50000, 783.5677,-1334.6044,13.2450,117.8206},
{411, "Infernus", "Sportwagen", 180000, 556.4919,-1291.0554,16.9793,29.2944},
{415, "Cheetah", "Sportwagen", 125000, 552.1659,-1291.0443,16.8787,30.3761},
{429, "Banshee", "Sportwagen", 70000, 547.8537,-1291.0387,16.9532,28.3049},
{451, "Turismo", "Sportwagen", 150000, 543.9739,-1291.0016,16.9495,28.5396},
{506, "Super GT", "Sportwagen", 100000, 539.7959,-1291.1113,16.9500,24.0811},
{541, "Bullet", "Sportwagen", 1450000, 536.0541,-1291.1334,16.9497,25.4171},
{560, "Sultan", "Sportwagen", 60000, 531.9727,-1291.0865,16.9505,22.0385},
{602, "Alpha", "Sportwagen", 75000, 527.5934,-1291.1440,16.9486,23.4635}
};
new kaufauto[25];
{
Name[50],
Float:posxx,
Float:posyy,
Float:poszz,
Float:spawnx,
Float:spawny,
Float:spawnz,
Float:spawna,
Kasse,
Besitzer[MAX_PLAYER_NAME]
}
enum AKInfo
{
modelid,
Name[35],
Autohausname[50],
Preis,
Float:posxx,
Float:posyy,
Float:poszz,
Float:posaa
}
enum Ainfo
{
Name[35],
modelid,
Float:HP,
Kaputt,
Nummernschild[20],
Float:posxx,
Float:posyy,
Float:poszz,
Float:posaa,
Abgeschlossen,
Farbe1,
Farbe2,
Paintjob,
Spoiler,
Hood,
Roof,
Sideskirt,
Lamps,
Nitro,
Exhaust,
Wheels,
Stereo,
Hydraulics,
FrontBumper,
RearBumper,
VentRight,
VentLeft
}
new Autohaus[2][AHInfo] = {
{"Mittelklassewagen", 753.6300, -1357.7891, 13.5000, 737.6641,-1343.2924,13.2495,271.4967, 0, "Staat"},
{"Sportwagen", 563.4568,-1292.7025,17.2482, 566.0915,-1280.0604,16.9498,33.4480, 0, "Staat"}
};
new Buycars[25][AKInfo] = {
{401, "Bravura", "Mittelklassewagen", 25000, 766.7662,-1334.1815,13.2480,210.7874},
{405, "Sentinel", "Mittelklassewagen", 25000, 761.2087,-1333.8333,13.2328,206.9077},
{418, "Moonbeam", "Mittelklassewagen", 30000, 755.4553,-1333.3359,13.2852,214.0488},
{422, "Bobcat", "Mittelklassewagen", 35000, 749.9855,-1333.5839,13.2508,217.2708},
{426, "Premier", "Mittelklassewagen", 30000, 743.5275,-1333.6078,13.2670,210.7271},
{458, "Solair", "Mittelklassewagen", 28000, 762.8854,-1379.3729,13.3188,299.0174},
{604, "Glendale Shit", "Mittelklassewagen", 10000, 761.7148,-1373.2991,13.2637,299.2405},
{475, "Sabre", "Mittelklassewagen", 35000, 761.5200,-1366.9171,13.2169,299.7655},
{500, "Mesa", "Mittelklassewagen", 38000, 760.8416,-1360.9537,13.2255,304.4968},
{507, "Elegant", "Mittelklassewagen", 28000, 783.9602,-1374.3782,13.2769,124.6623},
{526, "Fortune", "Mittelklassewagen", 20000, 784.1906,-1367.5514,13.1670,124.2438},
{533, "Feltzer", "Mittelklassewagen", 35000, 784.1780,-1360.2250,13.1719,122.4979},
{536, "Blade", "Mittelklassewagen", 27000, 783.9187,-1353.3546,13.1739,121.8231},
{549, "Tampa", "Mittelklassewagen", 35000, 784.1418,-1346.8944,13.1674,121.2379},
{555, "Windsor", "Mittelklassewagen", 38000, 784.1707,-1341.1776,13.2767,119.7063},
{579, "Huntley", "Mittelklassewagen", 50000, 783.9836,-1380.7814,13.4114,116.2054},
{587, "Euros", "Mittelklassewagen", 50000, 783.5677,-1334.6044,13.2450,117.8206},
{411, "Infernus", "Sportwagen", 180000, 556.4919,-1291.0554,16.9793,29.2944},
{415, "Cheetah", "Sportwagen", 125000, 552.1659,-1291.0443,16.8787,30.3761},
{429, "Banshee", "Sportwagen", 70000, 547.8537,-1291.0387,16.9532,28.3049},
{451, "Turismo", "Sportwagen", 150000, 543.9739,-1291.0016,16.9495,28.5396},
{506, "Super GT", "Sportwagen", 100000, 539.7959,-1291.1113,16.9500,24.0811},
{541, "Bullet", "Sportwagen", 1450000, 536.0541,-1291.1334,16.9497,25.4171},
{560, "Sultan", "Sportwagen", 60000, 531.9727,-1291.0865,16.9505,22.0385},
{602, "Alpha", "Sportwagen", 75000, 527.5934,-1291.1440,16.9486,23.4635}
};
new kaufauto[25];
#define MAX_CARS_PER_PLAYER 2
new Autos[MAX_PLAYERS][MAX_CARS_PER_PLAYER][Ainfo];
new Spielercar[MAX_PLAYERS][MAX_CARS_PER_PLAYER];
OnPlayerConnect:
for(new i = 0; i < MAX_CARS_PER_PLAYER; i++)
{
new Autodatei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,i);
if(dini_Exists(Autodatei))
{
Autos[playerid][i][modelid] = dini_Int(Autodatei,"modelid");
Autos[playerid][i][HP] = dini_Int(Autodatei,"HP");
Autos[playerid][i][Kaputt] = dini_Int(Autodatei,"Kaputt");
Autos[playerid][i][Farbe1] = dini_Int(Autodatei,"Farbe1");
Autos[playerid][i][Farbe2] = dini_Int(Autodatei,"Farbe2");
Autos[playerid][i][Paintjob] = dini_Int(Autodatei,"Paintjob");
format(Autos[playerid][i][Nummernschild],20,dini_Get(Autodatei,"Nummernschild"));
Autos[playerid][i][posxx] = dini_Int(Autodatei,"posxx");
Autos[playerid][i][posyy] = dini_Int(Autodatei,"posyy");
Autos[playerid][i][poszz] = dini_Int(Autodatei,"poszz");
Autos[playerid][i][posaa] = dini_Int(Autodatei,"posaa");
Autos[playerid][i][Abgeschlossen] = dini_Int(Autodatei,"Abgeschlossen");
Autos[playerid][i][Spoiler] = dini_Int(Autodatei,"Spoiler");
Autos[playerid][i][Wheels] = dini_Int(Autodatei,"Wheels");
Autos[playerid][i][Nitro] = dini_Int(Autodatei,"Nitro");
Autos[playerid][i][Roof] = dini_Int(Autodatei,"Roof");
Autos[playerid][i][Hood] = dini_Int(Autodatei,"Hood");
Autos[playerid][i][Sideskirt] = dini_Int(Autodatei,"Sideskirt");
Autos[playerid][i][Lamps] = dini_Int(Autodatei,"Lamps");
Autos[playerid][i][Exhaust] = dini_Int(Autodatei,"Exhaust");
Autos[playerid][i][Stereo] = dini_Int(Autodatei,"Stereo");
Autos[playerid][i][Hydraulics] = dini_Int(Autodatei,"Hydraulics");
Autos[playerid][i][VentRight] = dini_Int(Autodatei,"VentRight");
Autos[playerid][i][VentLeft] = dini_Int(Autodatei,"VentLeft");
Autos[playerid][i][FrontBumper] = dini_Int(Autodatei,"FrontBumper");
Autos[playerid][i][RearBumper] = dini_Int(Autodatei,"RearBumper");
Spielercar[playerid][i] = CreateVehicle(Autos[playerid][i][modelid],Autos[playerid][i][posxx],Autos[playerid][i][posyy],Autos[playerid][i][poszz]+1.5,Autos[playerid][i][posaa],-1,-1,-1);
SetVehicleNumberPlate(Spielercar[playerid][i],dini_Get(Autodatei,"Nummernschild"));
SetVehicleParamsForPlayer(Spielercar[playerid][i],playerid,0,0);
format(Autos[playerid][i][Name],20,dini_Get(Autodatei,"Name"));
if(Autos[playerid][i][HP] > 250)
{
SetVehicleHealth(Spielercar[playerid][i],Autos[playerid][i][HP]);
}
else SetVehicleHealth(Spielercar[playerid][i],255.0);
if(Autos[playerid][i][Paintjob] >= 0)
{
ChangeVehiclePaintjob(Spielercar[playerid][i],Autos[playerid][i][Paintjob]);
}
if(Autos[playerid][i][Farbe1] >= 0 || Autos[playerid][i][Farbe2] >= 0)
{
ChangeVehicleColor(Spielercar[playerid][i],Autos[playerid][i][Farbe1],Autos[playerid][i][Farbe2]);
}
if(Autos[playerid][i][Spoiler] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Spoiler]); }
if(Autos[playerid][i][Hood] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Hood]); }
if(Autos[playerid][i][Roof] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Roof]); }
if(Autos[playerid][i][Sideskirt] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Sideskirt]); }
if(Autos[playerid][i][Lamps] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Lamps]); }
if(Autos[playerid][i][Nitro] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Nitro]); }
if(Autos[playerid][i][Exhaust] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Exhaust]); }
if(Autos[playerid][i][Wheels] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Wheels]); }
if(Autos[playerid][i][Stereo] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Stereo]); }
if(Autos[playerid][i][Hydraulics] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Hydraulics]); }
if(Autos[playerid][i][FrontBumper] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][FrontBumper]); }
if(Autos[playerid][i][RearBumper] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][RearBumper]); }
if(Autos[playerid][i][VentRight] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][VentRight]); }
if(Autos[playerid][i][VentLeft] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][VentLeft]); }
if(Autos[playerid][i][Kaputt] == 1) { DestroyVehicle(Spielercar[playerid][i]); }
}
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new v = 0; v < MAX_CARS_PER_PLAYER; v++)
{
if(Autos[playerid][v][Abgeschlossen] == 1)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(Spielercar[playerid][v]),i,0,1);
Autos[playerid][v][Abgeschlossen] = 1;
}
else if(Autos[playerid][v][Abgeschlossen] == 0)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(Spielercar[playerid][v]),i,0,0);
Autos[playerid][v][Abgeschlossen] = 0;
}
}
}
OnPlayerDisconnect:
for(new i = 0; i < MAX_CARS_PER_PLAYER; i++)
{
new Autodatei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,i);
if(dini_Exists(Autodatei))
{
new Float:vhp;
GetVehicleHealth(Spielercar[playerid][i],vhp);
dini_IntSet(Autodatei,"Farbe1",Autos[playerid][i][Farbe1]);
dini_IntSet(Autodatei,"Farbe2",Autos[playerid][i][Farbe2]);
dini_IntSet(Autodatei,"Paintjob",Autos[playerid][i][Paintjob]);
dini_IntSet(Autodatei,"Abgeschlossen",Autos[playerid][i][Abgeschlossen]);
dini_IntSet(Autodatei,"Kaputt",Autos[playerid][i][Kaputt]);
dini_FloatSet(Autodatei,"posxx",Autos[playerid][i][posxx]);
dini_FloatSet(Autodatei,"posyy",Autos[playerid][i][posyy]);
dini_FloatSet(Autodatei,"poszz",Autos[playerid][i][poszz]);
dini_FloatSet(Autodatei,"posaa",Autos[playerid][i][posaa]);
dini_FloatSet(Autodatei,"HP",vhp);
dini_Set(Autodatei,"Nummernschild",Autos[playerid][i][Nummernschild]);
dini_Set(Autodatei,"Name",Autos[playerid][i][Name]);
dini_IntSet(Autodatei,"Spoiler",GetVehicleComponentInSlot(Spielercar[playerid][i],0));
dini_IntSet(Autodatei,"Hood",GetVehicleComponentInSlot(Spielercar[playerid][i],1));
dini_IntSet(Autodatei,"Roof",GetVehicleComponentInSlot(Spielercar[playerid][i],2));
dini_IntSet(Autodatei,"Sideskirt",GetVehicleComponentInSlot(Spielercar[playerid][i],3));
dini_IntSet(Autodatei,"Lamps",GetVehicleComponentInSlot(Spielercar[playerid][i],4));
dini_IntSet(Autodatei,"Nitro",GetVehicleComponentInSlot(Spielercar[playerid][i],5));
dini_IntSet(Autodatei,"Exhaust",GetVehicleComponentInSlot(Spielercar[playerid][i],6));
dini_IntSet(Autodatei,"Wheels",GetVehicleComponentInSlot(Spielercar[playerid][i],7));
dini_IntSet(Autodatei,"Stereo",GetVehicleComponentInSlot(Spielercar[playerid][i],8));
dini_IntSet(Autodatei,"Hydraulics",GetVehicleComponentInSlot(Spielercar[playerid][i],9));
dini_IntSet(Autodatei,"FrontBumper",GetVehicleComponentInSlot(Spielercar[playerid][i],10));
dini_IntSet(Autodatei,"RearBumper",GetVehicleComponentInSlot(Spielercar[playerid][i],11));
dini_IntSet(Autodatei,"VentRight",GetVehicleComponentInSlot(Spielercar[playerid][i],12));
dini_IntSet(Autodatei,"VentLeft",GetVehicleComponentInSlot(Spielercar[playerid][i],13));
DestroyVehicle(Spielercar[playerid][i]);
}
}
StateChange:
if(newstate == PLAYER_STATE_DRIVER)
{
for(new i = 0; i < sizeof Buycars; i++)
{
if(newcar == kaufauto[i])
{
new str[150];
format(str,sizeof(str),"|-------------------------------------------|\nMöchtest du dieses Fahrzeug wirklich kaufen?\n\nName: %s Preis: %d\n|-------------------------------------------|", Buycars[i][Name], Buycars[i][Preis]);
FreezePlayer(playerid);
return ShowPlayerDialog(playerid,Dialog_Buycar,DIALOG_STYLE_MSGBOX,"Autokauf",str,"Kaufen","Abbrechen");
}
}
DialogResponse:
else if(dialogid == Dialog_Buycar)
{
if(response)
{
new vehicleid = GetPlayerVehicleID(playerid);
for(new i = 0; i < sizeof Buycars; i++)
{
if(vehicleid == kaufauto[i])
{
new geld = GetPlayerMoney(playerid);
if(geld >= Buycars[i][Preis])
{
new datei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(datei,sizeof(datei),"/Autos/%s_Auto_0.ini",name);
if(dini_Exists(datei))
{
new datei2[100];
format(datei2,sizeof(datei2),"/Autos/%s_Auto_1.ini",name);
if(dini_Exists(datei2))
{
SendClientMessage(playerid,0xDD0000FF,"Fehler: Du besitzt bereits 2 Fahrzeuge!");
UnFreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
}
else AutoKaufen(playerid,1);
}
else AutoKaufen(playerid,0);
}
else
{
SendClientMessage(playerid,0xDD0000FF,"Fehler: Du hast nicht genügend Geld!");
UnFreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
}
}
}
}
else
{
UnFreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
}
}
Autokaufen(eigenes Public):
public AutoKaufen(playerid,autoid)
{
for(new i = 0; i < sizeof Buycars; i++)
{
if(GetPlayerVehicleID(playerid) == kaufauto[i])
{
for(new j = 0; j < sizeof Autohaus; j++)
{
if(!strcmp(Autohaus[j][Name],Buycars[i][Autohausname],true))
{
new Autodatei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,autoid);
dini_Create(Autodatei);
dini_Set(Autodatei,"Name",Buycars[i][Name]);
dini_IntSet(Autodatei,"modelid",Buycars[i][modelid]);
dini_FloatSet(Autodatei,"HP",1000.00);
dini_FloatSet(Autodatei,"posxx",Autohaus[j][spawnx]);
dini_FloatSet(Autodatei,"posyy",Autohaus[j][spawny]);
dini_FloatSet(Autodatei,"poszz",Autohaus[j][spawnz]);
dini_FloatSet(Autodatei,"posaa",Autohaus[j][spawna]);
dini_IntSet(Autodatei,"Abgeschlossen",0);
dini_IntSet(Autodatei,"Farbe1",0);
dini_IntSet(Autodatei,"Farbe2",0);
dini_IntSet(Autodatei,"Paintjob",3);
dini_Set(Autodatei,"Nummernschild",Buycars[i][Name]);
Spielercar[playerid][autoid] = CreateVehicle(Buycars[i][modelid],Autohaus[j][spawnx],Autohaus[j][spawny],Autohaus[j][spawnz],Autohaus[j][spawna],-1,-1,-1);
SetVehicleNumberPlate(Spielercar[playerid][autoid],dini_Get(Autodatei,"Nummernschild"));
dini_IntSet(Autodatei,"Spoiler",GetVehicleComponentInSlot(Spielercar[playerid][autoid],0));
dini_IntSet(Autodatei,"Hood",GetVehicleComponentInSlot(Spielercar[playerid][autoid],1));
dini_IntSet(Autodatei,"Roof",GetVehicleComponentInSlot(Spielercar[playerid][autoid],2));
dini_IntSet(Autodatei,"Sideskirt",GetVehicleComponentInSlot(Spielercar[playerid][autoid],3));
dini_IntSet(Autodatei,"Lamps",GetVehicleComponentInSlot(Spielercar[playerid][autoid],4));
dini_IntSet(Autodatei,"Nitro",GetVehicleComponentInSlot(Spielercar[playerid][autoid],5));
dini_IntSet(Autodatei,"Exhaust",GetVehicleComponentInSlot(Spielercar[playerid][autoid],6));
dini_IntSet(Autodatei,"Wheels",GetVehicleComponentInSlot(Spielercar[playerid][autoid],7));
dini_IntSet(Autodatei,"Stereo",GetVehicleComponentInSlot(Spielercar[playerid][autoid],8));
dini_IntSet(Autodatei,"Hydraulics",GetVehicleComponentInSlot(Spielercar[playerid][autoid],9));
dini_IntSet(Autodatei,"FrontBumper",GetVehicleComponentInSlot(Spielercar[playerid][autoid],10));
dini_IntSet(Autodatei,"RearBumper",GetVehicleComponentInSlot(Spielercar[playerid][autoid],11));
dini_IntSet(Autodatei,"VentRight",GetVehicleComponentInSlot(Spielercar[playerid][autoid],12));
dini_IntSet(Autodatei,"VentLeft",GetVehicleComponentInSlot(Spielercar[playerid][autoid],13));
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid,1);
GivePlayerMoney(playerid,-Buycars[i][Preis]);
Autohaus[j][Kasse]+=Buycars[i][Preis];
Autos[playerid][autoid][modelid] = dini_Int(Autodatei,"modelid");
Autos[playerid][autoid][HP] = dini_Int(Autodatei,"HP");
Autos[playerid][autoid][Farbe1] = dini_Int(Autodatei,"Farbe1");
Autos[playerid][autoid][Farbe2] = dini_Int(Autodatei,"Farbe2");
Autos[playerid][autoid][Paintjob] = dini_Int(Autodatei,"Paintjob");
Autos[playerid][autoid][Nummernschild] = dini_Int(Autodatei,"Nummernschild");
Autos[playerid][autoid][posxx] = dini_Int(Autodatei,"posxx");
Autos[playerid][autoid][posyy] = dini_Int(Autodatei,"posyy");
Autos[playerid][autoid][poszz] = dini_Int(Autodatei,"poszz");
Autos[playerid][autoid][posaa] = dini_Int(Autodatei,"posaa");
Autos[playerid][autoid][Abgeschlossen] = dini_Int(Autodatei,"Abgeschlossen");
Autos[playerid][autoid][Spoiler] = dini_Int(Autodatei,"Spoiler");
Autos[playerid][autoid][Wheels] = dini_Int(Autodatei,"Wheels");
Autos[playerid][autoid][Nitro] = dini_Int(Autodatei,"Nitro");
Autos[playerid][autoid][Roof] = dini_Int(Autodatei,"Roof");
Autos[playerid][autoid][Hood] = dini_Int(Autodatei,"Hood");
Autos[playerid][autoid][Sideskirt] = dini_Int(Autodatei,"Sideskirt");
Autos[playerid][autoid][Lamps] = dini_Int(Autodatei,"Lamps");
Autos[playerid][autoid][Exhaust] = dini_Int(Autodatei,"Exhaust");
Autos[playerid][autoid][Stereo] = dini_Int(Autodatei,"Stereo");
Autos[playerid][autoid][Hydraulics] = dini_Int(Autodatei,"Hydraulics");
Autos[playerid][autoid][VentRight] = dini_Int(Autodatei,"VentRight");
Autos[playerid][autoid][VentLeft] = dini_Int(Autodatei,"VentLeft");
Autos[playerid][autoid][FrontBumper] = dini_Int(Autodatei,"FrontBumper");
Autos[playerid][autoid][RearBumper] = dini_Int(Autodatei,"RearBumper");
}
}
}
}
return 1;
}
new Autos[MAX_PLAYERS][MAX_CARS_PER_PLAYER][Ainfo];
new Spielercar[MAX_PLAYERS][MAX_CARS_PER_PLAYER];
OnPlayerConnect:
for(new i = 0; i < MAX_CARS_PER_PLAYER; i++)
{
new Autodatei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,i);
if(dini_Exists(Autodatei))
{
Autos[playerid][i][modelid] = dini_Int(Autodatei,"modelid");
Autos[playerid][i][HP] = dini_Int(Autodatei,"HP");
Autos[playerid][i][Kaputt] = dini_Int(Autodatei,"Kaputt");
Autos[playerid][i][Farbe1] = dini_Int(Autodatei,"Farbe1");
Autos[playerid][i][Farbe2] = dini_Int(Autodatei,"Farbe2");
Autos[playerid][i][Paintjob] = dini_Int(Autodatei,"Paintjob");
format(Autos[playerid][i][Nummernschild],20,dini_Get(Autodatei,"Nummernschild"));
Autos[playerid][i][posxx] = dini_Int(Autodatei,"posxx");
Autos[playerid][i][posyy] = dini_Int(Autodatei,"posyy");
Autos[playerid][i][poszz] = dini_Int(Autodatei,"poszz");
Autos[playerid][i][posaa] = dini_Int(Autodatei,"posaa");
Autos[playerid][i][Abgeschlossen] = dini_Int(Autodatei,"Abgeschlossen");
Autos[playerid][i][Spoiler] = dini_Int(Autodatei,"Spoiler");
Autos[playerid][i][Wheels] = dini_Int(Autodatei,"Wheels");
Autos[playerid][i][Nitro] = dini_Int(Autodatei,"Nitro");
Autos[playerid][i][Roof] = dini_Int(Autodatei,"Roof");
Autos[playerid][i][Hood] = dini_Int(Autodatei,"Hood");
Autos[playerid][i][Sideskirt] = dini_Int(Autodatei,"Sideskirt");
Autos[playerid][i][Lamps] = dini_Int(Autodatei,"Lamps");
Autos[playerid][i][Exhaust] = dini_Int(Autodatei,"Exhaust");
Autos[playerid][i][Stereo] = dini_Int(Autodatei,"Stereo");
Autos[playerid][i][Hydraulics] = dini_Int(Autodatei,"Hydraulics");
Autos[playerid][i][VentRight] = dini_Int(Autodatei,"VentRight");
Autos[playerid][i][VentLeft] = dini_Int(Autodatei,"VentLeft");
Autos[playerid][i][FrontBumper] = dini_Int(Autodatei,"FrontBumper");
Autos[playerid][i][RearBumper] = dini_Int(Autodatei,"RearBumper");
Spielercar[playerid][i] = CreateVehicle(Autos[playerid][i][modelid],Autos[playerid][i][posxx],Autos[playerid][i][posyy],Autos[playerid][i][poszz]+1.5,Autos[playerid][i][posaa],-1,-1,-1);
SetVehicleNumberPlate(Spielercar[playerid][i],dini_Get(Autodatei,"Nummernschild"));
SetVehicleParamsForPlayer(Spielercar[playerid][i],playerid,0,0);
format(Autos[playerid][i][Name],20,dini_Get(Autodatei,"Name"));
if(Autos[playerid][i][HP] > 250)
{
SetVehicleHealth(Spielercar[playerid][i],Autos[playerid][i][HP]);
}
else SetVehicleHealth(Spielercar[playerid][i],255.0);
if(Autos[playerid][i][Paintjob] >= 0)
{
ChangeVehiclePaintjob(Spielercar[playerid][i],Autos[playerid][i][Paintjob]);
}
if(Autos[playerid][i][Farbe1] >= 0 || Autos[playerid][i][Farbe2] >= 0)
{
ChangeVehicleColor(Spielercar[playerid][i],Autos[playerid][i][Farbe1],Autos[playerid][i][Farbe2]);
}
if(Autos[playerid][i][Spoiler] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Spoiler]); }
if(Autos[playerid][i][Hood] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Hood]); }
if(Autos[playerid][i][Roof] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Roof]); }
if(Autos[playerid][i][Sideskirt] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Sideskirt]); }
if(Autos[playerid][i][Lamps] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Lamps]); }
if(Autos[playerid][i][Nitro] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Nitro]); }
if(Autos[playerid][i][Exhaust] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Exhaust]); }
if(Autos[playerid][i][Wheels] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Wheels]); }
if(Autos[playerid][i][Stereo] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Stereo]); }
if(Autos[playerid][i][Hydraulics] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][Hydraulics]); }
if(Autos[playerid][i][FrontBumper] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][FrontBumper]); }
if(Autos[playerid][i][RearBumper] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][RearBumper]); }
if(Autos[playerid][i][VentRight] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][VentRight]); }
if(Autos[playerid][i][VentLeft] >= 1000) { AddVehicleComponent(Spielercar[playerid][i],Autos[playerid][i][VentLeft]); }
if(Autos[playerid][i][Kaputt] == 1) { DestroyVehicle(Spielercar[playerid][i]); }
}
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new v = 0; v < MAX_CARS_PER_PLAYER; v++)
{
if(Autos[playerid][v][Abgeschlossen] == 1)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(Spielercar[playerid][v]),i,0,1);
Autos[playerid][v][Abgeschlossen] = 1;
}
else if(Autos[playerid][v][Abgeschlossen] == 0)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(Spielercar[playerid][v]),i,0,0);
Autos[playerid][v][Abgeschlossen] = 0;
}
}
}
OnPlayerDisconnect:
for(new i = 0; i < MAX_CARS_PER_PLAYER; i++)
{
new Autodatei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,i);
if(dini_Exists(Autodatei))
{
new Float:vhp;
GetVehicleHealth(Spielercar[playerid][i],vhp);
dini_IntSet(Autodatei,"Farbe1",Autos[playerid][i][Farbe1]);
dini_IntSet(Autodatei,"Farbe2",Autos[playerid][i][Farbe2]);
dini_IntSet(Autodatei,"Paintjob",Autos[playerid][i][Paintjob]);
dini_IntSet(Autodatei,"Abgeschlossen",Autos[playerid][i][Abgeschlossen]);
dini_IntSet(Autodatei,"Kaputt",Autos[playerid][i][Kaputt]);
dini_FloatSet(Autodatei,"posxx",Autos[playerid][i][posxx]);
dini_FloatSet(Autodatei,"posyy",Autos[playerid][i][posyy]);
dini_FloatSet(Autodatei,"poszz",Autos[playerid][i][poszz]);
dini_FloatSet(Autodatei,"posaa",Autos[playerid][i][posaa]);
dini_FloatSet(Autodatei,"HP",vhp);
dini_Set(Autodatei,"Nummernschild",Autos[playerid][i][Nummernschild]);
dini_Set(Autodatei,"Name",Autos[playerid][i][Name]);
dini_IntSet(Autodatei,"Spoiler",GetVehicleComponentInSlot(Spielercar[playerid][i],0));
dini_IntSet(Autodatei,"Hood",GetVehicleComponentInSlot(Spielercar[playerid][i],1));
dini_IntSet(Autodatei,"Roof",GetVehicleComponentInSlot(Spielercar[playerid][i],2));
dini_IntSet(Autodatei,"Sideskirt",GetVehicleComponentInSlot(Spielercar[playerid][i],3));
dini_IntSet(Autodatei,"Lamps",GetVehicleComponentInSlot(Spielercar[playerid][i],4));
dini_IntSet(Autodatei,"Nitro",GetVehicleComponentInSlot(Spielercar[playerid][i],5));
dini_IntSet(Autodatei,"Exhaust",GetVehicleComponentInSlot(Spielercar[playerid][i],6));
dini_IntSet(Autodatei,"Wheels",GetVehicleComponentInSlot(Spielercar[playerid][i],7));
dini_IntSet(Autodatei,"Stereo",GetVehicleComponentInSlot(Spielercar[playerid][i],8));
dini_IntSet(Autodatei,"Hydraulics",GetVehicleComponentInSlot(Spielercar[playerid][i],9));
dini_IntSet(Autodatei,"FrontBumper",GetVehicleComponentInSlot(Spielercar[playerid][i],10));
dini_IntSet(Autodatei,"RearBumper",GetVehicleComponentInSlot(Spielercar[playerid][i],11));
dini_IntSet(Autodatei,"VentRight",GetVehicleComponentInSlot(Spielercar[playerid][i],12));
dini_IntSet(Autodatei,"VentLeft",GetVehicleComponentInSlot(Spielercar[playerid][i],13));
DestroyVehicle(Spielercar[playerid][i]);
}
}
StateChange:
if(newstate == PLAYER_STATE_DRIVER)
{
for(new i = 0; i < sizeof Buycars; i++)
{
if(newcar == kaufauto[i])
{
new str[150];
format(str,sizeof(str),"|-------------------------------------------|\nMöchtest du dieses Fahrzeug wirklich kaufen?\n\nName: %s Preis: %d\n|-------------------------------------------|", Buycars[i][Name], Buycars[i][Preis]);
FreezePlayer(playerid);
return ShowPlayerDialog(playerid,Dialog_Buycar,DIALOG_STYLE_MSGBOX,"Autokauf",str,"Kaufen","Abbrechen");
}
}
DialogResponse:
else if(dialogid == Dialog_Buycar)
{
if(response)
{
new vehicleid = GetPlayerVehicleID(playerid);
for(new i = 0; i < sizeof Buycars; i++)
{
if(vehicleid == kaufauto[i])
{
new geld = GetPlayerMoney(playerid);
if(geld >= Buycars[i][Preis])
{
new datei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(datei,sizeof(datei),"/Autos/%s_Auto_0.ini",name);
if(dini_Exists(datei))
{
new datei2[100];
format(datei2,sizeof(datei2),"/Autos/%s_Auto_1.ini",name);
if(dini_Exists(datei2))
{
SendClientMessage(playerid,0xDD0000FF,"Fehler: Du besitzt bereits 2 Fahrzeuge!");
UnFreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
}
else AutoKaufen(playerid,1);
}
else AutoKaufen(playerid,0);
}
else
{
SendClientMessage(playerid,0xDD0000FF,"Fehler: Du hast nicht genügend Geld!");
UnFreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
}
}
}
}
else
{
UnFreezePlayer(playerid);
RemovePlayerFromVehicle(playerid);
}
}
Autokaufen(eigenes Public):
public AutoKaufen(playerid,autoid)
{
for(new i = 0; i < sizeof Buycars; i++)
{
if(GetPlayerVehicleID(playerid) == kaufauto[i])
{
for(new j = 0; j < sizeof Autohaus; j++)
{
if(!strcmp(Autohaus[j][Name],Buycars[i][Autohausname],true))
{
new Autodatei[100],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(Autodatei,sizeof(Autodatei),"/Autos/%s_Auto_%d.ini",name,autoid);
dini_Create(Autodatei);
dini_Set(Autodatei,"Name",Buycars[i][Name]);
dini_IntSet(Autodatei,"modelid",Buycars[i][modelid]);
dini_FloatSet(Autodatei,"HP",1000.00);
dini_FloatSet(Autodatei,"posxx",Autohaus[j][spawnx]);
dini_FloatSet(Autodatei,"posyy",Autohaus[j][spawny]);
dini_FloatSet(Autodatei,"poszz",Autohaus[j][spawnz]);
dini_FloatSet(Autodatei,"posaa",Autohaus[j][spawna]);
dini_IntSet(Autodatei,"Abgeschlossen",0);
dini_IntSet(Autodatei,"Farbe1",0);
dini_IntSet(Autodatei,"Farbe2",0);
dini_IntSet(Autodatei,"Paintjob",3);
dini_Set(Autodatei,"Nummernschild",Buycars[i][Name]);
Spielercar[playerid][autoid] = CreateVehicle(Buycars[i][modelid],Autohaus[j][spawnx],Autohaus[j][spawny],Autohaus[j][spawnz],Autohaus[j][spawna],-1,-1,-1);
SetVehicleNumberPlate(Spielercar[playerid][autoid],dini_Get(Autodatei,"Nummernschild"));
dini_IntSet(Autodatei,"Spoiler",GetVehicleComponentInSlot(Spielercar[playerid][autoid],0));
dini_IntSet(Autodatei,"Hood",GetVehicleComponentInSlot(Spielercar[playerid][autoid],1));
dini_IntSet(Autodatei,"Roof",GetVehicleComponentInSlot(Spielercar[playerid][autoid],2));
dini_IntSet(Autodatei,"Sideskirt",GetVehicleComponentInSlot(Spielercar[playerid][autoid],3));
dini_IntSet(Autodatei,"Lamps",GetVehicleComponentInSlot(Spielercar[playerid][autoid],4));
dini_IntSet(Autodatei,"Nitro",GetVehicleComponentInSlot(Spielercar[playerid][autoid],5));
dini_IntSet(Autodatei,"Exhaust",GetVehicleComponentInSlot(Spielercar[playerid][autoid],6));
dini_IntSet(Autodatei,"Wheels",GetVehicleComponentInSlot(Spielercar[playerid][autoid],7));
dini_IntSet(Autodatei,"Stereo",GetVehicleComponentInSlot(Spielercar[playerid][autoid],8));
dini_IntSet(Autodatei,"Hydraulics",GetVehicleComponentInSlot(Spielercar[playerid][autoid],9));
dini_IntSet(Autodatei,"FrontBumper",GetVehicleComponentInSlot(Spielercar[playerid][autoid],10));
dini_IntSet(Autodatei,"RearBumper",GetVehicleComponentInSlot(Spielercar[playerid][autoid],11));
dini_IntSet(Autodatei,"VentRight",GetVehicleComponentInSlot(Spielercar[playerid][autoid],12));
dini_IntSet(Autodatei,"VentLeft",GetVehicleComponentInSlot(Spielercar[playerid][autoid],13));
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid,1);
GivePlayerMoney(playerid,-Buycars[i][Preis]);
Autohaus[j][Kasse]+=Buycars[i][Preis];
Autos[playerid][autoid][modelid] = dini_Int(Autodatei,"modelid");
Autos[playerid][autoid][HP] = dini_Int(Autodatei,"HP");
Autos[playerid][autoid][Farbe1] = dini_Int(Autodatei,"Farbe1");
Autos[playerid][autoid][Farbe2] = dini_Int(Autodatei,"Farbe2");
Autos[playerid][autoid][Paintjob] = dini_Int(Autodatei,"Paintjob");
Autos[playerid][autoid][Nummernschild] = dini_Int(Autodatei,"Nummernschild");
Autos[playerid][autoid][posxx] = dini_Int(Autodatei,"posxx");
Autos[playerid][autoid][posyy] = dini_Int(Autodatei,"posyy");
Autos[playerid][autoid][poszz] = dini_Int(Autodatei,"poszz");
Autos[playerid][autoid][posaa] = dini_Int(Autodatei,"posaa");
Autos[playerid][autoid][Abgeschlossen] = dini_Int(Autodatei,"Abgeschlossen");
Autos[playerid][autoid][Spoiler] = dini_Int(Autodatei,"Spoiler");
Autos[playerid][autoid][Wheels] = dini_Int(Autodatei,"Wheels");
Autos[playerid][autoid][Nitro] = dini_Int(Autodatei,"Nitro");
Autos[playerid][autoid][Roof] = dini_Int(Autodatei,"Roof");
Autos[playerid][autoid][Hood] = dini_Int(Autodatei,"Hood");
Autos[playerid][autoid][Sideskirt] = dini_Int(Autodatei,"Sideskirt");
Autos[playerid][autoid][Lamps] = dini_Int(Autodatei,"Lamps");
Autos[playerid][autoid][Exhaust] = dini_Int(Autodatei,"Exhaust");
Autos[playerid][autoid][Stereo] = dini_Int(Autodatei,"Stereo");
Autos[playerid][autoid][Hydraulics] = dini_Int(Autodatei,"Hydraulics");
Autos[playerid][autoid][VentRight] = dini_Int(Autodatei,"VentRight");
Autos[playerid][autoid][VentLeft] = dini_Int(Autodatei,"VentLeft");
Autos[playerid][autoid][FrontBumper] = dini_Int(Autodatei,"FrontBumper");
Autos[playerid][autoid][RearBumper] = dini_Int(Autodatei,"RearBumper");
}
}
}
}
return 1;
}
Danke schonmal im Vorraus
Adrian