AryanV

I hate yini

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