gates.pwn 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Dynamic Gates System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <YSI\y_hooks>
  34. CMD:gate(playerid, params[])
  35. {
  36. new Float:X, Float:Y, Float:Z;
  37. for(new i = 0; i < sizeof(GateInfo); i++)
  38. {
  39. GetDynamicObjectPos(GateInfo[i][gGATE], X, Y, Z);
  40. if(GateInfo[i][gGroupID] != -1 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && PlayerInfo[playerid][pMember] == GateInfo[i][gGroupID] && IsPlayerInRangeOfPoint(playerid,GateInfo[i][gRange], X, Y, Z) && GetPlayerVirtualWorld(playerid) == GateInfo[i][gVW] && GetPlayerInterior(playerid) == GateInfo[i][gInt])
  41. {
  42. if(GateInfo[i][gLocked] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This gate is currently locked.");
  43. if(GateInfo[i][gAutomate] == 1) return 1;
  44. MoveGate(playerid, i);
  45. }
  46. else if(GateInfo[i][gAllegiance] != 0 && GateInfo[i][gGroupType] != 0 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance] == GateInfo[i][gAllegiance] && arrGroupData[PlayerInfo[playerid][pMember]][g_iGroupType] == GateInfo[i][gGroupType] && IsPlayerInRangeOfPoint(playerid,GateInfo[i][gRange], X, Y, Z) && GetPlayerVirtualWorld(playerid) == GateInfo[i][gVW] && GetPlayerInterior(playerid) == GateInfo[i][gInt])
  47. {
  48. if(GateInfo[i][gLocked] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This gate is currently locked.");
  49. if(GateInfo[i][gAutomate] == 1) return 1;
  50. MoveGate(playerid, i);
  51. }
  52. else if(GateInfo[i][gAllegiance] != 0 && GateInfo[i][gGroupType] == 0 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance] == GateInfo[i][gAllegiance] && IsPlayerInRangeOfPoint(playerid,GateInfo[i][gRange], X, Y, Z) && GetPlayerVirtualWorld(playerid) == GateInfo[i][gVW] && GetPlayerInterior(playerid) == GateInfo[i][gInt])
  53. {
  54. if(GateInfo[i][gLocked] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This gate is currently locked.");
  55. if(GateInfo[i][gAutomate] == 1) return 1;
  56. MoveGate(playerid, i);
  57. }
  58. else if(GateInfo[i][gAllegiance] == 0 && GateInfo[i][gGroupType] != 0 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iGroupType] == GateInfo[i][gGroupType] && IsPlayerInRangeOfPoint(playerid,GateInfo[i][gRange], X, Y, Z) && GetPlayerVirtualWorld(playerid) == GateInfo[i][gVW] && GetPlayerInterior(playerid) == GateInfo[i][gInt])
  59. {
  60. if(GateInfo[i][gLocked] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This gate is currently locked.");
  61. if(GateInfo[i][gAutomate] == 1) return 1;
  62. MoveGate(playerid, i);
  63. }
  64. }
  65. return 1;
  66. }
  67. CMD:agate(playerid, params[])
  68. {
  69. new Float:X, Float:Y, Float:Z;
  70. for(new i = 0; i < sizeof(GateInfo); i++)
  71. {
  72. GetDynamicObjectPos(GateInfo[i][gGATE], X, Y, Z);
  73. if(IsPlayerInRangeOfPoint(playerid, 15, X, Y, Z) && PlayerInfo[playerid][pAdmin] >= 2)
  74. {
  75. MoveGate(playerid, i);
  76. }
  77. }
  78. return 1;
  79. }
  80. /*
  81. CMD:citylockdown(playerid, params[])
  82. {
  83. for(new i = 0; i < sizeof(GateInfo); i++)
  84. {
  85. if((0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance] == GateInfo[i][gAllegiance] && GateInfo[i][gLocked] != 1 && arrGroupData[PlayerInfo[playerid][pMember]][g_iTollLockdown] >= PlayerInfo[playerid][pRank])
  86. {
  87. MoveGate(playerid, i);
  88. }
  89. }
  90. }*/
  91. CMD:gsave(playerid, params[])
  92. {
  93. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  94. {
  95. SendClientMessageEx(playerid, COLOR_YELLOW, "You have force saved the Gate database.");
  96. SaveGates();
  97. }
  98. else
  99. {
  100. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  101. }
  102. return 1;
  103. }
  104. CMD:hgate(playerid, params[])
  105. {
  106. return cmd_movegate(playerid, params);
  107. }
  108. CMD:movegate(playerid, params[])
  109. {
  110. if(isnull(params)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /movegate [pass]");
  111. new Float:X, Float:Y, Float:Z;
  112. for(new i = 0; i < sizeof(GateInfo); i++)
  113. {
  114. GetDynamicObjectPos(GateInfo[i][gGATE], X, Y, Z);
  115. if(GateInfo[i][gGroupID] == -1 && IsPlayerInRangeOfPoint(playerid,GateInfo[i][gRange], X, Y, Z) && GetPlayerVirtualWorld(playerid) == GateInfo[i][gVW])
  116. {
  117. if(GateInfo[i][gLocked] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This gate is currently locked.");
  118. if(GateInfo[i][gAutomate] == 1) return 1;
  119. if(strcmp(params, GateInfo[i][gPass], true) == 0)
  120. {
  121. if(GateInfo[i][gStatus] == 0)
  122. {
  123. MoveDynamicObject(GateInfo[i][gGATE], GateInfo[i][gPosXM], GateInfo[i][gPosYM], GateInfo[i][gPosZM], GateInfo[i][gSpeed], GateInfo[i][gRotXM], GateInfo[i][gRotYM], GateInfo[i][gRotZM]);
  124. GateInfo[i][gStatus] = 1;
  125. if(GateInfo[i][gTimer] != 0)
  126. {
  127. switch(GateInfo[i][gTimer])
  128. {
  129. case 1: SetTimerEx("MoveTimerGate", 3000, false, "i", i);
  130. case 2: SetTimerEx("MoveTimerGate", 5000, false, "i", i);
  131. case 3: SetTimerEx("MoveTimerGate", 7000, false, "i", i);
  132. case 4: SetTimerEx("MoveTimerGate", 10000, false, "i", i);
  133. }
  134. }
  135. }
  136. else if(GateInfo[i][gStatus] == 1 && GateInfo[i][gTimer] == 0)
  137. {
  138. MoveDynamicObject(GateInfo[i][gGATE], GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ], GateInfo[i][gSpeed], GateInfo[i][gRotX], GateInfo[i][gRotY], GateInfo[i][gRotZ]);
  139. GateInfo[i][gStatus] = 0;
  140. }
  141. }
  142. }
  143. }
  144. return 1;
  145. }
  146. CMD:admingatepw(playerid, params[])
  147. {
  148. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  149. {
  150. new string[128], gateid, pass[24];
  151. if(sscanf(params, "ds[24]", gateid, pass)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /admingatepw [gateid] [pass]");
  152. if(strlen(pass) > 24)
  153. {
  154. SendClientMessageEx(playerid, COLOR_GRAD2, " Must be 24 characters or less! ");
  155. return 1;
  156. }
  157. format(string, sizeof(string), "Gate Password for gate %d changed to %s", gateid, pass);
  158. format(GateInfo[gateid][gPass], 24, "%s", pass);
  159. SendClientMessageEx(playerid, COLOR_GRAD2, string);
  160. SaveGate(gateid);
  161. }
  162. else
  163. {
  164. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  165. return 1;
  166. }
  167. return 1;
  168. }
  169. CMD:housegatepw(playerid, params[])
  170. {
  171. SendClientMessageEx(playerid, COLOR_GREY, "/housegatepw has been changed to /setgatepass!");
  172. return 1;
  173. }
  174. CMD:setgatepass(playerid, params[])
  175. {
  176. new Float:X, Float:Y, Float:Z, string[128];
  177. if(Homes[playerid] == 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a home!");
  178. if(isnull(params)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setgatepass [pass]");
  179. if(strlen(params) > 24) return SendClientMessageEx(playerid, COLOR_GRAD2, " Must be 24 characters or less! ");
  180. for(new i = 0; i < sizeof(GateInfo); i++)
  181. {
  182. GetDynamicObjectPos(GateInfo[i][gGATE], X, Y, Z);
  183. if(IsPlayerInRangeOfPoint(playerid, GateInfo[i][gRange], X, Y, Z))
  184. {
  185. if(GateInfo[i][gHID] != -1 && GetPlayerSQLId(playerid) == HouseInfo[GateInfo[i][gHID]][hOwnerID] && GateInfo[i][gGroupID] == INVALID_GROUP_ID)
  186. {
  187. format(GateInfo[i][gPass], 24, "%s", params);
  188. SaveGate(i);
  189. format(string, sizeof(string), "House Gate Password for gate %d changed to: %s", i, params);
  190. return SendClientMessageEx(playerid, COLOR_GRAD2, string);
  191. }
  192. }
  193. }
  194. SendClientMessageEx(playerid, COLOR_WHITE, "* You're not near a gate that you own!");
  195. return 1;
  196. }
  197. CMD:lockgate(playerid, params[])
  198. {
  199. new Float:X, Float:Y, Float:Z, string[56];
  200. for(new i = 0; i < sizeof(GateInfo); i++)
  201. {
  202. GetDynamicObjectPos(GateInfo[i][gGATE], X, Y, Z);
  203. if(IsPlayerInRangeOfPoint(playerid, GateInfo[i][gRange], X, Y, Z) && GetPlayerVirtualWorld(playerid) == GateInfo[i][gVW])
  204. {
  205. if(GateInfo[i][gGroupID] == INVALID_GROUP_ID)
  206. {
  207. if(GateInfo[i][gHID] != -1 && GetPlayerSQLId(playerid) == HouseInfo[GateInfo[i][gHID]][hOwnerID])
  208. {
  209. if(GateInfo[i][gLocked] == 0)
  210. {
  211. GateInfo[i][gLocked] = 1;
  212. format(string, sizeof(string), "* %s has locked their gate.", GetPlayerNameEx(playerid));
  213. ProxDetector(GateInfo[i][gRange], playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  214. }
  215. else
  216. {
  217. GateInfo[i][gLocked] = 0;
  218. format(string, sizeof(string), "* %s has unlocked their gate.", GetPlayerNameEx(playerid));
  219. ProxDetector(GateInfo[i][gRange], playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  220. }
  221. }
  222. }
  223. else if(GateInfo[i][gGroupID] != INVALID_GROUP_ID)
  224. {
  225. if(PlayerInfo[playerid][pLeader] == GateInfo[i][gGroupID])
  226. {
  227. if(GateInfo[i][gLocked] == 0)
  228. {
  229. GateInfo[i][gLocked] = 1;
  230. format(string, sizeof(string), "* %s has locked the gate.", GetPlayerNameEx(playerid));
  231. ProxDetector(GateInfo[i][gRange], playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  232. }
  233. else
  234. {
  235. GateInfo[i][gLocked] = 0;
  236. format(string, sizeof(string), "* %s has unlocked the gate.", GetPlayerNameEx(playerid));
  237. ProxDetector(GateInfo[i][gRange], playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  238. }
  239. }
  240. }
  241. else if(GateInfo[i][gGroupType] != 0)
  242. {
  243. if(PlayerInfo[playerid][pFactionModerator] >= 1)
  244. {
  245. if(GateInfo[i][gLocked] == 0)
  246. {
  247. GateInfo[i][gLocked] = 1;
  248. format(string, sizeof(string), "* %s has locked the gate.", GetPlayerNameEx(playerid));
  249. ProxDetector(GateInfo[i][gRange], playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  250. format(string, sizeof(string), "%s(%d) has locked gate ID %d.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), i);
  251. Log("logs/gedit.log", string);
  252. }
  253. else
  254. {
  255. GateInfo[i][gLocked] = 0;
  256. format(string, sizeof(string), "* %s has unlocked the gate.", GetPlayerNameEx(playerid));
  257. ProxDetector(GateInfo[i][gRange], playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  258. format(string, sizeof(string), "%s(%d) has locked gate ID %d.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), i);
  259. Log("logs/gedit.log", string);
  260. }
  261. }
  262. }
  263. }
  264. }
  265. return 1;
  266. }
  267. CMD:gotogate(playerid, params[])
  268. {
  269. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  270. {
  271. new string[48], gatenum;
  272. if(sscanf(params, "d", gatenum)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gotogate [gatenumber]");
  273. if(gatenum <= 0 || gatenum >= MAX_GATES)
  274. {
  275. format(string, sizeof(string), "Gate ID must be between 1 and %d.", MAX_GATES - 1);
  276. return SendClientMessageEx(playerid, COLOR_GREY, string);
  277. }
  278. SetPlayerPos(playerid,GateInfo[gatenum][gPosX],GateInfo[gatenum][gPosY],GateInfo[gatenum][gPosZ] + 1);
  279. GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
  280. SetPlayerInterior(playerid, GateInfo[gatenum][gInt]);
  281. PlayerInfo[playerid][pInt] = GateInfo[gatenum][gInt];
  282. SetPlayerVirtualWorld(playerid, GateInfo[gatenum][gVW]);
  283. PlayerInfo[playerid][pVW] = GateInfo[gatenum][gVW];
  284. }
  285. return 1;
  286. }
  287. CMD:gstatus(playerid, params[])
  288. {
  289. new gateid;
  290. if(sscanf(params, "i", gateid))
  291. {
  292. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gstatus [gateid]");
  293. return 1;
  294. }
  295. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  296. {
  297. new string[128], timertxt, distancetxt;
  298. switch(GateInfo[gateid][gTimer])
  299. {
  300. case 1: timertxt = 1;
  301. case 2: timertxt = 3;
  302. case 3: timertxt = 5;
  303. case 4: timertxt = 10;
  304. default: timertxt = 0;
  305. }
  306. switch(GateInfo[gateid][gRenderHQ])
  307. {
  308. case 1: distancetxt = 100;
  309. case 2: distancetxt = 150;
  310. case 3: distancetxt = 200;
  311. default: distancetxt = 60;
  312. }
  313. format(string,sizeof(string),"|___________ Gate Status (ID: %d) ___________|", gateid);
  314. SendClientMessageEx(playerid, COLOR_GREEN, string);
  315. format(string, sizeof(string), "X: %f | Y: %f | Z: %f | RotX: %f | RotY: %f | RotZ: %f", GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  316. SendClientMessageEx(playerid, COLOR_WHITE, string);
  317. format(string, sizeof(string), "XM: %f | YM: %f | ZM: %f | RotXM: %f | RotYM: %f | RotZM: %f", GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM], GateInfo[gateid][gRotXM], GateInfo[gateid][gRotYM], GateInfo[gateid][gRotZM]);
  318. SendClientMessageEx(playerid, COLOR_WHITE, string);
  319. format(string, sizeof(string), "Model: %d | HID: %d | VW: %d | Int: %d | Allegiance: %d | Group Type: %d | Group: %d", GateInfo[gateid][gModel], GateInfo[gateid][gHID], GateInfo[gateid][gVW], GateInfo[gateid][gInt], GateInfo[gateid][gAllegiance], GateInfo[gateid][gGroupType], GateInfo[gateid][gGroupID]);
  320. SendClientMessageEx(playerid, COLOR_WHITE, string);
  321. format(string, sizeof(string), "Range: %.3f | Speed: %.3f | Timer: %d second(s) | Stream: %d | Automated: %d | Locked: %d | Pass: %s", GateInfo[gateid][gRange], GateInfo[gateid][gSpeed], timertxt, distancetxt, GateInfo[gateid][gAutomate], GateInfo[gateid][gLocked], GateInfo[gateid][gPass]);
  322. SendClientMessageEx(playerid, COLOR_WHITE, string);
  323. format(string, sizeof(string), "Assigned Facility: %d", GateInfo[gateid][gFacility]);
  324. SendClientMessageEx(playerid, COLOR_WHITE, string);
  325. if(GateInfo[gateid][gTModel] != INVALID_OBJECT_ID)
  326. {
  327. format(string, sizeof(string), "Texture Replacement - Index: %d | Model: %d | TXD File: %s | Texture: %s | Color: %x", GateInfo[gateid][gTIndex], GateInfo[gateid][gTModel], GateInfo[gateid][gTTXD], GateInfo[gateid][gTTexture], GateInfo[gateid][gTColor]);
  328. SendClientMessageEx(playerid, COLOR_WHITE, string);
  329. }
  330. }
  331. else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  332. return 1;
  333. }
  334. CMD:gnear(playerid, params[])
  335. {
  336. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  337. {
  338. new option;
  339. if(!sscanf(params, "d", option))
  340. {
  341. new string[64];
  342. format(string, sizeof(string), "* Listing all gates within 30 meters of you in VW %d...", option);
  343. SendClientMessageEx(playerid, COLOR_RED, string);
  344. for(new i, Float: fGatePos[3], szMessage[48]; i < MAX_GATES; i++)
  345. {
  346. GetDynamicObjectPos(GateInfo[i][gGATE], fGatePos[0], fGatePos[1], fGatePos[2]);
  347. if(option == -1)
  348. {
  349. if(IsPlayerInRangeOfPoint(playerid, 30, fGatePos[0], fGatePos[1], fGatePos[2]))
  350. {
  351. if(GateInfo[i][gModel] != 0 && GateInfo[i][gModel] != 18631)
  352. {
  353. format(szMessage, sizeof(szMessage), "Gate ID %d (VW: %d) | %f from you", i, GateInfo[i][gVW], GetPlayerDistanceFromPoint(playerid, fGatePos[0], fGatePos[1], fGatePos[2]));
  354. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  355. }
  356. }
  357. }
  358. else
  359. {
  360. if(IsPlayerInRangeOfPoint(playerid, 30, fGatePos[0], fGatePos[1], fGatePos[2]) && GateInfo[i][gVW] == option)
  361. {
  362. if(GateInfo[i][gModel] != 0 && GateInfo[i][gModel] != 18631)
  363. {
  364. format(szMessage, sizeof(szMessage), "Gate ID %d (VW: %d) | %f from you", i, GateInfo[i][gVW], GetPlayerDistanceFromPoint(playerid, fGatePos[0], fGatePos[1], fGatePos[2]));
  365. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  366. }
  367. }
  368. }
  369. }
  370. }
  371. else
  372. {
  373. SendClientMessageEx(playerid, COLOR_RED, "* Listing all gates within 30 meters of you...");
  374. for(new i, Float: fGatePos[3], szMessage[48]; i < MAX_GATES; i++)
  375. {
  376. GetDynamicObjectPos(GateInfo[i][gGATE], fGatePos[0], fGatePos[1], fGatePos[2]);
  377. if(IsPlayerInRangeOfPoint(playerid, 30, fGatePos[0], fGatePos[1], fGatePos[2]) && GateInfo[i][gVW] == GetPlayerVirtualWorld(playerid))
  378. {
  379. if(GateInfo[i][gModel] != 0 && GateInfo[i][gModel] != 18631)
  380. {
  381. format(szMessage, sizeof(szMessage), "Gate ID %d (VW: %d) | %f from you", i, GateInfo[i][gVW], GetPlayerDistanceFromPoint(playerid, fGatePos[0], fGatePos[1], fGatePos[2]));
  382. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  383. }
  384. }
  385. }
  386. }
  387. }
  388. else
  389. {
  390. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  391. }
  392. return 1;
  393. }
  394. CMD:gnext(playerid, params[])
  395. {
  396. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  397. {
  398. SendClientMessageEx(playerid, COLOR_RED, "* Listing next available gate...");
  399. for(new x;x<MAX_GATES;x++)
  400. {
  401. if(GateInfo[x][gModel] == 0)
  402. {
  403. new string[128];
  404. format(string, sizeof(string), "%d is available to use.", x);
  405. SendClientMessageEx(playerid, COLOR_WHITE, string);
  406. break;
  407. }
  408. }
  409. }
  410. else
  411. {
  412. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  413. return 1;
  414. }
  415. return 1;
  416. }
  417. CMD:gedit(playerid, params[])
  418. {
  419. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  420. {
  421. new x_job[128], gateid, Float:ofloat, string[128];
  422. if(sscanf(params, "s[128]iF", x_job, gateid, ofloat))
  423. {
  424. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gedit [name] [gateid] [value]");
  425. SendClientMessageEx(playerid, COLOR_GREY, "Available names: HID, Model, VW, Int, Open, Closed, PosX(M), PosY(M), PosZ(M), RotX(M), RotZ(M), ToMe(M)");
  426. SendClientMessageEx(playerid, COLOR_GREY, "Available names: Range, Speed, Allegiance, GroupType, GroupID, Stream, Timer, Facility");
  427. return 1;
  428. }
  429. if(strcmp(x_job, "hid", true) == 0)
  430. {
  431. new value = floatround(ofloat, floatround_round);
  432. if(value > MAX_HOUSES) return SendClientMessageEx(playerid, COLOR_WHITE, "* Invalid House ID!");
  433. GateInfo[gateid][gHID] = value;
  434. format(string, sizeof(string), "HID %d assigned to Gate %d", GateInfo[gateid][gHID], gateid);
  435. SendClientMessageEx(playerid, COLOR_WHITE, string);
  436. SaveGate(gateid);
  437. format(string, sizeof(string), "%s has edited GateID %d's House ID to %d.", GetPlayerNameEx(playerid), gateid, value);
  438. Log("logs/gedit.log", string);
  439. }
  440. else if(strcmp(x_job, "model", true) == 0)
  441. {
  442. new value = floatround(ofloat, floatround_round);
  443. if(value == 0)
  444. {
  445. GateInfo[gateid][gHID] = INVALID_HOUSE_ID;
  446. GateInfo[gateid][gPosX] = 0.0;
  447. GateInfo[gateid][gPosY] = 0.0;
  448. GateInfo[gateid][gPosZ] = 0.0;
  449. GateInfo[gateid][gRotX] = 0.0;
  450. GateInfo[gateid][gRotY] = 0.0;
  451. GateInfo[gateid][gRotZ] = 0.0;
  452. GateInfo[gateid][gPosXM] = 0.0;
  453. GateInfo[gateid][gPosYM] = 0.0;
  454. GateInfo[gateid][gPosZM] = 0.0;
  455. GateInfo[gateid][gRotXM] = 0.0;
  456. GateInfo[gateid][gRotYM] = 0.0;
  457. GateInfo[gateid][gRotZM] = 0.0;
  458. GateInfo[gateid][gVW] = 0;
  459. GateInfo[gateid][gInt] = 0;
  460. GateInfo[gateid][gAllegiance] = 0;
  461. GateInfo[gateid][gGroupType] = 0;
  462. GateInfo[gateid][gGroupID] = INVALID_GROUP_ID;
  463. }
  464. GateInfo[gateid][gModel] = value;
  465. format(string, sizeof(string), "Model %d assigned to Gate %d", GateInfo[gateid][gModel], gateid);
  466. CreateGate(gateid);
  467. SendClientMessageEx(playerid, COLOR_WHITE, string);
  468. SaveGate(gateid);
  469. format(string, sizeof(string), "%s has edited GateID %d's Model to %d.", GetPlayerNameEx(playerid), gateid, value);
  470. Log("logs/gedit.log", string);
  471. }
  472. else if(strcmp(x_job, "vw", true) == 0)
  473. {
  474. new value = floatround(ofloat, floatround_round);
  475. GateInfo[gateid][gVW] = value;
  476. format(string, sizeof(string), "Virtual World %d assigned to Gate %d", GateInfo[gateid][gVW], gateid);
  477. CreateGate(gateid);
  478. SendClientMessageEx(playerid, COLOR_WHITE, string);
  479. SaveGate(gateid);
  480. format(string, sizeof(string), "%s has edited GateID %d's VW to %d.", GetPlayerNameEx(playerid), gateid, value);
  481. Log("logs/gedit.log", string);
  482. }
  483. else if(strcmp(x_job, "int", true) == 0)
  484. {
  485. new value = floatround(ofloat, floatround_round);
  486. GateInfo[gateid][gInt] = value;
  487. format(string, sizeof(string), "Interior %d assigned to Gate %d", GateInfo[gateid][gInt], gateid);
  488. CreateGate(gateid);
  489. SendClientMessageEx(playerid, COLOR_WHITE, string);
  490. SaveGate(gateid);
  491. format(string, sizeof(string), "%s has edited GateID %d's InteriorID to %d.", GetPlayerNameEx(playerid), gateid, value);
  492. Log("logs/gedit.log", string);
  493. }
  494. else if(strcmp(x_job, "open", true) == 0)
  495. {
  496. foreach(new i:Player)
  497. {
  498. if(GetPVarInt(i, "EditingGateID") == gateid && i != playerid)
  499. {
  500. format(string, sizeof(string), "ERROR: %s (ID: %d) is currently editing this gate.", GetPlayerNameEx(i), i);
  501. return SendClientMessageEx(playerid, COLOR_WHITE, string);
  502. }
  503. }
  504. SetPVarInt(playerid, "gEdit", 1);
  505. SetPVarInt(playerid, "EditingGateID", gateid);
  506. SetDynamicObjectPos(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
  507. SetDynamicObjectRot(GateInfo[gateid][gGATE], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  508. EditDynamicObject(playerid, GateInfo[gateid][gGATE]);
  509. format(string, sizeof(string), "You are now editing the open position of Gate %d.", gateid);
  510. SendClientMessage(playerid, COLOR_WHITE, string);
  511. SendClientMessage(playerid, 0xFFFFAAAA, "HINT: Hold {8000FF}~k~~PED_SPRINT~ {FFFFAA}to move your camera, press escape to cancel");
  512. }
  513. else if(strcmp(x_job, "closed", true) == 0)
  514. {
  515. foreach(new i:Player)
  516. {
  517. if(GetPVarInt(i, "EditingGateID") == gateid && i != playerid)
  518. {
  519. format(string, sizeof(string), "ERROR: %s (ID: %d) is currently editing this gate.", GetPlayerNameEx(i), i);
  520. return SendClientMessageEx(playerid, COLOR_WHITE, string);
  521. }
  522. }
  523. SetPVarInt(playerid, "gEdit", 2);
  524. SetPVarInt(playerid, "EditingGateID", gateid);
  525. EditDynamicObject(playerid, GateInfo[gateid][gGATE]);
  526. format(string, sizeof(string), "You are now editing the closed position of Gate %d.", gateid);
  527. SendClientMessage(playerid, COLOR_WHITE, string);
  528. SendClientMessage(playerid, 0xFFFFAAAA, "HINT: Hold {8000FF}~k~~PED_SPRINT~ {FFFFAA}to move your camera, press escape to cancel");
  529. }
  530. else if(strcmp(x_job, "range", true) == 0)
  531. {
  532. GateInfo[gateid][gRange] = ofloat;
  533. format(string, sizeof(string), "Range of %.3f assigned to Gate %d", GateInfo[gateid][gRange], gateid);
  534. SendClientMessageEx(playerid, COLOR_WHITE, string);
  535. SaveGate(gateid);
  536. format(string, sizeof(string), "%s has edited GateID %d's Range to %.3f.", GetPlayerNameEx(playerid), gateid, ofloat);
  537. Log("logs/gedit.log", string);
  538. }
  539. else if(strcmp(x_job, "speed", true) == 0)
  540. {
  541. GateInfo[gateid][gSpeed] = ofloat;
  542. format(string, sizeof(string), "Speed of %.3f assigned to Gate %d", GateInfo[gateid][gSpeed], gateid);
  543. SendClientMessageEx(playerid, COLOR_WHITE, string);
  544. SaveGate(gateid);
  545. format(string, sizeof(string), "%s has edited GateID %d's Speed to %.3f.", GetPlayerNameEx(playerid), gateid, ofloat);
  546. Log("logs/gedit.log", string);
  547. }
  548. else if(strcmp(x_job, "posx", true) == 0)
  549. {
  550. GateInfo[gateid][gPosX] = ofloat;
  551. format(string, sizeof(string), "PosX %f assigned to Gate %d", GateInfo[gateid][gPosX], gateid);
  552. SetDynamicObjectPos(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
  553. SendClientMessageEx(playerid, COLOR_WHITE, string);
  554. SaveGate(gateid);
  555. }
  556. else if(strcmp(x_job, "posy", true) == 0)
  557. {
  558. GateInfo[gateid][gPosY] = ofloat;
  559. format(string, sizeof(string), "PosY %f assigned to Gate %d", GateInfo[gateid][gPosY], gateid);
  560. SetDynamicObjectPos(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
  561. SendClientMessageEx(playerid, COLOR_WHITE, string);
  562. SaveGate(gateid);
  563. }
  564. else if(strcmp(x_job, "posz", true) == 0)
  565. {
  566. GateInfo[gateid][gPosZ] = ofloat;
  567. format(string, sizeof(string), "PosZ %f assigned to Gate %d", GateInfo[gateid][gPosZ], gateid);
  568. SetDynamicObjectPos(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
  569. SendClientMessageEx(playerid, COLOR_WHITE, string);
  570. SaveGate(gateid);
  571. }
  572. else if(strcmp(x_job, "posxm", true) == 0)
  573. {
  574. GateInfo[gateid][gPosXM] = ofloat;
  575. format(string, sizeof(string), "PosXM %f assigned to Gate %d", GateInfo[gateid][gPosXM], gateid);
  576. SendClientMessageEx(playerid, COLOR_WHITE, string);
  577. SaveGate(gateid);
  578. }
  579. else if(strcmp(x_job, "posym", true) == 0)
  580. {
  581. GateInfo[gateid][gPosYM] = ofloat;
  582. format(string, sizeof(string), "PosYM %f assigned to Gate %d", GateInfo[gateid][gPosYM], gateid);
  583. SendClientMessageEx(playerid, COLOR_WHITE, string);
  584. SaveGate(gateid);
  585. }
  586. else if(strcmp(x_job, "poszm", true) == 0)
  587. {
  588. GateInfo[gateid][gPosZM] = ofloat;
  589. format(string, sizeof(string), "PosZM %f assigned to Gate %d", GateInfo[gateid][gPosZM], gateid);
  590. SendClientMessageEx(playerid, COLOR_WHITE, string);
  591. SaveGate(gateid);
  592. }
  593. else if(strcmp(x_job, "rotx", true) == 0)
  594. {
  595. GateInfo[gateid][gRotX] = ofloat;
  596. format(string, sizeof(string), "RotX %f assigned to Gate %d", GateInfo[gateid][gRotX], gateid);
  597. SetDynamicObjectRot(GateInfo[gateid][gGATE], GateInfo[gateid][gRotX],GateInfo[gateid][gRotY],GateInfo[gateid][gRotZ]);
  598. SendClientMessageEx(playerid, COLOR_WHITE, string);
  599. SaveGate(gateid);
  600. }
  601. else if(strcmp(x_job, "roty", true) == 0)
  602. {
  603. GateInfo[gateid][gRotY] = ofloat;
  604. format(string, sizeof(string), "RotY %f assigned to Gate %d", GateInfo[gateid][gRotY], gateid);
  605. SetDynamicObjectRot(GateInfo[gateid][gGATE], GateInfo[gateid][gRotX],GateInfo[gateid][gRotY],GateInfo[gateid][gRotZ]);
  606. SendClientMessageEx(playerid, COLOR_WHITE, string);
  607. SaveGate(gateid);
  608. }
  609. else if(strcmp(x_job, "rotz", true) == 0)
  610. {
  611. GateInfo[gateid][gRotZ] = ofloat;
  612. format(string, sizeof(string), "RotZ %f assigned to Gate %d", GateInfo[gateid][gRotZ], gateid);
  613. SetDynamicObjectRot(GateInfo[gateid][gGATE], GateInfo[gateid][gRotX],GateInfo[gateid][gRotY],GateInfo[gateid][gRotZ]);
  614. SendClientMessageEx(playerid, COLOR_WHITE, string);
  615. SaveGate(gateid);
  616. }
  617. else if(strcmp(x_job, "rotxm", true) == 0)
  618. {
  619. GateInfo[gateid][gRotXM] = ofloat;
  620. format(string, sizeof(string), "RotXM %f assigned to Gate %d", GateInfo[gateid][gRotXM], gateid);
  621. SendClientMessageEx(playerid, COLOR_WHITE, string);
  622. SaveGate(gateid);
  623. }
  624. else if(strcmp(x_job, "rotym", true) == 0)
  625. {
  626. GateInfo[gateid][gRotYM] = ofloat;
  627. format(string, sizeof(string), "RotYM %f assigned to Gate %d", GateInfo[gateid][gRotYM], gateid);
  628. SendClientMessageEx(playerid, COLOR_WHITE, string);
  629. SaveGate(gateid);
  630. }
  631. else if(strcmp(x_job, "rotzm", true) == 0)
  632. {
  633. GateInfo[gateid][gRotZM] = ofloat;
  634. format(string, sizeof(string), "RotZM %f assigned to Gate %d", GateInfo[gateid][gRotZM], gateid);
  635. SendClientMessageEx(playerid, COLOR_WHITE, string);
  636. SaveGate(gateid);
  637. }
  638. else if(strcmp(x_job, "tome", true) == 0)
  639. {
  640. GetPlayerPos(playerid,GateInfo[gateid][gPosX],GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
  641. GateInfo[gateid][gVW] = GetPlayerVirtualWorld(playerid);
  642. GateInfo[gateid][gInt] = GetPlayerInterior(playerid);
  643. format(string, sizeof(string), "Gate %d Pos moved to %f %f %f, VW: %d INT: %d", gateid, GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt]);
  644. SendClientMessageEx(playerid, COLOR_WHITE, string);
  645. if(GateInfo[gateid][gModel] == 0)
  646. {
  647. GateInfo[gateid][gModel] = 18631;
  648. GateInfo[gateid][gRange] = 10;
  649. GateInfo[gateid][gSpeed] = 5.0;
  650. }
  651. CreateGate(gateid);
  652. SaveGate(gateid);
  653. format(string, sizeof(string), "%s has edited GateID %d's Position.", GetPlayerNameEx(playerid), gateid);
  654. Log("logs/gedit.log", string);
  655. }
  656. else if(strcmp(x_job, "tomem", true) == 0)
  657. {
  658. GetPlayerPos(playerid,GateInfo[gateid][gPosXM],GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM]);
  659. format(string, sizeof(string), "Gate %d PosM moved to %f %f %f", gateid, GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM]);
  660. SendClientMessageEx(playerid, COLOR_WHITE, string);
  661. SaveGate(gateid);
  662. format(string, sizeof(string), "%s has edited GateID %d's Moved Position.", GetPlayerNameEx(playerid), gateid);
  663. Log("logs/gedit.log", string);
  664. }
  665. else if(strcmp(x_job, "allegiance", true) == 0)
  666. {
  667. new value = floatround(ofloat, floatround_round);
  668. GateInfo[gateid][gAllegiance] = value;
  669. format(string, sizeof(string), "Allegiance %d assigned to Gate %d", GateInfo[gateid][gAllegiance], gateid);
  670. SendClientMessageEx(playerid, COLOR_WHITE, string);
  671. SaveGate(gateid);
  672. format(string, sizeof(string), "%s has edited GateID %d's Allegiance to %d.", GetPlayerNameEx(playerid), gateid, value);
  673. Log("logs/gedit.log", string);
  674. }
  675. else if(strcmp(x_job, "grouptype", true) == 0)
  676. {
  677. new value = floatround(ofloat, floatround_round);
  678. GateInfo[gateid][gGroupType] = value;
  679. format(string, sizeof(string), "Group Type %d assigned to Gate %d", GateInfo[gateid][gGroupType], gateid);
  680. SendClientMessageEx(playerid, COLOR_WHITE, string);
  681. SaveGate(gateid);
  682. format(string, sizeof(string), "%s has edited GateID %d's Group Type to %d.", GetPlayerNameEx(playerid), gateid, value);
  683. Log("logs/gedit.log", string);
  684. }
  685. else if(strcmp(x_job, "groupid", true) == 0)
  686. {
  687. new value = floatround(ofloat, floatround_round);
  688. GateInfo[gateid][gGroupID] = value;
  689. format(string, sizeof(string), "Group ID %d assigned to Gate %d", GateInfo[gateid][gGroupID], gateid);
  690. SendClientMessageEx(playerid, COLOR_WHITE, string);
  691. SaveGate(gateid);
  692. format(string, sizeof(string), "%s has edited GateID %d's Group ID to %d.", GetPlayerNameEx(playerid), gateid, value);
  693. Log("logs/gedit.log", string);
  694. }
  695. else if(strcmp(x_job, "stream", true) == 0)
  696. {
  697. new value = floatround(ofloat, floatround_round);
  698. GateInfo[gateid][gRenderHQ] = value;
  699. format(string, sizeof(string), "Stream distance %d assigned to Gate %d", GateInfo[gateid][gRenderHQ], gateid);
  700. CreateGate(gateid);
  701. SendClientMessageEx(playerid, COLOR_WHITE, string);
  702. SaveGate(gateid);
  703. format(string, sizeof(string), "%s has edited GateID %d's stream distance to %d.", GetPlayerNameEx(playerid), gateid, value);
  704. Log("logs/gedit.log", string);
  705. }
  706. else if(strcmp(x_job, "timer", true) == 0)
  707. {
  708. new value = floatround(ofloat, floatround_round);
  709. GateInfo[gateid][gTimer] = value;
  710. format(string, sizeof(string), "Timer %d assigned to Gate %d", GateInfo[gateid][gTimer], gateid);
  711. SendClientMessageEx(playerid, COLOR_WHITE, string);
  712. SaveGate(gateid);
  713. format(string, sizeof(string), "%s has edited GateID %d's timer to %d.", GetPlayerNameEx(playerid), gateid, value);
  714. Log("logs/gedit.log", string);
  715. }
  716. else if(strcmp(x_job, "facility", true) == 0)
  717. {
  718. new value = floatround(ofloat, floatround_round);
  719. if(!(0 <= value < MAX_CRATE_FACILITY)) return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid facility ID.");
  720. GateInfo[gateid][gFacility] = value;
  721. format(string, sizeof(string), "Facility %d assigned to Gate %d", value, gateid);
  722. SendClientMessageEx(playerid, COLOR_WHITE, string);
  723. SaveGate(gateid);
  724. format(string, sizeof(string), "%s has edited GateID %d's assigned facility to %d.", GetPlayerNameEx(playerid), gateid, value);
  725. Log("logs/gedit.log", string);
  726. }
  727. }
  728. else
  729. {
  730. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  731. return 1;
  732. }
  733. return 1;
  734. }
  735. CMD:gedittexture(playerid, params[])
  736. {
  737. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  738. {
  739. new gateid, option[16], var[64], string[128];
  740. if(sscanf(params, "is[16]s[64]", gateid, option, var))
  741. {
  742. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gedittexture [gateid] [name] [value]");
  743. SendClientMessageEx(playerid, COLOR_GREY, "Available names: Index, Model, TXD, Texture, Color, Delete");
  744. return 1;
  745. }
  746. if(strcmp(option, "index", true) == 0)
  747. {
  748. new value = strval(var);
  749. GateInfo[gateid][gTIndex] = value;
  750. format(string, sizeof(string), "Texture index %d assigned to Gate %d", GateInfo[gateid][gTIndex], gateid);
  751. SendClientMessageEx(playerid, COLOR_WHITE, string);
  752. SaveGate(gateid);
  753. format(string, sizeof(string), "%s has edited GateID %d's texture index to %d.", GetPlayerNameEx(playerid), gateid, value);
  754. Log("logs/gedit.log", string);
  755. }
  756. else if(strcmp(option, "model", true) == 0)
  757. {
  758. new value = strval(var);
  759. GateInfo[gateid][gTModel] = value;
  760. format(string, sizeof(string), "Texture model %d assigned to Gate %d", GateInfo[gateid][gTModel], gateid);
  761. SendClientMessageEx(playerid, COLOR_WHITE, string);
  762. SaveGate(gateid);
  763. CreateGate(gateid);
  764. format(string, sizeof(string), "%s has edited GateID %d's texture model to %d.", GetPlayerNameEx(playerid), gateid, value);
  765. Log("logs/gedit.log", string);
  766. }
  767. else if(strcmp(option, "txd", true) == 0)
  768. {
  769. format(GateInfo[gateid][gTTXD], 64, "%s", var);
  770. format(string, sizeof(string), "TXD file %s assigned to Gate %d", GateInfo[gateid][gTTXD], gateid);
  771. SendClientMessageEx(playerid, COLOR_WHITE, string);
  772. SaveGate(gateid);
  773. format(string, sizeof(string), "%s has edited GateID %d's TXD file to %s.", GetPlayerNameEx(playerid), gateid, var);
  774. Log("logs/gedit.log", string);
  775. }
  776. else if(strcmp(option, "texture", true) == 0)
  777. {
  778. format(GateInfo[gateid][gTTexture], 64, "%s", var);
  779. format(string, sizeof(string), "Texture %s assigned to Gate %d", GateInfo[gateid][gTTexture], gateid);
  780. SendClientMessageEx(playerid, COLOR_WHITE, string);
  781. SaveGate(gateid);
  782. format(string, sizeof(string), "%s has edited GateID %d's texture to %s.", GetPlayerNameEx(playerid), gateid, var);
  783. Log("logs/gedit.log", string);
  784. }
  785. else if(strcmp(option, "color", true) == 0)
  786. {
  787. if(strlen(var) > 6 || !ishex(var)) return SendClientMessageEx(playerid, COLOR_GREY, "Color must be a valid hexadecimal color (ie: BCA3FF)");
  788. new value;
  789. sscanf(var, "h", value);
  790. GateInfo[gateid][gTColor] = value;
  791. format(string, sizeof(string), "Material color %d assigned to Gate %d", GateInfo[gateid][gTColor], gateid);
  792. SendClientMessageEx(playerid, COLOR_WHITE, string);
  793. SaveGate(gateid);
  794. format(string, sizeof(string), "%s has edited GateID %d's material color to %d.", GetPlayerNameEx(playerid), gateid, value);
  795. Log("logs/gedit.log", string);
  796. }
  797. if(strcmp(option, "delete", true) == 0)
  798. {
  799. GateInfo[gateid][gTIndex] = -1;
  800. GateInfo[gateid][gTModel] = INVALID_OBJECT_ID;
  801. GateInfo[gateid][gTTXD] = EOS;
  802. GateInfo[gateid][gTTexture] = EOS;
  803. GateInfo[gateid][gTColor] = 0;
  804. format(string, sizeof(string), "Texture removed from Gate %d", gateid);
  805. SendClientMessageEx(playerid, COLOR_WHITE, string);
  806. SaveGate(gateid);
  807. CreateGate(gateid);
  808. format(string, sizeof(string), "%s has removed GateID %d's texture.", GetPlayerNameEx(playerid), gateid);
  809. Log("logs/gedit.log", string);
  810. }
  811. }
  812. else return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  813. return 1;
  814. }
  815. CMD:listgates(playerid, params[])
  816. {
  817. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  818. new hid, string[128];
  819. if(sscanf(params, "d", hid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /listgates [houseid]");
  820. if(hid <= 0 || hid >= MAX_HOUSES)
  821. {
  822. format(string, sizeof(string), "House ID must be between 1 and %d.", MAX_HOUSES - 1);
  823. return SendClientMessageEx(playerid, COLOR_GREY, string);
  824. }
  825. format(string, sizeof(string), "Listing gates linked to house id: %d", hid);
  826. SendClientMessageEx(playerid, COLOR_WHITE, string);
  827. for(new i = 0; i < MAX_GATES; i++)
  828. {
  829. if(GateInfo[i][gHID] == hid)
  830. {
  831. format(string, sizeof(string), "- %d", i);
  832. SendClientMessageEx(playerid, COLOR_GREY, string);
  833. }
  834. }
  835. return 1;
  836. }
  837. CMD:gmove(playerid, params[])
  838. {
  839. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command.");
  840. new gateid, giveplayerid, fee, minfee;
  841. if(sscanf(params, "dudd", gateid, giveplayerid, fee, minfee))
  842. {
  843. SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gmove <Choice> <GateID> <playerid> <Fine (Percent)> <min. fine>");
  844. SendClientMessageEx(playerid, COLOR_GREY, "NOTE: Set fine as 0 if you don't want to fine this player.");
  845. return 1;
  846. }
  847. new string[128];
  848. new totalwealth = PlayerInfo[giveplayerid][pAccount] + GetPlayerCash(giveplayerid);
  849. if(PlayerInfo[giveplayerid][pPhousekey] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[giveplayerid][pPhousekey]][hOwnerID] == GetPlayerSQLId(giveplayerid)) totalwealth += HouseInfo[PlayerInfo[giveplayerid][pPhousekey]][hSafeMoney];
  850. if(PlayerInfo[giveplayerid][pPhousekey2] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[giveplayerid][pPhousekey2]][hOwnerID] == GetPlayerSQLId(giveplayerid)) totalwealth += HouseInfo[PlayerInfo[giveplayerid][pPhousekey2]][hSafeMoney];
  851. if(PlayerInfo[giveplayerid][pPhousekey3] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[giveplayerid][pPhousekey3]][hOwnerID] == GetPlayerSQLId(giveplayerid)) totalwealth += HouseInfo[PlayerInfo[giveplayerid][pPhousekey3]][hSafeMoney];
  852. if(fee > 0)
  853. {
  854. fee = totalwealth / 100 * fee;
  855. if(PlayerInfo[giveplayerid][pDonateRank] == 3)
  856. {
  857. fee = fee / 100 * 95;
  858. }
  859. if(PlayerInfo[giveplayerid][pDonateRank] >= 4)
  860. {
  861. fee = fee / 100 * 85;
  862. }
  863. }
  864. GetPlayerPos(playerid,GateInfo[gateid][gPosX],GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
  865. GateInfo[gateid][gVW] = GetPlayerVirtualWorld(playerid);
  866. GateInfo[gateid][gInt] = GetPlayerInterior(playerid);
  867. format(string, sizeof(string), "Gate %d Pos moved to %f %f %f, VW: %d INT: %d", gateid, GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt]);
  868. SendClientMessageEx(playerid, COLOR_WHITE, string);
  869. if(GateInfo[gateid][gModel] == 0)
  870. {
  871. GateInfo[gateid][gModel] = 18631;
  872. GateInfo[gateid][gRange] = 10;
  873. GateInfo[gateid][gSpeed] = 5.0;
  874. }
  875. CreateGate(gateid);
  876. SaveGate(gateid);
  877. format(string, sizeof(string), "%s has edited GateID %d's Position.", GetPlayerNameEx(playerid), gateid);
  878. Log("logs/gedit.log", string);
  879. if(minfee > fee && minfee > 0)
  880. {
  881. GivePlayerCashEx(giveplayerid, TYPE_ONHAND, -minfee);
  882. format(string, sizeof(string), "AdmCmd: %s(%d) was fined $%s by %s, reason: Dynamic Door Move", GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), number_format(minfee), GetPlayerNameEx(playerid));
  883. Log("logs/admin.log", string);
  884. format(string, sizeof(string), "AdmCmd: %s was fined $%s by %s, reason: Dynamic Door Move", GetPlayerNameEx(giveplayerid), number_format(minfee), GetPlayerNameEx(playerid));
  885. SendClientMessageToAllEx(COLOR_LIGHTRED, string);
  886. }
  887. else if(fee > 0)
  888. {
  889. GivePlayerCashEx(giveplayerid, TYPE_ONHAND, -fee);
  890. format(string, sizeof(string), "AdmCmd: %s(%d) was fined $%s by %s, reason: Dynamic Door Move", GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), number_format(fee), GetPlayerNameEx(playerid));
  891. Log("logs/admin.log", string);
  892. format(string, sizeof(string), "AdmCmd: %s was fined $%s by %s, reason: Dynamic Door Move", GetPlayerNameEx(giveplayerid), number_format(fee), GetPlayerNameEx(playerid));
  893. SendClientMessageToAllEx(COLOR_LIGHTRED, string);
  894. }
  895. return 1;
  896. }
  897. CMD:reloadgate(playerid, params[])
  898. {
  899. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  900. new gateid, string[128];
  901. if(sscanf(params, "d", gateid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /reloadgate <gateid>");
  902. CreateGate(gateid);
  903. format(string, sizeof(string), "Reloading Gate ID %d...", gateid);
  904. SendClientMessageEx(playerid, COLOR_WHITE, string);
  905. return 1;
  906. }
  907. CreateGate(gateid) {
  908. if(IsValidDynamicObject(GateInfo[gateid][gGATE])) DestroyDynamicObject(GateInfo[gateid][gGATE]);
  909. GateInfo[gateid][gGATE] = -1;
  910. if(GateInfo[gateid][gPosX] == 0.0) return 1;
  911. switch(GateInfo[gateid][gRenderHQ])
  912. {
  913. case 1: GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1, 100.0);
  914. case 2: GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1, 150.0);
  915. case 3: GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1, 200.0);
  916. default: GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1, 60.0);
  917. }
  918. if(GateInfo[gateid][gTModel] != INVALID_OBJECT_ID) SetDynamicObjectMaterial(GateInfo[gateid][gGATE], GateInfo[gateid][gTIndex], GateInfo[gateid][gTModel], GateInfo[gateid][gTTXD], GateInfo[gateid][gTTexture], GateInfo[gateid][gTColor]);
  919. return 1;
  920. }
  921. stock LoadGates()
  922. {
  923. printf("[LoadGates] Loading data from database...");
  924. mysql_tquery(MainPipeline, "SELECT * FROM `gates`", "OnLoadGates", "");
  925. }
  926. forward OnLoadGates();
  927. public OnLoadGates()
  928. {
  929. new i, rows;
  930. cache_get_row_count(rows);
  931. while(i < rows)
  932. {
  933. cache_get_value_name_int(i, "HID", GateInfo[i][gHID]);
  934. cache_get_value_name_float(i, "Speed", GateInfo[i][gSpeed]);
  935. cache_get_value_name_float(i, "Range", GateInfo[i][gRange]);
  936. cache_get_value_name_int(i, "Model", GateInfo[i][gModel]);
  937. cache_get_value_name_int(i, "VW", GateInfo[i][gVW]);
  938. cache_get_value_name_int(i, "Int", GateInfo[i][gInt]);
  939. cache_get_value_name(i, "Pass", GateInfo[i][gPass], 24);
  940. cache_get_value_name_float(i, "PosX", GateInfo[i][gPosX]);
  941. cache_get_value_name_float(i, "PosY", GateInfo[i][gPosY]);
  942. cache_get_value_name_float(i, "PosZ", GateInfo[i][gPosZ]);
  943. cache_get_value_name_float(i, "RotX", GateInfo[i][gRotX]);
  944. cache_get_value_name_float(i, "RotY", GateInfo[i][gRotY]);
  945. cache_get_value_name_float(i, "RotZ", GateInfo[i][gRotZ]);
  946. cache_get_value_name_float(i, "PosXM", GateInfo[i][gPosXM]);
  947. cache_get_value_name_float(i, "PosYM", GateInfo[i][gPosYM]);
  948. cache_get_value_name_float(i, "PosZM", GateInfo[i][gPosZM]);
  949. cache_get_value_name_float(i, "RotXM", GateInfo[i][gRotXM]);
  950. cache_get_value_name_float(i, "RotYM", GateInfo[i][gRotYM]);
  951. cache_get_value_name_float(i, "RotZM", GateInfo[i][gRotZM]);
  952. cache_get_value_name_int(i, "Allegiance", GateInfo[i][gAllegiance]);
  953. cache_get_value_name_int(i, "GroupType", GateInfo[i][gGroupType]);
  954. cache_get_value_name_int(i, "GroupID", GateInfo[i][gGroupID]);
  955. cache_get_value_name_int(i, "RenderHQ", GateInfo[i][gRenderHQ]);
  956. cache_get_value_name_int(i, "Timer", GateInfo[i][gTimer]);
  957. cache_get_value_name_int(i, "Automate", GateInfo[i][gAutomate]);
  958. cache_get_value_name_int(i, "Locked", GateInfo[i][gLocked]);
  959. cache_get_value_name_int(i, "TIndex", GateInfo[i][gTIndex]);
  960. cache_get_value_name_int(i, "TModel", GateInfo[i][gTModel]);
  961. cache_get_value_name(i, "TTXD", GateInfo[i][gTTXD], 64);
  962. cache_get_value_name(i, "TTexture", GateInfo[i][gTTexture], 64);
  963. cache_get_value_name_int(i, "TColor", GateInfo[i][gTColor]);
  964. cache_get_value_name_int(i, "Facility", GateInfo[i][gFacility]);
  965. if(GateInfo[i][gPosX] != 0.0) CreateGate(i);
  966. i++;
  967. }
  968. }
  969. stock SaveGate(id) {
  970. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `gates` SET \
  971. `HID`=%d, \
  972. `Speed`=%f, \
  973. `Range`=%f, \
  974. `Model`=%d, \
  975. `VW`=%d, \
  976. `Int`=%d, \
  977. `Pass`='%e', \
  978. `PosX`=%f, \
  979. `PosY`=%f, \
  980. `PosZ`=%f, \
  981. `RotX`=%f, \
  982. `RotY`=%f, \
  983. `RotZ`=%f, \
  984. `PosXM`=%f, \
  985. `PosYM`=%f, \
  986. `PosZM`=%f, \
  987. `RotXM`=%f, \
  988. `RotYM`=%f, \
  989. `RotZM`=%f, \
  990. `Allegiance`=%d, \
  991. `GroupType`=%d, \
  992. `GroupID`=%d, \
  993. `RenderHQ`=%d, \
  994. `Timer`=%d, \
  995. `Automate`=%d, \
  996. `Locked`=%d, \
  997. `TIndex`=%d, \
  998. `TModel`=%d, \
  999. `TTXD`='%e', \
  1000. `TTexture`='%e', \
  1001. `TColor`=%d, \
  1002. `Facility`=%d \
  1003. WHERE `ID` = %d",
  1004. GateInfo[id][gHID],
  1005. GateInfo[id][gSpeed],
  1006. GateInfo[id][gRange],
  1007. GateInfo[id][gModel],
  1008. GateInfo[id][gVW],
  1009. GateInfo[id][gInt],
  1010. GateInfo[id][gPass],
  1011. GateInfo[id][gPosX],
  1012. GateInfo[id][gPosY],
  1013. GateInfo[id][gPosZ],
  1014. GateInfo[id][gRotX],
  1015. GateInfo[id][gRotY],
  1016. GateInfo[id][gRotZ],
  1017. GateInfo[id][gPosXM],
  1018. GateInfo[id][gPosYM],
  1019. GateInfo[id][gPosZM],
  1020. GateInfo[id][gRotXM],
  1021. GateInfo[id][gRotYM],
  1022. GateInfo[id][gRotZM],
  1023. GateInfo[id][gAllegiance],
  1024. GateInfo[id][gGroupType],
  1025. GateInfo[id][gGroupID],
  1026. GateInfo[id][gRenderHQ],
  1027. GateInfo[id][gTimer],
  1028. GateInfo[id][gAutomate],
  1029. GateInfo[id][gLocked],
  1030. GateInfo[id][gTIndex],
  1031. GateInfo[id][gTModel],
  1032. GateInfo[id][gTTXD],
  1033. GateInfo[id][gTTexture],
  1034. GateInfo[id][gTColor],
  1035. GateInfo[id][gFacility],
  1036. id+1
  1037. );
  1038. mysql_tquery(MainPipeline, szMiscArray, "OnQueryFinish", "i", SENDDATA_THREAD);
  1039. return 0;
  1040. }
  1041. stock SaveGates()
  1042. {
  1043. for(new i = 0; i < MAX_GATES; i++)
  1044. {
  1045. SaveGate(i);
  1046. }
  1047. return 1;
  1048. }
  1049. forward MoveTimerGate(gateid);
  1050. public MoveTimerGate(gateid)
  1051. {
  1052. if(GateInfo[gateid][gTimer] != 0)
  1053. {
  1054. if((0 <= GateInfo[gateid][gFacility] < MAX_CRATE_FACILITY)) {
  1055. if(AdminOpened[GateInfo[gateid][gFacility]] || CrateFacility[GateInfo[gateid][gFacility]][cfRaidable] && CrateFacility[GateInfo[gateid][gFacility]][cfRaidTimer] > 0)
  1056. return 1;
  1057. }
  1058. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  1059. GateInfo[gateid][gStatus] = 0;
  1060. }
  1061. return 1;
  1062. }
  1063. stock MoveGate(playerid, gateid)
  1064. {
  1065. new string[128];
  1066. if(GateInfo[gateid][gStatus] == 0)
  1067. {
  1068. format(string, sizeof(string), "* %s uses their remote to open the gates.", GetPlayerNameEx(playerid));
  1069. // ProxDetector(GateInfo[gateid][gRange], playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  1070. ProxChatBubble(playerid, string);
  1071. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotXM], GateInfo[gateid][gRotYM], GateInfo[gateid][gRotZM]);
  1072. GateInfo[gateid][gStatus] = 1;
  1073. if(GateInfo[gateid][gTimer] != 0)
  1074. {
  1075. switch(GateInfo[gateid][gTimer])
  1076. {
  1077. case 1: SetTimerEx("MoveTimerGate", 3000, false, "i", gateid);
  1078. case 2: SetTimerEx("MoveTimerGate", 5000, false, "i", gateid);
  1079. case 3: SetTimerEx("MoveTimerGate", 8000, false, "i", gateid);
  1080. case 4: SetTimerEx("MoveTimerGate", 10000, false, "i", gateid);
  1081. }
  1082. }
  1083. }
  1084. else if(GateInfo[gateid][gStatus] == 1 && GateInfo[gateid][gTimer] == 0)
  1085. {
  1086. if((0 <= GateInfo[gateid][gFacility] < MAX_CRATE_FACILITY)) {
  1087. if(AdminOpened[GateInfo[gateid][gFacility]] || CrateFacility[GateInfo[gateid][gFacility]][cfRaidable] && CrateFacility[GateInfo[gateid][gFacility]][cfRaidTimer] > 0)
  1088. return SendClientMessageEx(playerid, COLOR_GRAD2, "Unable to close the gate it's currently being prevented by the facility!");
  1089. }
  1090. format(string, sizeof(string), "* %s uses their remote to close the gates.", GetPlayerNameEx(playerid));
  1091. // ProxDetector(GateInfo[gateid][gRange], playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  1092. ProxChatBubble(playerid, string);
  1093. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  1094. GateInfo[gateid][gStatus] = 0;
  1095. }
  1096. return 1;
  1097. }
  1098. stock MoveAutomaticGate(playerid, gateid)
  1099. {
  1100. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotXM], GateInfo[gateid][gRotYM], GateInfo[gateid][gRotZM]);
  1101. GateInfo[gateid][gStatus] = 1;
  1102. switch(GateInfo[gateid][gTimer])
  1103. {
  1104. case 1: SetTimerEx("AutomaticGateTimerClose", 3000, false, "ii", playerid, gateid);
  1105. case 2: SetTimerEx("AutomaticGateTimerClose", 5000, false, "ii", playerid, gateid);
  1106. case 3: SetTimerEx("AutomaticGateTimerClose", 8000, false, "ii", playerid, gateid);
  1107. case 4: SetTimerEx("AutomaticGateTimerClose", 10000, false, "ii", playerid, gateid);
  1108. default: SetTimerEx("AutomaticGateTimerClose", 3000, false, "ii", playerid, gateid);
  1109. }
  1110. return 1;
  1111. }
  1112. forward AutomaticGateTimer(playerid, gateid);
  1113. public AutomaticGateTimer(playerid, gateid)
  1114. {
  1115. if(GateInfo[gateid][gLocked] == 0)
  1116. {
  1117. if(GateInfo[gateid][gStatus] == 0 && IsPlayerInRangeOfPoint(playerid, GateInfo[gateid][gRange], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]))
  1118. {
  1119. if(GateInfo[gateid][gGroupID] != -1 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && PlayerInfo[playerid][pMember] == GateInfo[gateid][gGroupID]) MoveAutomaticGate(playerid, gateid);
  1120. else if(GateInfo[gateid][gAllegiance] != 0 && GateInfo[gateid][gGroupType] != 0 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance] == GateInfo[gateid][gAllegiance] && arrGroupData[PlayerInfo[playerid][pMember]][g_iGroupType] == GateInfo[gateid][gGroupType]) MoveAutomaticGate(playerid, gateid);
  1121. else if(GateInfo[gateid][gAllegiance] != 0 && GateInfo[gateid][gGroupType] == 0 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance] == GateInfo[gateid][gAllegiance]) MoveAutomaticGate(playerid, gateid);
  1122. else if(GateInfo[gateid][gAllegiance] == 0 && GateInfo[gateid][gGroupType] != 0 && (0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pMember]][g_iGroupType] == GateInfo[gateid][gGroupType]) MoveAutomaticGate(playerid, gateid);
  1123. else MoveAutomaticGate(playerid, gateid);
  1124. }
  1125. SetTimerEx("AutomaticGateTimer", 1000, false, "ii", playerid, gateid);
  1126. }
  1127. else
  1128. {
  1129. if(GateInfo[gateid][gStatus] == 1 && !IsPlayerInRangeOfPoint(playerid, GateInfo[gateid][gRange], GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM]))
  1130. {
  1131. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  1132. SetTimerEx("AutomaticGateTimer", 1000, false, "ii", playerid, gateid);
  1133. GateInfo[gateid][gStatus] = 0;
  1134. return 1;
  1135. }
  1136. }
  1137. return 1;
  1138. }
  1139. forward AutomaticGateTimerClose(playerid, gateid);
  1140. public AutomaticGateTimerClose(playerid, gateid)
  1141. {
  1142. if(GateInfo[gateid][gLocked] == 0)
  1143. {
  1144. if(GateInfo[gateid][gStatus] == 1 && !IsPlayerInRangeOfPoint(playerid, GateInfo[gateid][gRange], GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM]))
  1145. {
  1146. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  1147. SetTimerEx("AutomaticGateTimer", 1000, false, "ii", playerid, gateid);
  1148. GateInfo[gateid][gStatus] = 0;
  1149. return 1;
  1150. }
  1151. switch(GateInfo[gateid][gTimer])
  1152. {
  1153. case 1: SetTimerEx("AutomaticGateTimerClose", 3000, false, "ii", playerid, gateid);
  1154. case 2: SetTimerEx("AutomaticGateTimerClose", 5000, false, "ii", playerid, gateid);
  1155. case 3: SetTimerEx("AutomaticGateTimerClose", 8000, false, "ii", playerid, gateid);
  1156. case 4: SetTimerEx("AutomaticGateTimerClose", 10000, false, "ii", playerid, gateid);
  1157. default: SetTimerEx("AutomaticGateTimerClose", 3000, false, "ii", playerid, gateid);
  1158. }
  1159. }
  1160. else
  1161. {
  1162. if(GateInfo[gateid][gStatus] == 1 && !IsPlayerInRangeOfPoint(playerid, GateInfo[gateid][gRange], GateInfo[gateid][gPosXM], GateInfo[gateid][gPosYM], GateInfo[gateid][gPosZM]))
  1163. {
  1164. MoveDynamicObject(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gSpeed], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
  1165. SetTimerEx("AutomaticGateTimer", 1000, false, "ii", playerid, gateid);
  1166. GateInfo[gateid][gStatus] = 0;
  1167. return 1;
  1168. }
  1169. }
  1170. return 1;
  1171. }
  1172. forward DeleteGate(gateid, adminid);
  1173. public DeleteGate(gateid, adminid)
  1174. {
  1175. if(IsValidDynamicObject(GateInfo[gateid][gGATE])) DestroyDynamicObject(GateInfo[gateid][gGATE]), GateInfo[gateid][gGATE] = -1;
  1176. GateInfo[gateid][gHID] = INVALID_HOUSE_ID;
  1177. GateInfo[gateid][gSpeed] = 1.0;
  1178. GateInfo[gateid][gRange] = 1.0;
  1179. GateInfo[gateid][gModel] = 0;
  1180. GateInfo[gateid][gVW] = 0;
  1181. GateInfo[gateid][gInt] = 0;
  1182. GateInfo[gateid][gPosX] = 0.0;
  1183. GateInfo[gateid][gPosY] = 0.0;
  1184. GateInfo[gateid][gPosZ] = 0.0;
  1185. GateInfo[gateid][gRotX] = 0.0;
  1186. GateInfo[gateid][gRotY] = 0.0;
  1187. GateInfo[gateid][gRotZ] = 0.0;
  1188. GateInfo[gateid][gPosXM] = 0.0;
  1189. GateInfo[gateid][gPosYM] = 0.0;
  1190. GateInfo[gateid][gPosZM] = 0.0;
  1191. GateInfo[gateid][gRotXM] = 0.0;
  1192. GateInfo[gateid][gRotYM] = 0.0;
  1193. GateInfo[gateid][gRotZM] = 0.0;
  1194. GateInfo[gateid][gStatus] = 0;
  1195. GateInfo[gateid][gPass][0] = 0;
  1196. GateInfo[gateid][gAllegiance] = 0;
  1197. GateInfo[gateid][gGroupType] = 0;
  1198. GateInfo[gateid][gGroupID] = INVALID_GROUP_ID;
  1199. GateInfo[gateid][gRenderHQ] = 0;
  1200. GateInfo[gateid][gTimer] = 0;
  1201. GateInfo[gateid][gAutomate] = 0;
  1202. GateInfo[gateid][gLocked] = 0;
  1203. GateInfo[gateid][gFacility] = -1;
  1204. szMiscArray[0] = 0;
  1205. format(szMiscArray, sizeof(szMiscArray), "%s has deleted gate id %d", adminid != INVALID_PLAYER_ID ? GetPlayerNameEx(adminid) : ("(Inactive Player Resource System)"), gateid);
  1206. Log("logs/gedit.log", szMiscArray);
  1207. return 1;
  1208. }