Guest User

Untitled

a guest
Feb 21st, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.56 KB | None | 0 0
  1. enum CarInfo
  2. {
  3. ID,
  4. Model,
  5. Col1,
  6. Col2,
  7. Float:SpawnX,
  8. Float:SpawnY,
  9. Float:SpawnZ,
  10. Float:SpawnRot,
  11. mod1,
  12. mod2,
  13. mod3,
  14. mod4,
  15. mod5,
  16. mod6,
  17. mod7,
  18. mod8,
  19. mod9,
  20. mod10,
  21. mod11,
  22. mod12,
  23. mod13,
  24. mod14,
  25. mod15,
  26. mod16,
  27. mod17,
  28. VehSkin
  29. }
  30. new AutoData[MAX_VEHICLES][CarInfo];
  31. new Emptyfile;
  32.  
  33. new spoiler[20]= {
  34. 1000,1001,1002,1003,1014,1015,1016,1023,1058,
  35. 1060,1049,1050,1138,1139,1146,1147,1158,1162,
  36. 1163,1164};
  37. new nitro[3] = {1008,1009,1010};
  38. new frontbumper[23]= {
  39. 1117,1152,1153,1155,1157,1160,1165,1167,1169,
  40. 1170,1171,1172,1173,1174,1175,1179,1181,1182,
  41. 1185,1188,1189,1192,1193};
  42. new rbumper[22]= {
  43. 1140,1141,1148,1149,1150,1151,1154,1156,1159,
  44. 1161,1166,1168,1176,1177,1178,1180,1183,1184,
  45. 1186,1187,1190,1191};
  46. new exhaust[28]= {
  47. 1018,1019,1020,1021,1022,1028,1029,1037,1043,
  48. 1044,1045,1046,1059,1064,1065,1066,1089,1092,
  49. 1104,1105,1113,1114,1126,1127,1129,1132,1135,
  50. 1136};
  51. new bventr[2]= {1042,1044};
  52. new bventl[2]= {1043,1045};
  53. new bscoop[4]= {1004,1005,1011,1012};
  54. new rscoop[13]= {
  55. 1006,1032,1033,1035,1038,1053,1054,1055,1061,
  56. 1067,1068,1088,1091};
  57. new lskirt[21]= {
  58. 1007,1026,1031,1036,1039,1042,1047,1048,1056,
  59. 1057,1069,1070,1090,1093,1106,1108,1118,1119,
  60. 1133,1122,1134};
  61. new rskirt[21]= {
  62. 1017,1027,1030,1040,1041,1051,1052,1062,1063,
  63. 1071,1072,1094,1095,1099,1101,1102,1107,1120,
  64. 1121,1124,1137};
  65. new hydraulics= 1087;
  66. new base= 1086;
  67. new rbbars[2]= {1109,1110};
  68. new fbbars[2]= {1115,1116};
  69. new wheels[17]= {
  70. 1025,1073,1074,1075,1076,1077,1078,1079,1080,
  71. 1081,1082,1083,1084,1085,1096,1097,1098};
  72.  
  73. public OnGameModeExit()
  74. {
  75.     for(new i = 0;i< MAX_VEHICLES;i++)
  76.     {
  77.         SaveVehicle(i);
  78.     }
  79.     return 1;
  80. }
  81.  
  82. public OnPlayerDisconnect(playerid, reason)
  83. {
  84.    
  85.     new vehicleid = GetPlayerVehicleID(playerid),Float:x,Float:y,Float:z,Float:r;
  86.     GetVehiclePos(vehicleid,x,y,z);
  87.     GetVehicleZAngle(vehicleid,r);
  88.     AutoData[vehicleid][SpawnX] = x;
  89.     AutoData[vehicleid][SpawnY] = y;
  90.     AutoData[vehicleid][SpawnZ] = z;
  91.     AutoData[vehicleid][SpawnRot] = r;
  92.     SaveVehicle(vehicleid);
  93. }
  94.  
  95. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  96. {
  97.     if(AutoData[vehicleid][VehSkin]!=0)return ChangeVehiclePaintjob(vehicleid,AutoData[vehicleid][VehSkin]);
  98.     return 0;
  99. }
  100.  
  101. public OnPlayerExitVehicle(playerid, vehicleid)
  102. {
  103.     new Float:x,Float:y,Float:z;
  104.     GetVehicleVelocity(vehicleid,x,y,z);
  105.     PutPlayerInVehicle(playerid,vehicleid,1);
  106.     PutPlayerInVehicle(playerid,vehicleid,0);
  107.     SetVehicleVelocity(vehicleid,x,y,z);
  108.     return true;
  109. }
  110.  
  111. public OnVehicleMod(playerid, vehicleid, componentid)
  112. {
  113.     switch (FindSlotID(componentid))
  114.         {
  115.             case 1:  AutoData[vehicleid][mod1]=componentid;
  116.             case 2:  AutoData[vehicleid][mod2]=componentid;
  117.             case 3:  AutoData[vehicleid][mod3]=componentid;
  118.             case 4:  AutoData[vehicleid][mod4]=componentid;
  119.             case 5:  AutoData[vehicleid][mod5]=componentid;
  120.             case 6:  AutoData[vehicleid][mod6]=componentid;
  121.             case 7:  AutoData[vehicleid][mod7]=componentid;
  122.             case 8:  AutoData[vehicleid][mod8]=componentid;
  123.             case 9:  AutoData[vehicleid][mod9]=componentid;
  124.             case 10:  AutoData[vehicleid][mod10]=componentid;
  125.             case 11:  AutoData[vehicleid][mod11]=componentid;
  126.             case 12:  AutoData[vehicleid][mod12]=componentid;
  127.             case 13:  AutoData[vehicleid][mod13]=componentid;
  128.             case 14:  AutoData[vehicleid][mod14]=componentid;
  129.             case 15:  AutoData[vehicleid][mod15]=componentid;
  130.             case 16:  AutoData[vehicleid][mod16]=componentid;
  131.             case 17:  AutoData[vehicleid][mod17]=componentid;
  132.          }
  133.     SaveVehicle(vehicleid);
  134.     return 1;
  135. }
  136.  
  137. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  138. {
  139.     return AutoData[vehicleid][VehSkin]=paintjobid;
  140. }
  141.  
  142. stock Login(playerid,key[])
  143. {
  144.     new Spielerdatei[64];
  145.     new name[MAX_PLAYER_NAME];
  146.     GetPlayerName(playerid,name,sizeof(name));
  147.     format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
  148.     if(!strcmp(key,dini_Get(Spielerdatei,"Passwort"),false))
  149.     {
  150.         LoadAccount(playerid);
  151.         LoadVehicles();
  152.         SendClientMessage(playerid,GELB,"Erfolgreich eingeloggt.");
  153.         return 1;
  154.     }
  155.     else
  156.     {
  157.         SendClientMessage(playerid,GELB,"Falsches Passwort.");
  158.         ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Dein Account wurde gefunden. Gib bitte dein Passwort ein.","Login","Abbrechen");
  159.         return 1;
  160.      }
  161. }
  162.  
  163. stock LoadVehicles() //Fertig
  164. {
  165.         for(new i = 0; i< MAX_VEHICLES;i++)
  166.         {
  167.             new formatLD[256];
  168.             format(formatLD,256,"Cars/%d_ownerauto.ini",i);
  169.             if(dini_Exists(formatLD))
  170.                 {
  171.                         new model,col1,col2,Float:x,Float:y,Float:z,Float:r;
  172.                         model=dini_Int(formatLD, "Model");
  173.                         col1=dini_Int(formatLD, "Col1");
  174.                         col2=dini_Int(formatLD, "Col2");
  175.                         x=dini_Float(formatLD, "SpawnX");
  176.                         y=dini_Float(formatLD, "SpawnY");
  177.                         z=dini_Float(formatLD, "SpawnZ");
  178.                         r=dini_Float(formatLD, "SpawnRot");
  179.                         new veh = CreateVehicle(model,x,y,z,r,col1,col2,-1);
  180.                         AutoData[veh][Model]=model;
  181.                         AutoData[veh][Col1]=col1;
  182.                         AutoData[veh][Col2]=col2;
  183.                         AutoData[veh][SpawnX]=x;
  184.                         AutoData[veh][SpawnY]=y;
  185.                         AutoData[veh][SpawnZ]=z;
  186.                         AutoData[veh][SpawnRot]=r;
  187.                         AutoData[veh][ID]= i;
  188.                         AutoData[veh][mod1] = dini_Int(formatLD, "mod1");
  189.                         AutoData[veh][mod2] = dini_Int(formatLD, "mod2");
  190.                         AutoData[veh][mod3] = dini_Int(formatLD, "mod3");
  191.                         AutoData[veh][mod4] = dini_Int(formatLD, "mod4");
  192.                         AutoData[veh][mod5] = dini_Int(formatLD, "mod5");
  193.                         AutoData[veh][mod6] = dini_Int(formatLD, "mod6");
  194.                         AutoData[veh][mod7] = dini_Int(formatLD, "mod7");
  195.                         AutoData[veh][mod8] = dini_Int(formatLD, "mod8");
  196.                         AutoData[veh][mod9] = dini_Int(formatLD, "mod9");
  197.                         AutoData[veh][mod10] = dini_Int(formatLD, "mod10");
  198.                         AutoData[veh][mod11] = dini_Int(formatLD, "mod11");
  199.                         AutoData[veh][mod12] = dini_Int(formatLD, "mod12");
  200.                         AutoData[veh][mod13] = dini_Int(formatLD, "mod13");
  201.                         AutoData[veh][mod14] = dini_Int(formatLD, "mod14");
  202.                         AutoData[veh][mod15] = dini_Int(formatLD, "mod15");
  203.                         AutoData[veh][mod16] = dini_Int(formatLD, "mod16");
  204.                         AutoData[veh][mod17] = dini_Int(formatLD, "mod17");
  205.                         AutoData[veh][VehSkin] = dini_Int(formatLD, "VehSkin");
  206.                         AddCarComponents(veh);
  207.                 }
  208.         }
  209. }
  210.  
  211. stock SaveVehicle(vehicleid) // Fertig
  212. {
  213.         new formatLD[256];
  214.         format(formatLD,256,"Cars/%d_ownerauto.ini",AutoData[vehicleid][ID]);
  215.         if(dini_Exists(formatLD))
  216.         {
  217.                 dini_IntSet(formatLD,"Model",AutoData[vehicleid][Model]);
  218.                 dini_IntSet(formatLD,"Col1",AutoData[vehicleid][Col1]);
  219.                 dini_IntSet(formatLD,"Col2",AutoData[vehicleid][Col2]);
  220.                 dini_FloatSet(formatLD,"SpawnX",AutoData[vehicleid][SpawnX]);
  221.                 dini_FloatSet(formatLD,"SpawnY",AutoData[vehicleid][SpawnY]);
  222.                 dini_FloatSet(formatLD,"SpawnZ",AutoData[vehicleid][SpawnZ]);
  223.                 dini_FloatSet(formatLD,"SpawnRot",AutoData[vehicleid][SpawnRot]);
  224.                 dini_IntSet(formatLD,"mod1",AutoData[vehicleid][mod1]);
  225.                 dini_IntSet(formatLD,"mod2",AutoData[vehicleid][mod2]);
  226.                 dini_IntSet(formatLD,"mod3",AutoData[vehicleid][mod3]);
  227.                 dini_IntSet(formatLD,"mod4",AutoData[vehicleid][mod4]);
  228.                 dini_IntSet(formatLD,"mod5",AutoData[vehicleid][mod5]);
  229.                 dini_IntSet(formatLD,"mod6",AutoData[vehicleid][mod6]);
  230.                 dini_IntSet(formatLD,"mod7",AutoData[vehicleid][mod8]);
  231.                 dini_IntSet(formatLD,"mod9",AutoData[vehicleid][mod9]);
  232.                 dini_IntSet(formatLD,"mod10",AutoData[vehicleid][mod10]);
  233.                 dini_IntSet(formatLD,"mod11",AutoData[vehicleid][mod11]);
  234.                 dini_IntSet(formatLD,"mod12",AutoData[vehicleid][mod12]);
  235.                 dini_IntSet(formatLD,"mod13",AutoData[vehicleid][mod13]);
  236.                 dini_IntSet(formatLD,"mod14",AutoData[vehicleid][mod14]);
  237.                 dini_IntSet(formatLD,"mod15",AutoData[vehicleid][mod15]);
  238.                 dini_IntSet(formatLD,"mod16",AutoData[vehicleid][mod16]);
  239.                 dini_IntSet(formatLD,"mod17",AutoData[vehicleid][mod17]);
  240.                 dini_IntSet(formatLD,"VehSkin",AutoData[vehicleid][VehSkin]);
  241.         }
  242.         else
  243.         {
  244.                 dini_Create(formatLD);
  245.                 SaveVehicle(vehicleid); // Wiederhole Befehl nachdem Datei erstellt
  246.         }
  247.         return 1;
  248.  
  249. }
  250. stock GetEmptyFile()
  251. {
  252.         new formatLD[256];
  253.         for(new id = 0; id<MAX_VEHICLES;id++)
  254.         {
  255.         format(formatLD,256,"Cars/%d_ownerauto.ini",id);
  256.             if(!fexist(formatLD))
  257.                 Emptyfile=id;
  258.         }
  259.     return 1;
  260. }
  261.  
  262. stock CreateNewVehicle(model,Float:x,Float:y,Float:z,Float:rot,col1,col2) // Fertig
  263. {
  264.         GetEmptyFile();
  265.         new tmpid = CreateVehicle(model,x,y,z,rot,col1,col2,-1);
  266.         new formatLD[256];
  267.         format(formatLD,256,"Cars/%d_ownerauto.ini",Emptyfile);
  268.         if(dini_Exists(formatLD)) return GetEmptyFile();
  269.         AutoData[tmpid][Model]=model;
  270.         AutoData[tmpid][ID] = Emptyfile;
  271.         AutoData[tmpid][Col1]=col1;
  272.         AutoData[tmpid][Col2]=col2;
  273.         AutoData[tmpid][SpawnX]=x;
  274.         AutoData[tmpid][SpawnY]=y;
  275.         AutoData[tmpid][SpawnZ]=z;
  276.         AutoData[tmpid][SpawnRot]=rot;
  277.         dini_Create(formatLD);
  278.         SaveVehicle(tmpid);
  279.         return tmpid;
  280.  
  281. }
  282.  
  283. stock AddCarComponents(vehicleid)
  284. {
  285.                 if(AutoData[vehicleid][mod1]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod1]);
  286.                 if(AutoData[vehicleid][mod2]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod2]);
  287.                 if(AutoData[vehicleid][mod3]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod3]);
  288.                 if(AutoData[vehicleid][mod4]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod4]);
  289.                 if(AutoData[vehicleid][mod5]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod5]);
  290.                 if(AutoData[vehicleid][mod6]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod6]);
  291.                 if(AutoData[vehicleid][mod7]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod7]);
  292.                 if(AutoData[vehicleid][mod8]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod8]);
  293.                 if(AutoData[vehicleid][mod9]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod9]);
  294.                 if(AutoData[vehicleid][mod10]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod10]);
  295.                 if(AutoData[vehicleid][mod11]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod11]);
  296.                 if(AutoData[vehicleid][mod12]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod12]);
  297.                 if(AutoData[vehicleid][mod13]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod13]);
  298.                 if(AutoData[vehicleid][mod14]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod14]);
  299.                 if(AutoData[vehicleid][mod15]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod15]);
  300.                 if(AutoData[vehicleid][mod16]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod16]);
  301.                 if(AutoData[vehicleid][mod17]!=0) AddVehicleComponent(vehicleid,AutoData[vehicleid][mod17]);
  302.                 if(AutoData[vehicleid][VehSkin]!=0)  ChangeVehiclePaintjob(vehicleid,AutoData[vehicleid][VehSkin]);
  303.                 return 1;
  304. }
  305.  
  306. stock FindSlotID(componentid)
  307. {
  308.         new i;
  309.         for(i=0; i<20; i++)if(spoiler[i]==componentid) return 1;
  310.         for(i=0; i<3; i++)if(nitro[i]==componentid) return 2;
  311.         for(i=0; i<23; i++)if(frontbumper[i]==componentid) return 3;
  312.         for(i=0; i<22; i++)if(rbumper[i]==componentid) return 4;
  313.         for(i=0; i<28; i++)if(exhaust[i]==componentid) return 5;
  314.         for(i=0; i<2; i++)if(bventr[i]==componentid) return 6;
  315.         for(i=0; i<2; i++)if(bventl[i]==componentid) return 7;
  316.         for(i=0; i<4; i++)if(bscoop[i]==componentid) return 8;
  317.         for(i=0; i<13; i++)if(rscoop[i]==componentid) return 9;
  318.         for(i=0; i<21; i++)if(lskirt[i]==componentid) return 10;
  319.         for(i=0; i<21; i++)if(rskirt[i]==componentid) return 11;
  320.         if(hydraulics==componentid) return 12;
  321.         if(base==componentid) return 13;
  322.         for(i=0; i<2; i++)if(rbbars[i]==componentid) return 14;
  323.         for(i=0; i<2; i++)if(fbbars[i]==componentid) return 15;
  324.         for(i=0; i<17; i++)if(wheels[i]==componentid) return 16;
  325.         return 0;
  326. }
Advertisement
Add Comment
Please, Sign In to add comment