AryanV

Test bla bla

Jul 18th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.03 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #include <zcmd>
  4. #include <streamer>
  5. #include <sscanf2>
  6. #define COLOR_BLUE 0x009AE5B0
  7. #define COLOR_YELLOW 0xFFFF00B4
  8. #define COLOR_RED 0xB40000B5
  9. #define MAX_OBJ 1000
  10. #define Path "Objects/%d.ini"
  11. new bool:ObjCreated[MAX_OBJ];
  12. new objectz[MAX_OBJ];
  13.  
  14. enum obinfo
  15.     {
  16.        model,
  17.        Float:posx,
  18.        Float:posy,
  19.        Float:posz,
  20.        Float:rotx,
  21.        Float:roty,
  22.        Float:rotz,
  23.  
  24.     };
  25.  
  26. new gobject[MAX_OBJ][obinfo];
  27.  
  28. forward LoadObjects(ob, name[], value[]);
  29. public LoadObjects(ob, name[], value[])
  30.     {
  31.         INI_Int("model",gobject[ob][model]);
  32.         INI_Float("posx",gobject[ob][posx]);
  33.         INI_Float("posy",gobject[ob][posy]);
  34.         INI_Float("posz",gobject[ob][posz]);
  35.         INI_Float("rotx",gobject[ob][rotx]);
  36.         INI_Float("roty",gobject[ob][roty]);
  37.         INI_Float("rotz",gobject[ob][rotz]);
  38.         return 1;
  39.     }
  40.  
  41. stock SavePath(i)
  42.     {
  43.      new str[128];
  44.      format(str, sizeof(str),Path,i);
  45.      return str;
  46.     }
  47.  
  48. forward SaveFile(objectid);
  49. public SaveFile(objectid)
  50.     {
  51.         new INI:file = INI_Open(SavePath(objectid));
  52.         INI_SetTag(file,"Values and Data");
  53.         INI_WriteInt(file,"model",gobject[objectid][model]);
  54.         INI_WriteFloat(file,"posx",gobject[objectid][posx]);
  55.         INI_WriteFloat(file,"posy",gobject[objectid][posy]);
  56.         INI_WriteFloat(file,"posz",gobject[objectid][posz]);
  57.         INI_WriteFloat(file,"rotx",gobject[objectid][rotx]);
  58.         INI_WriteFloat(file,"roty",gobject[objectid][roty]);
  59.         INI_WriteFloat(file,"rotz",gobject[objectid][rotz]);
  60.         INI_Close(file);
  61.         return 1;
  62.     }
  63.  
  64.  
  65. forward LoadAll();
  66. public LoadAll()
  67.     {
  68.  
  69.         for(new i=0;i<MAX_OBJ;i++)
  70.         {
  71.  
  72.             if(fexist(SavePath(i)))
  73.                 {  
  74.                     INI_ParseFile(SavePath(i),"LoadObjects",.bExtra = true, .extra = i);
  75.                     objectz[i]=CreateDynamicObject(gobject[i][model],gobject[i][posx],gobject[i][posy],gobject[i][posz],gobject[i][rotx],gobject[i][roty],gobject[i][rotz]);
  76.                     ObjCreated[i]=true;
  77.                     printf("Loaded %d",i);
  78.                 }
  79.                 else
  80.             {
  81.                 break;
  82.             }
  83.         }
  84.         return 1;
  85.     }
  86.  
  87.  
  88. public OnFilterScriptInit()
  89.     {
  90.         print(" Object Editor By Rage Loaded!");
  91.         LoadAll();
  92.        
  93.         return 1;
  94.     }
  95.  
  96. public OnFilterScriptExit()
  97.     {
  98.             print(" Object Editor By Rage UNLoaded!");
  99.             for(new i=0;i<MAX_OBJ;i++)
  100.             {
  101.              if(ObjCreated[i]==true)
  102.                 {  
  103.                     SaveFile(i);
  104.                    
  105.                 }
  106.                      
  107.             }
  108.             return 1;
  109.     }
  110.  
  111. CMD:createobject(playerid,params[])
  112.     {
  113.         new modelid;
  114.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
  115.         if(sscanf(params, "i" ,modelid)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /createobject <Model ID>");
  116.         new Float:x,Float:y,Float:z;
  117.         GetPlayerPos(playerid,x,y,z);
  118.         for(new i=0; i<MAX_OBJ;i++)
  119.         {
  120.             if(!ObjCreated[i])
  121.             {
  122.                 objectz[i]=CreateDynamicObject(modelid,x+2,y,z,0,0,0);
  123.                 new str[128];
  124.                 format(str,sizeof(str),"You have created a object(ID:%d) with Model ID:%d",i,modelid);
  125.                 SendClientMessage(playerid, COLOR_BLUE,str);
  126.                 new Float:x1,Float:y1,Float:z1;
  127.                 GetObjectPos(objectz[i],x1,y1,z1);
  128.                 new Float:x2,Float:y2,Float:z2;
  129.                 GetObjectRot(objectz[i],x2,y2,z2);
  130.                 ObjCreated[i]=true;
  131.                 gobject[i][model]=modelid;
  132.                 gobject[i][posx]=x1;
  133.                 gobject[i][posy]=y1;
  134.                 gobject[i][posz]=z1;
  135.                 gobject[i][rotx]=x2;
  136.                 gobject[i][roty]=y2;
  137.                 gobject[i][rotz]=z2;
  138.                 new INI:file = INI_Open(SavePath(i));
  139.                 INI_SetTag(file,"Values and Data");
  140.                 INI_WriteInt(file,"model",gobject[i][model]);
  141.                 INI_WriteFloat(file,"posx",gobject[i][posx]);
  142.                 INI_WriteFloat(file,"posy",gobject[i][posy]);
  143.                 INI_WriteFloat(file,"posz",gobject[i][posz]);
  144.                 INI_WriteFloat(file,"rotx",gobject[i][rotx]);
  145.                 INI_WriteFloat(file,"roty",gobject[i][roty]);
  146.                 INI_WriteFloat(file,"rotz",gobject[i][rotz]);
  147.                 INI_Close(file);
  148.                 break;
  149.             }
  150.         }
  151.         return 1;
  152.     }
  153.  
  154. CMD:editobject(playerid,params[])
  155.     {
  156.         new id;
  157.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
  158.         if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /editobject <ID>");
  159.         if(!IsValidDynamicObject(objectz[id])) return SendClientMessage(playerid, COLOR_RED,"Failed: That Object ID does not exist");
  160.         EditDynamicObject(playerid, objectz[id]);
  161.         new str[128];
  162.         format(str,sizeof(str),"Success: You are editing object ID: %d",id);
  163.         SendClientMessage(playerid, COLOR_YELLOW,str);
  164.         return 1;
  165.     }
  166.  
  167. CMD:destroyobject(playerid,params[])
  168.     {
  169.         new id;
  170.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
  171.         if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /destroyobject <ID>");
  172.         if(!IsValidDynamicObject(objectz[id])) return SendClientMessage(playerid, COLOR_RED,"Failed: That Object ID does not exist");
  173.         DestroyDynamicObject(objectz[id]);
  174.         new str[128];
  175.         format(str,sizeof(str),"Success: You have deleted object ID:%d",id);
  176.         SendClientMessage(playerid, COLOR_RED,str);
  177.         ObjCreated[id]=false;
  178.         return 1;
  179.     }
Add Comment
Please, Sign In to add comment