-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHOUSE.pwn
830 lines (756 loc) · 23.9 KB
/
HOUSE.pwn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
//House System
#define MAX_HOUSES 500
#define LIMIT_PER_PLAYER 3
#define Loop(%0,%1,%2) for(new %0 = %2; %0 < %1; %0++)
enum houseinfo
{
hOwner[MAX_PLAYER_NAME],
hAddress[128],
hPrice,
hType,
hLocked,
hMoney,
hWeapon[10],
hAmmo[10],
hInt,
Float:hExtpos[4],
Float:hIntpos[4],
hVisit,
//Not Saved
hPickup,
hCP,
Text3D:hLabel
};
new hData[MAX_HOUSES][houseinfo],
Iterator: Houses<MAX_HOUSES>;
Player_OwnsHouse(playerid, houseid)
{
if(houseid == -1) return 0;
if(!IsPlayerConnected(playerid)) return 0;
if(!strcmp(hData[houseid][hOwner], pData[playerid][pName], true)) return 1;
return 0;
}
Player_HouseCount(playerid)
{
#if LIMIT_PER_PLAYER != 0
new count;
foreach(new i : Houses)
{
if(Player_OwnsHouse(playerid, i)) count++;
}
return count;
#else
return 0;
#endif
}
HouseReset(houseid)
{
format(hData[houseid][hOwner], MAX_PLAYER_NAME, "-");
hData[houseid][hLocked] = 1;
hData[houseid][hMoney] = 0;
hData[houseid][hWeapon] = 0;
hData[houseid][hAmmo] = 0;
hData[houseid][hVisit] = 0;
House_Type(houseid);
for (new i = 0; i < 10; i ++)
{
hData[houseid][hWeapon][i] = 0;
hData[houseid][hAmmo][i] = 0;
}
}
House_WeaponStorage(playerid, houseid)
{
if(houseid == -1)
return 0;
static
string[320];
string[0] = 0;
for (new i = 0; i < 5; i ++)
{
if(!hData[houseid][hWeapon][i])
format(string, sizeof(string), "%sEmpty Slot\n", string);
else
format(string, sizeof(string), "%s%s (Ammo: %d)\n", string, ReturnWeaponName(hData[houseid][hWeapon][i]), hData[houseid][hAmmo][i]);
}
ShowPlayerDialog(playerid, HOUSE_WEAPONS, DIALOG_STYLE_LIST, "Weapon Storage", string, "Select", "Cancel");
return 1;
}
House_OpenStorage(playerid, houseid)
{
if(houseid == -1)
return 0;
new
items[1],
string[10 * 32];
for (new i = 0; i < 5; i ++) if(hData[houseid][hWeapon][i])
{
items[0]++;
}
if(!Player_OwnsHouse(playerid, houseid))
format(string, sizeof(string), "Weapon Storage (%d/5)", items[0]);
else
format(string, sizeof(string), "Weapon Storage (%d/5)\nMoney Safe (%s)", items[0], FormatMoney(hData[houseid][hMoney]));
ShowPlayerDialog(playerid, HOUSE_STORAGE, DIALOG_STYLE_LIST, "House Storage", string, "Select", "Cancel");
return 1;
}
GetOwnedHouses(playerid)
{
new tmpcount;
foreach(new hid : Houses)
{
if(!strcmp(hData[hid][hOwner], pData[playerid][pName], true))
{
tmpcount++;
}
}
return tmpcount;
}
ReturnPlayerHousesID(playerid, hslot)
{
new tmpcount;
if(hslot < 1 && hslot > LIMIT_PER_PLAYER) return -1;
foreach(new hid : Houses)
{
if(!strcmp(pData[playerid][pName], hData[hid][hOwner], true))
{
tmpcount++;
if(tmpcount == hslot)
{
return hid;
}
}
}
return -1;
}
House_Save(houseid)
{
new cQuery[1536];
format(cQuery, sizeof(cQuery), "UPDATE houses SET owner='%s', address='%s', price='%d', type='%d', locked='%d', money='%d'",
hData[houseid][hOwner],
hData[houseid][hAddress],
hData[houseid][hPrice],
hData[houseid][hType],
hData[houseid][hLocked],
hData[houseid][hMoney]
);
for (new i = 0; i < 10; i ++)
{
format(cQuery, sizeof(cQuery), "%s, houseWeapon%d='%d', houseAmmo%d='%d'", cQuery, i + 1, hData[houseid][hWeapon][i], i + 1, hData[houseid][hAmmo][i]);
}
format(cQuery, sizeof(cQuery), "%s, houseint='%d', extposx='%f', extposy='%f', extposz='%f', extposa='%f', intposx='%f', intposy='%f', intposz='%f', intposa='%f', visit='%d' WHERE ID='%d'",
cQuery,
hData[houseid][hInt],
hData[houseid][hExtpos][0],
hData[houseid][hExtpos][1],
hData[houseid][hExtpos][2],
hData[houseid][hExtpos][3],
hData[houseid][hIntpos][0],
hData[houseid][hIntpos][1],
hData[houseid][hIntpos][2],
hData[houseid][hIntpos][3],
hData[houseid][hVisit],
houseid
);
return mysql_tquery(g_SQL, cQuery);
}
House_Type(houseid)
{
if(hData[houseid][hType] == 1)
{
switch(random(2))
{
case 0:
{
hData[houseid][hIntpos][0] = 845.89;
hData[houseid][hIntpos][1] = -2048.00;
hData[houseid][hIntpos][2] = 1476.91;
hData[houseid][hIntpos][3] = 92.60;
hData[houseid][hInt] = 1;
}
case 1:
{
hData[houseid][hIntpos][0] = 845.89;
hData[houseid][hIntpos][1] = -2048.00;
hData[houseid][hIntpos][2] = 1476.91;
hData[houseid][hIntpos][3] = 92.60;
hData[houseid][hInt] = 1;
}
/*case 0:
{
hData[houseid][hIntpos][0] = 223.32;
hData[houseid][hIntpos][1] = 1287.26;
hData[houseid][hIntpos][2] = 1082.14;
hData[houseid][hIntpos][3] = 352.43;
hData[houseid][hInt] = 1;
}
case 1:
{
hData[houseid][hIntpos][0] = -68.85;
hData[houseid][hIntpos][1] = 1351.42;
hData[houseid][hIntpos][2] = 1080.21;
hData[houseid][hIntpos][3] = 358.06;
hData[houseid][hInt] = 6;
}
case 2:
{
hData[houseid][hIntpos][0] = -42.59;
hData[houseid][hIntpos][1] = 1405.65;
hData[houseid][hIntpos][2] = 1084.42;
hData[houseid][hIntpos][3] = 354.17;
hData[houseid][hInt] = 8;
}
case 3:
{
hData[houseid][hIntpos][0] = 260.82;
hData[houseid][hIntpos][1] = 1237.48;
hData[houseid][hIntpos][2] = 1084.25;
hData[houseid][hIntpos][3] = 9.24;
hData[houseid][hInt] = 9;
}
case 4:
{
hData[houseid][hIntpos][0] = 22.90;
hData[houseid][hIntpos][1] = 1403.32;
hData[houseid][hIntpos][2] = 1084.43;
hData[houseid][hIntpos][3] = 0.24;
hData[houseid][hInt] = 5;
}
case 5:
{
hData[houseid][hIntpos][0] = 226.17;
hData[houseid][hIntpos][1] = 1239.99;
hData[houseid][hIntpos][2] = 1082.14;
hData[houseid][hIntpos][3] = 84.87;
hData[houseid][hInt] = 2;
}*/
}
}
if(hData[houseid][hType] == 2)
{
switch(random(2))
{
case 0:
{
hData[houseid][hIntpos][0] = 302.74;
hData[houseid][hIntpos][1] = 1774.35;
hData[houseid][hIntpos][2] = 514.65;
hData[houseid][hIntpos][3] = 0.35;
hData[houseid][hInt] = 1;
}
case 1:
{
hData[houseid][hIntpos][0] = 302.74;
hData[houseid][hIntpos][1] = 1774.35;
hData[houseid][hIntpos][2] = 514.65;
hData[houseid][hIntpos][3] = 0.35;
hData[houseid][hInt] = 1;
}
/*case 0:
{
hData[houseid][hIntpos][0] = 235.25;
hData[houseid][hIntpos][1] = 1186.68;
hData[houseid][hIntpos][2] = 1080.25;
hData[houseid][hIntpos][3] = 10.63;
hData[houseid][hInt] = 3;
}
case 1:
{
hData[houseid][hIntpos][0] = 295.04;
hData[houseid][hIntpos][1] = 1472.60;
hData[houseid][hIntpos][2] = 1080.25;
hData[houseid][hIntpos][3] = 3.49;
hData[houseid][hInt] = 15;
}
case 2:
{
hData[houseid][hIntpos][0] = 24.13;
hData[houseid][hIntpos][1] = 1340.47;
hData[houseid][hIntpos][2] = 1084.37;
hData[houseid][hIntpos][3] = 0.72;
hData[houseid][hInt] = 10;
}
case 3:
{
hData[houseid][hIntpos][0] = -260.73;
hData[houseid][hIntpos][1] = 1456.78;
hData[houseid][hIntpos][2] = 1084.36;
hData[houseid][hIntpos][3] = 97.64;
hData[houseid][hInt] = 4;
}
case 4:
{
hData[houseid][hIntpos][0] = 83.28;
hData[houseid][hIntpos][1] = 1322.48;
hData[houseid][hIntpos][2] = 1083.86;
hData[houseid][hIntpos][3] = 354.73;
hData[houseid][hInt] = 9;
}*/
}
}
if(hData[houseid][hType] == 3)
{
switch(random(4))
{
case 0:
{
hData[houseid][hIntpos][0] = 1855.38;
hData[houseid][hIntpos][1] = -1709.12;
hData[houseid][hIntpos][2] = 1720.06;
hData[houseid][hIntpos][3] = 273.58;
hData[houseid][hInt] = 1;
}
case 1:
{
hData[houseid][hIntpos][0] = 4577.82;
hData[houseid][hIntpos][1] = -2527.82;
hData[houseid][hIntpos][2] = 5.28;
hData[houseid][hIntpos][3] = 262.63;
hData[houseid][hInt] = 1;
}
case 2:
{
hData[houseid][hIntpos][0] = 1263.68;
hData[houseid][hIntpos][1] = -605.30;
hData[houseid][hIntpos][2] = 1001.08;
hData[houseid][hIntpos][3] = 189.50;
hData[houseid][hInt] = 1;
}
case 3:
{
hData[houseid][hIntpos][0] = 1224.34;
hData[houseid][hIntpos][1] = -749.22;
hData[houseid][hIntpos][2] = 1085.72;
hData[houseid][hIntpos][3] = 265.59;
hData[houseid][hInt] = 1;
}
/*case 0:
{
hData[houseid][hIntpos][0] = 226.70;
hData[houseid][hIntpos][1] = 1114.22;
hData[houseid][hIntpos][2] = 1080.99;
hData[houseid][hIntpos][3] = 267.25;
hData[houseid][hInt] = 5;
}
case 1:
{
hData[houseid][hIntpos][0] = 2323.84;
hData[houseid][hIntpos][1] = -1149.33;
hData[houseid][hIntpos][2] = 1050.71;
hData[houseid][hIntpos][3] = 8.92;
hData[houseid][hInt] = 12;
}
case 2:
{
hData[houseid][hIntpos][0] = 139.83;
hData[houseid][hIntpos][1] = 1366.16;
hData[houseid][hIntpos][2] = 1083.85;
hData[houseid][hIntpos][3] = 354.86;
hData[houseid][hInt] = 5;
}
case 3:
{
hData[houseid][hIntpos][0] = 234.04;
hData[houseid][hIntpos][1] = 1063.92;
hData[houseid][hIntpos][2] = 1084.21;
hData[houseid][hIntpos][3] = 351.12;
hData[houseid][hInt] = 6;
}*/
}
}
}
House_Refresh(houseid)
{
if(houseid != -1)
{
if(IsValidDynamic3DTextLabel(hData[houseid][hLabel]))
DestroyDynamic3DTextLabel(hData[houseid][hLabel]);
if(IsValidDynamicPickup(hData[houseid][hPickup]))
DestroyDynamicPickup(hData[houseid][hPickup]);
if(IsValidDynamicCP(hData[houseid][hCP]))
DestroyDynamicCP(hData[houseid][hCP]);
static
string[255];
new type[128];
if(hData[houseid][hType] == 1)
{
type= "Small";
}
else if(hData[houseid][hType] == 2)
{
type= "Medium";
}
else if(hData[houseid][hType] == 3)
{
type= "Large";
}
else
{
type= "Unknow";
}
if(strcmp(hData[houseid][hOwner], "-"))
{
format(string, sizeof(string), "[ID: %d]\n{FFFFFF}House Location {FFFF00}%s\n{FFFFFF}House Type {FFFF00}%s\n"WHITE_E"Owned by %s\nPress '{FF0000}ENTER{FFFFFF}' to enter", houseid, GetLocation(hData[houseid][hExtpos][0], hData[houseid][hExtpos][1], hData[houseid][hExtpos][2]), type, hData[houseid][hOwner]);
hData[houseid][hPickup] = CreateDynamicPickup(1273, 23, hData[houseid][hExtpos][0], hData[houseid][hExtpos][1], hData[houseid][hExtpos][2]+0.2, 0, 0, _, 4);
}
else
{
format(string, sizeof(string), "[ID: %d]\n{00FF00}This house for sell\n{FFFFFF}House Location: {FFFF00}%s\n{FFFFFF}House Type: {FFFF00}%s\n{FFFFFF}House Price: {FFFF00}%s\n"WHITE_E"Type /buy to purchase", houseid, GetLocation(hData[houseid][hExtpos][0], hData[houseid][hExtpos][1], hData[houseid][hExtpos][2]), type, FormatMoney(hData[houseid][hPrice]));
hData[houseid][hPickup] = CreateDynamicPickup(1273, 23, hData[houseid][hExtpos][0], hData[houseid][hExtpos][1], hData[houseid][hExtpos][2]+0.2, 0, 0, _, 4);
}
hData[houseid][hCP] = CreateDynamicCP(hData[houseid][hIntpos][0], hData[houseid][hIntpos][1], hData[houseid][hIntpos][2], 1, houseid, hData[houseid][hInt], -1, 3, -1, 0);
hData[houseid][hLabel] = CreateDynamic3DTextLabel(string, COLOR_GREEN, hData[houseid][hExtpos][0], hData[houseid][hExtpos][1], hData[houseid][hExtpos][2]+0.5, 2.5, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0);
}
return 1;
}
function LoadHouses()
{
static
str[128],
hid;
new rows = cache_num_rows(), owner[128], address[128];
if(rows)
{
for(new i; i < rows; i++)
{
cache_get_value_name_int(i, "ID", hid);
cache_get_value_name(i, "owner", owner);
format(hData[hid][hOwner], 128, owner);
cache_get_value_name(i, "address", address);
format(hData[hid][hAddress], 128, address);
cache_get_value_name_int(i, "price", hData[hid][hPrice]);
cache_get_value_name_int(i, "type", hData[hid][hType]);
cache_get_value_name_float(i, "extposx", hData[hid][hExtpos][0]);
cache_get_value_name_float(i, "extposy", hData[hid][hExtpos][1]);
cache_get_value_name_float(i, "extposz", hData[hid][hExtpos][2]);
cache_get_value_name_float(i, "extposa", hData[hid][hExtpos][3]);
cache_get_value_name_float(i, "intposx", hData[hid][hIntpos][0]);
cache_get_value_name_float(i, "intposy", hData[hid][hIntpos][1]);
cache_get_value_name_float(i, "intposz", hData[hid][hIntpos][2]);
cache_get_value_name_float(i, "intposa", hData[hid][hIntpos][3]);
cache_get_value_name_int(i, "houseint", hData[hid][hInt]);
cache_get_value_name_int(i, "money", hData[hid][hMoney]);
cache_get_value_name_int(i, "locked", hData[hid][hLocked]);
cache_get_value_name_int(i, "visit", hData[hid][hVisit]);
for (new j = 0; j < 10; j ++)
{
format(str, 24, "houseWeapon%d", j + 1);
cache_get_value_name_int(i, str, hData[hid][hWeapon][j]);
format(str, 24, "houseAmmo%d", j + 1);
cache_get_value_name_int(i, str, hData[hid][hAmmo][j]);
}
House_Refresh(hid);
Iter_Add(Houses, hid);
}
printf("[Houses] Number of Loaded: %d.", rows);
}
}
//----------[ House Commands ]--------
//House System
CMD:createhouse(playerid, params[])
{
if(pData[playerid][pAdmin] < 4)
return PermissionError(playerid);
new hid = Iter_Free(Houses), address[128];
if(hid == -1) return Error(playerid, "You cant create more door!");
new price, type, query[512];
if(sscanf(params, "dd", price, type)) return Usage(playerid, "/createhouse [price] [type, 1.small 2.medium 3.Big]");
format(hData[hid][hOwner], 128, "-");
GetPlayerPos(playerid, hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2]);
GetPlayerFacingAngle(playerid, hData[hid][hExtpos][3]);
hData[hid][hPrice] = price;
hData[hid][hType] = type;
address = GetLocation(hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2]);
format(hData[hid][hAddress], 128, address);
hData[hid][hLocked] = 1;
hData[hid][hMoney] = 0;
hData[hid][hInt] = 0;
hData[hid][hIntpos][0] = 0;
hData[hid][hIntpos][1] = 0;
hData[hid][hIntpos][2] = 0;
hData[hid][hIntpos][3] = 0;
hData[hid][hVisit] = 0;
House_Type(hid);
for (new i = 0; i < 10; i ++)
{
hData[hid][hWeapon][i] = 0;
hData[hid][hAmmo][i] = 0;
}
House_Refresh(hid);
Iter_Add(Houses, hid);
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO houses SET ID='%d', owner='%s', price='%d', type='%d', extposx='%f', extposy='%f', extposz='%f', extposa='%f', address='%s'", hid, hData[hid][hOwner], hData[hid][hPrice], hData[hid][hType], hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2], hData[hid][hExtpos][3], hData[hid][hAddress]);
mysql_tquery(g_SQL, query, "OnHousesCreated", "i", hid);
return 1;
}
function OnHousesCreated(hid)
{
House_Save(hid);
return 1;
}
CMD:gotohouse(playerid, params[])
{
new hid;
if(pData[playerid][pAdmin] < 4)
return PermissionError(playerid);
if(sscanf(params, "d", hid))
return Usage(playerid, "/gotohouse [id]");
if(!Iter_Contains(Houses, hid)) return Error(playerid, "The doors you specified ID of doesn't exist.");
SetPlayerPosition(playerid, hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2], hData[hid][hExtpos][3]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessageEx(playerid, COLOR_WHITE, "You has teleport to house id %d", hid);
pData[playerid][pInDoor] = -1;
pData[playerid][pInHouse] = -1;
pData[playerid][pInBiz] = -1;
return 1;
}
CMD:typehouses(playerid, params[])
{
if(pData[playerid][pAdmin] < 4)
return PermissionError(playerid);
new count = 0;
foreach(new hid : Houses)
{
if(Iter_Contains(Houses, hid))
{
House_Type(hid);
}
count++;
}
Servers(playerid, "Anda telah me reset house interior type sebanyak %d rumah.", count);
return 1;
}
CMD:edithouse(playerid, params[])
{
static
hid,
type[24],
string[128];
if(pData[playerid][pAdmin] < 4)
return PermissionError(playerid);
if(sscanf(params, "ds[24]S()[128]", hid, type, string))
{
Usage(playerid, "/edithouse [id] [name]");
SendClientMessage(playerid, COLOR_YELLOW, "[NAMES]:{FFFFFF} location, interior, locked, owner, price, type, reset");
return 1;
}
if((hid < 0 || hid >= MAX_HOUSES))
return Error(playerid, "You have specified an invalid ID.");
if(!Iter_Contains(Houses, hid)) return Error(playerid, "The doors you specified ID of doesn't exist.");
if(!strcmp(type, "location", true))
{
GetPlayerPos(playerid, hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2]);
GetPlayerFacingAngle(playerid, hData[hid][hExtpos][3]);
House_Save(hid);
House_Refresh(hid);
SendAdminMessage(COLOR_LRED, "%s has adjusted the location of house ID: %d.", pData[playerid][pAdminname], hid);
}
else if(!strcmp(type, "interior", true))
{
GetPlayerPos(playerid, hData[hid][hIntpos][0], hData[hid][hIntpos][1], hData[hid][hIntpos][2]);
GetPlayerFacingAngle(playerid, hData[hid][hIntpos][3]);
hData[hid][hInt] = GetPlayerInterior(playerid);
House_Save(hid);
House_Refresh(hid);
/*foreach (new i : Player)
{
if(pData[i][pEntrance] == EntranceData[id][entranceID])
{
SetPlayerPos(i, EntranceData[id][entranceInt][0], EntranceData[id][entranceInt][1], EntranceData[id][entranceInt][2]);
SetPlayerFacingAngle(i, EntranceData[id][entranceInt][3]);
SetPlayerInterior(i, EntranceData[id][entranceInterior]);
SetCameraBehindPlayer(i);
}
}*/
SendAdminMessage(COLOR_RED, "%s has adjusted the interior spawn of house ID: %d.", pData[playerid][pAdminname], hid);
}
else if(!strcmp(type, "locked", true))
{
new locked;
if(sscanf(string, "d", locked))
return Usage(playerid, "/edithouse [id] [locked] [0/1]");
if(locked < 0 || locked > 1)
return Error(playerid, "You must specify at least 0 or 1.");
hData[hid][hLocked] = locked;
House_Save(hid);
House_Refresh(hid);
if(locked) {
SendAdminMessage(COLOR_RED, "%s has locked house ID: %d.", pData[playerid][pAdminname], hid);
}
else {
SendAdminMessage(COLOR_RED, "%s has unlocked house ID: %d.", pData[playerid][pAdminname], hid);
}
}
else if(!strcmp(type, "price", true))
{
new price;
if(sscanf(string, "d", price))
return Usage(playerid, "/edithouse [id] [Price] [Amount]");
hData[hid][hPrice] = price;
House_Save(hid);
House_Refresh(hid);
SendAdminMessage(COLOR_RED, "%s has adjusted the price of house ID: %d to %d.", pData[playerid][pAdminname], hid, price);
}
else if(!strcmp(type, "type", true))
{
new htype;
if(sscanf(string, "d", htype))
return Usage(playerid, "/edithouse [id] [Type] [1.small 2.medium 3.Big]");
hData[hid][hType] = htype;
House_Type(hid);
House_Save(hid);
House_Refresh(hid);
SendAdminMessage(COLOR_RED, "%s has adjusted the type of house ID: %d to %d.", pData[playerid][pAdminname], hid, htype);
}
else if(!strcmp(type, "owner", true))
{
new owners[MAX_PLAYER_NAME];
if(sscanf(string, "s[32]", owners))
return Usage(playerid, "/edithouse [id] [owner] [player name] (use '-' to no owner)");
format(hData[hid][hOwner], MAX_PLAYER_NAME, owners);
House_Save(hid);
House_Refresh(hid);
SendAdminMessage(COLOR_RED, "%s has adjusted the owner of house ID: %d to %s", pData[playerid][pAdminname], hid, owners);
}
else if(!strcmp(type, "reset", true))
{
HouseReset(hid);
House_Save(hid);
House_Refresh(hid);
SendAdminMessage(COLOR_RED, "%s has reset house ID: %d.", pData[playerid][pAdminname], hid);
}
return 1;
}
/*
CMD:buyhouse(playerid, params[])
{
foreach(new hid : Houses)
{
if(IsPlayerInRangeOfPoint(playerid, 2.5, hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2]))
{
if(hData[hid][hPrice] > GetPlayerMoney(playerid)) return Error(playerid, "Not enough money, you can't afford this houses.");
if(strcmp(hData[hid][hOwner], "-")) return Error(playerid, "Someone already owns this house.");
if(pData[playerid][pVip] == 1)
{
#if LIMIT_PER_PLAYER > 0
if(Player_HouseCount(playerid) + 1 > 2) return Error(playerid, "You can't buy any more houses.");
#endif
}
else if(pData[playerid][pVip] == 2)
{
#if LIMIT_PER_PLAYER > 0
if(Player_HouseCount(playerid) + 1 > 3) return Error(playerid, "You can't buy any more houses.");
#endif
}
else if(pData[playerid][pVip] == 3)
{
#if LIMIT_PER_PLAYER > 0
if(Player_HouseCount(playerid) + 1 > 4) return Error(playerid, "You can't buy any more houses.");
#endif
}
else
{
#if LIMIT_PER_PLAYER > 0
if(Player_HouseCount(playerid) + 1 > 1) return Error(playerid, "You can't buy any more houses.");
#endif
}
GivePlayerMoneyEx(playerid, -hData[hid][hPrice]);
GetPlayerName(playerid, hData[hid][hOwner], MAX_PLAYER_NAME);
hData[hid][hVisit] = gettime();
House_Refresh(hid);
House_Save(hid);
}
}
return 1;
}*/
alias:lockhouse("unlockhouse")
CMD:lockhouse(playerid, params[])
{
foreach(new hid : Houses)
{
if(IsPlayerInRangeOfPoint(playerid, 2.5, hData[hid][hExtpos][0], hData[hid][hExtpos][1], hData[hid][hExtpos][2]))
{
if(!Player_OwnsHouse(playerid, hid)) return Error(playerid, "You don't own this house.");
if(!hData[hid][hLocked])
{
hData[hid][hLocked] = 1;
House_Save(hid);
InfoTD_MSG(playerid, 4000, "You have ~r~locked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
}
else
{
hData[hid][hLocked] = 0;
House_Save(hid);
InfoTD_MSG(playerid, 4000,"You have ~g~unlocked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
}
}
}
return 1;
}
CMD:sellhouse(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid, 3.0, 1392.77, -22.25, 1000.97)) return Error(playerid, "Anda harus berada di City Hall!");
if(GetOwnedHouses(playerid) == -1) return Error(playerid, "You don't have a houses.");
//if(!Player_OwnsBusiness(playerid, id)) return Error(playerid, "You don't own this business.");
new hid, _tmpstring[128], count = GetOwnedHouses(playerid), CMDSString[1024];
CMDSString = "";
new lock[128];
Loop(itt, (count + 1), 1)
{
hid = ReturnPlayerHousesID(playerid, itt);
if(hData[hid][hLocked] == 1)
{
lock = "{FF0000}Locked";
}
else
{
lock = "{00FF00}Unlocked";
}
if(itt == count)
{
format(_tmpstring, sizeof(_tmpstring), ""LB_E"%d.\t{FFFF2A}%s (%s{FFFF2A})\n", itt, hData[hid][hAddress], lock);
}
else format(_tmpstring, sizeof(_tmpstring), ""LB_E"%d.\t{FFFF2A}%s (%s{FFFF2A})\n", itt, hData[hid][hAddress], lock);
strcat(CMDSString, _tmpstring);
}
ShowPlayerDialog(playerid, DIALOG_SELL_HOUSES, DIALOG_STYLE_LIST, "Sell Houses", CMDSString, "Sell", "Cancel");
return 1;
}
CMD:myhouse(playerid)
{
if(GetOwnedHouses(playerid) == -1) return Error(playerid, "You don't have a houses.");
//if(!Player_OwnsBusiness(playerid, id)) return Error(playerid, "You don't own this business.");
new hid, _tmpstring[128], count = GetOwnedHouses(playerid), CMDSString[1024];
CMDSString = "";
new lock[128];
Loop(itt, (count + 1), 1)
{
hid = ReturnPlayerHousesID(playerid, itt);
if(hData[hid][hLocked] == 1)
{
lock = "{FF0000}Locked";
}
else
{
lock = "{00FF00}Unlocked";
}
if(itt == count)
{
format(_tmpstring, sizeof(_tmpstring), ""LB_E"%d.\t{FFFF2A}%s (%s)\n", itt, hData[hid][hAddress], lock);
}
else format(_tmpstring, sizeof(_tmpstring), ""LB_E"%d.\t{FFFF2A}%s (%s)\n", itt, hData[hid][hAddress], lock);
strcat(CMDSString, _tmpstring);
}
ShowPlayerDialog(playerid, DIALOG_MY_HOUSES, DIALOG_STYLE_LIST, "{FF0000}SoI:RP: {0000FF}Houses", CMDSString, "Select", "Cancel");
return 1;
}
CMD:storage(playerid, params[])
{
if(!Player_OwnsHouse(playerid, pData[playerid][pInHouse]))
if(pData[playerid][pFaction] != 1)
return Error(playerid, "You don't own this house.");
House_OpenStorage(playerid, pData[playerid][pInHouse]);
return 1;
}
//--------------[ House Dialog ]----------