AryanV

Hate it

Jul 18th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.16 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.    model,
  16.    Float:posx,
  17.    Float:posy,
  18.    Float:posz,
  19.    Float:rotx,
  20.    Float:roty,
  21.    Float:rotz,
  22.  
  23. };
  24.  
  25. new gobject[MAX_OBJ][obinfo];
  26.  
  27. public OnFilterScriptInit()
  28. {
  29.     print(" Object Editor By Rage Loaded!");
  30.     for(new i=0;i<MAX_OBJ;i++){
  31.       if(fexist(SavePath(i))){  
  32.       INI_ParseFile(SavePath(i),"LoadObjects",.bExtra = true, .extra = i);
  33.       objectz[i]=CreateObject(gobject[i][model],gobject[i][posx],gobject[i][posy],gobject[i][posz],gobject[i][rotx],gobject[i][roty],gobject[i][rotz],300);
  34.       ObjCreated[i]=true;
  35.       printf("Loaded %d",i);
  36.       }
  37.       else
  38.       {
  39.       break;
  40.       }
  41.     }
  42.    
  43.     return 1;
  44. }
  45.  
  46. public OnFilterScriptExit()
  47. {
  48.   print(" Object Editor By Rage UNLoaded!");
  49.   for(new i=0;i<MAX_OBJ;i++){
  50.   SaveFile(i);
  51.  
  52.   }
  53.     return 1;
  54. }
  55.  
  56. CMD:createobject(playerid,params[]){
  57. new modelid;
  58. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
  59. if(sscanf(params, "i" ,modelid)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /createobject <Model ID>");
  60. new Float:x,Float:y,Float:z;
  61. GetPlayerPos(playerid,x,y,z);
  62. for(new i=0; i<MAX_OBJ;i++){
  63. if(!ObjCreated[i]){
  64. objectz[i]=CreateDynamicObject(modelid,x+2,y,z,0,0,0);
  65. new str[128];
  66. format(str,sizeof(str),"You have created a object(ID:%d) with Model ID:%d",i,modelid);
  67. SendClientMessage(playerid, COLOR_BLUE,str);
  68. new Float:x1,Float:y1,Float:z1;
  69. GetObjectPos(objectz[i],x1,y1,z1);
  70. new Float:x2,Float:y2,Float:z2;
  71. GetObjectRot(objectz[i],x2,y2,z2);
  72. ObjCreated[i]=true;
  73. gobject[i][model]=modelid;
  74. gobject[i][posx]=x1;
  75. gobject[i][posy]=y1;
  76. gobject[i][posz]=z1;
  77. gobject[i][rotx]=x2;
  78. gobject[i][roty]=y2;
  79. gobject[i][rotz]=z2;
  80. SaveFile(i);
  81.     break;
  82. }
  83. }
  84. return 1;
  85. }
  86.  
  87. CMD:editobject(playerid,params[]){
  88. new id;
  89. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
  90. if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /editobject <ID>");
  91. if(!IsValidDynamicObject(objectz[id])) return SendClientMessage(playerid, COLOR_RED,"Failed: That Object ID does not exist");
  92. EditDynamicObject(playerid, objectz[id]);
  93. new str[128];
  94. format(str,sizeof(str),"Success: You are editing object ID: %d",id);
  95. SendClientMessage(playerid, COLOR_YELLOW,str);
  96. return 1;
  97. }
  98.  
  99. CMD:destroyobject(playerid,params[]){
  100. new id;
  101. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
  102. if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /destroyobject <ID>");
  103. if(!IsValidDynamicObject(objectz[id])) return SendClientMessage(playerid, COLOR_RED,"Failed: That Object ID does not exist");
  104. DestroyDynamicObject(objectz[id]);
  105. new str[128];
  106. format(str,sizeof(str),"Success: You have deleted object ID:%d",id);
  107. SendClientMessage(playerid, COLOR_RED,str);
  108. ObjCreated[id]=false;
  109. return 1;
  110. }
  111. forward LoadObjects(i, name[], value[]);
  112. public LoadObjects(i, name[], value[]){
  113.  
  114. INI_Int("model",gobject[i][model]);
  115. INI_Float("posx",gobject[i][posx]);
  116. INI_Float("posy",gobject[i][posy]);
  117. INI_Float("posz",gobject[i][posz]);
  118. INI_Float("rotx",gobject[i][rotx]);
  119. INI_Float("roty",gobject[i][roty]);
  120. INI_Float("rotz",gobject[i][rotz]);
  121.  
  122. return 1;
  123. }
  124.  
  125. SavePath(objectid){
  126.  new str[10];
  127.  format(str, sizeof(str),Path,objectid);
  128.  return str;
  129. }
  130.  
  131. forward SaveFile(objectid);
  132. public SaveFile(objectid){
  133.  new INI:file=INI_Open(SavePath(objectid));
  134.  INI_WriteInt(file,"model",gobject[objectid][model]);
  135. INI_WriteFloat(file,"posx",gobject[objectid][posx]);
  136. INI_WriteFloat(file,"posy",gobject[objectid][posy]);
  137. INI_WriteFloat(file,"posz",gobject[objectid][posz]);
  138. INI_WriteFloat(file,"rotx",gobject[objectid][rotx]);
  139. INI_WriteFloat(file,"roty",gobject[objectid][roty]);
  140. INI_WriteFloat(file,"rotz",gobject[objectid][rotz]);
  141. INI_Close(file);
  142. return 1;
  143. }
Add Comment
Please, Sign In to add comment