Hallo,
Ich habs nicht so mit speichern/laden und deshalb wäre ich euch sehr verbunden, wenn ihr mir helfen könntet.
Ich möchte die Fahrzeuge speichern und zwar: Model, Farbe 1, Farbe 2, Position X Y und Z, mod 1-17, Lackierung aus dem Tuningshop.
Nun habe ich das hier, aber es funktioniert nicht. Wenn ich mir als Admin ein Auto spawnen lasse, es dann tune und dann den Server schließe und noch einmal öffne, wird in der Datei nur die Tuning Sachen und die Position gespeichert, aber wenn ich dann erneut verbinde ist das Fahrzeug nicht mehr da:
pastebin
oder
Achtung sehr langer Code!
enum CarInfo{ID,Model,Col1,Col2,Float:SpawnX,Float:SpawnY,Float:SpawnZ,Float:SpawnRot,mod1,mod2,mod3,mod4,mod5,mod6,mod7,mod8,mod9,mod10,mod11,mod12,mod13,mod14,mod15,mod16,mod17,VehSkin}new AutoData[MAX_VEHICLES][CarInfo];new Emptyfile;
new spoiler[20]= {1000,1001,1002,1003,1014,1015,1016,1023,1058,1060,1049,1050,1138,1139,1146,1147,1158,1162,1163,1164};new nitro[3] = {1008,1009,1010};new frontbumper[23]= {1117,1152,1153,1155,1157,1160,1165,1167,1169,1170,1171,1172,1173,1174,1175,1179,1181,1182,1185,1188,1189,1192,1193};new rbumper[22]= {1140,1141,1148,1149,1150,1151,1154,1156,1159,1161,1166,1168,1176,1177,1178,1180,1183,1184,1186,1187,1190,1191};new exhaust[28]= {1018,1019,1020,1021,1022,1028,1029,1037,1043,1044,1045,1046,1059,1064,1065,1066,1089,1092,1104,1105,1113,1114,1126,1127,1129,1132,1135,1136};new bventr[2]= {1042,1044};new bventl[2]= {1043,1045};new bscoop[4]= {1004,1005,1011,1012};new rscoop[13]= {1006,1032,1033,1035,1038,1053,1054,1055,1061,1067,1068,1088,1091};new lskirt[21]= {1007,1026,1031,1036,1039,1042,1047,1048,1056,1057,1069,1070,1090,1093,1106,1108,1118,1119,1133,1122,1134};new rskirt[21]= {1017,1027,1030,1040,1041,1051,1052,1062,1063,1071,1072,1094,1095,1099,1101,1102,1107,1120,1121,1124,1137};new hydraulics= 1087;new base= 1086;new rbbars[2]= {1109,1110};new fbbars[2]= {1115,1116};new wheels[17]= {1025,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1096,1097,1098};
public OnGameModeExit(){ for(new i = 0;i< MAX_VEHICLES;i++) { SaveVehicle(i); } return 1;}
public OnPlayerDisconnect(playerid, reason){ new vehicleid = GetPlayerVehicleID(playerid),Float:x,Float:y,Float:z,Float:r; GetVehiclePos(vehicleid,x,y,z); GetVehicleZAngle(vehicleid,r); AutoData[vehicleid][SpawnX] = x; AutoData[vehicleid][SpawnY] = y; AutoData[vehicleid][SpawnZ] = z; AutoData[vehicleid][SpawnRot] = r; SaveVehicle(vehicleid);
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger){ if(AutoData[vehicleid][VehSkin]!=0)return ChangeVehiclePaintjob(vehicleid,AutoData[vehicleid][VehSkin]); return 0;}
public OnPlayerExitVehicle(playerid, vehicleid){ new Float:x,Float:y,Float:z; GetVehicleVelocity(vehicleid,x,y,z); PutPlayerInVehicle(playerid,vehicleid,1); PutPlayerInVehicle(playerid,vehicleid,0); SetVehicleVelocity(vehicleid,x,y,z); return true;}
public OnVehicleMod(playerid, vehicleid, componentid){ switch (FindSlotID(componentid)) { case 1: AutoData[vehicleid][mod1]=componentid; case 2: AutoData[vehicleid][mod2]=componentid; case 3: AutoData[vehicleid][mod3]=componentid; case 4: AutoData[vehicleid][mod4]=componentid; case 5: AutoData[vehicleid][mod5]=componentid; case 6: AutoData[vehicleid][mod6]=componentid; case 7: AutoData[vehicleid][mod7]=componentid; case 8: AutoData[vehicleid][mod8]=componentid; case 9: AutoData[vehicleid][mod9]=componentid; case 10: AutoData[vehicleid][mod10]=componentid; case 11: AutoData[vehicleid][mod11]=componentid; case 12: AutoData[vehicleid][mod12]=componentid; case 13: AutoData[vehicleid][mod13]=componentid; case 14: AutoData[vehicleid][mod14]=componentid; case 15: AutoData[vehicleid][mod15]=componentid; case 16: AutoData[vehicleid][mod16]=componentid; case 17: AutoData[vehicleid][mod17]=componentid; } SaveVehicle(vehicleid); return 1;}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid){ return AutoData[vehicleid][VehSkin]=paintjobid;}
stock Login(playerid,key[]){ new Spielerdatei[64]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name); if(!strcmp(key,dini_Get(Spielerdatei,"Passwort"),false)) { LoadAccount(playerid); LoadVehicles(); SendClientMessage(playerid,GELB,"Erfolgreich eingeloggt."); return 1; } else { SendClientMessage(playerid,GELB,"Falsches Passwort."); ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Dein Account wurde gefunden. Gib bitte dein Passwort ein.","Login","Abbrechen"); return 1; }}
stock LoadVehicles() //Fertig{ for(new i = 0; i< MAX_VEHICLES;i++) { new formatLD[256]; format(formatLD,256,"Cars/%d_ownerauto.ini",i); if(dini_Exists(formatLD)) { new model,col1,col2,Float:x,Float:y,Float:z,Float:r; model=dini_Int(formatLD, "Model"); col1=dini_Int(formatLD, "Col1"); col2=dini_Int(formatLD, "Col2"); x=dini_Float(formatLD, "SpawnX"); y=dini_Float(formatLD, "SpawnY"); z=dini_Float(formatLD, "SpawnZ"); r=dini_Float(formatLD, "SpawnRot"); new veh = CreateVehicle(model,x,y,z,r,col1,col2,-1); AutoData[veh][Model]=model; AutoData[veh][Col1]=col1; AutoData[veh][Col2]=col2; AutoData[veh][SpawnX]=x; AutoData[veh][SpawnY]=y; AutoData[veh][SpawnZ]=z; AutoData[veh][SpawnRot]=r; AutoData[veh][ID]= i; AutoData[veh][mod1] = dini_Int(formatLD, "mod1"); AutoData[veh][mod2] = dini_Int(formatLD, "mod2"); AutoData[veh][mod3] = dini_Int(formatLD, "mod3"); AutoData[veh][mod4] = dini_Int(formatLD, "mod4"); AutoData[veh][mod5] = dini_Int(formatLD, "mod5"); AutoData[veh][mod6] = dini_Int(formatLD, "mod6"); AutoData[veh][mod7] = dini_Int(formatLD, "mod7"); AutoData[veh][mod8] = dini_Int(formatLD, "mod8"); AutoData[veh][mod9] = dini_Int(formatLD, "mod9"); AutoData[veh][mod10] = dini_Int(formatLD, "mod10"); AutoData[veh][mod11] = dini_Int(formatLD, "mod11"); AutoData[veh][mod12] = dini_Int(formatLD, "mod12"); AutoData[veh][mod13] = dini_Int(formatLD, "mod13"); AutoData[veh][mod14] = dini_Int(formatLD, "mod14"); AutoData[veh][mod15] = dini_Int(formatLD, "mod15"); AutoData[veh][mod16] = dini_Int(formatLD, "mod16"); AutoData[veh][mod17] = dini_Int(formatLD, "mod17"); AutoData[veh][VehSkin] = dini_Int(formatLD, "VehSkin"); AddCarComponents(veh); } }}stock SaveVehicle(vehicleid) // Fertig{ new formatLD[256]; format(formatLD,256,"Cars/%d_ownerauto.ini",AutoData[vehicleid][ID]); if(dini_Exists(formatLD)) { dini_IntSet(formatLD,"Model",AutoData[vehicleid][Model]); dini_IntSet(formatLD,"Col1",AutoData[vehicleid][Col1]); dini_IntSet(formatLD,"Col2",AutoData[vehicleid][Col2]); dini_FloatSet(formatLD,"SpawnX",AutoData[vehicleid][SpawnX]); dini_FloatSet(formatLD,"SpawnY",AutoData[vehicleid][SpawnY]); dini_FloatSet(formatLD,"SpawnZ",AutoData[vehicleid][SpawnZ]); dini_FloatSet(formatLD,"SpawnRot",AutoData[vehicleid][SpawnRot]); dini_IntSet(formatLD,"mod1",AutoData[vehicleid][mod1]); dini_IntSet(formatLD,"mod2",AutoData[vehicleid][mod2]); dini_IntSet(formatLD,"mod3",AutoData[vehicleid][mod3]); dini_IntSet(formatLD,"mod4",AutoData[vehicleid][mod4]); dini_IntSet(formatLD,"mod5",AutoData[vehicleid][mod5]); dini_IntSet(formatLD,"mod6",AutoData[vehicleid][mod6]); dini_IntSet(formatLD,"mod7",AutoData[vehicleid][mod8]); dini_IntSet(formatLD,"mod9",AutoData[vehicleid][mod9]); dini_IntSet(formatLD,"mod10",AutoData[vehicleid][mod10]); dini_IntSet(formatLD,"mod11",AutoData[vehicleid][mod11]); dini_IntSet(formatLD,"mod12",AutoData[vehicleid][mod12]); dini_IntSet(formatLD,"mod13",AutoData[vehicleid][mod13]); dini_IntSet(formatLD,"mod14",AutoData[vehicleid][mod14]); dini_IntSet(formatLD,"mod15",AutoData[vehicleid][mod15]); dini_IntSet(formatLD,"mod16",AutoData[vehicleid][mod16]); dini_IntSet(formatLD,"mod17",AutoData[vehicleid][mod17]); dini_IntSet(formatLD,"VehSkin",AutoData[vehicleid][VehSkin]); } else { dini_Create(formatLD); SaveVehicle(vehicleid); // Wiederhole Befehl nachdem Datei erstellt } return 1;}stock GetEmptyFile(){ new formatLD[256]; for(new id = 0; id<MAX_VEHICLES;id++) { format(formatLD,256,"Cars/%d_ownerauto.ini",id); if(!fexist(formatLD)) Emptyfile=id; } return 1;}stock CreateNewVehicle(model,Float:x,Float:y,Float:z,Float:rot,col1,col2) // Fertig{ GetEmptyFile(); new tmpid = CreateVehicle(model,x,y,z,rot,col1,col2,-1); new formatLD[256]; format(formatLD,256,"Cars/%d_ownerauto.ini",Emptyfile); if(dini_Exists(formatLD)) return GetEmptyFile(); AutoData[tmpid][Model]=model; AutoData[tmpid][ID] = Emptyfile; AutoData[tmpid][Col1]=col1; AutoData[tmpid][Col2]=col2; AutoData[tmpid][SpawnX]=x; AutoData[tmpid][SpawnY]=y; AutoData[tmpid][SpawnZ]=z; AutoData[tmpid][SpawnRot]=rot; dini_Create(formatLD); SaveVehicle(tmpid); return tmpid;}stock AddCarComponents(vehicleid){ if(AutoData[vehicleid][mod1]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod1]); if(AutoData[vehicleid][mod2]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod2]); if(AutoData[vehicleid][mod3]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod3]); if(AutoData[vehicleid][mod4]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod4]); if(AutoData[vehicleid][mod5]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod5]); if(AutoData[vehicleid][mod6]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod6]); if(AutoData[vehicleid][mod7]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod7]); if(AutoData[vehicleid][mod8]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod8]); if(AutoData[vehicleid][mod9]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod9]); if(AutoData[vehicleid][mod10]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod10]); if(AutoData[vehicleid][mod11]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod11]); if(AutoData[vehicleid][mod12]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod12]); if(AutoData[vehicleid][mod13]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod13]); if(AutoData[vehicleid][mod14]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod14]); if(AutoData[vehicleid][mod15]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod15]); if(AutoData[vehicleid][mod16]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod16]); if(AutoData[vehicleid][mod17]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod17]); if(AutoData[vehicleid][VehSkin]!=0) ChangeVehiclePaintjob(vehicleid,AutoData[vehicleid][VehSkin]); return 1;}stock FindSlotID(componentid){ new i; for(i=0; i<20; i++)if(spoiler[i]==componentid) return 1; for(i=0; i<3; i++)if(nitro[i]==componentid) return 2; for(i=0; i<23; i++)if(frontbumper[i]==componentid) return 3; for(i=0; i<22; i++)if(rbumper[i]==componentid) return 4; for(i=0; i<28; i++)if(exhaust[i]==componentid) return 5; for(i=0; i<2; i++)if(bventr[i]==componentid) return 6; for(i=0; i<2; i++)if(bventl[i]==componentid) return 7; for(i=0; i<4; i++)if(bscoop[i]==componentid) return 8; for(i=0; i<13; i++)if(rscoop[i]==componentid) return 9; for(i=0; i<21; i++)if(lskirt[i]==componentid) return 10; for(i=0; i<21; i++)if(rskirt[i]==componentid) return 11; if(hydraulics==componentid) return 12; if(base==componentid) return 13; for(i=0; i<2; i++)if(rbbars[i]==componentid) return 14; for(i=0; i<2; i++)if(fbbars[i]==componentid) return 15; for(i=0; i<17; i++)if(wheels[i]==componentid) return 16; return 0;}
Sorry für den langen Code
mfG [CGR]BlackJack