Convert SA:MP to MTA
#1

Good afternoon. I have a question:
Is it possible to from this code (for example):
Код HTML:
RemoveBuildingForPlayer(playerid, 689, -1682.7500, -2939.0701, 16.6610, 0.25);
Do this:
Код HTML:
<removeWorldObject id="removeWorldObject (sm_fir_copse1) (25)" radius="97.231597900391" interior="0" model="689" lodModel="785" posX="785.349" posY="-2352.16992" posZ="37.249" rotX="0" rotY="0" rotZ="0"></removeWorldObject>
??
Reply
#2

I could write a script for you to convert it. It's possible, but there's not a script out there yet.
Reply
#3

Actually, it isn't that hard to do, you might use sscanf and it would be pretty handy to do.
Reply
#4

I would gladly do so, if I knew how.
Reply
#5

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Actually, it isn't that hard to do, you might use sscanf and it would be pretty handy to do.
Actually, I know it may be going out of date, but strcmp is what I would use alongside fread (file read). It would be a lot of script for something so simple. I would likely use a few loops.
Reply
#6

Might some warnings but I think it works, I don't know if it's well written aswell.
Give me the credits for it:
http://pastebin.com/nu9SYhZh
Reply
#7

And how to use it?
Reply
#8

Just add the RemoveBuildingForPlayer code in somefile.txt in your scriptfiles folder.

PHP код:

#include <a_samp>
#include <sscanf2>
main()
{
    
ConvertF("somefile.txt");
}
public 
OnGameModeInit()
{
    return 
1;
}
#define MAX_OBJECTS_TO_REMOVE   500
enum obInfo
{
        
Model,
        
Float:X,
        
Float:Y,
        
Float:Z,
        
Float:Radius,
}
new 
ObjectInfo[MAX_OBJECTS_TO_REMOVE][obInfo];
forward ConvertF(const file[]);
public 
ConvertF(const file[])
{
    new 
File:openfile fopen(file,io_read);
    if(!
openfile) return printf("File %s was not found. Please make sure you have placed it on your ScriptFiles folder."file);
    new 
File:newfile fopen("WorldObject.txt",io_write);
    new 
string[600], lodsobjectsobjectkk[50];
    while(
fread(openfilestring))
    {
        if(
object >= sizeof(ObjectInfo)) break;
        if(!
sscanf(string"P<(),>{s[2]}'playerid'dffff"ObjectInfo[object][Model],ObjectInfo[object][X],ObjectInfo[object][Y],ObjectInfo[object][Z], ObjectInfo[object][Radius]))
        {
            
format(string,sizeof(string),"\t<removeWorldObject id=\"removeWorldObject (sm_fir_copse1) (25)\" radius=\"%f\" interior=\"0\" model=\"%d\" lodModel=\"%d\" posX=\"%f\" posY=\"%f\" posZ=\"%f\" rotX=\"0\" rotY=\"0\" rotZ=\"0\"></removeWorldObject>\r\n",ObjectInfo[object][Radius], ObjectInfo[object][Model], ObjectInfo[object][Model], ObjectInfo[object][X],ObjectInfo[object][Y],ObjectInfo[object][Z]);
            
fwrite(newfile,string);
            
object++;
        }
    }
    
fwrite(newfile,"a");
    
fclose(openfile);
    
fclose(newfile);
    
printf("Code exported to WorldObject.txt. Objects converted: %d"object);
    return 
object;

Compile the above code and run it as a gamemode. The code wll be exported to WorldObject.txt
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)