View difference between Paste ID: 6EmHgYm2 and vSMZkE9r
SHOW: | | - or go back to the newest paste.
1
// Sayros Dynamic Object System V1.0
2
// This FilterScript Is made by Sayros!
3
// August 27, 2014 : Date of release
4
//For SAMP 0.3z
5
// Please If you are attempting to Edit This filterscript, make sure you mention that it is edited and always refer to the Original link: http://forum.sa-mp.com/showthread.php?p=3177962#post3177962
6
7
//This Gate System allows you to create objects and move them, edit their pass, owner, range, speed and MUCH more
8
//Do not forget to add an Empty folder called "Gates" inside the filterscriptes Folder
9
10
11
12
13
#define FILTERSCRIPT
14
//includes
15
#include <a_samp>
16
#include <zcmd>
17
#include <sscanf2>
18
#include <YSI\y_ini>
19
20
//Some Colors
21
#define COLOR_WHITE 0xFFFFFFFF
22
#define COL_WHITE "{FFFFFF}"
23
#define COL_RED "{F81414}"
24
#define COL_GREEN "{00FF22}"
25
#define COL_LIGHTBLUE "{00CED1}"
26
//DIALOGS
27
#define DIALOG_GATE 1
28
#define DIALOG_CREATEGATE 2
29
#define DIALOG_GOTOGATE 3
30
#define DIALOG_GEDITPOS 4
31
#define DIALOG_GEDITPOSM 5
32
#define DIALOG_EDITGMODEL 6
33
#define DIALOG_NEWGMODEL 7
34
#define DIALOG_GUNMOVABLE 8
35
#define DIALOG_DELETEGATE 9
36
#define DIALOG_EDITGPASS 10
37
#define DIALOG_EDITGOWNER 11
38
#define DIALOG_NEWGPASS 12
39
#define DIALOG_NEWGOWNER 13
40
#define DIALOG_EDITGSPEED 14
41
#define DIALOG_EDITGRANGE 15
42
#define DIALOG_NEWGSPEED 16
43
#define DIALOG_NEWGRANGE 17
44
#define DIALOG_GATEINFOS 18
45
#define DIALOG_GPOSTOME 19
46
#define DIALOG_GPOSLIST 20
47
#define DIALOG_GPOSMLIST 21
48
#define DIALOG_GCOORDS 22
49
#define DIALOG_GMCOORDS 23
50
#define DIALOG_NEWGCOORDS 24
51
#define DIALOG_NEWGMCOORDS 25
52
#define DIALOG_NEWGCOORD 26
53
#define DIALOG_NEWGMCOORD 27
54
#define DIALOG_GCHANGEPASS 28
55
#if !defined isnull
56
    #define isnull(%1) \
57
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
58
#endif
59
//ALL variables here
60
new lastgate;
61
new Float:Gpos[1000][3], Float:Gposm[1000][3], Float:Grot[1000][3], Float:Grotm[1000][3];
62
new fgmodelid[1000],fgateid[1000], gpassword[1000][25], gowner[1000][MAX_PLAYER_NAME], Float:gspeed[1000], Float:grange[1000];
63
new bool:normalpostest[1000], bool:posmtest[1000], Float:Oldp[1000][3], Float:Oldr[1000][3], gsaveid[MAX_PLAYERS], glistitem[MAX_PLAYERS], bool:GateStatus[1000], OpenedTimer[MAX_PLAYERS][1000], ClosedTimer[MAX_PLAYERS][1000];
64
forward LoadGateData_data(fobjectid, name[], value[]);
65
forward LoadLastGate_data(name[], value[]);
66
forward GateClosed(playerid);
67
forward GateOpened(playerid);
68
// Functions
69
GateINI(gatenumber)
70
{
71
	new gastring[128];
72
	format(gastring, 128, "/Gates/Gate%i.INI", gatenumber);
73
	return gastring;
74
}
75
public LoadGateData_data(fobjectid, name[], value[])
76
{
77
	INI_Int("gateid", fgateid[fobjectid]);
78
	INI_Int("gatemodel", fgmodelid[fobjectid]);
79
	INI_Float("speed", gspeed[fobjectid]);
80
	INI_Float("range", grange[fobjectid]);
81
	INI_String("password", gpassword[fobjectid], 25);
82
	INI_String("owner", gowner[fobjectid], MAX_PLAYER_NAME);
83
	INI_Float("gposx", Gpos[fobjectid][0]);
84
	INI_Float("gposy", Gpos[fobjectid][1]);
85
	INI_Float("gposz", Gpos[fobjectid][2]);
86
	INI_Float("grotx", Grot[fobjectid][0]);
87
	INI_Float("groty", Grot[fobjectid][1]);
88
	INI_Float("grotz", Grot[fobjectid][2]);
89
	INI_Float("gposxm", Gposm[fobjectid][0]);
90
	INI_Float("gposym", Gposm[fobjectid][1]);
91
	INI_Float("gposzm", Gposm[fobjectid][2]);
92
	INI_Float("grotxm", Grotm[fobjectid][0]);
93
	INI_Float("grotym", Grotm[fobjectid][1]);
94
	INI_Float("grotzm", Grotm[fobjectid][2]);
95
	return 1;
96
}
97
public LoadLastGate_data(name[], value[])
98
{
99
	INI_Int("lastgate", lastgate);
100
	return 1;
101
}
102
public GateOpened(playerid)
103
{
104
	SendClientMessage(playerid, -1, ""COL_GREEN"Gate Opened!");
105
}
106
public GateClosed(playerid)
107
{
108
	SendClientMessage(playerid, -0x8C8C8C8C, "Gate Closed!");
109
}
110
111
public OnFilterScriptInit()
112
{
113
	print("\n--------------------------------------");
114
	print(" Gate Sysem By Sayros");
115
	print("--------------------------------------\n");
116
	INI_ParseFile("/Gates/gdata.INI", "LoadLastGate_%s");
117
	for (new j=1; j<= lastgate; j++)
118
	{
119
	    if (fexist(GateINI(j)))
120
	    {
121
	        INI_ParseFile(GateINI(j), "LoadGateData_%s", .bExtra = true, .extra = j);
122
			new gid = CreateObject(fgmodelid[j], Gpos[j][0], Gpos[j][1], Gpos[j][2], Grot[j][0], Grot[j][1], Grot[j][2], 100.0);
123
			new INI:gatefile = INI_Open(GateINI(j));
124
			INI_SetTag(gatefile, "data");
125
			INI_WriteInt(gatefile, "gateid", gid);
126
			INI_Close(gatefile);
127
			GateStatus[j] = false;
128
		}
129
	}
130
	return 1;
131
}
132
133
public OnFilterScriptExit()
134
{
135
	return 1;
136
}
137
public OnPlayerRequestClass(playerid, classid)
138
{
139
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
140
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
141
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
142
	return 1;
143
}
144
145
public OnPlayerConnect(playerid)
146
{
147
	return 1;
148
}
149
150
public OnPlayerDisconnect(playerid, reason)
151
{
152
	return 1;
153
}
154
155
public OnPlayerSpawn(playerid)
156
{
157
	return 1;
158
}
159
160
public OnPlayerDeath(playerid, killerid, reason)
161
{
162
	return 1;
163
}
164
165
public OnVehicleSpawn(vehicleid)
166
{
167
	return 1;
168
}
169
170
public OnVehicleDeath(vehicleid, killerid)
171
{
172
	return 1;
173
}
174
175
public OnPlayerText(playerid, text[])
176
{
177
	return 1;
178
}
179
180
public OnPlayerCommandText(playerid, cmdtext[])
181
{
182
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
183
	{
184
		// Do something here
185
		return 1;
186
	}
187
	return 0;
188
}
189
190
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
191
{
192
	return 1;
193
}
194
195
public OnPlayerExitVehicle(playerid, vehicleid)
196
{
197
	return 1;
198
}
199
200
public OnPlayerStateChange(playerid, newstate, oldstate)
201
{
202
	return 1;
203
}
204
205
public OnPlayerEnterCheckpoint(playerid)
206
{
207
	return 1;
208
}
209
210
public OnPlayerLeaveCheckpoint(playerid)
211
{
212
	return 1;
213
}
214
215
public OnPlayerEnterRaceCheckpoint(playerid)
216
{
217
	return 1;
218
}
219
220
public OnPlayerLeaveRaceCheckpoint(playerid)
221
{
222
	return 1;
223
}
224
225
public OnRconCommand(cmd[])
226
{
227
	return 1;
228
}
229
230
public OnPlayerRequestSpawn(playerid)
231
{
232
	return 1;
233
}
234
235
public OnObjectMoved(objectid)
236
{
237
	return 1;
238
}
239
240
public OnPlayerObjectMoved(playerid, objectid)
241
{
242
	return 1;
243
}
244
245
public OnPlayerPickUpPickup(playerid, pickupid)
246
{
247
	return 1;
248
}
249
250
public OnVehicleMod(playerid, vehicleid, componentid)
251
{
252
	return 1;
253
}
254
255
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
256
{
257
	return 1;
258
}
259
260
public OnVehicleRespray(playerid, vehicleid, color1, color2)
261
{
262
	return 1;
263
}
264
265
public OnPlayerSelectedMenuRow(playerid, row)
266
{
267
	return 1;
268
}
269
270
public OnPlayerExitedMenu(playerid)
271
{
272
	return 1;
273
}
274
275
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
276
{
277
	return 1;
278
}
279
280
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
281
{
282
	return 1;
283
}
284
285
public OnRconLoginAttempt(ip[], password[], success)
286
{
287
	return 1;
288
}
289
290
public OnPlayerUpdate(playerid)
291
{
292
	return 1;
293
}
294
295
public OnPlayerStreamIn(playerid, forplayerid)
296
{
297
	return 1;
298
}
299
300
public OnPlayerStreamOut(playerid, forplayerid)
301
{
302
	return 1;
303
}
304
305
public OnVehicleStreamIn(vehicleid, forplayerid)
306
{
307
	return 1;
308
}
309
310
public OnVehicleStreamOut(vehicleid, forplayerid)
311
{
312
	return 1;
313
}
314
315
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
316
{
317
318
	if (dialogid == DIALOG_GATE)
319
	{
320
	if (response)
321
	{
322
		if (listitem == 0) ShowPlayerDialog(playerid, DIALOG_CREATEGATE, DIALOG_STYLE_INPUT, "Model ID", "Type the model ID here", "Ok", "Cancel");
323
		if (listitem == 1) ShowPlayerDialog(playerid, DIALOG_GOTOGATE, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID that you want to go to!", "Ok", "Cancel");
324
		if (listitem == 2) ShowPlayerDialog(playerid, DIALOG_GATEINFOS, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to find its infos!", "Ok", "Cancel");
325
		if (listitem == 3)
326
		{
327
		    SendClientMessage(playerid, 0xFFFFFFFF, "------------------------Near Gates (use  { /gate --> Go to gate } to find  a specific gate)------------------------");
328
		    new astring[128];
329
		    for (new j=1; j<=lastgate; j++)
330
			{
331
			    if (fexist(GateINI(j)))
332
			    {
333
					new Float:p[3];
334
					INI_ParseFile(GateINI(j), "LoadGateData_%s", .bExtra = true, .extra = j);
335
					GetObjectPos(fgateid[j], p[0], p[1], p[2]);
336
					if (IsPlayerInRangeOfPoint(playerid, 50, p[0], p[1], p[2]))
337
					{
338
			    		new Float:dis = GetPlayerDistanceFromPoint(playerid, Gpos[j][0], Gpos[j][1], Gpos[j][2]);
339
			    		new d = floatround(dis);
340
341
342
			    		format(astring, 128, "%Gate ID: %i, Distance: %i.", j, d);
343
			    		SendClientMessage(playerid, 0x99FF66, astring);
344
					}
345
				}
346
			}
347
		}
348
349
		if (listitem == 4) ShowPlayerDialog(playerid, DIALOG_GPOSTOME, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID!", "Ok", "Cancel");
350
		if (listitem == 5) ShowPlayerDialog(playerid, DIALOG_GPOSLIST, DIALOG_STYLE_LIST, "Edit Gate's Pos", "Edit by typing the coords\nEdit using the Graphical User Interface", "Ok", "Cancel");
351
		if (listitem == 6) ShowPlayerDialog(playerid, DIALOG_GPOSMLIST, DIALOG_STYLE_LIST, "Edit Gate's PosM", "Edit by typing the coords\nEdit using the Graphical User Interface", "Ok", "Cancel");
352
		if (listitem == 7) ShowPlayerDialog(playerid, DIALOG_EDITGMODEL, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change the model for!", "Ok", "Cancel");
353
		if (listitem == 8) ShowPlayerDialog(playerid, DIALOG_EDITGSPEED, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change the speed for!", "Ok", "Cancel");
354
		if (listitem == 9) ShowPlayerDialog(playerid, DIALOG_EDITGRANGE, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change the range for!", "Ok", "Cancel");
355
		if (listitem == 10) ShowPlayerDialog(playerid, DIALOG_GUNMOVABLE, DIALOG_STYLE_INPUT, "Gate ID", "Make gate Unmovable, Type the gate's ID!",  "Ok", "Cancel");
356
		if (listitem == 11) ShowPlayerDialog(playerid, DIALOG_EDITGPASS, DIALOG_STYLE_INPUT, "Gate ID", "ID of the gate to set the pass for!", "Ok", "Cancel");
357
		if (listitem == 12) ShowPlayerDialog(playerid, DIALOG_EDITGOWNER, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID!", "Ok", "Cancel");
358
		if (listitem == 13) ShowPlayerDialog(playerid, DIALOG_DELETEGATE, DIALOG_STYLE_INPUT, "Gate ID", "The ID of the Gate to be deleted!", "Ok", "Cancel");
359
360
	}
361
	}
362
	else if (dialogid == DIALOG_CREATEGATE)
363
	{
364
	    if (response)
365
	    {
366
	        new Float:p[3], Float:fa, gateid, gmodelid, nextgate;
367
			GetPlayerPos(playerid, p[0], p[1], p[2]);
368
			GetPlayerFacingAngle(playerid, fa);
369
			gmodelid= strval(inputtext);
370
			gateid = CreateObject(gmodelid, p[0]+0.15, p[1]+0.15, p[2]+1, 0, 0, fa, 100);
371
			lastgate++;
372
			for (new n = lastgate; n>=1; n--)
373
			{
374
			    if (!fexist(GateINI(n))) nextgate = n;
375
			}
376
			if (nextgate != lastgate) lastgate --;
377
			new INI:gatedata = INI_Open("/Gates/gdata.INI");
378
			INI_SetTag(gatedata, "data");
379
			INI_WriteInt(gatedata, "lastgate", lastgate);
380
			INI_Close(gatedata);
381
			new INI:gatefile = INI_Open(GateINI(nextgate));
382
			INI_SetTag(gatefile, "data");
383
			INI_WriteInt(gatefile, "gateid", gateid);
384
			INI_WriteInt(gatefile, "gatemodel", gmodelid);
385
			INI_WriteFloat(gatefile, "speed", 0);
386
			INI_WriteFloat(gatefile, "range", 0);
387
			INI_WriteString(gatefile, "password", "none");
388
			INI_WriteString(gatefile, "owner", "none");
389
			INI_WriteFloat(gatefile, "gposx", p[0]+1);
390
			INI_WriteFloat(gatefile, "gposy", p[1]+1);
391
			INI_WriteFloat(gatefile, "gposz", p[2]+1);
392
			INI_WriteFloat(gatefile, "grotx", 0);
393
			INI_WriteFloat(gatefile, "groty", 0);
394
			INI_WriteFloat(gatefile, "grotz", fa);
395
			INI_WriteFloat(gatefile, "gposxm", p[0]+1);
396
			INI_WriteFloat(gatefile, "gposym", p[1]+1);
397
			INI_WriteFloat(gatefile, "gposzm", p[2]+1);
398
			INI_WriteFloat(gatefile, "grotxm", 0);
399
			INI_WriteFloat(gatefile, "grotym", 0);
400
			INI_WriteFloat(gatefile, "grotzm", fa);
401
			INI_Close(gatefile);
402
			GateStatus[nextgate] = false;
403
			new gatecreated[128];
404
			format(gatecreated, 128, "Gate Created ID: %i", nextgate);
405
			SendClientMessage(playerid, COLOR_WHITE ,gatecreated);
406
		}
407
	}
408
	else if(dialogid == DIALOG_GOTOGATE)
409
	{
410
		if(response)
411
		{
412
		    new fobjectid;
413
		    fobjectid = strval(inputtext);
414
			if (fexist( GateINI(fobjectid) ) )
415
			{
416
			    new Float:p[3];
417
			    INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
418
			    GetObjectPos(fgateid[fobjectid], p[0], p[1], p[2]);
419
			    SetPlayerPos(playerid, p[0]+1, p[1]+1, p[2]+1);
420
			}
421
			else SendClientMessage(playerid, -1, ""COL_RED"This gate does not exist!");
422
		}
423
	}
424
	else if (dialogid == DIALOG_GEDITPOS)
425
	{
426
		if (response)
427
		{
428
		    new fobjectid;
429
		    fobjectid = strval(inputtext);
430
		    if (fexist(GateINI(fobjectid)))
431
		    {
432
		    INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
433
		    if (IsPlayerInRangeOfPoint(playerid, 25, Gpos[fobjectid][0], Gpos[fobjectid][1], Gpos[fobjectid][2]))
434
		    {
435
		    GetObjectPos(fgateid[fobjectid], Oldp[fobjectid][0], Oldp[fobjectid][1], Oldp[fobjectid][2]);
436
			GetObjectRot(fgateid[fobjectid], Oldr[fobjectid][0], Oldr[fobjectid][1], Oldr[fobjectid][2]);
437
		    normalpostest[fobjectid] = true;
438
		    posmtest[fobjectid] = false;
439
			EditObject(playerid, fgateid[fobjectid]);
440
			}
441
		    else SendClientMessage(playerid, -1, ""COL_GREEN"You must be near the gate!");
442
		    }
443
		    else SendClientMessage(playerid, -1, ""COL_RED"This gate does not exist!");
444
		}
445
	}
446
	else if (dialogid == DIALOG_GEDITPOSM)
447
	{
448
		if (response)
449
		{
450
		    new fobjectid;
451
		    fobjectid = strval(inputtext);
452
		    if (fexist(GateINI(fobjectid)))
453
		    {
454
		    INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
455
		    if (IsPlayerInRangeOfPoint(playerid, 25, Gpos[fobjectid][0], Gpos[fobjectid][1], Gpos[fobjectid][2]))
456
			{
457
			GetObjectPos(fgateid[fobjectid], Oldp[fobjectid][0], Oldp[fobjectid][1], Oldp[fobjectid][2]);
458
			GetObjectRot(fgateid[fobjectid], Oldr[fobjectid][0], Oldr[fobjectid][1], Oldr[fobjectid][2]);
459
			posmtest[fobjectid] = true;
460
			normalpostest[fobjectid] = false;
461
		 	EditObject(playerid, fgateid[fobjectid]);
462
			}
463
		    else SendClientMessage(playerid, -1, ""COL_GREEN"You must be near the gate!");
464
		    }
465
		    else SendClientMessage(playerid, -1, ""COL_RED"This gate does not exist!");
466
		}
467
	}
468
	else if (dialogid == DIALOG_EDITGMODEL)
469
	{
470
	    if (response)
471
	    {
472
     		new fobjectid;
473
		    fobjectid = strval(inputtext);
474
		    if (fexist(GateINI(fobjectid)))
475
		    {
476
				gsaveid[playerid] = fobjectid;
477
				ShowPlayerDialog(playerid, DIALOG_NEWGMODEL, DIALOG_STYLE_INPUT, "Gate ID", "Type the new gate model ID.",  "Ok", "Cancel");
478
			}
479
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
480
		}
481
	}
482
	else if (dialogid == DIALOG_NEWGMODEL)
483
	{
484
		if (response)
485
		{
486
		    new gid, modelg = strval(inputtext);
487
		    INI_ParseFile(GateINI(gsaveid[playerid]), "LoadGateData_%s", .bExtra = true, .extra = gsaveid[playerid]);
488
		    DestroyObject(fgateid[gsaveid[playerid]]);
489
		    gid = CreateObject(modelg, Gpos[gsaveid[playerid]][0], Gpos[gsaveid[playerid]][1], Gpos[gsaveid[playerid]][2], Grot[gsaveid[playerid]][0], Grot[gsaveid[playerid]][1], Grot[gsaveid[playerid]][2], 100);
490
			new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
491
			INI_SetTag(gatefile, "data");
492
			INI_WriteInt(gatefile, "gateid", gid);
493
			INI_WriteInt(gatefile, "gatemodel", modelg);
494
			INI_Close(gatefile);
495
			GateStatus[gsaveid[playerid]] = false;
496
			SendClientMessage(playerid, -1, ""COL_GREEN"Gate Model changed");
497
		}
498
	}
499
	else if (dialogid == DIALOG_GUNMOVABLE)
500
	{
501
	    if (response)
502
	    {
503
	      	new fobjectid, astring[128];
504
		    fobjectid = strval(inputtext);
505
		    if (fexist(GateINI(fobjectid)))
506
		    {
507
		        INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
508
				new INI:gatefile = INI_Open(GateINI(fobjectid));
509
				INI_SetTag(gatefile, "data");
510
				INI_WriteFloat(gatefile, "speed", 0);
511
				INI_WriteFloat(gatefile, "range", 0);
512
				INI_WriteFloat(gatefile, "gposxm", Gpos[fobjectid][0]);
513
				INI_WriteFloat(gatefile, "gposym", Gpos[fobjectid][1]);
514
				INI_WriteFloat(gatefile, "gposzm", Gpos[fobjectid][2]);
515
				INI_WriteFloat(gatefile, "grotxm", Grot[fobjectid][0]);
516
				INI_WriteFloat(gatefile, "grotym", Grot[fobjectid][1]);
517
				INI_WriteFloat(gatefile, "grotzm", Grot[fobjectid][2]);
518
				INI_Close(gatefile);
519
				format(astring, 128, ""COL_GREEN"Gate %i is now unmovable, Edit the gate's movement, the range and the speed to make it movable again", fobjectid);
520
				SendClientMessage(playerid, -1,astring);
521
			}
522
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
523
		}
524
	}
525
	else if (dialogid == DIALOG_DELETEGATE)
526
	{
527
	    if (response)
528
	    {
529
	    	new fobjectid, astring [128];
530
	    	fobjectid = strval(inputtext);
531
	    	if (fexist(GateINI(fobjectid)))
532
	    	{
533
				INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
534
				DestroyObject(fgateid[fobjectid]);
535
				fremove(GateINI(fobjectid));
536
				if (fobjectid == lastgate)
537
				{
538
		  			new fakelastgate = lastgate;
539
					for (new j = 1; j<=fakelastgate; j++)
540
					{
541
					    if (fexist(GateINI(j))) lastgate = j;
542
					}
543
					new INI:gatedata = INI_Open("/Gates/gdata.INI");
544
					INI_SetTag(gatedata, "data");
545
					INI_WriteInt(gatedata, "lastgate", lastgate);
546
					INI_Close(gatedata);
547
				}
548
				format(astring, 128, ""COL_GREEN"You have deleted Gate ID %i", fobjectid);
549
				SendClientMessage(playerid, -1, astring);
550
			}
551
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist");
552
		}
553
	}
554
	else if (dialogid == DIALOG_EDITGPASS)
555
	{
556
	    if (response)
557
		{
558
		    new fobjectid = strval(inputtext);
559
		    if (fexist(GateINI(fobjectid)))
560
			{
561
			gsaveid[playerid] = fobjectid;
562
			ShowPlayerDialog(playerid, DIALOG_NEWGPASS, DIALOG_STYLE_INPUT,"Gate's Password", ""COL_GREEN"Type the gate's pass (25 characters MAX), type 'none' to remove the pass", "Ok", "Cancel");
563
			}
564
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
565
		}
566
	}
567
	else if(dialogid == DIALOG_NEWGPASS)
568
	{
569
	    if (response)
570
	    {
571
			if (strlen(inputtext)>25) ShowPlayerDialog(playerid, DIALOG_NEWGPASS, DIALOG_STYLE_INPUT, "Gate's Password", ""COL_GREEN"Password "COL_RED"CANNOT"COL_GREEN"pass 25 characters", "Ok", "Cancel");
572
		    else
573
		    {
574
		        new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
575
		        INI_SetTag(gatefile, "data");
576
		        INI_WriteString(gatefile, "password", inputtext);
577
		        INI_Close(gatefile);
578
		        new astring[128];
579
		        format(astring, 128, ""COL_LIGHTBLUE"You have changed Gate %i's pass to \"%s\".", gsaveid[playerid], inputtext);
580
		        SendClientMessage(playerid, -1, astring);
581
			}
582
		}
583
	}
584
	else if (dialogid == DIALOG_EDITGOWNER)
585
	{
586
	    if (response)
587
	    {
588
	        new astring[128];
589
     		new fobjectid = strval(inputtext);
590
			gsaveid[playerid] = fobjectid;
591
		    if (fexist(GateINI(fobjectid)))
592
			{
593
			    INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
594
			    if( !strcmp(gowner[fobjectid], "none")) ShowPlayerDialog(playerid, DIALOG_NEWGOWNER, DIALOG_STYLE_INPUT,"Set Gate Owner", "This Gate is not owned: please type the new Owner ID/Name", "Ok", "Cancel");
595
			    else
596
			    {
597
			        format(astring, 128, ""COL_RED"This gate (ID: %i) is Owned by %s! If you want to change the owner type the new owner name/ID", fobjectid, gowner[fobjectid]);
598
                    ShowPlayerDialog(playerid, DIALOG_NEWGOWNER, DIALOG_STYLE_INPUT,"Set Gate Owner", astring, "Ok", "Cancel");
599
				}
600
			}
601
			else    SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
602
		}
603
	}
604
	else if (dialogid == DIALOG_NEWGOWNER)
605
	{
606
	    if (response)
607
	    {
608
	        new ostring[MAX_PLAYER_NAME], astring[128];
609
	        strcpy(ostring, gowner[gsaveid[playerid]]);
610
	        new plid;
611
			if (sscanf(inputtext, "u", plid)) SendClientMessage(playerid, -1, ""COL_RED"Invalid Player ID/Name");
612
			else if (plid == INVALID_PLAYER_ID) SendClientMessage(playerid, -1, ""COL_RED"Invalid Player");
613
			else
614
			{
615
			    new pname[MAX_PLAYER_NAME];
616
			    GetPlayerName(plid, pname, MAX_PLAYER_NAME);
617
			    if(!strcmp(gowner[gsaveid[playerid]], pname))
618
			    {
619
       				format(astring, 128, ""COL_WHITE"%s is already the owner of the gate %i", pname, gsaveid[playerid]);
620
       				SendClientMessage(playerid, -1, astring);
621
				}
622
				else
623
				{
624
			    	new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
625
			    	INI_SetTag(gatefile, "data");
626
			    	INI_WriteString(gatefile, "owner", pname);
627
			    	INI_Close(gatefile);
628
			    	if (!strcmp(ostring, "none")) format(astring, 128, ""COL_GREEN"You have set %s to be the owner of the gate %i.", pname, gsaveid[playerid]);
629
			    	else format(astring, 128, ""COL_GREEN"%s is no longer the owner of the gate %i. %s is the new owner", ostring, gsaveid[playerid], pname);
630
			    	SendClientMessage(playerid, -1, astring);
631
				}
632
			}
633
		}
634
	}
635
	else if (dialogid == DIALOG_EDITGSPEED)
636
	{
637
	    if (response)
638
	    {
639
			new fobjectid = strval(inputtext);
640
			gsaveid[playerid] = fobjectid;
641
			if (fexist(GateINI(fobjectid)))
642
			{
643
			    ShowPlayerDialog(playerid, DIALOG_NEWGSPEED, DIALOG_STYLE_INPUT, "Set Speed", "Type the new Speed here(50 MAX)", "Ok", "Cancel");
644
			}
645
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
646
		}
647
	}
648
	else if (dialogid == DIALOG_NEWGSPEED)
649
	{
650
	    if (response)
651
	    {
652
	        new astring[128], Float:gsp = floatstr(inputtext);
653
	        if (gsp<=50)
654
			{
655
			    new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
656
			    INI_SetTag(gatefile, "data");
657
			    INI_WriteFloat(gatefile, "speed", gsp);
658
			    INI_Close(gatefile);
659
			    format(astring, 128, ""COL_LIGHTBLUE"You have set gate %i Speed on %f.", gsaveid[playerid], gsp);
660
				SendClientMessage(playerid, -1, astring);
661
662
			}
663
			else ShowPlayerDialog(playerid, DIALOG_NEWGSPEED, DIALOG_STYLE_INPUT, "Set Speed", ""COL_GREEN"Speed "COL_RED"CANNOT"COL_GREEN" pass 30!", "Ok", "Cancel");
664
		}
665
	}
666
	else if (dialogid == DIALOG_EDITGRANGE)
667
	{
668
	    if (response)
669
	    {
670
            new fobjectid = strval(inputtext);
671
			gsaveid[playerid] = fobjectid;
672
			if (fexist(GateINI(fobjectid)))
673
			{
674
			    ShowPlayerDialog(playerid, DIALOG_NEWGRANGE, DIALOG_STYLE_INPUT, "Set Range", "Type the new Range here(100 MAX)", "Ok", "Cancel");
675
			}
676
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
677
		}
678
	 }
679
	else if (dialogid == DIALOG_NEWGRANGE)
680
	{
681
		if (response)
682
 		{
683
	        new astring[128], Float:gran = floatstr(inputtext);
684
	        if (gran<=100)
685
			{
686
			    new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
687
			    INI_SetTag(gatefile, "data");
688
			    INI_WriteFloat(gatefile, "range", gran);
689
			    INI_Close(gatefile);
690
			    format(astring, 128, ""COL_LIGHTBLUE"You have set gate %i Range on %f.", gsaveid[playerid], gran);
691
				SendClientMessage(playerid, -1, astring);
692
			}
693
            else ShowPlayerDialog(playerid, DIALOG_NEWGSPEED, DIALOG_STYLE_INPUT, "Set Speed", ""COL_GREEN"Range"COL_RED"CANNOT"COL_GREEN" pass 50!", "Ok", "Cancel");
694
		}
695
	}
696
	else if (dialogid == DIALOG_GATEINFOS)
697
	{
698
    	if (response)
699
    	{
700
    	    new fobjectid = strval(inputtext);
701
    	    if(fexist(GateINI(fobjectid)))
702
        	{
703
            new astring[146];
704
            INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
705
            format(astring, sizeof(astring), "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
706
            SendClientMessage(playerid, 0x9ACD3200, astring);
707
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE"Gate ID: %i "COL_GREEN"||"COL_WHITE" Model ID: %i "COL_GREEN"||"COL_WHITE" Speed: %f "COL_GREEN"||", fobjectid, fgmodelid[fobjectid], gspeed[fobjectid]);
708
            SendClientMessage(playerid, -1, astring);
709
			format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" Range: %f "COL_GREEN"||"COL_WHITE" Owner: %s "COL_GREEN"||"COL_WHITE" Pass: %s "COL_GREEN"||", grange[fobjectid], gowner[fobjectid], gpassword[fobjectid]);
710
            SendClientMessage(playerid, -1, astring);
711
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" PosX: %f "COL_GREEN"|| "COL_WHITE"PosY: %f "COL_GREEN"|| "COL_WHITE"PosZ: %f "COL_GREEN"||", Gpos[fobjectid][0], Gpos[fobjectid][1], Gpos[fobjectid][2]);
712
            SendClientMessage(playerid, -1, astring);
713
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" RotX: %f "COL_GREEN"|| "COL_WHITE"RotY: %f "COL_GREEN"|| "COL_WHITE"RotZ: %f "COL_GREEN"||", Grot[fobjectid][0], Grot[fobjectid][1], Grot[fobjectid][2]);
714
            SendClientMessage(playerid, -1, astring);
715
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" PosXm: %f "COL_GREEN"|| "COL_WHITE"PosYm: %f "COL_GREEN"|| "COL_WHITE"PosZm: %f "COL_GREEN"||", Gposm[fobjectid][0], Gposm[fobjectid][1], Gposm[fobjectid][2]);
716
            SendClientMessage(playerid, -1, astring);
717
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" RotXm: %f "COL_GREEN"|| "COL_WHITE"RotYm: %f "COL_GREEN"|| "COL_WHITE"RotZm: %f "COL_GREEN"||", Grotm[fobjectid][0], Grotm[fobjectid][1], Grotm[fobjectid][2]);
718
            SendClientMessage(playerid, -1, astring);
719
            format(astring, sizeof(astring), "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
720
            SendClientMessage(playerid, 0x9ACD3200, astring);
721
        	}
722
        	else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
723
    	}
724
	}
725
	else if (dialogid == DIALOG_GPOSTOME)
726
	{
727
	    if (response)
728
	    {
729
	        new fobjectid = strval(inputtext);
730
    	    if(fexist(GateINI(fobjectid)))
731
    	    {
732
    	        new Float:p[3];
733
    	        GetPlayerPos(playerid, p[0], p[1], p[2]);
734
    	        INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
735
    	        SetObjectPos(fgateid[fobjectid], p[0]+0.15, p[1]+0.15, p[2]+0.15);
736
    	        new INI:gatefile = INI_Open(GateINI(fobjectid));
737
    	        INI_SetTag(gatefile, "data");
738
    	        INI_WriteFloat(gatefile, "gposx", p[0]+0.15);
739
    	        INI_WriteFloat(gatefile, "gposy", p[1]+0.15);
740
    	        INI_WriteFloat(gatefile, "gposz", p[2]+0.15);
741
    	        INI_Close(gatefile);
742
    	        GateStatus[fobjectid] = false;
743
			}
744
			else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
745
		}
746
	}
747
	else if (dialogid == DIALOG_GPOSLIST)
748
	{
749
	    if (response)
750
		{
751
	 		if (listitem == 1) ShowPlayerDialog(playerid, DIALOG_GEDITPOS, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change its position!", "Ok", "Cancel");
752
	    	else if (listitem == 0) ShowPlayerDialog(playerid, DIALOG_GCOORDS, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change its position!", "Ok", "Cancel");
753
		}
754
	}
755
	else if (dialogid == DIALOG_GPOSMLIST)
756
	{
757
	    if (response)
758
		{
759
	 		if (listitem == 1) ShowPlayerDialog(playerid, DIALOG_GEDITPOSM, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change its Movement Position!", "Ok", "Cancel");
760
	    	else if (listitem == 0) ShowPlayerDialog(playerid, DIALOG_GMCOORDS, DIALOG_STYLE_INPUT, "Gate ID", "Type the gate's ID to change its Movement Position!", "Ok", "Cancel");
761
		}
762
	}
763
	else if (dialogid == DIALOG_GCOORDS)
764
	{
765
	    if (response)
766
	    {
767
	        new fobjectid = strval(inputtext);
768
	        gsaveid[playerid] = fobjectid;
769
	        if (fexist(GateINI(fobjectid))) ShowPlayerDialog(playerid,DIALOG_NEWGCOORDS, DIALOG_STYLE_LIST, "New Gate's Coords", "PosX\nPosY\nPosZ\nRotX\nRotY\nRotZ", "Ok", "Cancel");
770
	        else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
771
		}
772
	}
773
	else if (dialogid == DIALOG_GMCOORDS)
774
	{
775
	    if (response)
776
	    {
777
	        new fobjectid = strval(inputtext);
778
	        gsaveid[playerid] = fobjectid;
779
	        if (fexist(GateINI(fobjectid))) ShowPlayerDialog(playerid,DIALOG_NEWGMCOORDS, DIALOG_STYLE_LIST, "New Gate's Movement Coords", "PosXm\nPosYm\nPosZm\nRotXm\nRotYm\nRotZm", "Ok", "Cancel");
780
	        else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
781
		}
782
	}
783
	else if(dialogid == DIALOG_NEWGCOORDS)
784
	{
785
		if (response)
786
		{
787
			new liststring[6][5], astring[64];
788
			strcpy(liststring[0], "PosX");
789
			strcpy(liststring[1], "PosY");
790
			strcpy(liststring[2], "PosZ");
791
			strcpy(liststring[3], "RotX");
792
			strcpy(liststring[4], "RotY");
793
			strcpy(liststring[5], "RotZ");
794
			glistitem[playerid] = listitem;
795
			format(astring, 64, ""COL_GREEN"Edit %s, Gate ID: %i", liststring[listitem], gsaveid[playerid]);
796
			ShowPlayerDialog(playerid, DIALOG_NEWGCOORD, DIALOG_STYLE_INPUT,"Edit Pos", astring, "Ok", "Cancel");
797
		}
798
	}
799
	else if(dialogid == DIALOG_NEWGMCOORDS)
800
	{
801
		if (response)
802
		{
803
			new liststrings[6][6]; // idk why ask in samp forums
804
			strcpy(liststrings[0], "PosXm");
805
			strcpy(liststrings[1], "PosYm");
806
			strcpy(liststrings[2], "PosZm");
807
			strcpy(liststrings[3], "RotXm");
808
			strcpy(liststrings[4], "RotYm");
809
			strcpy(liststrings[5], "RotZm");
810
		    new astring[64];
811
			glistitem[playerid] = listitem;
812
			format(astring, 64, ""COL_GREEN"Edit %s, Gate ID: %i", liststrings[listitem], gsaveid[playerid]);
813
			ShowPlayerDialog(playerid, DIALOG_NEWGMCOORD, DIALOG_STYLE_INPUT,"Edit Posm", astring, "Ok", "Cancel");
814
		}
815
	}
816
	else if(dialogid == DIALOG_NEWGCOORD)
817
	{
818
	    if (response)
819
	    {
820
	        new Float:newpos = floatstr(inputtext);
821
	        if (glistitem[playerid] ==0)
822
	        {
823
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
824
	            INI_SetTag(gatefile, "data");
825
	            INI_WriteFloat(gatefile, "gposx", newpos);
826
	            INI_Close(gatefile);
827
			}
828
			else if (glistitem[playerid] ==1)
829
	        {
830
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
831
	            INI_SetTag(gatefile, "data");
832
	            INI_WriteFloat(gatefile, "gposy", newpos);
833
	            INI_Close(gatefile);
834
			}
835
			else  if (glistitem[playerid] ==2)
836
	        {
837
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
838
	            INI_SetTag(gatefile, "data");
839
	            INI_WriteFloat(gatefile, "gposz", newpos);
840
	            INI_Close(gatefile);
841
			}
842
			else  if (glistitem[playerid] ==3)
843
	        {
844
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
845
	            INI_SetTag(gatefile, "data");
846
	            INI_WriteFloat(gatefile, "grotx", newpos);
847
	            INI_Close(gatefile);
848
			}
849
			else  if (glistitem[playerid] ==4)
850
	        {
851
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
852
	            INI_SetTag(gatefile, "data");
853
	            INI_WriteFloat(gatefile, "groty", newpos);
854
	            INI_Close(gatefile);
855
			}
856
	  		else if (glistitem[playerid] ==5)
857
	        {
858
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
859
	            INI_SetTag(gatefile, "data");
860
	            INI_WriteFloat(gatefile, "grotz", newpos);
861
	            INI_Close(gatefile);
862
			}
863
	        INI_ParseFile(GateINI(gsaveid[playerid]), "LoadGateData_%s", .bExtra = true, .extra = gsaveid[playerid]);
864
	        SetObjectPos(fgateid[gsaveid[playerid]], Gpos[gsaveid[playerid]][0], Gpos[gsaveid[playerid]][1], Gpos[gsaveid[playerid]][2]);
865
	        SetObjectRot(fgateid[gsaveid[playerid]], Grot[gsaveid[playerid]][0], Grot[gsaveid[playerid]][1], Grot[gsaveid[playerid]][2]);
866
	        GateStatus[gsaveid[playerid]] = false;
867
		}
868
	}
869
	else if(dialogid == DIALOG_NEWGMCOORD)
870
	{
871
	    if (response)
872
	    {
873
	        new Float:newpos = floatstr(inputtext);
874
	        if (glistitem[playerid] ==0)
875
	        {
876
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
877
	            INI_SetTag(gatefile, "data");
878
	            INI_WriteFloat(gatefile, "gposxm", newpos);
879
	            INI_Close(gatefile);
880
	            GateStatus[gsaveid[playerid]] = false;
881
			}
882
			else if (glistitem[playerid] ==1)
883
	        {
884
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
885
	            INI_SetTag(gatefile, "data");
886
	            INI_WriteFloat(gatefile, "gposym", newpos);
887
	            INI_Close(gatefile);
888
			}
889
			else  if (glistitem[playerid] ==2)
890
	        {
891
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
892
	            INI_SetTag(gatefile, "data");
893
	            INI_WriteFloat(gatefile, "gposzm", newpos);
894
	            INI_Close(gatefile);
895
			}
896
			else  if (glistitem[playerid] ==3)
897
	        {
898
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
899
	            INI_SetTag(gatefile, "data");
900
	            INI_WriteFloat(gatefile, "grotxm", newpos);
901
	            INI_Close(gatefile);
902
			}
903
			else  if (glistitem[playerid] ==4)
904
	        {
905
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
906
	            INI_SetTag(gatefile, "data");
907
	            INI_WriteFloat(gatefile, "grotym", newpos);
908
	            INI_Close(gatefile);
909
			}
910
	  		else if (glistitem[playerid] ==5)
911
	        {
912
	            new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
913
	            INI_SetTag(gatefile, "data");
914
	            INI_WriteFloat(gatefile, "grotzm", newpos);
915
	            INI_Close(gatefile);
916
			}
917
	        INI_ParseFile(GateINI(gsaveid[playerid]), "LoadGateData_%s", .bExtra = true, .extra = gsaveid[playerid]);
918
	        SetObjectPos(fgateid[gsaveid[playerid]], Gposm[gsaveid[playerid]][0], Gposm[gsaveid[playerid]][1], Gposm[gsaveid[playerid]][2]);
919
	        SetObjectRot(fgateid[gsaveid[playerid]], Grotm[gsaveid[playerid]][0], Grotm[gsaveid[playerid]][1], Grotm[gsaveid[playerid]][2]);
920
	        GateStatus[gsaveid[playerid]] = true;
921
		}
922
	}
923
	else if(dialogid == DIALOG_GCHANGEPASS)
924
	{
925
	    if(response)
926
	    {
927
	    	new  pname[MAX_PLAYER_NAME], bool:testbool = false;
928
	    	GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
929
	    	if (strlen(inputtext) >25) return SendClientMessage(playerid, -1, ""COL_RED"Pass can't contain more than 25 characters");
930
	    	else
931
			{
932
				for (new j = 1; j<=lastgate; j++)
933
				{
934
			    	if (fexist(GateINI(j)))
935
			    	{
936
			        	INI_ParseFile(GateINI(j), "LoadGateData_%s", .bExtra = true, .extra = j);
937
						if( (IsPlayerInRangeOfPoint(playerid, 3, Gpos[j][0], Gpos[j][1], Gpos[j][2])) && (!strcmp(gowner[j], pname)) )
938
						{
939
							new INI:gatefile = INI_Open(GateINI(j)), astring[64];
940
							INI_SetTag(gatefile, "data");
941
							INI_WriteString(gatefile, "password", inputtext);
942
							INI_Close(gatefile);
943
							testbool = true;
944
							format(astring, 64, "Gate's Pass changed to \"%s\"", inputtext);
945
							SendClientMessage(playerid, COLOR_WHITE, astring);
946
						}
947
					}
948
				}
949
			}
950
			if (testbool == false) return SendClientMessage(playerid, -1, ""COL_RED"You must be near a gate that you own!");
951
		}
952
	}
953
954
955
956
957
	return 1;
958
}
959
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
960
{
961
	if (response == EDIT_RESPONSE_FINAL)
962
	{
963
		new fobjectid;
964
		for (new k = 1; k<=lastgate; k++)
965
		{
966
		    if (fexist(GateINI(k)))
967
			{
968-
		 		INI_ParseFile(GateINI(k), "GateLoadData_%s", .bExtra = true, .extra = k);
968+
		 		INI_ParseFile(GateINI(k), "LoadGateData_%s", .bExtra = true, .extra = k);
969
		    	if (fgateid[k]==objectid) fobjectid = k;
970
971
		    }
972
		}
973
		if (normalpostest[fobjectid] == true)
974
		{
975
		    SetObjectPos(objectid, fX, fY, fZ);
976
		    SetObjectRot(objectid, fRotX, fRotY, fRotZ);
977
			new INI:gatefile = INI_Open(GateINI(fobjectid));
978
			INI_SetTag(gatefile, "data");
979
			INI_WriteFloat(gatefile, "gposx", fX);
980
			INI_WriteFloat(gatefile, "gposy", fY);
981
			INI_WriteFloat(gatefile, "gposz", fZ);
982
			INI_WriteFloat(gatefile, "grotx", fRotX);
983
			INI_WriteFloat(gatefile, "groty", fRotY);
984
			INI_WriteFloat(gatefile, "grotz", fRotZ);
985
			INI_Close(gatefile);
986
			GateStatus[fobjectid] = false;
987
			SendClientMessage(playerid, -1, ""COL_LIGHTBLUE"Gate's pos edited!");
988
		}
989
		else if (posmtest[fobjectid] == true)
990
		{
991
		    SetObjectPos(objectid, fX, fY, fZ);
992
		    SetObjectRot(objectid, fRotX, fRotY, fRotZ);
993
			new INI:gatefile = INI_Open(GateINI(fobjectid));
994
			INI_SetTag(gatefile, "data");
995
			INI_WriteFloat(gatefile, "gposxm", fX);
996
			INI_WriteFloat(gatefile, "gposym", fY);
997
			INI_WriteFloat(gatefile, "gposzm", fZ);
998
			INI_WriteFloat(gatefile, "grotxm", fRotX);
999
			INI_WriteFloat(gatefile, "grotym", fRotY);
1000
			INI_WriteFloat(gatefile, "grotzm", fRotZ);
1001
			INI_Close(gatefile);
1002
			GateStatus[fobjectid] = true;
1003
			SendClientMessage(playerid, -1, ""COL_LIGHTBLUE"Gate's Mpos edited!");
1004
		}
1005
	}
1006
	else if (response == EDIT_RESPONSE_CANCEL)
1007
	{
1008
		new fobjectid;
1009
		for (new k = 1; k<=lastgate; k++)
1010
		{
1011
		    if (fexist(GateINI(k)))
1012
			{
1013-
		 		INI_ParseFile(GateINI(k), "GateLoadData_%s", .bExtra = true, .extra = k);
1013+
		 		INI_ParseFile(GateINI(k), "LoadGateData_%s", .bExtra = true, .extra = k);
1014
		    	if (fgateid[k]==objectid) fobjectid = k;
1015
		    }
1016
		}
1017
		SetObjectPos(objectid, Oldp[fobjectid][0], Oldp[fobjectid][1], Oldp[fobjectid][2]);
1018
		SetObjectRot(objectid, Oldr[fobjectid][0], Oldr[fobjectid][1], Oldr[fobjectid][2]);
1019
	}
1020
1021
1022
	return 1;
1023
}
1024
1025
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
1026
{
1027
	return 1;
1028
}
1029
CMD:gate(playerid, params[])
1030
{
1031
if (IsPlayerAdmin(playerid)) ShowPlayerDialog(playerid, DIALOG_GATE, DIALOG_STYLE_LIST, "Create a Gate or Modify an already existing one", "Create a new gate\nGo To Gate\nGet gate's infos\nNear Gates\nGet Gate to my current pos\nEdit gate's position\nEdit gate's Movement pos\nEdit Model\nSet Movement Speed\nSet Control range\nSet gate unmovable\nEdit gate's pass\nSet Gate's Owner\nDelete gate", "Ok", "Cancel");
1032
else SendClientMessage(playerid, 0xAFAFAFAA, "You are not authorized to use this command");
1033
return 1;
1034
}                                                                                                                                                                           
1035
CMD:remote(playerid, params[])
1036
{
1037
	new pna[MAX_PLAYER_NAME];
1038
	GetPlayerName(playerid, pna, MAX_PLAYER_NAME);
1039
	for (new j = 1; j<=lastgate; j++)
1040
	{
1041
	    if(fexist(GateINI(j)))
1042
	    {
1043
			new Float:p[3];
1044
	        INI_ParseFile(GateINI(j), "LoadGateData_%s", .bExtra = true, .extra = j);
1045
	        if(strcmp(gowner[j], "none"))
1046
	        {
1047
	        	GetObjectPos(fgateid[j], p[0], p[1], p[2]);
1048
         		if (  IsPlayerInRangeOfPoint(playerid, grange[j], p[0], p[1], p[2]) && !strcmp(gowner[j], pna) )
1049
	        	{
1050
	        	    if (GateStatus[j] == true)
1051
					{
1052
					if(IsObjectMoving(fgateid[j])) KillTimer(OpenedTimer[playerid][j]);
1053
					SendClientMessage(playerid, -1, ""COL_RED"Closing...");
1054
				 	new time = MoveObject(fgateid[j], Gpos[j][0], Gpos[j][1], Gpos[j][2], gspeed[j], Grot[j][0], Grot[j][1], Grot[j][2]);
1055
				 	ClosedTimer[playerid][j] = SetTimerEx("GateClosed", time, false, "%i", playerid);
1056
				 	GateStatus[j] = false;
1057
				 	}
1058
	        	    else if (GateStatus[j] == false)
1059
	        	    {
1060
	        	    if(IsObjectMoving(fgateid[j])) KillTimer(ClosedTimer[playerid][j]);
1061
	        	    SendClientMessage(playerid, -1, ""COL_RED"Opening...");
1062
					new time = MoveObject(fgateid[j], Gposm[j][0], Gposm[j][1], Gposm[j][2], gspeed[j], Grotm[j][0], Grotm[j][1], Grotm[j][2]);
1063
					OpenedTimer[playerid][j] = SetTimerEx("GateOpened", time, false, "%i", playerid);
1064
					GateStatus[j] = true;
1065
					}
1066
				}
1067
			}
1068
		}
1069
	}
1070
	return 1;
1071
}
1072
CMD:gatepass(playerid, params[])
1073
{
1074
    if (isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /gatepass [Gate Pass]");
1075
    else
1076
    {
1077
    	new passw[26];
1078
    	strcpy(passw, params);
1079
		for (new j = 1; j<=lastgate; j++)
1080
		{
1081
1082
		    if(fexist(GateINI(j)))
1083
		    {
1084
		        new Float:p[3];
1085
	    	    INI_ParseFile(GateINI(j), "LoadGateData_%s", .bExtra = true, .extra = j);
1086
	    	    if (strcmp(gpassword[j], "none") )
1087
	    	    {
1088
	    	    	GetObjectPos(fgateid[j], p[0], p[1], p[2]);
1089
	        		if ( IsPlayerInRangeOfPoint(playerid, grange[j], p[0], p[1], p[2]) && !strcmp(gpassword[j], passw) )
1090
	        		{
1091
	        		    if (GateStatus[j] == true)
1092
						{
1093
						if(IsObjectMoving(fgateid[j])) KillTimer(OpenedTimer[playerid][j]);
1094
						SendClientMessage(playerid, -1, ""COL_RED"Closing...");
1095
					 	new time = MoveObject(fgateid[j], Gpos[j][0], Gpos[j][1], Gpos[j][2], gspeed[j], Grot[j][0], Grot[j][1], Grot[j][2]);
1096
					 	ClosedTimer[playerid][j] = SetTimerEx("GateClosed", time, false, "%i", playerid);
1097
					 	GateStatus[j] = false;
1098
					 	}
1099
	        		    else if (GateStatus[j] == false)
1100
	        		    {
1101
	        		    if(IsObjectMoving(fgateid[j])) KillTimer(ClosedTimer[playerid][j]);
1102
	        		    SendClientMessage(playerid, -1, ""COL_RED"Opening...");
1103
						new time = MoveObject(fgateid[j], Gposm[j][0], Gposm[j][1], Gposm[j][2], gspeed[j], Grotm[j][0], Grotm[j][1], Grotm[j][2]);
1104
						OpenedTimer[playerid][j] = SetTimerEx("GateOpened", time, false, "%i", playerid);
1105
						GateStatus[j] = true;
1106
						}
1107
					}
1108
				}
1109
			}
1110
		}
1111
	}
1112
	return 1;
1113
}
1114
CMD:changegpass(playerid, params[])
1115
{
1116
	ShowPlayerDialog(playerid, DIALOG_GCHANGEPASS, DIALOG_STYLE_INPUT, "Gate's Password", "Type the new password for your gate (25 charactes Max), type 'none' to remove the pass!", "Ok", "Cancel");
1117
	return 1;
1118
}