Guest User

GarObject 1.3

a guest
May 20th, 2012
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.62 KB | None | 0 0
  1. //==============================================================================
  2. // GarObject v1.3 by [03]Garsino!
  3. //==============================================================================
  4. // - Credits to DracoBlue for dini, dcmd and dudb.
  5. // - Credits to Y_Less for sscanf2.
  6. // - Thanks to everyone who gave me ideas for this object editing system (Admins on Garsino's Funserver).
  7. // - Thanks to everyone who helped me find bugs.
  8. //==============================================================================
  9. // Changelog
  10. //==============================================================================
  11. // - [Fixed] Fixed problem with editing objects after loading them from a file.
  12. // - [Added] Added /startobjectloop - it will move your object from point (A) to point (B). When arrived at point (B) it will go back to point (A) like a loop.
  13. // - [Added] Added /startallobjectloop - it will move all your objects from point (A) to point (B). When arrived at point (B) they will go back to point (A) like a loop.
  14. // - [Added] Added /sol - shortcut command for /startobjectloop.
  15. // - [Added] Added /sallol - shortcut command for /startallobjectloop.
  16. // - [Added] Added /stopobjectloop - it will stop the current ongoing object loop for your object.
  17. // - [Added] Added /stopallobjectloop - it will stop the current ongoing object loop for all your objects.
  18. // - [Added] Added /stopol - shortcut command for /stopobjectloop.
  19. // - [Added] Added /stopallol - shortcut command for /stopallobjectloop.
  20. // - [Added] Added /getmypos (only works if you have defined GO_DEBUG_CMDS).
  21. //==============================================================================
  22. // Includes
  23. //==============================================================================
  24. #include <a_samp> // Credits to the SA:MP Developement Team
  25. #include <sscanf2> // Credits to Y_Less
  26. //==============================================================================
  27. // Configuration
  28. //==============================================================================
  29. #undef MAX_PLAYERS
  30. #define MAX_PLAYERS 500 // Change it to the amount of server slots!!
  31. //#define G_OBJ_AUTOSAVE // Uncomment to enable autosave of objects on disconnect/filterscript exit. Objects will be saved in <PlayerName>.txt
  32. #define G_OBJ_USE_SHORTCUTS // Unomment to enable command shortcuts.
  33. //#define GO_DEBUG_CMDS // Uncomment to enable debug commands like /getmypos.
  34. #define GOBJ_MAX_OBJECTS_CREATED 400 // Max objects an admin can create (Remember the limit is 400 in SA:MP 0.3b/0.3c...)
  35. #define G_OBJ_DID 12357
  36. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  37. #define Loop(%0,%1) for(new %0 = 0; %0 < %1; %0++)
  38. new Objects[MAX_PLAYERS][GOBJ_MAX_OBJECTS_CREATED], ObjectCreator[MAX_OBJECTS];
  39. new Float:oOffset[MAX_OBJECTS][3], Float:oRot[MAX_OBJECTS][3], Float:oPos[MAX_OBJECTS][3], ModelID[MAX_OBJECTS];
  40. new Float:oStart[MAX_OBJECTS][3], Float:oEnd[MAX_OBJECTS][3], oMoving[MAX_OBJECTS], oLap[MAX_OBJECTS], Float:oMSpeed[MAX_OBJECTS];
  41. new AttachedVehicle[MAX_OBJECTS], AttachedPlayer[MAX_OBJECTS];
  42. new Float:X, Float:Y, Float:Z;
  43. //==============================================================================
  44. // Colours
  45. //==============================================================================
  46. #define COLOUR_INFO 0x00FFFFFF
  47. #define COLOUR_SYSTEM 0xB60000FF
  48. //==============================================================================
  49. // Awesomeness
  50. //==============================================================================
  51. public OnFilterScriptInit()
  52. {
  53. Loop(obj, MAX_OBJECTS)
  54. {
  55. ObjectCreator[obj] = INVALID_PLAYER_ID;
  56. ModelID[obj] = -1;
  57. }
  58. Loop(i, MAX_PLAYERS)
  59. {
  60. Loop(o, GOBJ_MAX_OBJECTS_CREATED)
  61. {
  62. Objects[i][o] = INVALID_OBJECT_ID;
  63. }
  64. }
  65. print("\n>> GarObject v1.3 By [03]Garsino Loaded <<\n");
  66. return 1;
  67. }
  68. public OnFilterScriptExit()
  69. {
  70. #if defined G_OBJ_AUTOSAVE
  71. new filename[MAX_PLAYER_NAME+4];
  72. Loop(i, MAX_PLAYERS)
  73. {
  74. if(!IsPlayerAdmin(i) || !IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
  75. format(filename, sizeof(filename), "%s.txt", pNick(i));
  76. SaveObjectsToFile(i, filename, 0);
  77. SaveHObjectsToFile(i, filename, 0);
  78. }
  79. #endif
  80. Loop(obj, MAX_OBJECTS)
  81. {
  82. if(ObjectCreator[obj] != INVALID_PLAYER_ID && ModelID[obj] != -1)
  83. {
  84. DestroyObject(obj);
  85. ModelID[obj] = -1;
  86. }
  87. }
  88. print("\n>> GarObject v1.3 By [03]Garsino Unloaded <<\n");
  89. return 1;
  90. }
  91. public OnPlayerConnect(playerid)
  92. {
  93. Loop(o, GOBJ_MAX_OBJECTS_CREATED)
  94. {
  95. Objects[playerid][o] = INVALID_OBJECT_ID;
  96. }
  97. return 1;
  98. }
  99. public OnPlayerDisconnect(playerid, reason)
  100. {
  101. #if defined G_OBJ_AUTOSAVE
  102. if(IsPlayerAdmin(playerid))
  103. {
  104. new filename[MAX_PLAYER_NAME+4];
  105. format(filename, sizeof(filename), "%s.txt", pNick(playerid));
  106. SaveObjectsToFile(playerid, filename, 0);
  107. SaveHObjectsToFile(playerid, filename, 0);
  108. }
  109. #endif
  110. Loop(o, MAX_OBJECTS)
  111. {
  112. if(ObjectCreator[o] == playerid)
  113. {
  114. if(ModelID[o] != -1)
  115. {
  116. DestroyObject(o);
  117. ModelID[o] = -1;
  118. }
  119. ObjectCreator[o] = INVALID_PLAYER_ID;
  120. }
  121. }
  122. Loop(o2, GOBJ_MAX_OBJECTS_CREATED)
  123. {
  124. Objects[playerid][o2] = INVALID_OBJECT_ID;
  125. }
  126. return 1;
  127. }
  128. public OnPlayerCommandText(playerid, cmdtext[])
  129. {
  130. dcmd(stopallobjectloop, 17, cmdtext);
  131. dcmd(stopobjectloop, 14, cmdtext);
  132. dcmd(startallobjectloop, 18, cmdtext);
  133. dcmd(startobjectloop, 15, cmdtext);
  134. dcmd(createobject, 12, cmdtext);
  135. dcmd(rotateobject, 12, cmdtext);
  136. dcmd(attachpobject, 13, cmdtext);
  137. dcmd(deattachpobject, 15, cmdtext);
  138. dcmd(attachvobject, 13, cmdtext);
  139. dcmd(deattachvobject, 15, cmdtext);
  140. dcmd(rotateallobject, 15, cmdtext);
  141. dcmd(destroyobject, 13, cmdtext);
  142. dcmd(destroyallobject, 16, cmdtext);
  143. dcmd(stopobject, 10, cmdtext);
  144. dcmd(stopallobject, 13, cmdtext);
  145. dcmd(moveobject, 10, cmdtext);
  146. dcmd(moveallobject, 13, cmdtext);
  147. dcmd(getobject, 9, cmdtext);
  148. dcmd(getallobject, 12, cmdtext);
  149. dcmd(objecttele, 10, cmdtext);
  150. dcmd(sethobj, 7, cmdtext);
  151. dcmd(stophobj, 8, cmdtext);
  152. dcmd(stopallhobj, 11, cmdtext);
  153. dcmd(saveobject, 10, cmdtext);
  154. dcmd(loadobject, 10, cmdtext);
  155. dcmd(savehobject, 11, cmdtext);
  156. dcmd(loadhobject, 11, cmdtext);
  157. dcmd(copyobject, 10, cmdtext);
  158. dcmd(garobject, 9, cmdtext);
  159. #if defined G_OBJ_USE_SHORTCUTS
  160. dcmd(oc, 2, cmdtext); // /createobject
  161. dcmd(or, 2, cmdtext); // /rotateobject
  162. dcmd(apo, 3, cmdtext); // /attachpobject
  163. dcmd(deapo, 5, cmdtext); // /deattachpobject
  164. dcmd(avo, 3, cmdtext); // /attachvobject
  165. dcmd(deavo, 5, cmdtext); // /deattachvobject
  166. dcmd(orall, 5, cmdtext); // /rotateallobject
  167. dcmd(od, 2, cmdtext); // /destroyobject
  168. dcmd(odall, 5, cmdtext); // /destroyallobject
  169. dcmd(os, 2, cmdtext); // /stopobject
  170. dcmd(osall, 5, cmdtext); // /stopallobject
  171. dcmd(om, 2, cmdtext); // /moveobject
  172. dcmd(omall, 5, cmdtext); // /moveallobject
  173. dcmd(og, 2, cmdtext); // /getobject
  174. dcmd(ogall, 5, cmdtext); // /getallobject
  175. dcmd(ot, 2, cmdtext); // /objecttele
  176. dcmd(setho, 5, cmdtext); // /sethobj
  177. dcmd(stopho, 6, cmdtext); // /stophobj
  178. dcmd(stopallho, 9, cmdtext); // /stopallhobj
  179. dcmd(so, 2, cmdtext); // /saveobject
  180. dcmd(lo, 2, cmdtext); // /loadobject
  181. dcmd(sho, 3, cmdtext); // /savehobject
  182. dcmd(lho, 3, cmdtext); // /loadhobject
  183. dcmd(co, 2, cmdtext); // /copyobject
  184. dcmd(sallol, 6, cmdtext); // /startallobjectloop
  185. dcmd(sol, 3, cmdtext); // /startobjectloop
  186. dcmd(stopallol, 6, cmdtext); // /stopallobjectloop
  187. dcmd(stopol, 3, cmdtext); // /stopobjectloop
  188. dcmd(gobj, 4, cmdtext); // /garobject
  189. #endif
  190. #if defined GO_DEBUG_CMDS
  191. dcmd(getmypos, 8, cmdtext);
  192. #endif
  193. return 0;
  194. }
  195. dcmd_createobject(playerid, params[])
  196. {
  197. if(IsPlayerAdmin(playerid))
  198. {
  199. new modelid, Float:rX, Float:rY, Float:rZ, string[128], objid = GetFreeObjectID(playerid);
  200. if(sscanf(params, "dF(0)F(0)F(0)", modelid, rX, rY, rZ)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /createobject (object id) (rotX) (rotY) (rotZ)");
  201. if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT && !IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "You need to spawn to be able to use this command.");
  202. if(GetTotalNativeObjects() >= (MAX_OBJECTS-1)) return SendClientMessage(playerid, COLOUR_SYSTEM, "The SA:MP object limit has been reached. You can not spawn any more objects.");
  203. if(objid < 0) return SendClientMessage(playerid, COLOUR_SYSTEM, "You can not spawn any more objects. Please delete one of the current ones first.");
  204. else
  205. {
  206. GetPlayerPos(playerid, X, Y, Z);
  207. Objects[playerid][objid] = CreateObject(modelid, X, Y, Z, rX, rY, rZ);
  208. new o = Objects[playerid][objid];
  209. ModelID[o] = modelid;
  210. ObjectCreator[o] = playerid;
  211. oPos[o][0] = X, oPos[o][1] = Y, oPos[o][2] = Z;
  212. oRot[o][0] = rX, oRot[o][1] = rY, oRot[o][2] = rZ;
  213. AttachedVehicle[o] = INVALID_VEHICLE_ID, AttachedPlayer[o] = INVALID_PLAYER_ID;
  214. format(string, sizeof(string), "Object ID %d created. Modelid: %d. Rotation: X: %0.2f | Y: %0.2f | Z: %0.2f.", objid, modelid, rX, rY, rZ);
  215. SendClientMessage(playerid, COLOUR_INFO, string);
  216. }
  217. return 1;
  218. }
  219. else return 0;
  220. }
  221. dcmd_copyobject(playerid, params[])
  222. {
  223. if(IsPlayerAdmin(playerid))
  224. {
  225. new string[128], objectid, objid = GetFreeObjectID(playerid);
  226. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /copyobject (objectid)");
  227. if(GetTotalNativeObjects() >= (MAX_OBJECTS-1)) return SendClientMessage(playerid, COLOUR_SYSTEM, "The SA:MP object limit has been reached. You can not spawn any more objects.");
  228. if(objid < 0) return SendClientMessage(playerid, COLOUR_SYSTEM, "You can not spawn any more objects. Please delete one of the current ones first.");
  229. else
  230. {
  231. new o2 = Objects[playerid][objectid];
  232. Objects[playerid][objid] = CreateObject(ModelID[o2], oPos[o2][0], oPos[o2][1], oPos[o2][2], oRot[o2][0], oRot[o2][1], oRot[o2][2]);
  233. new o = Objects[playerid][objid];
  234. ModelID[o] = ModelID[o2];
  235. ObjectCreator[o] = playerid;
  236. oPos[o][0] = oPos[o2][0], oPos[o][1] = oPos[o2][1], oPos[o][2] = oPos[o2][2];
  237. oRot[o][0] = oRot[o2][0], oRot[o][1] = oRot[o2][1], oRot[o][2] = oRot[o2][2];
  238. AttachedVehicle[o] = AttachedVehicle[o2], AttachedPlayer[o] = AttachedPlayer[o2];
  239. if(AttachedVehicle[o] != INVALID_VEHICLE_ID)
  240. {
  241. oOffset[o][0] = oOffset[o2][0], oOffset[o][1] = oOffset[o2][1], oOffset[o][2] = oOffset[o2][2];
  242. oRot[o][0] = oRot[o][0], oRot[o][1] = oRot[o2][1], oRot[o][2] = oRot[o2][2];
  243. AttachObjectToVehicle(o, AttachedVehicle[o], oOffset[o2][0], oOffset[o2][1], oOffset[o2][2], oRot[o2][0], oRot[o2][1], oRot[o2][2]);
  244. }
  245. if(AttachedPlayer[o] != INVALID_PLAYER_ID)
  246. {
  247. oOffset[o][0] = oOffset[o2][0], oOffset[o][1] = oOffset[o2][1], oOffset[o][2] = oOffset[o2][2];
  248. oRot[o][0] = oRot[o][0], oRot[o][1] = oRot[o2][1], oRot[o][2] = oRot[o2][2];
  249. AttachObjectToVehicle(o, AttachedPlayer[o], oOffset[o2][0], oOffset[o2][1], oOffset[o2][2], oRot[o2][0], oRot[o2][1], oRot[o2][2]);
  250. }
  251. format(string, sizeof(string), "Object ID %d copied. Object ID for the copied object is %d.", objectid, objid);
  252. SendClientMessage(playerid, COLOUR_INFO, string);
  253. }
  254. return 1;
  255. }
  256. else return 0;
  257. }
  258. dcmd_rotateobject(playerid, params[])
  259. {
  260. if(IsPlayerAdmin(playerid))
  261. {
  262. new objectid, Float:rX, Float:rY, Float:rZ, string[128];
  263. if(sscanf(params, "dF(0)F(0)F(0)", objectid, rX, rY, rZ)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /rotateobject (object id) (rotX) (rotY) (rotZ)");
  264. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  265. else
  266. {
  267. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  268. {
  269. new o = Objects[playerid][objectid];
  270. SetObjectRot(o, rX, rY, rZ);
  271. oRot[o][0] = rX, oRot[o][1] = rY, oRot[o][2] = rZ;
  272. format(string, sizeof(string), "Object ID %d rotated. New rotation: X: %0.2f | Y: %0.2f | Z: %0.2f.", objectid, rX, rY, rZ);
  273. SendClientMessage(playerid, COLOUR_INFO, string);
  274. }
  275. }
  276. return 1;
  277. }
  278. else return 0;
  279. }
  280. dcmd_attachpobject(playerid, params[])
  281. {
  282. if(IsPlayerAdmin(playerid))
  283. {
  284. new id, objectid, Float:ofsX, Float:ofsY, Float:ofsZ, Float:rX, Float:rY, Float:rZ, string[128];
  285. if(sscanf(params, "duF(0)F(0)F(0)F(0)F(0)F(0)", objectid, id, ofsX, ofsY, ofsZ, rX, rY, rZ)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /attachpobject (object id) (nick/id) (offset X) (offset Y) (offset Z) (rotation X) (rotation Y) (rotation Z)");
  286. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  287. if(AttachedVehicle[Objects[playerid][objectid]] != INVALID_VEHICLE_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "You can not attach an object to a player wich is already attached to a vehicle!");
  288. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOUR_SYSTEM, "This player is not connected!");
  289. else
  290. {
  291. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  292. {
  293. new o = Objects[playerid][objectid];
  294. oOffset[o][0] = ofsX, oOffset[o][1] = ofsY, oOffset[o][2] = ofsZ;
  295. oRot[o][0] = rX, oRot[o][1] = rY, oRot[o][2] = rZ;
  296. AttachedPlayer[o] = id;
  297. AttachObjectToPlayer(o, id, ofsX, ofsY, ofsZ, rX, rY, rZ);
  298. format(string, sizeof(string), "Object ID %d attached to %s (%d). Offset: X: %0.2f | Y: %0.2f | Z: %0.2f | Rotation: X: %0.2f | Y: %0.2f | Z: %0.2f.", objectid, pNick(id), id, ofsX, ofsY, ofsZ, rX, rY, rZ);
  299. SendClientMessage(playerid, COLOUR_INFO, string);
  300. }
  301. }
  302. return 1;
  303. }
  304. else return 0;
  305. }
  306. dcmd_deattachpobject(playerid, params[])
  307. {
  308. if(IsPlayerAdmin(playerid))
  309. {
  310. new objectid, string[128], o, o2;
  311. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /deattachpobject (object id)");
  312. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  313. else
  314. {
  315. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  316. {
  317. DestroyObject(Objects[playerid][objectid]);
  318. ObjectCreator[Objects[playerid][objectid]] = INVALID_PLAYER_ID;
  319. o = Objects[playerid][objectid];
  320. Objects[playerid][objectid] = CreateObject(ModelID[o], (oPos[o][0] + oOffset[o][0]), (oPos[o][1] + oOffset[o][1]), (oPos[o][2] + oOffset[o][2]), oRot[o][0], oRot[o][1], oRot[o][2]);
  321. o2 = Objects[playerid][objectid];
  322. ModelID[o2] = ModelID[o], oPos[o2][0] = (oPos[o][0] + oOffset[o][0]), oPos[o2][1] = (oPos[o][1] + oOffset[o][1]), oPos[o2][2] = (oPos[o][2] + oOffset[o][2]), oRot[o2][0] = oRot[o][0], oRot[o2][1] = oRot[o][1], oRot[o2][2] = oRot[o][2];
  323. ObjectCreator[o2] = playerid;
  324. format(string, sizeof(string), "Object ID %d de-attached from %s (%d).", objectid, pNick(AttachedPlayer[o]), AttachedPlayer[o]);
  325. SendClientMessage(playerid, COLOUR_INFO, string);
  326. AttachedPlayer[o2] = INVALID_PLAYER_ID, AttachedPlayer[o] = INVALID_PLAYER_ID;
  327. }
  328. }
  329. return 1;
  330. }
  331. else return 0;
  332. }
  333. dcmd_attachvobject(playerid, params[])
  334. {
  335. if(IsPlayerAdmin(playerid))
  336. {
  337. new vehicleid, objectid, Float:ofsX, Float:ofsY, Float:ofsZ, Float:rX, Float:rY, Float:rZ, string[128];
  338. if(sscanf(params, "ddF(0)F(0)F(0)F(0)F(0)F(0)", objectid, vehicleid, ofsX, ofsY, ofsZ, rX, rY, rZ)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /attachpobject (object id) (vehicleid) (offset X) (offset Y) (offset Z) (rotation X) (rotation Y) (rotation Z)");
  339. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  340. if(AttachedPlayer[Objects[playerid][objectid]] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "You can not attach an object to a vehicle wich is already attached to a player!");
  341. if(vehicleid == INVALID_VEHICLE_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid vehicle ID!");
  342. else
  343. {
  344. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  345. {
  346. new o = Objects[playerid][objectid];
  347. oOffset[o][0] = ofsX, oOffset[o][1] = ofsY, oOffset[o][2] = ofsZ;
  348. oRot[o][0] = rX, oRot[o][1] = rY, oRot[o][2] = rZ;
  349. AttachedVehicle[o] = vehicleid;
  350. AttachObjectToVehicle(o, vehicleid, ofsX, ofsY, ofsZ, rX, rY, rZ);
  351. format(string, sizeof(string), "Object ID %d attached to vehicle ID %d. Offset: X: %0.2f | Y: %0.2f | Z: %0.2f | Rotation: X: %0.2f | Y: %0.2f | Z: %0.2f.", objectid, vehicleid, ofsX, ofsY, ofsZ, rX, rY, rZ);
  352. SendClientMessage(playerid, COLOUR_INFO, string);
  353. }
  354. }
  355. return 1;
  356. }
  357. else return 0;
  358. }
  359. dcmd_deattachvobject(playerid, params[])
  360. {
  361. if(IsPlayerAdmin(playerid))
  362. {
  363. new objectid, string[128], o, o2;
  364. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /deattachpobject (object id)");
  365. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  366. else
  367. {
  368. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  369. {
  370. DestroyObject(Objects[playerid][objectid]);
  371. ObjectCreator[Objects[playerid][objectid]] = INVALID_PLAYER_ID;
  372. o = Objects[playerid][objectid];
  373. GetVehiclePos(AttachedVehicle[o], oPos[o][0], oPos[o][1], oPos[o][2]);
  374. Objects[playerid][objectid] = CreateObject(ModelID[o], (oPos[o][0] + oOffset[o][0]), (oPos[o][1] + oOffset[o][1]), (oPos[o][2] + oOffset[o][2]), oRot[o][0], oRot[o][1], oRot[o][2]);
  375. o2 = Objects[playerid][objectid];
  376. ObjectCreator[o2] = playerid;
  377. format(string, sizeof(string), "Object %d de-attached from vehicle ID %d.", objectid, AttachedVehicle[o]);
  378. SendClientMessage(playerid, COLOUR_INFO, string);
  379. ModelID[o2] = ModelID[o], oPos[o2][0] = (oPos[o][0] + oOffset[o][0]), oPos[o2][1] = (oPos[o][1] + oOffset[o][1]), oPos[o2][2] = (oPos[o][2] + oOffset[o][2]), oRot[o2][0] = oRot[o][0], oRot[o2][1] = oRot[o][1], oRot[o2][2] = oRot[o][2];
  380. AttachedVehicle[o2] = INVALID_VEHICLE_ID, AttachedVehicle[o] = INVALID_VEHICLE_ID;
  381. }
  382. }
  383. return 1;
  384. }
  385. else return 0;
  386. }
  387. dcmd_sethobj(playerid, params[])
  388. {
  389. if(IsPlayerAdmin(playerid))
  390. {
  391. new id, modelid, slot, Float:rX[3], Float:rY[3], Float:rZ[3], string[128], bodypart[36], bid;
  392. if(sscanf(params, "udds[36]F(0)F(0)F(0)F(0)F(0)F(0)F(1)F(1)F(1)", id, modelid, slot, bodypart, rX[0], rY[0], rZ[0], rX[1], rY[1], rZ[1], rX[2], rY[2], rZ[2])) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /sethobj (nick/id) (modelid) (slot: 0-4) (bodypart: name/id) (rotX) (rotY) (rotZ) (rotX) (rotY) (rotZ) (sizeX) (sizeY) (sizeZ)");
  393. if(strlen(bodypart) < 1 || bodypart[35] || GetBodypartIDFromName(bodypart) == -1) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid Bodypart Name/ID.");
  394. if(slot < 0 || slot > 4) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid slot ID. Valid slot IDs are between 0-4.");
  395. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOUR_SYSTEM, "This player is not connected!");
  396. else
  397. {
  398. if(IsPlayerAttachedObjectSlotUsed(id, slot))
  399. {
  400. RemovePlayerAttachedObject(id, slot);
  401. }
  402. bid = GetBodypartIDFromName(bodypart);
  403. SetPlayerAttachedObject(id, slot, modelid, bid, rX[0], rY[0], rZ[0], rX[1], rY[1], rZ[1], rX[2], rY[2], rZ[2]);
  404. format(string, sizeof(string), "Modelid %d has been attached to %s's (%d) Bodypart [%s].", modelid, pNick(id), id, GetBodypartName(bodypart));
  405. SendClientMessage(playerid, COLOUR_INFO, string);
  406. SetHOPVar(playerid, "HOIndex", slot, slot);
  407. SetHOPVar(playerid, "HOModel", modelid, slot);
  408. SetHOPVar(playerid, "HOBone", bid, slot);
  409. SetHOPFloat(playerid, "HOOX", rX[0], slot);
  410. SetHOPFloat(playerid, "HOOY", rY[0], slot);
  411. SetHOPFloat(playerid, "HOOZ", rZ[0], slot);
  412. SetHOPFloat(playerid, "HORX", rX[1], slot);
  413. SetHOPFloat(playerid, "HORY", rY[1], slot);
  414. SetHOPFloat(playerid, "HORZ", rZ[1], slot);
  415. SetHOPFloat(playerid, "HOSX", rX[2], slot);
  416. SetHOPFloat(playerid, "HOSY", rY[2], slot);
  417. SetHOPFloat(playerid, "HOSZ", rZ[2], slot);
  418. }
  419. return 1;
  420. }
  421. else return 0;
  422. }
  423. dcmd_stophobj(playerid, params[])
  424. {
  425. if(IsPlayerAdmin(playerid))
  426. {
  427. new id, string[128], slot;
  428. if(sscanf(params, "ud", id, slot)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /stophobj (nick/id) (slot: 0-4)");
  429. if(slot < 0 || slot > 4) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid slot ID. Valid slot IDs are between 0-4.");
  430. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOUR_SYSTEM, "This player is not connected!");
  431. else
  432. {
  433. RemovePlayerAttachedObject(id, slot);
  434. format(string, sizeof(string), "Attached object in slot ID %d removed from %s's (%d) bodypart.", slot, pNick(id), id);
  435. SendClientMessage(playerid, COLOUR_INFO, string);
  436. }
  437. return 1;
  438. }
  439. else return 0;
  440. }
  441. dcmd_stopallhobj(playerid, params[])
  442. {
  443. if(IsPlayerAdmin(playerid))
  444. {
  445. new id, string[128], count;
  446. if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /stopallhobj (nick/id)");
  447. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOUR_SYSTEM, "This player is not connected!");
  448. else
  449. {
  450. Loop(slot, 5)
  451. {
  452. if(IsPlayerAttachedObjectSlotUsed(id, slot))
  453. {
  454. count++;
  455. RemovePlayerAttachedObject(id, slot);
  456. }
  457. }
  458. format(string, sizeof(string), "All attached objects removed from %s's (%d) bodyparts (%d in total).", pNick(id), id, count);
  459. SendClientMessage(playerid, COLOUR_INFO, string);
  460. }
  461. return 1;
  462. }
  463. else return 0;
  464. }
  465. stock GetBodypartName(bodypart[])
  466. {
  467. new string[25];
  468. if(!strcmp(bodypart, "0", true)) format(string, sizeof(string), "-1");
  469. if(!strcmp(bodypart, "Spine", true) || !strcmp(bodypart, "1", true)) format(string, sizeof(string), "Spine - 1");
  470. if(!strcmp(bodypart, "Head", true) || !strcmp(bodypart, "2", true)) format(string, sizeof(string), "Head - 2");
  471. if(!strcmp(bodypart, "Left upper arm", true) || !strcmp(bodypart, "3", true)) format(string, sizeof(string), "Left upper arm - 3");
  472. if(!strcmp(bodypart, "Right upper arm", true) || !strcmp(bodypart, "4", true)) format(string, sizeof(string), "Right upper arm - 4");
  473. if(!strcmp(bodypart, "Left hand", true) || !strcmp(bodypart, "5", true)) format(string, sizeof(string), "Left hand - 5");
  474. if(!strcmp(bodypart, "Right hand", true) || !strcmp(bodypart, "6", true)) format(string, sizeof(string), "Right hand - 6");
  475. if(!strcmp(bodypart, "Left thigh ", true) || !strcmp(bodypart, "7", true)) format(string, sizeof(string), "Left thigh - 7");
  476. if(!strcmp(bodypart, "Right thigh ", true) || !strcmp(bodypart, "8", true)) format(string, sizeof(string), "Right thigh - 8");
  477. if(!strcmp(bodypart, "Left foot", true) || !strcmp(bodypart, "9", true)) format(string, sizeof(string), "Left foot - 9");
  478. if(!strcmp(bodypart, "Right foot", true) || !strcmp(bodypart, "10", true)) format(string, sizeof(string), "Right foot - 10");
  479. if(!strcmp(bodypart, "Left calf ", true) || !strcmp(bodypart, "11", true)) format(string, sizeof(string), "Left calf - 11");
  480. if(!strcmp(bodypart, "Right calf ", true) || !strcmp(bodypart, "12", true)) format(string, sizeof(string), "Right calf - 12");
  481. if(!strcmp(bodypart, "Left forearm", true) || !strcmp(bodypart, "13", true)) format(string, sizeof(string), "Left forearm - 13");
  482. if(!strcmp(bodypart, "Right forearm ", true) || !strcmp(bodypart, "14", true)) format(string, sizeof(string), "Right forearm - 14");
  483. if(!strcmp(bodypart, "Left clavicle ", true) || !strcmp(bodypart, "15", true)) format(string, sizeof(string), "Left clavicle - 15");
  484. if(!strcmp(bodypart, "Right clavicle ", true) || !strcmp(bodypart, "16", true)) format(string, sizeof(string), "Right clavicle - 16");
  485. if(!strcmp(bodypart, "Neck", true) || !strcmp(bodypart, "17", true)) format(string, sizeof(string), "Neck - 17");
  486. if(!strcmp(bodypart, "Jew", true) || !strcmp(bodypart, "18", true)) format(string, sizeof(string), "Jew - 18");
  487. return string;
  488. }
  489. stock GetBodypartIDFromName(bodypart[])
  490. {
  491. if(!strcmp(bodypart, "0", true)) return -1;
  492. if(!strcmp(bodypart, "Spine", true) || strval(bodypart) == 1) return 1;
  493. if(!strcmp(bodypart, "Head", true) || strval(bodypart) == 2) return 2;
  494. if(!strcmp(bodypart, "Left upper arm", true) || strval(bodypart) == 3) return 3;
  495. if(!strcmp(bodypart, "Right upper arm", true) || strval(bodypart) == 4) return 4;
  496. if(!strcmp(bodypart, "Left hand", true) || strval(bodypart) == 5) return 5;
  497. if(!strcmp(bodypart, "Right hand", true) || strval(bodypart) == 6) return 6;
  498. if(!strcmp(bodypart, "Left thigh ", true) || strval(bodypart) == 7) return 7;
  499. if(!strcmp(bodypart, "Right thigh ", true) || strval(bodypart) == 8) return 8;
  500. if(!strcmp(bodypart, "Left foot", true) || strval(bodypart) == 9) return 9;
  501. if(!strcmp(bodypart, "Right foot", true) || strval(bodypart) == 10) return 10;
  502. if(!strcmp(bodypart, "Left calf ", true) || strval(bodypart) == 11) return 11;
  503. if(!strcmp(bodypart, "Right calf ", true) || strval(bodypart) == 12) return 12;
  504. if(!strcmp(bodypart, "Left forearm", true) || strval(bodypart) == 13) return 13;
  505. if(!strcmp(bodypart, "Right forearm ", true) || strval(bodypart) == 14) return 14;
  506. if(!strcmp(bodypart, "Left clavicle ", true) || strval(bodypart) == 15) return 15;
  507. if(!strcmp(bodypart, "Right clavicle ", true) || strval(bodypart) == 16) return 16;
  508. if(!strcmp(bodypart, "Neck", true) || strval(bodypart) == 17) return 17;
  509. if(!strcmp(bodypart, "Jew", true) || strval(bodypart) == 18) return 18;
  510. else return -1;
  511. }
  512. dcmd_rotateallobject(playerid, params[])
  513. {
  514. if(IsPlayerAdmin(playerid))
  515. {
  516. new Float:rX, Float:rY, Float:rZ, string[128];
  517. if(sscanf(params, "F(0)F(0)F(0)", rX, rY, rZ)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /rotateallobject (rotX) (rotY) (rotZ)");
  518. else
  519. {
  520. Loop(o, MAX_OBJECTS)
  521. {
  522. if(ObjectCreator[o] == playerid)
  523. {
  524. SetObjectRot(o, rX, rY, rZ);
  525. oRot[o][0] = rX, oRot[o][1] = rY, oRot[o][2] = rZ;
  526. }
  527. }
  528. format(string, sizeof(string), "All of your objects have been rotated. New rotation: X: %0.2f | Y: %0.2f | Z: %0.2f.", rX, rY, rZ);
  529. SendClientMessage(playerid, COLOUR_INFO, string);
  530. }
  531. return 1;
  532. }
  533. else return 0;
  534. }
  535.  
  536. dcmd_destroyobject(playerid, params[])
  537. {
  538. if(IsPlayerAdmin(playerid))
  539. {
  540. new objectid, string[128];
  541. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /destroyobject (object id)");
  542. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  543. else
  544. {
  545. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  546. {
  547. new o = Objects[playerid][objectid];
  548. if(ModelID[o] != -1)
  549. {
  550. DestroyObject(o);
  551. ModelID[o] = -1;
  552. }
  553. ObjectCreator[o] = INVALID_PLAYER_ID;
  554. oOffset[o][0] = -1, oOffset[o][1] = -1, oOffset[o][2] = -1;
  555. oPos[o][0] = -1, oPos[o][1] = -1, oPos[o][2] = -1;
  556. oRot[o][0] = -1, oRot[o][1] = -1, oRot[o][2] = -1;
  557. AttachedVehicle[o] = INVALID_VEHICLE_ID, AttachedPlayer[o] = INVALID_PLAYER_ID;
  558. format(string, sizeof(string), "Object ID %d destroyed.", objectid);
  559. SendClientMessage(playerid, COLOUR_INFO, string);
  560. Objects[playerid][objectid] = INVALID_OBJECT_ID;
  561. }
  562. }
  563. return 1;
  564. }
  565. else return 0;
  566. }
  567. dcmd_destroyallobject(playerid, params[])
  568. {
  569. #pragma unused params
  570. if(IsPlayerAdmin(playerid))
  571. {
  572. if(GetFreeObjectID(playerid) >= GOBJ_MAX_OBJECTS_CREATED-1) return SendClientMessage(playerid, COLOUR_SYSTEM, "You haven't created any objects.");
  573. else
  574. {
  575. Loop(o, MAX_OBJECTS)
  576. {
  577. if(ObjectCreator[o] == playerid)
  578. {
  579. if(ModelID[o] != -1)
  580. {
  581. DestroyObject(o);
  582. ModelID[o] = -1;
  583. }
  584. ObjectCreator[o] = INVALID_PLAYER_ID;
  585. oOffset[o][0] = -1, oOffset[o][1] = -1, oOffset[o][2] = -1;
  586. oPos[o][0] = -1, oPos[o][1] = -1, oPos[o][2] = -1;
  587. oRot[o][0] = -1, oRot[o][1] = -1, oRot[o][2] = -1;
  588. AttachedVehicle[o] = INVALID_VEHICLE_ID, AttachedPlayer[o] = INVALID_PLAYER_ID;
  589. }
  590. }
  591. Loop(o2, GOBJ_MAX_OBJECTS_CREATED)
  592. {
  593. Objects[playerid][o2] = INVALID_OBJECT_ID;
  594. }
  595. SendClientMessage(playerid, COLOUR_SYSTEM, "All of your objects have been destroyed.");
  596. return 1;
  597. }
  598. }
  599. else return 0;
  600. }
  601. dcmd_stopobject(playerid, params[])
  602. {
  603. if(IsPlayerAdmin(playerid))
  604. {
  605. new objectid, string[128];
  606. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /stopobject (object id)");
  607. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  608. else
  609. {
  610. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  611. {
  612. new o = Objects[playerid][objectid];
  613. StopObject(o);
  614. GetObjectPos(o, oPos[o][0], oPos[o][1], oPos[o][2]);
  615. format(string, sizeof(string), "You have stopped the movement of object ID %d.", objectid);
  616. SendClientMessage(playerid, COLOUR_INFO, string);
  617. }
  618. }
  619. return 1;
  620. }
  621. else return 0;
  622. }
  623. dcmd_stopallobject(playerid, params[])
  624. {
  625. #pragma unused params
  626. if(IsPlayerAdmin(playerid))
  627. {
  628. Loop(o, MAX_OBJECTS)
  629. {
  630. if(ObjectCreator[o] == playerid)
  631. {
  632. StopObject(o);
  633. GetObjectPos(o, oPos[o][0], oPos[o][1], oPos[o][2]);
  634. }
  635. }
  636. return 1;
  637. }
  638. else return 0;
  639. }
  640. dcmd_moveobject(playerid, params[])
  641. {
  642. if(IsPlayerAdmin(playerid))
  643. {
  644. new objectid, direction[6], Float:amount, Float:speed, string[128];
  645. if(sscanf(params, "ds[6]F(10)F(10)", objectid, direction, amount, speed)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /moveobject (object id) (direction) (amount) (speed) - Accepted directions are: north, south, east, west, up and down.");
  646. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  647. if(strlen(direction) < 2 || strlen(direction) > 5) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid direction. Accepted directions are: north, south, east, west, up and down.");
  648. if(strcmp(direction, "north", true) && strcmp(direction, "south", true) && strcmp(direction, "east", true) && strcmp(direction, "west", true) && strcmp(direction, "up", true) && strcmp(direction, "down", true)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid direction. Accepted directions are: north, south, east, west, up and down.");
  649. else
  650. {
  651. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  652. {
  653. new o = Objects[playerid][objectid];
  654. GetObjectPos(o, X, Y, Z);
  655. if(!strcmp(direction, "north", true)) MoveObject(o, X, Y+amount, Z, speed), oPos[o][1]+=amount;
  656. if(!strcmp(direction, "south", true)) MoveObject(o, X, Y-amount, Z, speed), oPos[o][1]-=amount;
  657. if(!strcmp(direction, "east", true)) MoveObject(o, X+amount, Y, Z, speed), oPos[o][0]+=amount;
  658. if(!strcmp(direction, "west", true)) MoveObject(o, X-amount, Y, Z, speed), oPos[o][0]-=amount;
  659. if(!strcmp(direction, "up", true)) MoveObject(o, X, Y, Z+amount, speed), oPos[o][2]+=amount;
  660. if(!strcmp(direction, "down", true)) MoveObject(o, X, Y, Z-amount, speed), oPos[o][2]-=amount;
  661. format(string, sizeof(string), "Object ID %d moved. Direction: %s (%d meters, %0.2f speed).", objectid, direction, speed);
  662. SendClientMessage(playerid, COLOUR_INFO, string);
  663. }
  664. }
  665. return 1;
  666. }
  667. else return 0;
  668. }
  669. dcmd_moveallobject(playerid, params[])
  670. {
  671. if(IsPlayerAdmin(playerid))
  672. {
  673. new direction[6], Float:amount, Float:speed, string[128], count;
  674. if(sscanf(params, "s[6]F(10)F(10)", direction, amount, speed)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /moveallobject (direction) (amount) (speed) - Accepted directions are: north, south, east, west, up and down.");
  675. if(strlen(direction) < 2 || strlen(direction) > 5) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid direction. Accepted directions are: north, south, east, west, up and down.");
  676. if(strcmp(direction, "north", true) && strcmp(direction, "south", true) && strcmp(direction, "east", true) && strcmp(direction, "west", true) && strcmp(direction, "up", true) && strcmp(direction, "down", true)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid direction. Accepted directions are: north, south, east, west, up and down.");
  677. else
  678. {
  679. Loop(o, MAX_OBJECTS)
  680. {
  681. if(ObjectCreator[o] == playerid)
  682. {
  683. GetObjectPos(o, X, Y, Z);
  684. if(!strcmp(direction, "north", true)) MoveObject(o, X, Y+amount, Z, speed), oPos[o][1]+=amount;
  685. if(!strcmp(direction, "south", true)) MoveObject(o, X, Y-amount, Z, speed), oPos[o][1]-=amount;
  686. if(!strcmp(direction, "east", true)) MoveObject(o, X+amount, Y, Z, speed), oPos[o][0]+=amount;
  687. if(!strcmp(direction, "west", true)) MoveObject(o, X-amount, Y, Z, speed), oPos[o][0]-=amount;
  688. if(!strcmp(direction, "up", true)) MoveObject(o, X, Y, Z+amount, speed), oPos[o][2]+=amount;
  689. if(!strcmp(direction, "down", true)) MoveObject(o, X, Y, Z-amount, speed), oPos[o][2]-=amount;
  690. count++;
  691. }
  692. }
  693. format(string, sizeof(string), "Moved %d objects. Direction: %s (%d meters, %0.2f speed).", count, direction, speed);
  694. SendClientMessage(playerid, COLOUR_INFO, string);
  695. }
  696. return 1;
  697. }
  698. else return 0;
  699. }
  700. dcmd_startobjectloop(playerid, params[])
  701. {
  702. if(IsPlayerAdmin(playerid))
  703. {
  704. new objectid, Float:Pos[6], Float:speed, string[128];
  705. if(sscanf(params, "dffffffF(10.0)", objectid, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], speed)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /startobjectloop (object id) (x1) (y1) (z1) (x2) (y2) (z2) (speed)");
  706. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  707. else
  708. {
  709. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  710. {
  711. new o = Objects[playerid][objectid];
  712. SetObjectPos(o, Pos[0], Pos[1], Pos[2]);
  713. oMoving[o] = 1, oLap[o] = 1, oMSpeed[o] = speed;
  714. oStart[o][0] = Pos[0], oStart[o][1] = Pos[1], oStart[o][2] = Pos[2];
  715. oEnd[o][0] = Pos[3], oEnd[o][1] = Pos[4], oEnd[o][2] = Pos[5];
  716. MoveObject(o, Pos[3], Pos[4], Pos[5], speed);
  717. format(string, sizeof(string), "Object loop for object ID %d started.", objectid);
  718. SendClientMessage(playerid, COLOUR_INFO, string);
  719. }
  720. }
  721. return 1;
  722. }
  723. else return 0;
  724. }
  725. dcmd_startallobjectloop(playerid, params[])
  726. {
  727. if(IsPlayerAdmin(playerid))
  728. {
  729. new Float:Pos[6], Float:speed, string[128], count;
  730. if(sscanf(params, "ffffffF(10.0)", Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], speed)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /startallobjectloop (x1) (y1) (z1) (x2) (y2) (z2) (speed)");
  731. else
  732. {
  733. Loop(o, MAX_OBJECTS)
  734. {
  735. if(ObjectCreator[o] == playerid)
  736. {
  737. SetObjectPos(o, Pos[0], Pos[1], Pos[2]);
  738. oMoving[o] = 1, oLap[o] = 1, oMSpeed[o] = speed;
  739. oStart[o][0] = Pos[0], oStart[o][1] = Pos[1], oStart[o][2] = Pos[2];
  740. oEnd[o][0] = Pos[3], oEnd[o][1] = Pos[4], oEnd[o][2] = Pos[5];
  741. MoveObject(o, Pos[3], Pos[4], Pos[5], speed);
  742. count++;
  743. }
  744. }
  745. format(string, sizeof(string), "Object loop for %d objects started.", count);
  746. SendClientMessage(playerid, COLOUR_INFO, string);
  747. }
  748. return 1;
  749. }
  750. else return 0;
  751. }
  752. dcmd_stopobjectloop(playerid, params[])
  753. {
  754. if(IsPlayerAdmin(playerid))
  755. {
  756. new objectid, string[128];
  757. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /stopobjectloop (object id)");
  758. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  759. else
  760. {
  761. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  762. {
  763. oMoving[Objects[playerid][objectid]] = 0;
  764. StopObject(Objects[playerid][objectid]);
  765. format(string, sizeof(string), "Stopped the object loop for object ID %d.", objectid);
  766. SendClientMessage(playerid, COLOUR_INFO, string);
  767. }
  768. }
  769. return 1;
  770. }
  771. else return 0;
  772. }
  773. #if defined GO_DEBUG_CMDS
  774. dcmd_getmypos(playerid, params[])
  775. {
  776. if(IsPlayerAdmin(playerid))
  777. {
  778. new Float:Pos[3], string[128];
  779. switch(IsPlayerInAnyVehicle(playerid))
  780. {
  781. case 0:
  782. {
  783. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  784. format(string, sizeof(string), "Position: X: %0.2f | Y: %0.2f | Z: %0.2f", Pos[0], Pos[1], Pos[2]);
  785. }
  786. case 1:
  787. {
  788. GetVehiclePos(GetPlayerVehicleID(playerid), Pos[0], Pos[1], Pos[2]);
  789. format(string, sizeof(string), "Position: X: %0.2f | Y: %0.2f | Z: %0.2f", Pos[0], Pos[1], Pos[2]);
  790. }
  791. }
  792. SendClientMessage(playerid, COLOUR_INFO, string);
  793. return 1;
  794. }
  795. }
  796. #endif
  797. dcmd_stopallobjectloop(playerid, params[])
  798. {
  799. #pragma unused params
  800. if(IsPlayerAdmin(playerid))
  801. {
  802. new string[128], count;
  803. Loop(o, MAX_OBJECTS)
  804. {
  805. if(ObjectCreator[o] == playerid)
  806. {
  807. oMoving[o] = 0;
  808. StopObject(o);
  809. count++;
  810. }
  811. }
  812. format(string, sizeof(string), "Stopped the object loop for %d objects.", count);
  813. SendClientMessage(playerid, COLOUR_INFO, string);
  814. return 1;
  815. }
  816. else return 0;
  817. }
  818. public OnObjectMoved(objectid)
  819. {
  820. if(oMoving[objectid] == 1)
  821. {
  822. switch(oLap[objectid])
  823. {
  824. case 0:
  825. {
  826. MoveObject(objectid, oEnd[objectid][0], oEnd[objectid][1], oEnd[objectid][2], oMSpeed[objectid]);
  827. oLap[objectid] = 1;
  828. }
  829. case 1:
  830. {
  831. MoveObject(objectid, oStart[objectid][0], oStart[objectid][1], oStart[objectid][2], oMSpeed[objectid]);
  832. oLap[objectid] = 0;
  833. }
  834. }
  835. }
  836. return 1;
  837. }
  838. dcmd_getobject(playerid, params[])
  839. {
  840. if(IsPlayerAdmin(playerid))
  841. {
  842. new objectid;
  843. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /getobject (object id)");
  844. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  845. else
  846. {
  847. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  848. {
  849. new o = Objects[playerid][objectid];
  850. GetPlayerPos(playerid, X, Y, Z);
  851. SetObjectPos(o, X, Y, Z);
  852. GetObjectPos(o, oPos[o][0], oPos[o][1], oPos[o][2]);
  853. }
  854. }
  855. return 1;
  856. }
  857. else return 0;
  858. }
  859. dcmd_getallobject(playerid, params[])
  860. {
  861. #pragma unused params
  862. if(IsPlayerAdmin(playerid))
  863. {
  864. GetPlayerPos(playerid, X, Y, Z);
  865. Loop(o, MAX_OBJECTS)
  866. {
  867. if(ObjectCreator[o] == playerid)
  868. {
  869. SetObjectPos(o, X, Y, Z);
  870. GetObjectPos(o, oPos[o][0], oPos[o][1], oPos[o][2]);
  871. }
  872. }
  873. return 1;
  874. }
  875. else return 0;
  876. }
  877. dcmd_objecttele(playerid, params[])
  878. {
  879. if(IsPlayerAdmin(playerid))
  880. {
  881. new objectid;
  882. if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /objecttele (objectid)");
  883. if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT && !IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_SYSTEM, "You need to spawn to be able to use this command.");
  884. if(objectid < 0 || objectid >= GOBJ_MAX_OBJECTS_CREATED-1 || Objects[playerid][objectid] == INVALID_OBJECT_ID) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid object ID!");
  885. else
  886. {
  887. if(ObjectCreator[Objects[playerid][objectid]] == playerid)
  888. {
  889. GetObjectPos(Objects[playerid][objectid], X, Y, Z);
  890. SetPlayerPos(playerid, X, Y, Z+1);
  891. }
  892. }
  893. return 1;
  894. }
  895. else return 0;
  896. }
  897. dcmd_saveobject(playerid, params[])
  898. {
  899. #pragma unused params
  900. if(IsPlayerAdmin(playerid))
  901. {
  902. return ShowPlayerDialog(playerid, G_OBJ_DID, DIALOG_STYLE_INPUT, "{009900}GarObject - Object Saving", "{FF0000}Warning! {FFFFFF}You're about to save objects to a file.\nYou must include the .txt tag at the end of the filename.\nAll existing text in the file you're saving to will be overwritten.\n\nEnter the filename where you want to save the objects below:", "Save", "Cancel");
  903. }
  904. else return 0;
  905. }
  906. dcmd_loadobject(playerid, params[])
  907. {
  908. #pragma unused params
  909. if(IsPlayerAdmin(playerid))
  910. {
  911. return ShowPlayerDialog(playerid, (G_OBJ_DID+1), DIALOG_STYLE_INPUT, "{009900}GarObject - Object Loading", "{FF0000}Warning! {FFFFFF}You're about to load objects from a file.\nYou must include the .txt tag at the end of the filename.\n\nEnter the filename where you want to load the objects from below:", "Load", "Cancel");
  912. }
  913. else return 0;
  914. }
  915. dcmd_savehobject(playerid, params[])
  916. {
  917. #pragma unused params
  918. if(IsPlayerAdmin(playerid))
  919. {
  920. return ShowPlayerDialog(playerid, (G_OBJ_DID+2), DIALOG_STYLE_INPUT, "{009900}GarObject - Object Saving", "{FF0000}Warning! {FFFFFF}You're about to save objects to a file.\nYou must include the .txt tag at the end of the filename.\nAll existing text in the file you're saving to will be overwritten.\n\nEnter the filename where you want to save the objects below:", "Save", "Cancel");
  921. }
  922. else return 0;
  923. }
  924. dcmd_loadhobject(playerid, params[])
  925. {
  926. #pragma unused params
  927. if(IsPlayerAdmin(playerid))
  928. {
  929. return ShowPlayerDialog(playerid, (G_OBJ_DID+3), DIALOG_STYLE_INPUT, "{009900}GarObject - Object Loading", "{FF0000}Warning! {FFFFFF}You're about to load objects from a file.\nYou must include the .txt tag at the end of the filename.\n\nEnter the filename where you want to load the objects from below:", "Load", "Cancel");
  930. }
  931. else return 0;
  932. }
  933. dcmd_garobject(playerid, params[])
  934. {
  935. if(IsPlayerAdmin(playerid))
  936. {
  937. #pragma unused params
  938. #if !defined G_OBJ_USE_SHORTCUTS
  939. ShowPlayerDialog(playerid, (G_OBJ_DID+4), DIALOG_STYLE_MSGBOX, "{00BC00}GarObject {FF0000}v1.3 {00BC00}by {FF0000}[03]Garsino", "/createobject\n/destroy(all)object\n/rotate(all)object\n/stop(all)object\n/move(all)object\n/objecttele\n/(de)attachpobject\n/get(all)object\n/sethobj\n/(de)attachvobject\n/stop(all)hobj\n/copyobject\n/saveobject\n/loadobject\n/savehobject\n/loadhobject\n/start(all)objectloop\n/stop(all)objectloop\n\n{00BC00}Available at the {FF0000}SA:MP {00BC00}forum.", "Close", "");
  940. #endif
  941. #if defined G_OBJ_USE_SHORTCUTS
  942. new string[500];
  943. strcat(string, "/createobject\t\t/oc\n/destroy(all)object\t/od(all)\n/rotate(all)object\t/orot(all)\n/stop(all)object\t/os(all)\n/move(all)object\t/om(all)\n/objecttele\t\t/ot\n");
  944. strcat(string, "/(de)attachpobject\t/(de)apo\n/get(all)object\t\t/og(all)\n/sethobj\t\t/setho\n/(de)attachvobject\t/(de)avo\n/stop(all)hobj\t\t/stop(all)ho\n/copyobject\t\t/co\n/saveobject\t\t/so\n/loadobject\t\t/lo\n/savehobject\t\t/sho\n/loadhobject\t\t/lho\n/start(all)objectloop\t/s(all)ol\n/stop(all)objectloop\t/stop(all)ol\n\n{00BC00}Available at the {FF0000}SA:MP {00BC00}forum.");
  945. ShowPlayerDialog(playerid, (G_OBJ_DID+4), DIALOG_STYLE_MSGBOX, "{00BC00}GarObject {FF0000}v1.3 {00BC00}by {FF0000}[03]Garsino", string, "Close", "");
  946. #endif
  947. return 1;
  948. }
  949. else return 0;
  950. }
  951. #if defined G_OBJ_USE_SHORTCUTS
  952. dcmd_stopallol(playerid, params[]) return dcmd_stopallobjectloop(playerid, params);
  953. dcmd_stopol(playerid, params[]) return dcmd_stopobjectloop(playerid, params);
  954. dcmd_sallol(playerid, params[]) return dcmd_startallobjectloop(playerid, params);
  955. dcmd_sol(playerid, params[]) return dcmd_startobjectloop(playerid, params);
  956. dcmd_oc(playerid, params[]) return dcmd_createobject(playerid, params);
  957. dcmd_or(playerid, params[]) return dcmd_rotateobject(playerid, params);
  958. dcmd_apo(playerid, params[]) return dcmd_attachpobject(playerid, params);
  959. dcmd_deapo(playerid, params[]) return dcmd_deattachpobject(playerid, params);
  960. dcmd_avo(playerid, params[]) return dcmd_attachvobject(playerid, params);
  961. dcmd_deavo(playerid, params[]) return dcmd_deattachvobject(playerid, params);
  962. dcmd_orall(playerid, params[]) return dcmd_rotateallobject(playerid, params);
  963. dcmd_od(playerid, params[]) return dcmd_destroyobject(playerid, params);
  964. dcmd_odall(playerid, params[]) return dcmd_destroyallobject(playerid, params);
  965. dcmd_os(playerid, params[]) return dcmd_stopobject(playerid, params);
  966. dcmd_osall(playerid, params[]) return dcmd_stopallobject(playerid, params);
  967. dcmd_om(playerid, params[]) return dcmd_moveobject(playerid, params);
  968. dcmd_omall(playerid, params[]) return dcmd_moveallobject(playerid, params);
  969. dcmd_og(playerid, params[]) return dcmd_getobject(playerid, params);
  970. dcmd_ogall(playerid, params[]) return dcmd_getallobject(playerid, params);
  971. dcmd_ot(playerid, params[]) return dcmd_objecttele(playerid, params);
  972. dcmd_setho(playerid, params[]) return dcmd_sethobj(playerid, params);
  973. dcmd_stopho(playerid, params[]) return dcmd_stophobj(playerid, params);
  974. dcmd_stopallho(playerid, params[]) return dcmd_stopallhobj(playerid, params);
  975. dcmd_so(playerid, params[]) return dcmd_saveobject(playerid, params);
  976. dcmd_lo(playerid, params[]) return dcmd_loadobject(playerid, params);
  977. dcmd_sho(playerid, params[]) return dcmd_savehobject(playerid, params);
  978. dcmd_lho(playerid, params[]) return dcmd_loadhobject(playerid, params);
  979. dcmd_co(playerid, params[]) return dcmd_copyobject(playerid, params);
  980. dcmd_gobj(playerid, params[]) return dcmd_garobject(playerid, params);
  981. #endif
  982. stock GetFreeObjectID(playerid)
  983. {
  984. for(new a = 0; a < GOBJ_MAX_OBJECTS_CREATED; a++)
  985. {
  986. if(Objects[playerid][a] == INVALID_OBJECT_ID)
  987. {
  988. return a;
  989. }
  990. }
  991. return -1;
  992. }
  993. stock GetTotalNativeObjects()
  994. {
  995. new tmpcount = 0;
  996. Loop(o, MAX_OBJECTS)
  997. {
  998. if(IsValidObject(o))
  999. {
  1000. tmpcount++;
  1001. }
  1002. }
  1003. return tmpcount;
  1004. }
  1005. stock pNick(playerid)
  1006. {
  1007. new GFSnick[MAX_PLAYER_NAME];
  1008. GetPlayerName(playerid, GFSnick, MAX_PLAYER_NAME);
  1009. return GFSnick;
  1010. }
  1011. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1012. {
  1013. if(dialogid == G_OBJ_DID && response)
  1014. {
  1015. return SaveObjectsToFile(playerid, inputtext);
  1016. }
  1017. if(dialogid == (G_OBJ_DID + 1) && response)
  1018. {
  1019. return LoadObjectsFromFile(playerid, inputtext);
  1020. }
  1021. if(dialogid == (G_OBJ_DID + 2) && response)
  1022. {
  1023. return SaveHObjectsToFile(playerid, inputtext);
  1024. }
  1025. if(dialogid == (G_OBJ_DID + 3) && response)
  1026. {
  1027. return LoadHObjectsFromFile(playerid, inputtext);
  1028. }
  1029. return 0;
  1030. }
  1031. stock SaveObjectsToFile(playerid, filename[], sendmsg = 1)
  1032. {
  1033. new File:gFile, string[158], count;
  1034. if(strlen(filename) < 4) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered is shorter than 4 characters. Minimum filename is 4 characters including the .txt extension.");
  1035. if(strfind(filename, ".txt", true) == -1) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered didn't have the .txt extension at the end. Please add it and continue.");
  1036. else
  1037. {
  1038. if(fexist(filename))
  1039. {
  1040. fremove(filename);
  1041. }
  1042. gFile = fopen(filename, io_write);
  1043. fclose(gFile);
  1044. gFile = fopen(filename, io_append);
  1045. Loop(o, MAX_OBJECTS)
  1046. {
  1047. if(ObjectCreator[o] == playerid && ModelID[o] != -1)
  1048. {
  1049. format(string, sizeof(string), "CreateObject(%d, %f, %f, %f, %f, %f, %f);\r\n", ModelID[o], oPos[o][0], oPos[o][1], oPos[o][2], oRot[o][0], oRot[o][1], oRot[o][2]);
  1050. fwrite(gFile, string);
  1051. DestroyObject(o);
  1052. ModelID[o] = -1;
  1053. count++;
  1054. }
  1055. }
  1056. fclose(gFile);
  1057. if(sendmsg == 1)
  1058. {
  1059. format(string, sizeof(string), "{009900}Save Successfull{FFFFFF}! Saved{009900} %d{FFFFFF} objects to {009900}%s{FFFFFF}.", count, filename);
  1060. SendClientMessage(playerid, COLOUR_INFO, string);
  1061. }
  1062. }
  1063. return 1;
  1064. }
  1065. stock LoadObjectsFromFile(playerid, filename[], sendmsg = 1)
  1066. {
  1067. new File:file_ptr, modelid, Float:pos[3], Float:rot[3], count, line[256];
  1068. if(strlen(filename) < 4) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered is shorter than 4 characters. Minimum filename is 4 characters including the .txt extension.");
  1069. if(strfind(filename, ".txt", true) == -1) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered didn't have the .txt extension at the end. Please add it and continue.");
  1070. if(!fexist(filename)) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}This file does not exist.");
  1071. else
  1072. {
  1073. file_ptr = fopen(filename, io_read);
  1074. while(fread(file_ptr, line) > 0)
  1075. {
  1076. if(GetTotalNativeObjects() >= (MAX_OBJECTS-1)) return SendClientMessage(playerid, COLOUR_SYSTEM, "The SA:MP object limit has been reached. You can not spawn any more objects.");
  1077. if(GetFreeObjectID(playerid) < 0) return SendClientMessage(playerid, COLOUR_SYSTEM, "You can not spawn any more objects. Please delete one of the current ones first.");
  1078. if(!sscanf(line, "p<,>'('ifffffp<)>f", modelid, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]))
  1079. {
  1080. new obj = GetFreeObjectID(playerid);
  1081. Objects[playerid][obj] = CreateObject(modelid, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]);
  1082. new o = Objects[playerid][obj];
  1083. ObjectCreator[o] = playerid, ModelID[o] = modelid, oPos[o][0] = pos[0], oPos[o][1] = pos[1], oPos[o][2] = pos[2], oRot[o][0] = rot[0], oRot[o][1] = rot[1], oRot[o][2] = rot[2], AttachedVehicle[o] = INVALID_VEHICLE_ID, AttachedPlayer[o] = INVALID_PLAYER_ID;
  1084. count++;
  1085. }
  1086. }
  1087. fclose(file_ptr);
  1088. if(sendmsg == 1)
  1089. {
  1090. format(line, sizeof(line), "{009900}Load Successfull{FFFFFF}! Loaded{009900} %d{FFFFFF} objects from {009900}%s{FFFFFF}.", count, filename);
  1091. SendClientMessage(playerid, COLOUR_INFO, line);
  1092. }
  1093. }
  1094. return 1;
  1095. }
  1096. stock SetHOPVar(playerid, varname[], int_value, slot)
  1097. {
  1098. new string[128];
  1099. format(string, sizeof(string), "%s%d", varname, slot);
  1100. return SetPVarInt(playerid, string, int_value);
  1101. }
  1102. stock GetHOPVar(playerid, varname[], slot)
  1103. {
  1104. new string[128];
  1105. format(string, sizeof(string), "%s%d", varname, slot);
  1106. return GetPVarInt(playerid, string);
  1107. }
  1108. stock SetHOPFloat(playerid, varname[], Float:int_value, slot)
  1109. {
  1110. new string[128];
  1111. format(string, sizeof(string), "%s%d", varname, slot);
  1112. return SetPVarFloat(playerid, string, int_value);
  1113. }
  1114. stock Float:GetHOPFloat(playerid, varname[], slot)
  1115. {
  1116. new string[128];
  1117. format(string, sizeof(string), "%s%d", varname, slot);
  1118. return GetPVarFloat(playerid, string);
  1119. }
  1120. stock CountTotalHoldingObjects(playerid)
  1121. {
  1122. new count;
  1123. Loop(o, 5)
  1124. {
  1125. if(IsPlayerAttachedObjectSlotUsed(playerid, o))
  1126. {
  1127. count++;
  1128. }
  1129. }
  1130. return count;
  1131. }
  1132. stock SaveHObjectsToFile(pid, filename[], sendmsg = 1)
  1133. {
  1134. new File:gFile, string[158], count;
  1135. if(strlen(filename) < 4) return SendClientMessage(pid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered is shorter than 4 characters. Minimum filename is 4 characters including the .txt extension.");
  1136. if(strfind(filename, ".txt", true) == -1) return SendClientMessage(pid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered didn't have the .txt extension at the end. Please add it and continue.");
  1137. if(CountTotalHoldingObjects(pid) == 0) return SendClientMessage(pid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}You do not have any objects to save.");
  1138. else
  1139. {
  1140. if(fexist(filename))
  1141. {
  1142. fremove(filename);
  1143. }
  1144. gFile = fopen(filename, io_write);
  1145. fclose(gFile);
  1146. gFile = fopen(filename, io_append);
  1147. Loop(o, 5)
  1148. {
  1149. if(IsPlayerAttachedObjectSlotUsed(pid, o))
  1150. {
  1151. format(string, sizeof(string), "SetPlayerAttachedObject(playerid, %d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f);\r\n", GetHOPVar(pid, "HOIndex", o), GetHOPVar(pid, "HOModel", o), GetHOPVar(pid, "HOBone", o), GetHOPFloat(pid, "HOOX", o), GetHOPFloat(pid, "HOOY", o), GetHOPFloat(pid, "HOOZ", o), GetHOPFloat(pid, "HORX", o), GetHOPFloat(pid, "HORY", o), GetHOPFloat(pid, "HORZ", o), GetHOPFloat(pid, "HOSX", o), GetHOPFloat(pid, "HOSY", o), GetHOPFloat(pid, "HOSZ", o));
  1152. print(string);
  1153. fwrite(gFile, string);
  1154. RemovePlayerAttachedObject(pid, o);
  1155. count++;
  1156. }
  1157. }
  1158. fclose(gFile);
  1159. if(sendmsg == 1)
  1160. {
  1161. format(string, sizeof(string), "{009900}Save Successfull{FFFFFF}! Saved{009900} %d{FFFFFF} objects to {009900}%s{FFFFFF}.", count, filename);
  1162. SendClientMessage(pid, COLOUR_INFO, string);
  1163. }
  1164. }
  1165. return 1;
  1166. }
  1167. stock LoadHObjectsFromFile(playerid, filename[], sendmsg = 1)
  1168. {
  1169. new File:file_ptr, modelid, bone, index, Float:o[3], Float:r[3], Float:s[3], count, line[256];
  1170. if(strlen(filename) < 4) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered is shorter than 4 characters. Minimum filename is 4 characters including the .txt extension.");
  1171. if(strfind(filename, ".txt", true) == -1) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}The filename you entered didn't have the .txt extension at the end. Please add it and continue.");
  1172. if(!fexist(filename)) return SendClientMessage(playerid, COLOUR_SYSTEM, "{FF0000}Error! {FFFFFF}This file does not exist.");
  1173. else
  1174. {
  1175. file_ptr = fopen(filename, io_read);
  1176. while(fread(file_ptr, line) > 0)
  1177. {
  1178. if(!sscanf(line, "p<,>'(playerid'dddffffffffp<)>f", index, modelid, bone, o[0], o[1], o[2], r[0], r[1], r[2], s[0], s[1], s[2]))
  1179. {
  1180. print(line);
  1181. SetPlayerAttachedObject(playerid, count, modelid, bone, o[0], o[1], o[2], r[0], r[1], r[2], s[0], s[1], s[2]);
  1182. SetHOPVar(playerid, "HOIndex", count, count);
  1183. SetHOPVar(playerid, "HOModel", modelid, count);
  1184. SetHOPVar(playerid, "HOBone", bone, count);
  1185. SetHOPFloat(playerid, "HOOX", o[0], count);
  1186. SetHOPFloat(playerid, "HOOY", o[1], count);
  1187. SetHOPFloat(playerid, "HOOZ", o[2], count);
  1188. SetHOPFloat(playerid, "HORX", r[0], count);
  1189. SetHOPFloat(playerid, "HORY", r[1], count);
  1190. SetHOPFloat(playerid, "HORZ", r[2], count);
  1191. SetHOPFloat(playerid, "HOSX", s[0], count);
  1192. SetHOPFloat(playerid, "HOSY", s[1], count);
  1193. SetHOPFloat(playerid, "HOSZ", s[2], count);
  1194. count++;
  1195. }
  1196. }
  1197. fclose(file_ptr);
  1198. if(sendmsg == 1)
  1199. {
  1200. format(line, sizeof(line), "{009900}Load Successfull{FFFFFF}! Loaded{009900} %d{FFFFFF} objects from {009900}%s{FFFFFF}.", count, filename);
  1201. SendClientMessage(playerid, COLOUR_INFO, line);
  1202. }
  1203. }
  1204. return 1;
  1205. }
Advertisement
Add Comment
Please, Sign In to add comment