Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <sscanf2>//Credits for sscanf goes to Y_Less
- public OnFilterScriptInit()
- {
- print("\n-------------------------------------------------");
- print(" MTA:SA map converter for SA:MP 0.3c by leong124");
- print("-------------------------------------------------\n");
- if(!fexist("source.map")) return print("Error: source.map does not found.");
- new File:source = fopen("source.map",io_read);
- new File:output = fopen("output.txt",io_write);
- new string[384],tmp[384];
- new objid,Float:px,Float:py,Float:pz,Float:rx,Float:ry,Float:rz;
- new paintjob,i = 0,k = 0,j = 1;
- new modelstr[32],pjstr[32],npstr[2][32],intstr[32],pxstr[32],pystr[32],pzstr[32],rxstr[32],rystr[32],rzstr[32];
- while(fread(source,string,sizeof(string)))
- {
- if(!sscanf(string,"'<object's[384]",tmp))
- {
- 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))
- {
- switch(objid)
- {
- case 14383..14483: objid += 4248;
- case 14770..14856: objid += 4063;
- case 14858..14871: objid += 4062;
- case 18000..18036: objid += 934;
- case 18038..18101: objid += 933;
- case 14872..14883: objid += 4163;
- case 14885..14891: objid += 4162;
- case 13590..13667: objid += 5142;
- case 14500..14522: objid += 4310;
- case 12835..12944: objid += 6219;
- case 16000..16143: objid += 3164;
- case 14892: objid += 5009;
- }
- format(string,sizeof(string),"CreateObject(%d, %f, %f, %f, %f, %f, %f, 300);\r\n",objid,px,py,pz,rx,ry,rz);
- fwrite(output,string);
- k++;
- }
- else printf("Error: Incorrect object format at line %d.",j);
- }
- else if(!sscanf(string,"'<vehicle's[384]",tmp))
- {
- 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))
- {
- if(strcmp(npstr[1],"interior",true,8))
- {
- sscanf(npstr[0],"p<\">{s[32]}s[32]",npstr[0]);
- sscanf(npstr[1],"p<\">s[32] ",npstr[1]);
- strcat(npstr[0],npstr[1]);
- }
- else sscanf(npstr[0],"p<\">{s[32]}s[32] ",npstr[0]);
- sscanf(pxstr,"p<\">{s[32]}f",px);
- sscanf(pystr,"p<\">{s[32]}f",py);
- sscanf(pzstr,"p<\">{s[32]}f",pz);
- sscanf(rzstr,"p<\">{s[32]}f",rz);
- 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));
- fwrite(output,string);
- format(string,sizeof(string),"ChangeVehiclePaintjob(vehicle%d, %d);\r\n",i,paintjob);
- fwrite(output,string);
- format(string,sizeof(string),"SetVehicleNumberPlate(vehicle%d, \"%s\");\r\n",i,npstr[0]);
- fwrite(output,string);
- i++;
- }
- else printf("Error: Incorrect vehicle format at line %d.",j);
- }
- j++;
- }
- if(i)
- {
- fwrite(output,"\r\n//Put these on the top of your script:\r\n");
- for(j = 0;j < i;j++)
- {
- format(string,sizeof(string),"new vehicle%d;\r\n",j);
- fwrite(output,string);
- }
- }
- fclose(source);
- fclose(output);
- printf("%d objects converted, %d vehicles converted.",k,i);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement