Advertisement
Fitri_Fahim

Create

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