Advertisement
leong124

mta0.3c.pwn

Aug 26th, 2011
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.46 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <sscanf2>//Credits for sscanf goes to Y_Less
  5.  
  6. public OnFilterScriptInit()
  7. {
  8.     print("\n-------------------------------------------------");
  9.     print(" MTA:SA map converter for SA:MP 0.3c by leong124");
  10.     print("-------------------------------------------------\n");
  11.     if(!fexist("source.map")) return print("Error: source.map does not found.");
  12.     new File:source = fopen("source.map",io_read);
  13.     new File:output = fopen("output.txt",io_write);
  14.     new string[384],tmp[384];
  15.     new objid,Float:px,Float:py,Float:pz,Float:rx,Float:ry,Float:rz;
  16.     new paintjob,i = 0,k = 0,j = 1;
  17.     new modelstr[32],pjstr[32],npstr[2][32],intstr[32],pxstr[32],pystr[32],pzstr[32],rxstr[32],rystr[32],rzstr[32];
  18.     while(fread(source,string,sizeof(string)))
  19.     {
  20.         if(!sscanf(string,"'<object's[384]",tmp))
  21.         {
  22.             if(!sscanf(string,"'doublesided=\"false\"'s[32]{s[32]s[32]}s[32]s[32]s[32]s[32]s[32]s[32] ",modelstr,pxstr,pystr,pzstr,rxstr,rystr,rzstr) && !sscanf(modelstr,"p<\">{s[32]}d",objid) && !sscanf(pxstr,"p<\">{s[32]}f",px) && !sscanf(pystr,"p<\">{s[32]}f",py) && !sscanf(pzstr,"p<\">{s[32]}f",pz) && !sscanf(rxstr,"p<\">{s[32]}f",rx) && !sscanf(rystr,"p<\">{s[32]}f",ry) && !sscanf(rzstr,"p<\">{s[32]}f",rz))
  23.             {
  24.                 switch(objid)
  25.                 {
  26.                     case 14383..14483: objid += 4248;
  27.                     case 14770..14856: objid += 4063;
  28.                     case 14858..14871: objid += 4062;
  29.                     case 18000..18036: objid += 934;
  30.                     case 18038..18101: objid += 933;
  31.                     case 14872..14883: objid += 4163;
  32.                     case 14885..14891: objid += 4162;
  33.                     case 13590..13667: objid += 5142;
  34.                     case 14500..14522: objid += 4310;
  35.                     case 12835..12944: objid += 6219;
  36.                     case 16000..16143: objid += 3164;
  37.                     case 14892: objid += 5009;
  38.                 }
  39.                 format(string,sizeof(string),"CreateObject(%d, %f, %f, %f, %f, %f, %f, 300);\r\n",objid,px,py,pz,rx,ry,rz);
  40.                 fwrite(output,string);
  41.                 k++;
  42.             }
  43.             else printf("Error: Incorrect object format at line %d.",j);
  44.         }
  45.         else if(!sscanf(string,"'<vehicle's[384]",tmp))
  46.         {
  47.             if(!sscanf(string,"{s[32]s[32]s[32]s[32]}s[32]s[32]s[32]s[32]s[32]{s[32]}s[32]s[32]s[32]{s[32]s[32]}s[32] ",pjstr,modelstr,npstr[0],npstr[1],intstr,pxstr,pystr,pzstr,rzstr) && !sscanf(pjstr,"p<\">{s[32]}d",paintjob) && !sscanf(modelstr,"p<\">{s[32]}d",objid))
  48.             {
  49.                 if(strcmp(npstr[1],"interior",true,8))
  50.                 {
  51.                     sscanf(npstr[0],"p<\">{s[32]}s[32]",npstr[0]);
  52.                     sscanf(npstr[1],"p<\">s[32] ",npstr[1]);
  53.                     strcat(npstr[0],npstr[1]);
  54.                 }
  55.                 else sscanf(npstr[0],"p<\">{s[32]}s[32] ",npstr[0]);
  56.                 sscanf(pxstr,"p<\">{s[32]}f",px);
  57.                 sscanf(pystr,"p<\">{s[32]}f",py);
  58.                 sscanf(pzstr,"p<\">{s[32]}f",pz);
  59.                 sscanf(rzstr,"p<\">{s[32]}f",rz);
  60.                 format(string,sizeof(string),"vehicle%d = AddStaticVehicle(%d, %f, %f, %f, %f, %d, %d);\r\n",i,objid,px,py,pz,rz,random(128),random(128));
  61.                 fwrite(output,string);
  62.                 format(string,sizeof(string),"ChangeVehiclePaintjob(vehicle%d, %d);\r\n",i,paintjob);
  63.                 fwrite(output,string);
  64.                 format(string,sizeof(string),"SetVehicleNumberPlate(vehicle%d, \"%s\");\r\n",i,npstr[0]);
  65.                 fwrite(output,string);
  66.                 i++;
  67.             }
  68.             else printf("Error: Incorrect vehicle format at line %d.",j);
  69.         }
  70.         j++;
  71.     }
  72.     if(i)
  73.     {
  74.         fwrite(output,"\r\n//Put these on the top of your script:\r\n");
  75.         for(j = 0;j < i;j++)
  76.         {
  77.             format(string,sizeof(string),"new vehicle%d;\r\n",j);
  78.             fwrite(output,string);
  79.         }
  80.     }
  81.     fclose(source);
  82.     fclose(output);
  83.     printf("%d objects converted, %d vehicles converted.",k,i);
  84.     return 1;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement