· 6 years ago · Jun 01, 2019, 01:00 PM
1/*
2 _____ .__ .__ .__ .__ .___ __________ .__ .__
3 / \ __ __| | | |__ ____ | | | | _____ ____ __| _/ \______ \ ____ | | ____ ______ | | _____ ___.__.
4 / \ / \| | \ | | | \ / _ \| | | | \__ \ / \ / __ | | _// _ \| | _/ __ \\____ \| | \__ \< | |
5/ Y \ | / |_| Y ( <_> ) |_| |__/ __ \| | \/ /_/ | | | ( <_> ) |_\ ___/| |_> > |__/ __ \\___ |
6\____|__ /____/|____/___| /\____/|____/____(____ /___| /\____ | |____|_ /\____/|____/\___ > __/|____(____ / ____|
7 \/ \/ \/ \/ \/ \/ \/|__| \/\/
8 gates.inc
9*/
10// ADD VARIABLE TO RESET: g_GatesInfo[gate_id][E_GATE_ACTIVE_EDIT_BY] = playerid;
11
12#if defined MAX_GATES_PASSWORD_SIZE
13 #undef MAX_GATES_PASSWORD_SIZE
14#endif
15#define MAX_GATES_PASSWORD_SIZE 128 + 1
16
17#if defined MAX_GATES
18 #undef MAX_GATES
19#endif
20#define MAX_GATES 50
21
22#if defined MAX_GATES_RANGE
23 #undef MAX_GATES_RANGE
24#endif
25#define MAX_GATES_RANGE 50.0
26
27#if defined MAX_GATES_SPEED
28 #undef MAX_GATES_SPEED
29#endif
30#define MAX_GATES_SPEED 50.0
31
32enum E_GATES_DATA{
33 E_GATE_MODEL_ID,
34 Float:E_GATE_POS[3],
35 Float:E_GATE_ROT[3],
36 E_GATE_WORLD,
37 E_GATE_INT,
38 E_GATE_OWNER_ID,
39 E_GATE_FACTION_ID,
40 E_GATE_GROUP_ID,
41 E_GATE_PASSWORD[MAX_GATES_PASSWORD_SIZE],
42 bool:E_GATE_CAN_OPEN,
43 bool:E_GATE_VISIBLE,
44 Float:E_GATE_OPEN_POS[3],
45 Float:E_GATE_OPEN_ROT[3],
46 bool:E_GATE_STATE,
47 Float:E_GATE_SPEED,
48 Float:E_GATE_RANGE,
49 E_GATE_OBJECT,
50 E_GATE_BY_SQLID,
51
52 E_GATE_ACTIVE_EDIT_BY,
53
54 bool:E_GATE_EXISTS,
55}
56
57enum E_GATE_MANIPULATE{
58 E_GATE_MANIPULATE_ADMIN,
59 E_GATE_MANIPULATE_DEV,
60}
61
62new g_GatesInfo[MAX_GATES][E_GATES_DATA];
63
64static
65 g_GateAdminRank = 1,
66 g_GateDevRank = 1;
67
68GATES_ManipulateRank(const E_GATE_MANIPULATE:type, bool:set = false, value = 1){
69 if(set){
70 if(type == E_GATE_MANIPULATE_ADMIN)
71 g_GateAdminRank = value;
72 else
73 g_GateDevRank = value;
74 return 1;
75 }
76 else{
77 if(type == E_GATE_MANIPULATE_ADMIN)
78 return g_GateAdminRank;
79 else
80 return g_GateDevRank;
81 }
82}
83
84stock GATES_GetNearby(const playerid, const bool:entry = true, Float:distance = 5.0)
85{
86 for(new i = 0; i < MAX_GATES; i++)
87 {
88 if(!g_GatesInfo[i][E_GATE_EXISTS])
89 continue;
90 if(entry)
91 {
92 if(IsPlayerInRangeOfPoint(playerid, distance, g_GatesInfo[i][E_GATE_POS][0], g_GatesInfo[i][E_GATE_POS][1], g_GatesInfo[i][E_GATE_POS][2]))
93 if(GetPlayerVirtualWorld(playerid) == g_GatesInfo[i][E_GATE_WORLD] && GetPlayerInterior(playerid) == g_GatesInfo[i][E_GATE_INT])
94 return i;
95 }
96 }
97 return -1;
98}
99
100stock GATES_UseNearby(const playerid, const bool:entry = true)
101{
102 for(new i = 0; i < MAX_GATES; i++)
103 {
104 if(!g_GatesInfo[i][E_GATE_EXISTS])
105 continue;
106 if(entry)
107 {
108 if(IsPlayerInRangeOfPoint(playerid, g_GatesInfo[i][E_GATE_RANGE], g_GatesInfo[i][E_GATE_POS][0], g_GatesInfo[i][E_GATE_POS][1], g_GatesInfo[i][E_GATE_POS][2]))
109 if(GetPlayerVirtualWorld(playerid) == g_GatesInfo[i][E_GATE_WORLD] && GetPlayerInterior(playerid) == g_GatesInfo[i][E_GATE_INT])
110 return i;
111 }
112 }
113 return -1;
114}
115
116GATES_Init(){
117 GATES_ResetVarsAll();
118
119 new queryBuffer[1000];
120 mysql_format(MHRP_SQL, queryBuffer, sizeof queryBuffer,
121 "CREATE TABLE IF NOT EXISTS `Gates` (\
122 `ID` INT(11) NOT NULL DEFAULT '0',\
123 `modelID` INT(11) NOT NULL DEFAULT '0',\
124 `X` FLOAT NOT NULL DEFAULT '0.0',\
125 `Y` FLOAT NOT NULL DEFAULT '0.0',\
126 `Z` FLOAT NOT NULL DEFAULT '0.0',\
127 `rX` FLOAT NOT NULL DEFAULT '0.0',\
128 `rY` FLOAT NOT NULL DEFAULT '0.0',\
129 `rZ` FLOAT NOT NULL DEFAULT '0.0',\
130 `VW` INT(5) NOT NULL DEFAULT '0',\
131 `INTER` INT(2) NOT NULL DEFAULT '0',\
132 `ownerID` INT(11) NOT NULL DEFAULT '0',\
133 `factionID` INT(11) NOT NULL DEFAULT '0',\
134 `groupID` INT(11) NOT NULL DEFAULT '0',\
135 `password` VARCHAR(128) NOT NULL DEFAULT \"\",\
136 `visible` INT(2) NOT NULL DEFAULT '1',\
137 `oX` FLOAT NOT NULL DEFAULT '0.0',\
138 `oY` FLOAT NOT NULL DEFAULT '0.0',\
139 `oZ` FLOAT NOT NULL DEFAULT '0.0',\
140 `orX` FLOAT NOT NULL DEFAULT '0.0',\
141 `orY` FLOAT NOT NULL DEFAULT '0.0',\
142 `orZ` FLOAT NOT NULL DEFAULT '0.0',\
143 `speed` FLOAT NOT NULL DEFAULT '0.0',\
144 `range` FLOAT NOT NULL DEFAULT '0.0',\
145 `by_SQLID` INT(11) NOT NULL DEFAULT '0',\
146 PRIMARY KEY (ID)\
147 );");
148
149 mysql_tquery(MHRP_SQL, queryBuffer, "");
150
151 new queryBuffer2[256];
152 mysql_format(MHRP_SQL, queryBuffer2, sizeof queryBuffer2,
153 "CREATE TABLE IF NOT EXISTS `logs_gates` (\
154 `by_SQLID` INT(11) NOT NULL DEFAULT '0',\
155 `time` datetime NOT NULL,\
156 `oldinfo` VARCHAR(256) NOT NULL DEFAULT \"\",\
157 `newinfo` VARCHAR(256) NOT NULL DEFAULT \"\",\
158 `action` VARCHAR(128) NOT NULL DEFAULT \"\"\
159 );");
160
161 mysql_tquery(MHRP_SQL, queryBuffer2, "");
162
163 inline QueryExec(){
164
165 new rows = cache_num_rows();
166 new count = 0;
167 if(rows){
168 for(new i = 0; i < rows; i++){
169 cache_get_value_name_int(i, "modelID", g_GatesInfo[i][E_GATE_MODEL_ID]);
170 cache_get_value_name_float(i, "X", g_GatesInfo[i][E_GATE_POS][0]);
171 cache_get_value_name_float(i, "Y", g_GatesInfo[i][E_GATE_POS][1]);
172 cache_get_value_name_float(i, "Z", g_GatesInfo[i][E_GATE_POS][2]);
173 cache_get_value_name_float(i, "rX", g_GatesInfo[i][E_GATE_ROT][0]);
174 cache_get_value_name_float(i, "rY", g_GatesInfo[i][E_GATE_ROT][1]);
175 cache_get_value_name_float(i, "rZ", g_GatesInfo[i][E_GATE_ROT][2]);
176 cache_get_value_name_int(i, "VW", g_GatesInfo[i][E_GATE_WORLD]);
177 cache_get_value_name_int(i, "INTER", g_GatesInfo[i][E_GATE_INT]);
178 cache_get_value_name_float(i, "speed", g_GatesInfo[i][E_GATE_SPEED]);
179 cache_get_value_name_float(i, "range", g_GatesInfo[i][E_GATE_RANGE]);
180 cache_get_value_name_int(i, "ownerID", g_GatesInfo[i][E_GATE_OWNER_ID]);
181 cache_get_value_name_int(i, "factionID", g_GatesInfo[i][E_GATE_FACTION_ID]);
182 cache_get_value_name_int(i, "groupID", g_GatesInfo[i][E_GATE_GROUP_ID]);
183 cache_get_value_name(i, "password", g_GatesInfo[i][E_GATE_PASSWORD], MAX_GATES_PASSWORD_SIZE);
184 cache_get_value_name_bool(i, "visible", g_GatesInfo[i][E_GATE_VISIBLE]);
185 cache_get_value_name_float(i, "oX", g_GatesInfo[i][E_GATE_OPEN_POS][0]);
186 cache_get_value_name_float(i, "oY", g_GatesInfo[i][E_GATE_OPEN_POS][1]);
187 cache_get_value_name_float(i, "oZ", g_GatesInfo[i][E_GATE_OPEN_POS][2]);
188 cache_get_value_name_float(i, "orX", g_GatesInfo[i][E_GATE_OPEN_ROT][0]);
189 cache_get_value_name_float(i, "orY", g_GatesInfo[i][E_GATE_OPEN_ROT][1]);
190 cache_get_value_name_float(i, "orZ", g_GatesInfo[i][E_GATE_OPEN_ROT][2]);
191 cache_get_value_name_int(i, "by_SQLID", g_GatesInfo[i][E_GATE_BY_SQLID]);
192
193 if( g_GatesInfo[i][E_GATE_OPEN_POS][0] == 0.0 &&
194 g_GatesInfo[i][E_GATE_OPEN_POS][1] == 0.0 &&
195 g_GatesInfo[i][E_GATE_OPEN_POS][2] == 0.0 &&
196 g_GatesInfo[i][E_GATE_OPEN_ROT][0] == 0.0 &&
197 g_GatesInfo[i][E_GATE_OPEN_ROT][1] == 0.0 &&
198 g_GatesInfo[i][E_GATE_OPEN_ROT][2] == 0.0
199 )
200 g_GatesInfo[i][E_GATE_CAN_OPEN] = false;
201 else
202 g_GatesInfo[i][E_GATE_CAN_OPEN] = true;
203
204 g_GatesInfo[i][E_GATE_EXISTS] = true;
205
206 GATES_ResetDisplay(i);
207 count++;
208 }
209 }
210 printf("[GATES] %d loaded", count);
211 }
212
213 mysql_tquery_inline(MHRP_SQL, "SELECT * FROM `Gates` LIMIT "#MAX_GATES, using inline QueryExec);
214
215 return 1;
216}
217
218GATES_ResetVars(gate_id){
219 g_GatesInfo[gate_id][E_GATE_MODEL_ID] = 0;
220 g_GatesInfo[gate_id][E_GATE_POS][0] = 0.0;
221 g_GatesInfo[gate_id][E_GATE_POS][1] = 0.0;
222 g_GatesInfo[gate_id][E_GATE_POS][2] = 0.0;
223 g_GatesInfo[gate_id][E_GATE_ROT][0] = 0.0;
224 g_GatesInfo[gate_id][E_GATE_ROT][1] = 0.0;
225 g_GatesInfo[gate_id][E_GATE_ROT][2] = 0.0;
226 g_GatesInfo[gate_id][E_GATE_WORLD] = 0;
227 g_GatesInfo[gate_id][E_GATE_INT] = 0;
228 g_GatesInfo[gate_id][E_GATE_OWNER_ID] = 0;
229 g_GatesInfo[gate_id][E_GATE_FACTION_ID] = 0;
230 g_GatesInfo[gate_id][E_GATE_GROUP_ID] = 0;
231 format(g_GatesInfo[gate_id][E_GATE_PASSWORD], MAX_GATES_PASSWORD_SIZE, "");
232 g_GatesInfo[gate_id][E_GATE_VISIBLE] = false;
233 g_GatesInfo[gate_id][E_GATE_OPEN_POS][0] = 0.0;
234 g_GatesInfo[gate_id][E_GATE_OPEN_POS][1] = 0.0;
235 g_GatesInfo[gate_id][E_GATE_OPEN_POS][2] = 0.0;
236 g_GatesInfo[gate_id][E_GATE_SPEED] = 0.0;
237 g_GatesInfo[gate_id][E_GATE_RANGE] = 0.0;
238 g_GatesInfo[gate_id][E_GATE_CAN_OPEN] = false;
239 g_GatesInfo[gate_id][E_GATE_BY_SQLID] = 0;
240
241 DestroyDynamicObject(g_GatesInfo[gate_id][E_GATE_OBJECT]);
242
243 g_GatesInfo[gate_id][E_GATE_EXISTS] = false;
244
245 return 1;
246}
247GATES_ResetVarsAll(){
248 for(new i = 0; i < MAX_GATES; i++)
249 GATES_ResetVars(i);
250 return 1;
251}
252
253stock GATES_GetFreeSlot(){
254 for(new i = 0; i < MAX_GATES; i++){
255 if(!g_GatesInfo[i][E_GATE_EXISTS])
256 return i;
257 }
258 return -1;
259}
260
261GATES_DestroyDisplay(gate_id)
262{
263 if(!g_GatesInfo[gate_id][E_GATE_EXISTS])
264 return 0;
265
266 DestroyDynamicObject(g_GatesInfo[gate_id][E_GATE_OBJECT]);
267
268 return 1;
269}
270
271GATES_CreateGateDisplay(gate_id)
272{
273 if(!g_GatesInfo[gate_id][E_GATE_EXISTS])
274 return 0;
275
276 if(!g_GatesInfo[gate_id][E_GATE_VISIBLE])
277 {
278 GATES_DestroyDisplay(gate_id);
279 return 0;
280 }
281
282 g_GatesInfo[gate_id][E_GATE_OBJECT] = CreateDynamicObject(g_GatesInfo[gate_id][E_GATE_MODEL_ID], g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2], g_GatesInfo[gate_id][E_GATE_ROT][0], g_GatesInfo[gate_id][E_GATE_ROT][1], g_GatesInfo[gate_id][E_GATE_ROT][2], g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT]);
283
284 return 1;
285}
286
287GATES_ResetDisplay(gate_id){
288 GATES_DestroyDisplay(gate_id);
289 GATES_CreateGateDisplay(gate_id);
290 return 1;
291}
292
293stock GATES_SaveData(gate_id){
294 if(!g_GatesInfo[gate_id][E_GATE_EXISTS])
295 return 0;
296 else{
297 new queryBuffer[1000];
298 new flag;
299 if(g_GatesInfo[gate_id][E_GATE_VISIBLE])
300 flag = 1;
301 else
302 flag = 0;
303
304 mysql_format(MHRP_SQL, queryBuffer, sizeof queryBuffer,
305 "UPDATE `Gates` SET \
306 `X`='%f',\
307 `Y`='%f',\
308 `Z`='%f',\
309 `rX`='%f',\
310 `rY`='%f',\
311 `rZ`='%f',\
312 `VW`='%d',\
313 `INTER`='%d', \
314 `speed`='%f', \
315 `range`='%f'",
316 g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2],
317 g_GatesInfo[gate_id][E_GATE_ROT][0], g_GatesInfo[gate_id][E_GATE_ROT][1], g_GatesInfo[gate_id][E_GATE_ROT][2],
318 g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT], g_GatesInfo[gate_id][E_GATE_SPEED], g_GatesInfo[gate_id][E_GATE_RANGE]);
319 mysql_format(MHRP_SQL, queryBuffer, sizeof queryBuffer,
320 "%s,\
321 `modelID`='%d',\
322 `ownerID`='%d',\
323 `factionID`='%d',\
324 `groupID`='%d',\
325 `password`='%e',\
326 `visible`='%d'",
327 queryBuffer, g_GatesInfo[gate_id][E_GATE_MODEL_ID], g_GatesInfo[gate_id][E_GATE_OWNER_ID], g_GatesInfo[gate_id][E_GATE_FACTION_ID], g_GatesInfo[gate_id][E_GATE_GROUP_ID], g_GatesInfo[gate_id][E_GATE_PASSWORD], flag);
328 mysql_format(MHRP_SQL, queryBuffer, sizeof queryBuffer,
329 "%s,\
330 `oX`='%f',\
331 `oY`='%f',\
332 `oZ`='%f',\
333 `orX`='%f',\
334 `orY`='%f',\
335 `orZ`='%f',\
336 `by_SQLID`='%d'\
337 WHERE `ID`='%d';",
338 queryBuffer, g_GatesInfo[gate_id][E_GATE_OPEN_POS][0], g_GatesInfo[gate_id][E_GATE_OPEN_POS][1], g_GatesInfo[gate_id][E_GATE_OPEN_POS][2],
339 g_GatesInfo[gate_id][E_GATE_OPEN_ROT][0], g_GatesInfo[gate_id][E_GATE_OPEN_ROT][1], g_GatesInfo[gate_id][E_GATE_OPEN_ROT][2], g_GatesInfo[gate_id][E_GATE_BY_SQLID], gate_id);
340
341 mysql_pquery(MHRP_SQL, queryBuffer, "");
342 }
343 return 1;
344}
345
346enum E_GATE_EDIT_TYPE{
347 E_GATE_EDIT_MODEL_ID,
348 E_GATE_EDIT_CLOSED_POS,
349 E_GATE_EDIT_OWNER_ID,
350 E_GATE_EDIT_FACTION_ID,
351 E_GATE_EDIT_GROUP_ID,
352 E_GATE_EDIT_PASSWORD,
353 E_GATE_EDIT_VISIBLE,
354 E_GATE_EDIT_CAN_OPEN,
355 E_GATE_EDIT_OPEN_POS,
356 E_GATE_EDIT_INFO,
357 E_GATE_EDIT_MAIN
358}
359
360GATES_AdminEditDialog(playerid, gate_id, const E_GATE_EDIT_TYPE:step){
361
362 if(!g_GatesInfo[gate_id][E_GATE_EXISTS]){
363 Dialog_Show(playerid, DIALOG_STYLE_MSGBOX,
364 INLINE[COLOR_SICKBLUE]"Gates",
365 "{FFFFFF}The gate you were trying to edit has since been deleted.", "Close");
366 return 1;
367 }
368
369 switch(step){
370 case E_GATE_EDIT_INFO:{
371
372 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
373 #pragma unused dialogid, listitem, inputtext
374 if(response){
375 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
376 }
377 }
378
379 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_MSGBOX,
380 INLINE[COLOR_SICKBLUE]"Gates",
381 "{FFFFFF}To edit any attribute of a gate simply select an option and further details will be provided.", "Continue", "Close");
382 }
383 case E_GATE_EDIT_MAIN:{
384 new
385 dialogStr[500],
386 _title[24],
387 exitStatus[15],
388 _visibility[15];
389
390 if(!g_GatesInfo[gate_id][E_GATE_VISIBLE])
391 format(_visibility, sizeof _visibility, INLINE[COLOR_RED]"No");
392 else
393 format(_visibility, sizeof _visibility, INLINE[COLOR_GREEN]"Yes");
394
395 format(dialogStr, sizeof dialogStr,
396 "Set gate model ID\n\
397 Set gate closed position\n\
398 Set gate owner (CHRID)\n\
399 Set gate faction (FACID)\n\
400 Set gate group (GRPID)\n\
401 Set gate password\n\
402 Set gate visibility\t%s\n", _visibility);
403
404 if(g_GatesInfo[gate_id][E_GATE_CAN_OPEN]){
405 format(exitStatus, sizeof exitStatus, INLINE[COLOR_GREEN]"Yes");
406 format(dialogStr, sizeof dialogStr,
407 "%sGate can open?\t%s\n\
408 Set gate open position",
409 dialogStr, exitStatus);
410 }
411 else{
412 format(exitStatus, sizeof exitStatus, INLINE[COLOR_RED]"No");
413 format(dialogStr, sizeof dialogStr, "%sGate can open?\t%s", dialogStr, exitStatus);
414 }
415
416 format(_title, sizeof _title, "Editing Gate [ID %d]", gate_id);
417
418 inline DialogResponse_1(_playerid, dialogid, response, listitem, inputtext[]){
419 #pragma unused dialogid, inputtext
420 if(response){
421 switch(listitem){
422 case E_GATE_EDIT_MODEL_ID:{
423 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MODEL_ID);
424 }
425 case E_GATE_EDIT_CLOSED_POS:{
426 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_CLOSED_POS);
427 }
428 case E_GATE_EDIT_OWNER_ID:{
429 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_OWNER_ID);
430 }
431 case E_GATE_EDIT_FACTION_ID:{
432 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_FACTION_ID);
433 }
434 case E_GATE_EDIT_GROUP_ID:{
435 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_GROUP_ID);
436 }
437 case E_GATE_EDIT_PASSWORD:{
438 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_PASSWORD);
439 }
440 case E_GATE_EDIT_VISIBLE:{
441 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_VISIBLE);
442 }
443 case E_GATE_EDIT_CAN_OPEN:{
444 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_CAN_OPEN);
445 }
446 case E_GATE_EDIT_OPEN_POS:{
447 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_OPEN_POS);
448 }
449 default:{
450 Dialog_Show(playerid, DIALOG_STYLE_MSGBOX, INLINE[COLOR_SICKBLUE]"Gates",
451 "{FFFFFF}Looks like you somehow chose a non-existant option. Please contact $kylar", "Close");
452 }
453 }
454 }
455 }
456 Dialog_ShowCallback(playerid, using inline DialogResponse_1, DIALOG_STYLE_LIST, _title, dialogStr, "Select", "Close");
457 }
458 case E_GATE_EDIT_MODEL_ID:{
459
460 }
461 case E_GATE_EDIT_CLOSED_POS:{
462
463 inline DialogResponse_Pos(_playerid, dialogid, response, listitem, inputtext[]){
464 #pragma unused dialogid, listitem, inputtext
465 if(response){
466 //g_GatesInfo[gate_id][E_GATE_ACTIVE_EDIT_BY] = playerid;
467 EditDynamicObject(playerid, g_GatesInfo[gate_id][E_GATE_OBJECT]);
468 GATES_ResetDisplay(gate_id);
469 GATES_SaveData(gate_id);
470 }
471 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
472 }
473
474 new _str[500];
475 format(_str, sizeof _str,
476 "{FFFFFF}You may now move the gate to the appropriate position.\n\
477 Please note that other players will only see the changes once you press save.\n\
478 Before updating the position, please ensure that you are satisfied with the location.");
479
480 Dialog_ShowCallback(playerid, using inline DialogResponse_Pos, DIALOG_STYLE_MSGBOX, INLINE[COLOR_SICKBLUE]"Doors", _str, "Update", "Return");
481 }
482 case E_GATE_EDIT_OWNER_ID:{
483 new _str[200];
484 if(!g_GatesInfo[gate_id][E_GATE_OWNER_ID])
485 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] has no owner (CHRID) assigned to it.", gate_id);
486 else
487 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] is currently owned by CHRID %d.\n\
488 To remove the owner of this gate, use the input '0'.",
489 gate_id, g_GatesInfo[gate_id][E_GATE_OWNER_ID]);
490
491 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
492 #pragma unused dialogid, listitem
493
494 if(!response)
495 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
496 else{
497
498 if(!IsNumeric(inputtext)){
499 SendClientMessage(_playerid, COLOR[COLOR_ERROR], "The owner ID must be the CHRID of the owner. Use /whois to find the relevant ID.");
500 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_OWNER_ID);
501 }
502 else{
503 if(!strval(inputtext))
504 g_GatesInfo[gate_id][E_GATE_OWNER_ID] = 0;
505 else{
506 inline QueryExec(){
507 new rows = cache_num_rows();
508 if(!rows){
509 SendClientMessage(_playerid, COLOR[COLOR_ERROR], "This CHRID does not exist.");
510 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_OWNER_ID);
511 }
512 else{
513 g_GatesInfo[gate_id][E_GATE_OWNER_ID] = strval(inputtext);
514 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
515 GATES_SaveData(gate_id);
516 }
517 }
518
519 mysql_format(MHRP_SQL, _str, sizeof _str, "SELECT `CHRID` FROM `characters` WHERE `CHRID`='%d' LIMIT 1;", strval(inputtext));
520 mysql_pquery_inline(MHRP_SQL, _str, using inline QueryExec);
521 }
522 }
523 }
524 }
525 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_INPUT, INLINE[COLOR_SICKBLUE]"Gate Owner", _str, "Update", "Return");
526 }
527 case E_GATE_EDIT_FACTION_ID:{
528 new _str[200];
529 if(!g_GatesInfo[gate_id][E_GATE_FACTION_ID])
530 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] has no faction (FACID) assigned to it.", gate_id);
531 else
532 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] is currently owned by FACID %d.\n\
533 To remove the owner of this gate, use the input '0'.",
534 gate_id, g_GatesInfo[gate_id][E_GATE_FACTION_ID]);
535
536 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
537 #pragma unused dialogid, listitem
538
539 if(!response)
540 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
541 else{
542
543 if(!IsNumeric(inputtext)){
544 SendClientMessage(_playerid, COLOR[COLOR_ERROR], "The owner ID must be the FACID of the faction. Use /factions to find the relevant ID.");
545 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_FACTION_ID);
546 }
547 else{
548 if(!strval(inputtext))
549 g_GatesInfo[gate_id][E_GATE_FACTION_ID] = 0;
550 else{
551 inline QueryExec(){
552 new rows = cache_num_rows();
553 if(!rows){
554 SendClientMessage(_playerid, COLOR[COLOR_ERROR], "This FACID does not exist.");
555 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_FACTION_ID);
556 }
557 else{
558 g_GatesInfo[gate_id][E_GATE_FACTION_ID] = strval(inputtext);
559 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
560 GATES_SaveData(gate_id);
561 }
562 }
563
564 mysql_format(MHRP_SQL, _str, sizeof _str, "SELECT `FACID` FROM `factions` WHERE `FACID`='%d' LIMIT 1;", strval(inputtext));
565 mysql_pquery_inline(MHRP_SQL, _str, using inline QueryExec);
566 }
567 }
568 }
569 }
570 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_INPUT, INLINE[COLOR_SICKBLUE]"Gate Owner", _str, "Update", "Return");
571 }
572 case E_GATE_EDIT_GROUP_ID:{
573 new _str[200];
574 if(!g_GatesInfo[gate_id][E_GATE_GROUP_ID])
575 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] has no group (GRPID) assigned to it.", gate_id);
576 else
577 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] is currently owned by GRPID %d.\n\
578 To remove the owner of this gate, use the input '0'.",
579 gate_id, g_GatesInfo[gate_id][E_GATE_GROUP_ID]);
580
581 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
582 #pragma unused dialogid, listitem
583
584 if(!response)
585 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
586 else{
587
588 if(!IsNumeric(inputtext)){
589 SendClientMessage(_playerid, COLOR[COLOR_ERROR], "The owner ID must be the GRPID of the group. Use /groups to find the relevant ID.");
590 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_GROUP_ID);
591 }
592 else{
593 if(!strval(inputtext))
594 g_GatesInfo[gate_id][E_GATE_GROUP_ID] = 0;
595 else{
596 inline QueryExec(){
597 new rows = cache_num_rows();
598 if(!rows){
599 SendClientMessage(_playerid, COLOR[COLOR_ERROR], "This GRPID does not exist.");
600 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_GROUP_ID);
601 }
602 else{
603 g_GatesInfo[gate_id][E_GATE_GROUP_ID] = strval(inputtext);
604 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
605 GATES_SaveData(gate_id);
606 }
607 }
608
609 mysql_format(MHRP_SQL, _str, sizeof _str, "SELECT `GRPID` FROM `groups` WHERE `GRPID`='%d' LIMIT 1;", strval(inputtext));
610 mysql_pquery_inline(MHRP_SQL, _str, using inline QueryExec);
611 }
612 }
613 }
614 }
615 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_INPUT, INLINE[COLOR_SICKBLUE]"Gate Owner", _str, "Update", "Return");
616 }
617 case E_GATE_EDIT_PASSWORD:{
618 new _str[250];
619 format(_str, sizeof _str, "%s", g_GatesInfo[gate_id][E_GATE_PASSWORD]);
620 if(isnull(_str)){
621 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] has no password assigned to it.", gate_id);
622 }
623 else{
624 format(_str, sizeof _str, INLINE[COLOR_SADMIN]"This gate [ID %d] its password currently is %s.",
625 gate_id, g_GatesInfo[gate_id][E_GATE_PASSWORD]);
626 }
627
628 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
629 #pragma unused dialogid, listitem
630 if(!response){
631 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
632 }
633 else{
634 if(strlen(inputtext) > MAX_GATES_PASSWORD_SIZE - 1){
635 SendClientMessageEx(_playerid, COLOR[COLOR_ERROR], "A gate password cannot exceed more than %d characters.", MAX_GATES_PASSWORD_SIZE - 1);
636 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_PASSWORD);
637 }
638 else{
639 format(g_GatesInfo[gate_id][E_GATE_PASSWORD], MAX_GATES_PASSWORD_SIZE, "%s", inputtext);
640 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
641 GATES_SaveData(gate_id);
642 }
643 }
644 }
645 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_INPUT,
646 "{0085d6}Gate Password", _str, "Update", "Return");
647 }
648 case E_GATE_EDIT_VISIBLE:{
649 new
650 _title[64],
651 _str[250],
652 _button[12];
653 if(!g_GatesInfo[gate_id][E_GATE_VISIBLE]){
654 format(_title, sizeof _title, INLINE[COLOR_WHITE]"Gate visibility? "INLINE[COLOR_RED]"No");
655 format(_str, sizeof _str, INLINE[COLOR_WHITE]"This gate is currently not visible.\n\
656 This means that the gate's open & closed position is invisible. It is also not possible to interact with it.");
657 format(_button, sizeof _button, "Enable");
658 }
659 else{
660 format(_title, sizeof _title, INLINE[COLOR_WHITE]"Gate visibility? "INLINE[COLOR_GREEN]"Yes");
661 format(_str, sizeof _str, INLINE[COLOR_WHITE]"This gate is currently visible.\n\
662 This means that the gate's open & closed position is visible. It is also possible to interact with it.");
663 format(_button, sizeof _button, "Disable");
664 }
665
666 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
667 #pragma unused dialogid, listitem, inputtext
668
669 if(response){
670 if(!g_GatesInfo[gate_id][E_GATE_VISIBLE])
671 g_GatesInfo[gate_id][E_GATE_VISIBLE] = true;
672 else
673 g_GatesInfo[gate_id][E_GATE_VISIBLE] = false;
674
675 GATES_ResetDisplay(gate_id);
676 GATES_SaveData(gate_id);
677 }
678
679 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
680 }
681
682 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_MSGBOX, _title, _str, _button, "Back");
683 }
684 case E_GATE_EDIT_CAN_OPEN:{
685
686 new
687 _str[300],
688 _title[64];
689
690 if(!g_GatesInfo[gate_id][E_GATE_CAN_OPEN]){
691 format(_str, sizeof _str,
692 INLINE[COLOR_WHITE]"This gate [ID %d] currently has no open position.\n\
693 Do you wish to assign your current X-Y-Z coordinates as the open position?\n\
694 Note: You can always change the open position later.", gate_id);
695 format(_title, sizeof _title, INLINE[COLOR_SICKBLUE]"Gate can open? "INLINE[COLOR_RED]"No");
696 }
697 else{
698 format(_str, sizeof _str, INLINE[COLOR_WHITE]"This gate [ID %d] can open.\n\
699 Do you wish to remove this open position and disable it?", gate_id);
700 format(_title, sizeof _title, INLINE[COLOR_INFO]"Gate can open? "INLINE[COLOR_GREEN]"Yes");
701 }
702
703 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
704 #pragma unused dialogid, listitem, inputtext
705
706 if(response){
707 if(!g_GatesInfo[gate_id][E_GATE_CAN_OPEN]){
708 GetPlayerPos(_playerid, g_GatesInfo[gate_id][E_GATE_OPEN_POS][0], g_GatesInfo[gate_id][E_GATE_OPEN_POS][1], g_GatesInfo[gate_id][E_GATE_OPEN_POS][2]);
709 g_GatesInfo[gate_id][E_GATE_OPEN_ROT][0] = g_GatesInfo[gate_id][E_GATE_OPEN_ROT][1] = g_GatesInfo[gate_id][E_GATE_OPEN_ROT][2] = 0.0;
710 g_GatesInfo[gate_id][E_GATE_CAN_OPEN] = true;
711
712 }
713 else{
714 g_GatesInfo[gate_id][E_GATE_CAN_OPEN] = false;
715 g_GatesInfo[gate_id][E_GATE_OPEN_POS][0] = g_GatesInfo[gate_id][E_GATE_OPEN_POS][1] = g_GatesInfo[gate_id][E_GATE_OPEN_POS][2] = 0.0;
716 g_GatesInfo[gate_id][E_GATE_OPEN_ROT][0] = g_GatesInfo[gate_id][E_GATE_OPEN_ROT][1] = g_GatesInfo[gate_id][E_GATE_OPEN_ROT][2] = 0.0;
717 }
718 GATES_ResetDisplay(gate_id);
719 GATES_SaveData(gate_id);
720 }
721
722 GATES_AdminEditDialog(_playerid, gate_id, E_GATE_EDIT_MAIN);
723 }
724
725 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_MSGBOX, _title, _str, "Update", "Return");
726 }
727 /*case E_GATE_OPEN_POS:{
728 if(!g_IconsInfo[icon_id][E_ICON_HAS_EXIT]){
729
730 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
731 #pragma unused dialogid, listitem, inputtext
732 if(response){
733 ICON_AdminEditDialog(_playerid, icon_id, E_ICON_EDIT_MAIN);
734 }
735 }
736
737 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_MSGBOX, INLINE[COLOR_SICKBLUE]"Doors",
738 INLINE[COLOR_WHITE]"The door you were trying to edit has since been deleted.", "Close");
739 }
740 else{
741
742 new _str[500];
743 format(_str, sizeof _str,
744 INLINE[COLOR_WHITE]"Please note that the position of the door's exit (X-Y-Z coordinates) depend on your current location.\n\
745 This also goes for the angle you are currently facing, the virtual world and the interior. \n\
746 Before updating the exit position, please ensure that you are satisfied with the location.");
747
748 inline DialogResponse(_playerid, dialogid, response, listitem, inputtext[]){
749 #pragma unused dialogid, listitem, inputtext
750 if(response){
751 GetPlayerPos(_playerid, g_IconsInfo[icon_id][E_ICON_EXIT_POS][0], g_IconsInfo[icon_id][E_ICON_EXIT_POS][1], g_IconsInfo[icon_id][E_ICON_EXIT_POS][2]);
752 GetPlayerFacingAngle(_playerid, g_IconsInfo[icon_id][E_ICON_EXIT_ANG]);
753 g_IconsInfo[icon_id][E_ICON_EXIT_WORLD] = GetPlayerVirtualWorld(_playerid);
754 g_IconsInfo[icon_id][E_ICON_EXIT_INT] = GetPlayerInterior(_playerid);
755 ICON_ResetDisplay(icon_id);
756 ICON_SaveData(icon_id);
757 }
758 ICON_AdminEditDialog(_playerid, icon_id, E_ICON_EDIT_MAIN);
759 }
760
761 Dialog_ShowCallback(playerid, using inline DialogResponse, DIALOG_STYLE_MSGBOX, INLINE[COLOR_SICKBLUE]"Doors", _str, "Update", "Back");
762 }
763 }*/
764 }
765 return 1;
766}
767
768CMD:agate(playerid, params[])
769{
770 if(IsAdmin(playerid) >= GATES_ManipulateRank(E_GATE_MANIPULATE_ADMIN) && IsDev(playerid) >= GATES_ManipulateRank(E_GATE_MANIPULATE_DEV))
771 {
772 new subcmd[30], scmd_params[30];
773
774 if(sscanf(params, "s[30]S()[30]",subcmd, scmd_params))
775 {
776 SendClientMessage(playerid, COLOR[COLOR_INFO], "/agate [subcommand]");
777 SendClientMessage(playerid, COLOR[COLOR_INFO], "List of available subcommands:");
778 SendClientMessage(playerid, COLOR[COLOR_INFO], "create, delete, info, goto, edit");
779 }
780
781 // create subcmd
782 else if(strmatch(subcmd, "create"))
783 {
784 new gate_id;
785 if((gate_id = GATES_GetFreeSlot()) == -1)
786 return SendClientMessageEx(playerid,COLOR[COLOR_ERROR],"The gate count limit of %d has been reached.", MAX_GATES);
787
788 new Float:_pos[3];
789 GetPlayerPosEx(playerid, _pos);
790
791 for(new i = 0; i < sizeof _pos; i++)
792 g_GatesInfo[gate_id][E_GATE_POS][i] = _pos[i];
793 g_GatesInfo[gate_id][E_GATE_WORLD] = GetPlayerVirtualWorld(playerid);
794 g_GatesInfo[gate_id][E_GATE_INT] = GetPlayerInterior(playerid);
795 g_GatesInfo[gate_id][E_GATE_STATE] = false;
796 g_GatesInfo[gate_id][E_GATE_MODEL_ID] = 2930;
797 g_GatesInfo[gate_id][E_GATE_EXISTS] = true;
798 g_GatesInfo[gate_id][E_GATE_BY_SQLID] = g_AccountInfo[playerid][E_ACCOUNT_SQLID];
799
800 g_GatesInfo[gate_id][E_GATE_OBJECT] = CreateDynamicObject(g_GatesInfo[gate_id][E_GATE_MODEL_ID], g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2], g_GatesInfo[gate_id][E_GATE_ROT][0], g_GatesInfo[gate_id][E_GATE_ROT][1], g_GatesInfo[gate_id][E_GATE_ROT][2], g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT]);
801
802 new queryBuffer[256];
803 mysql_format(MHRP_SQL, queryBuffer, sizeof queryBuffer,
804 "INSERT INTO `Gates` (`ID`, `modelID`, `X`, `Y`, `Z`, `VW`, `INTER`, `by_SQLID`) VALUES ('%d', '%d', '%f', '%f', '%f', '%d', '%d', %d)",
805 gate_id, g_GatesInfo[gate_id][E_GATE_MODEL_ID], _pos[0], _pos[1], _pos[2], g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT], g_GatesInfo[gate_id][E_GATE_BY_SQLID]);
806 mysql_pquery(MHRP_SQL, queryBuffer, "");
807
808 // related to logs ---------------------------
809 new action[128];
810 format(action, sizeof(action), "gate created");
811
812 new oldinfo[5];
813 format(oldinfo, sizeof(oldinfo), "N/A");
814
815 new newinfo[256];
816 format(newinfo, sizeof(newinfo), "id: %d x: %f y: %f z: %f vw: %d int: %d own: %d fac: %d gro: %d",\
817 gate_id, g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2], g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT],\
818 g_GatesInfo[gate_id][E_GATE_OWNER_ID], g_GatesInfo[gate_id][E_GATE_FACTION_ID], g_GatesInfo[gate_id][E_GATE_GROUP_ID]);
819
820 new queryBuffer2[256];
821 mysql_format(MHRP_SQL, queryBuffer2, sizeof queryBuffer2,
822 "INSERT INTO `logs_gates` (`by_SQLID`, `time`, `oldinfo`, `newinfo`, `action`) VALUES ('%d', UTC_TIMESTAMP(), '%e', '%e', '%e')",
823 g_AccountInfo[playerid][E_ACCOUNT_SQLID], oldinfo, newinfo, action);
824 mysql_pquery(MHRP_SQL, queryBuffer2, "");
825 // related to logs ---------------------------
826
827 new str[128];
828 format(str, sizeof str, "%s(%d) has created a gate. [ID: %d]", ReturnICName(playerid), playerid, gate_id);
829
830 StaffBroadCast(COLOR[COLOR_SADMIN], str, 1, 1);
831 return 1;
832 }
833
834 // delete subcmd
835 else if(strmatch(subcmd, "delete"))
836 {
837 new confirm[10];
838 if(sscanf(params, "s[30]S(0)[10]", subcmd, confirm))
839 return SendClientMessage(playerid, COLOR[COLOR_INFO], "/agate delete confirm");
840
841 new gate_id;
842 if((gate_id = GATES_GetNearby(playerid)) == -1)
843 return SendClientMessage(playerid,COLOR[COLOR_ERROR],"You must be near a gate's default(closed) position.");
844
845 if(strcmp(confirm, "confirm", false))
846 return SendClientMessageEx(playerid, COLOR[COLOR_SADMIN], "If conditions remain unchanged, you are about to delete gate ID %d.", gate_id) && SendClientMessage(playerid, COLOR[COLOR_INFO], "Use '/agate delete confirm' to proceed.");
847
848 new queryBuffer[50];
849 mysql_format(MHRP_SQL, queryBuffer, sizeof queryBuffer, "DELETE FROM `Gates` WHERE `ID`='%d';", gate_id);
850 mysql_pquery(MHRP_SQL, queryBuffer, "");
851
852 // related to logs ---------------------------
853 new action[128];
854 format(action, sizeof(action), "gate deleted");
855
856 new newinfo[5];
857 format(newinfo, sizeof(newinfo), "N/A");
858
859 new oldinfo[256];
860 format(oldinfo, sizeof(oldinfo), "id: %d x: %f y: %f z: %f vw: %d int: %d own: %d fac: %d gro: %d",\
861 gate_id, g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2], g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT],\
862 g_GatesInfo[gate_id][E_GATE_OWNER_ID], g_GatesInfo[gate_id][E_GATE_FACTION_ID], g_GatesInfo[gate_id][E_GATE_GROUP_ID]);
863
864 new queryBuffer2[256];
865 mysql_format(MHRP_SQL, queryBuffer2, sizeof queryBuffer2,
866 "INSERT INTO `logs_gates` (`by_SQLID`, `time`, `oldinfo`, `newinfo`, `action`) VALUES ('%d', UTC_TIMESTAMP(), '%e', '%e', '%e')",
867 g_AccountInfo[playerid][E_ACCOUNT_SQLID], oldinfo, newinfo, action);
868 mysql_pquery(MHRP_SQL, queryBuffer2, "");
869 // related to logs ---------------------------
870
871 GATES_ResetVars(gate_id);
872
873 new str[128];
874 format(str, sizeof str, "%s(%d) has deleted a gate. [ID: %d]", ReturnICName(playerid), playerid, gate_id);
875
876 StaffBroadCast(COLOR[COLOR_SADMIN], str, 1, 1);
877
878 return 1;
879 }
880
881 // info subcmd
882 else if(strmatch(subcmd, "info"))
883 {
884 new bool:check;
885 for(new gate_id = 0; gate_id < MAX_GATES; gate_id++) // GATES_GetNearby was not used so that multiple gates near eachother can have their info loaded.
886 {
887 if(!g_GatesInfo[gate_id][E_GATE_EXISTS]) continue;
888 {
889 if(IsPlayerInRangeOfPoint(playerid, g_GatesInfo[gate_id][E_GATE_RANGE] + 1.0, g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2]))
890 if(GetPlayerVirtualWorld(playerid) == g_GatesInfo[gate_id][E_GATE_WORLD] && GetPlayerInterior(playerid) == g_GatesInfo[gate_id][E_GATE_INT])
891 {
892 SendClientMessage(playerid, COLOR[COLOR_SADMIN], "Gate info loaded.");
893 new str[128];
894 format(str, sizeof(str), "[ID: %d, Model ID: %d, Created by SQLID: %d]", gate_id, g_GatesInfo[gate_id][E_GATE_MODEL_ID], g_GatesInfo[gate_id][E_GATE_BY_SQLID]);
895 SendClientMessage(playerid, COLOR[COLOR_WHITE], str);
896 format(str, sizeof(str), "[World: %d, Interior: %d, Speed: %d, Range: %d]", g_GatesInfo[gate_id][E_GATE_WORLD], g_GatesInfo[gate_id][E_GATE_INT], g_GatesInfo[gate_id][E_GATE_SPEED], g_GatesInfo[gate_id][E_GATE_RANGE]);
897 SendClientMessage(playerid, COLOR[COLOR_WHITE], str);
898 format(str, sizeof(str), "[Owner ID: %d, Faction ID: %d, Group ID: %d]", g_GatesInfo[gate_id][E_GATE_OWNER_ID], g_GatesInfo[gate_id][E_GATE_FACTION_ID], g_GatesInfo[gate_id][E_GATE_GROUP_ID]);
899 SendClientMessage(playerid, COLOR[COLOR_WHITE], str);
900 check = true;
901 }
902 }
903 }
904 if(!check) return SendClientMessage(playerid, COLOR[COLOR_ERROR], "No gates found. Ensure you are near the default(closed) position.");
905 }
906
907 // goto subcmd
908 else if(strmatch(subcmd, "goto"))
909 {
910 new gate_id;
911
912 if(sscanf(params, "s[30]d", subcmd, gate_id))
913 return SendClientMessage(playerid, COLOR[COLOR_INFO], "/agate goto [gate id]");
914
915 if(!(0 <= gate_id < MAX_GATES))
916 return SendClientMessageEx(playerid, COLOR[COLOR_ERROR], "The gate count limit is %d. Use an ID within that range.", MAX_GATES);
917
918 if(!g_GatesInfo[gate_id][E_GATE_EXISTS])
919 return SendClientMessage(playerid, COLOR[COLOR_ERROR], "That gate ID does not exist.");
920
921 SetPlayerPos(playerid, g_GatesInfo[gate_id][E_GATE_POS][0], g_GatesInfo[gate_id][E_GATE_POS][1], g_GatesInfo[gate_id][E_GATE_POS][2]);
922 SetPlayerInterior(playerid, g_GatesInfo[gate_id][E_GATE_INT]);
923 SetPlayerVirtualWorld(playerid, g_GatesInfo[gate_id][E_GATE_WORLD]);
924
925 SendClientMessageEx(playerid, COLOR[COLOR_SADMIN], "You have been teleported to gate ID %d", gate_id);
926 return 1;
927 }
928
929 // edit subcmd
930 else if(strmatch(subcmd, "edit"))
931 {
932 new gate_id;
933
934 if(sscanf(params, "s[30]d", subcmd, gate_id))
935 return SendClientMessage(playerid, COLOR[COLOR_INFO], "/agate edit [gate id]");
936
937 if(!(0 <= gate_id < MAX_GATES))
938 return SendClientMessageEx(playerid, COLOR[COLOR_ERROR], "The gate count limit is %d. Use an ID within that range.", MAX_GATES);
939
940 if(!g_GatesInfo[gate_id][E_GATE_EXISTS])
941 return SendClientMessage(playerid, COLOR[COLOR_INFO], "That gate ID does not exist.");
942
943 GATES_AdminEditDialog(playerid, gate_id, E_GATE_EDIT_INFO);
944 return 1;
945 }
946
947 // if no strmatch
948 else return SendClientMessage(playerid, COLOR[COLOR_ERROR], "That subcommand does not exist.");
949 }
950
951 else return SendClientMessage(playerid,COLOR[COLOR_ERROR],"You do not have the required access to execute this command.");
952
953 return 1;
954}
955
956
957// player commands
958
959////gate > open gate, if group/fac assigned no pass required, check for pass last. would be cool if there was a shortcut for this too
960
961////gatepass > set gate pass as owner