· 5 years ago · Mar 30, 2020, 11:54 AM
1#include <a_samp>
2#include <crashdetect>
3#include <a_mysql>
4#include <YSI\y_ini>
5#include <sscanf2>
6#include <zcmd>
7#include <progress>
8#include <mapandreas>
9#include <PreviewModelDialog>
10#include <FCNPC>
11#include <colandreas>
12#include <streamer>
13#include <foreach>
14#include <strlib>
15
16////////////////////////////////////////////////////////////////////////////////
17// DEFINES /////////////////////////////////////////////////////////////////////
18////////////////////////////////////////////////////////////////////////////////
19
20#define MYSQL_DETAILS_FILE "just_aftermath/server_data/mysql.ini"
21
22#define CREATED_ITEMS_FILE "just_aftermath/items/created_items/items.txt"
23
24#define SERVER_NAME "Just : Aftermath [Zombie Roleplay]"
25#define SERVER_MODE "Zombie Roleplay"
26#define SERVER_LANGUAGE "English"
27#define SERVER_WEBSITE "www.yourwebsite.com"
28#define SERVER_TAG "{FED85D}[Aftermath]{FFFFFF}"
29#define SERVER_NAME_TAG ""
30
31#define MAX_LOGIN_ATTEMPTS 3
32#define MAX_SPAWN_AREAS 5
33#define MAX_JOBS 8
34#define MAX_PM_OFF 10
35
36#define MAX_SLOTS 90
37#define MAX_ITEMS 500
38
39#define MAX_VEHICLE_SLOTS 30
40
41#define MAX_WEAPON_ITEMS 18
42#define MAX_AMMO_ITEMS 6
43
44#define MAX_MELEE_WEAPON_ITEMS 5
45
46#define MAX_HEAD_WEARABLE_ITEMS 6
47#define MAX_BODY_WEARABLE_ITEMS 18
48
49#define MAX_BACKPACK_ITEMS 21
50
51#define MAX_FOOD_ITEMS 13
52#define MAX_MEDICAL_ITEMS 8
53#define MAX_COOKABLE_ITEMS 1
54#define MAX_RESOURCE_ITEMS 5
55#define MAX_TOOL_ITEMS 10
56#define MAX_BIG_ITEMS 1
57#define MAX_MISC_ITEMS 4
58#define MAX_ARMOUR_ITEMS 2
59
60#define MAX_CRAFTABLE_ITEMS 1
61
62#define MAX_WEAPON_TYPES 5
63#define MAX_WEAPON_SLOTS 5
64
65#define LOGIN_TIME_LIMIT "60"
66
67#define MAX_SCATTERED_ZOMBIES 600
68
69#define COLOR_WHITE "{FFFFFF}"
70#define COLOR_MAIN_HEX "{FED85D}"
71
72#define COLOR_MAIN 0xFED85DFF
73#define COLOR_PM 0xFF0000FF
74
75#define COLOR_HUNGER 0xFFA500FF
76#define COLOR_THIRST 0x00BFFFFF
77
78#define PRESSING(%0,%1) \
79 (%0 & (%1))
80
81#define RELEASED(%0) \
82 (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
83
84////////////////////////////////////////////////////////////////////////////////
85////////////////////////////////////////////////////////////////////////////////
86
87enum dialog_ids
88{
89 LOGIN_DIALOG_ID,
90
91 SETUP_DIALOG_ID_1,
92 SETUP_DIALOG_ID_2,
93 SETUP_DIALOG_ID_3,
94 SETUP_DIALOG_ID_4,
95 SETUP_DIALOG_ID_5,
96 SETUP_DIALOG_ID_6,
97
98 ADD_ITEM_DIALOG_ID_1,
99 ADD_ITEM_DIALOG_ID_2,
100 ADD_ITEM_DIALOG_ID_3,
101
102 PLAYER_INVENTORY_DIALOG_ID_1,
103 PLAYER_INVENTORY_DIALOG_ID_2,
104
105 NEARBY_ITEMS_DIALOG_ID_1,
106 PM_OFF_LIST_DIALOG_ID,
107
108 EQUIPPED_ITEMS_DIALOG_ID_1,
109 EQUIPPED_ITEMS_DIALOG_ID_2,
110 EQUIPPED_ITEMS_DIALOG_ID_3,
111
112 NEARBY_ITEMS_DIALOG_ID_2,
113 NEARBY_ITEMS_DIALOG_ID_3,
114 NEARBY_ITEMS_DIALOG_ID_2_PART,
115
116 CUFF_PLAYER_DIALOG_ID,
117 UNCUFF_PLAYER_DIALOG_ID_1,
118 UNCUFF_PLAYER_DIALOG_ID_2,
119
120 DRIVING_LICENSE_DIALOG_ID,
121 PLAYER_BADGE_DIALOG_ID,
122
123 LOOTING_ACTOR_DIALOG_ID_1,
124 LOOTING_ACTOR_DIALOG_ID_2,
125 LOOTING_ACTOR_DIALOG_ID_3,
126
127 CHARACTER_INFO_DIALOG_ID,
128 CRAFTABLE_ITEMS_DIALOG_ID,
129
130 CRAFTING_RECIPE_DIALOG_ID,
131 CRAFTING_RECIPE_DIALOG_ID_2,
132
133 CAR_REPAIR_DIALOG_ID,
134 VEHICLE_INVENTORY_DIALOG_ID
135};
136
137enum player_data
138{
139 account_id,
140 password [32],
141 login_attempts,
142 logged_in,
143 loaded,
144
145 age,
146 skin,
147 gender,
148
149 Float: health,
150 Float: hunger,
151 Float: thirst,
152
153 job,
154
155 cooking,
156 hunting,
157 crafting,
158 learning,
159 repairing,
160 durability,
161 strength,
162
163 Float: last_x,
164 Float: last_y,
165 Float: last_z,
166
167 last_interior,
168
169 private_messages,
170
171 head_protection,
172
173 carrying,
174
175 cooked,
176 cooking_time,
177 cooking_timer,
178
179 crafting_method[64],
180
181 crafted,
182 crafting_time,
183 crafting_timer,
184
185 player_action, // 1 = cooking, 2 = crafting
186
187 equipped_wearable_items,
188 inventory_virtual_slots,
189 inventory_slots,
190 slots_used,
191
192 spawned,
193 initiated,
194 data_loaded,
195 player_spawn,
196
197 kick_timer,
198
199 item_added,
200
201 selected_nearby_item,
202 selected_inventory_slot,
203
204 selected_actor,
205 selected_item_type,
206 selected_item_ammo,
207 selected_item_amount,
208 selected_item_state,
209
210 selected_item_model_id,
211 selected_item_static_id,
212
213 nearby_items [64],
214
215 in_zombie_zone,
216
217 weapon_shot,
218
219 getting_chased,
220 zombies_chasing,
221 player_zombies,
222
223 walking,
224
225 selected_recipe,
226 selected_recipe_method,
227
228 current_weapon,
229
230 sprinting,
231
232 selected_vehicle
233};
234
235new WORLD_TIME;
236new SERVER_SLOTS;
237new PlayerInfo [MAX_PLAYERS][player_data];
238
239#include <../../gamemodes/modules/mysql_connection.inc>
240#include <../../gamemodes/modules/data_arrays.inc>
241#include <../../gamemodes/modules/functions.inc>
242#include <../../gamemodes/modules/zombies.inc>
243
244////////////////////////////////////////////////////////////////////////////////
245// ENUMERATORS /////////////////////////////////////////////////////////////////
246////////////////////////////////////////////////////////////////////////////////
247
248enum job_data
249{
250 name [24],
251
252 cooking,
253 hunting,
254 crafting,
255 learning,
256 repairing,
257 strength,
258 durability
259
260};
261
262enum slot_data
263{
264 item [124]
265};
266
267enum food_items_data
268{
269 name [34],
270 model_id,
271
272 Float: healing,
273 Float: hunger,
274 Float: thirst,
275
276 ammo_per_use,
277 item_ammo,
278
279 item_static_id
280};
281
282enum medical_items_data
283{
284 name [46],
285 model_id,
286
287 Float: healing,
288
289 ammo_per_use,
290 item_ammo,
291
292 item_static_id
293};
294
295enum cookable_items_data
296{
297 name [24],
298 model_id,
299
300 item_static_id
301};
302
303enum resource_items_data
304{
305 name [24],
306 model_id,
307
308 item_static_id
309};
310
311enum tool_items_data
312{
313 name [24],
314 model_id,
315
316 item_static_id
317};
318
319enum big_items_data
320{
321 name [24],
322
323 model_id_1,
324 model_id_2,
325
326 item_ammo,
327
328 item_static_id
329};
330
331enum misc_items_data
332{
333 name [24],
334 model_id,
335
336 item_static_id
337};
338
339enum weapon_items_data
340{
341 name [46],
342 weapon_id,
343 weapon_model_id,
344 Float: weapon_damage,
345 item_static_id,
346 weapon_bullet_type
347};
348
349enum ammo_items_data
350{
351 name [54],
352 item_static_id
353};
354
355enum melee_items_data
356{
357 name [44],
358 weapon_id,
359 weapon_model_id,
360 Float: weapon_damage,
361
362 item_static_id
363};
364
365enum head_wearable_items
366{
367 name [42],
368 model_id,
369 wearable_type,
370 head_hits,
371
372 item_static_id
373};
374
375enum body_wearable_items
376{
377 wearable_name [34],
378 wearable_model_id,
379 wearable_type,
380 wearable_slots,
381
382 item_static_id
383};
384
385enum backpack_items
386{
387 name [34],
388 slots,
389 model_id,
390
391 item_static_id
392};
393
394enum armour_items_data
395{
396 name [24],
397 model_id,
398
399 Float: armour,
400
401 item_static_id
402};
403
404enum created_item_data
405{
406 item_id,
407 item_static_id,
408 item_model_id,
409
410 item_type,
411 item_amount,
412 item_ammo,
413
414 item_attached,
415 item_timer,
416
417 item_unique_id
418};
419
420enum player_weapon_data
421{
422 weapon_id,
423 weapon_model_id,
424 weapon_static_id,
425 weapon_type,
426 Float: weapon_damage,
427 weapon_ammo,
428
429 slot_used
430};
431
432enum vehicle_data
433{
434 vehicle_model,
435
436 vehicle_color_1,
437 vehicle_color_2,
438
439 Float: vehicle_health,
440 Float: vehicle_fuel,
441
442 vehicle_engine,
443 vehicle_lights,
444 vehicle_alarm,
445 vehicle_doors,
446 vehicle_bonnet,
447 vehicle_boot,
448
449 vehicle_d_panels,
450 vehicle_d_doors,
451 vehicle_d_lights,
452 vehicle_d_tires,
453
454
455 vehicle_driving,
456
457 Float: vehicle_x,
458 Float: vehicle_y,
459 Float: vehicle_z,
460 Float: vehicle_a,
461
462 wheel_usage,
463 engine_usage
464};
465
466enum vehicle_slot_data
467{
468 item [124]
469};
470
471new VehicleInfo [MAX_VEHICLES][vehicle_data];
472new VehicleInventory [MAX_VEHICLES][MAX_VEHICLE_SLOTS][vehicle_slot_data];
473
474////////////////////////////////////////////////////////////////////////////////
475// ARRAYS //////////////////////////////////////////////////////////////////////
476////////////////////////////////////////////////////////////////////////////////
477
478new Jobs [MAX_JOBS][job_data] =
479{
480 {"Police", 2, 1, 4, 1, 2, 4, 2},
481 {"Doctor", 0, 2, 2, 0, 4, 1, 1},
482 {"Teacher", 0, 4, 0, 0, 6, 1, 1},
483 {"Repairman", 10, 0, 3, 0, 3, 2, 1},
484 {"Cooker", 0, 10, 4, 0, 4, 1, 1},
485 {"Worker", 5, 0, 4, 2, 1, 3, 1},
486 {"Hunter", 2, 4, 4, 9, 1, 3, 1},
487 {"Soldier", 3, 1, 2, 2, 0, 6, 2}
488};
489
490new FoodItems [MAX_FOOD_ITEMS][food_items_data] =
491{
492 {"Pizza", 19580, 5.0, 10.0, 2.0, 5, 10, 0},
493 {"Milk Pack", 19570, 10.0, 5.0, 50.0, 10, 50, 1},
494 {"Apple", 19576, 15.0, 10.0, 25.0, 1, 1, 2},
495 {"Banana", 19578, 15.0, 15.0, 15.0, 1, 1, 3},
496 {"Box of Pizza", 19571, 30.0, 50.0, 15.0, 1, 1, 4},
497 {"Water Bottle", 19570, 10.0, 2.5, 50.0, 20, 100, 5},
498 {"Military MRE", 2663, 15.0, 30.0, 10.0, 20, 120, 6},
499 {"Civilian MRE", 19573, 15.0, 30.0, 10.0, 20, 120, 7},
500 {"Cooked Meat", -2027, 35.0, 50.0, 35.0, -1, -1, 8},
501 {"Tomato Can", 11722, 10.0, 10.0, 10.0, -1, -1, 9},
502 {"Soup Can", 11723, 10.0, 10.0, 10.0, -1, -1, 10},
503 {"Cola", -2026, 10.0, 20.0, 5.0, 5, 15, 11},
504 {"Beans", -2020, 10.0, 20.0, 5.0, 5, 15, 12}
505};
506
507new MedicalItems [MAX_MEDICAL_ITEMS][medical_items_data] =
508{
509 {"IFAK Tactical Frist Aidkit", 11738, 20.0, 20, 150, 0},
510 {"Car First Aidkit", 11738, 25.0, 20, 100, 1},
511 {"Solo First Aidkit", 11736, 50.0, 25, 100, 2},
512 {"Antibiotics", -2018, 40.0, 1, 2, 3},
513 {"Morphine", -2040, 10.0, 1, 1, 4},
514 {"Painkillers", -2045, 25.0, 2, 2, 5},
515 {"Splint", 11788, 25.0, 1, 1, 6},
516 {"Fuel Can", 1650, 50.0, 20, 100, 7}
517};
518
519new CookableItems [MAX_COOKABLE_ITEMS][cookable_items_data] =
520{
521 {"Raw Meat", 2804, 0}
522};
523
524new ResourceItems [MAX_RESOURCE_ITEMS][resource_items_data] =
525{
526 {"Dollar", 1212, 0},
527 {"Wood", 19793, 1},
528 {"Paper", 19873, 2},
529 {"Toilet Paper", 19873, 3},
530 {"Cloth", 19469, 4}
531};
532
533new ToolItems [MAX_TOOL_ITEMS][tool_items_data] =
534{
535 {"Handcuff", 11749, 0},
536 {"Hundcuff Key", 11746, 1},
537 {"Toolbox", -2051, 2},
538 {"Can Opener", -1, 3},
539 {"Pan", 19581, 4},
540 {"Bear Trap", -2023, 5},
541 {"Watch", -2053, 6},
542 {"Matches", -1, 7},
543 {"Box Of Cigarretes", 19897, 8},
544 {"Car tire", 1096, 9}
545};
546
547new BigItems [MAX_BIG_ITEMS][big_items_data] =
548{
549 {"Camp Fire", 1463, 18689, 3, 0}
550};
551
552new MiscItems [MAX_MISC_ITEMS][misc_items_data] =
553{
554 {"Driver License", 19792, 0},
555 {"Badge", 19785, 1},
556 {"Recipe Book", 2059, 2},
557 {"Cigarette", 19897, 3}
558};
559
560new WeaponItems [MAX_WEAPON_ITEMS][weapon_items_data] =
561{
562 {"Glock 17", 24, -2006, 63.0, 0, 0},
563 {"Jericho 941", 24, -2007, 63.0, 1, 0},
564 {"Clot M1911", 24, -2004, 69.0, 2, 5},
565 {"Python", 24, -2004, 74.0, 3, 5},
566 {"Mossberg 590", 25, -2013, 72.0, 4, 2},
567 {"Remington 870", 25, -2013, 72.0, 5, 2},
568 {"Benelli M4", 27, -2002, 65.0, 6, 2},
569 {"MP5", 29, -2014, 15.0, 7, 0},
570 {"TEC-9", 32, -2016, 14.0, 8, 0},
571 {"Skorpion", 32, 372, 14.0, 9, 0},
572 {"AKS-74U", 29, 353, 25.0, 10, 3},
573 {"M16A2", 31, -2011, 44.0, 11, 3},
574 {"M4A1", 31, -2008, 46.0, 12, 3},
575 {"AK-47", 30, -2001, 49.0, 13, 4},
576 {"FN FAL", 30, -2005, 53.0, 14, 4},
577 {"Remington 700 BDL", 34, -2015, 91.0, 15, 4},
578 {"Hunter Rifle", 33, -2017, 79.0, 16, 4},
579 {"M14", 31, -2010, 86.0, 17, 4}
580};
581
582new AmmoItems [MAX_AMMO_ITEMS][ammo_items_data] =
583{
584 {"9mm Ammo", 0},
585 {".45 ACP Ammo", 1},
586 {"12 Gauge Ammo", 2},
587 {"5.56 Ammo", 3},
588 {"7.62 Ammo", 4},
589 {".50 Ammo", 5}
590};
591
592new MeleeWeaponItems [MAX_MELEE_WEAPON_ITEMS][melee_items_data] =
593{
594 {"Axe", 3, 334, 50.0, 0},
595 {"Combat Knife", 4, 335, 15.0, 1},
596 {"Kitchen Knife", 4, 335, 10.0, 2},
597 {"Baseball Bat", 5, 336, 30.0, 3},
598 {"Tire Lever", 15, 326, 30.0, 4}
599};
600
601new HeadWearableItems [MAX_HEAD_WEARABLE_ITEMS][head_wearable_items] =
602{
603 {""COLOR_MAIN_HEX"Hard Hat", 19093, 0, 3, 0},
604 {""COLOR_MAIN_HEX"Army Helmet", 19101, 0, 6, 1},
605 {""COLOR_MAIN_HEX"Motorcycle Helmet", -2024, 0, 4, 2},
606 {""COLOR_MAIN_HEX"SWAT Helmet", 19141, 0, 5, 3},
607 {"Police Cap", 19521, 0, 0, 4},
608 {"Black Police Cap", 18636, 0, 0, 5}
609};
610
611new BodyWearableItems [MAX_BODY_WEARABLE_ITEMS][body_wearable_items] =
612{
613 {"Black Leather Jacket", 2386, 1, 4, 0},
614 {"Brown Leather Jacket", 2386, 1, 4, 1},
615 {"Red Raincoat", 2386, 1, 3, 2},
616 {"Green Raincoat", 2386, 1, 3, 3},
617 {"Military Shirt", 2386, 1, 1, 4},
618 {"Tactical Jacket", 2386, 1, 6, 5},
619
620 {"Hunter Vest", 2386, 1, 8, 6},
621 {"Alpha Vest", 2386, 1, 14, 7},
622 {"Military Vest", 2386, 1, 19, 8},
623 {"Construction Vest", 2386, 1, 4, 9},
624
625 {"Black Cargo Pants", 2386, 3, 2, 10},
626 {"Brown Cargo Pants", 2386, 3, 2, 11},
627 {"Khaki Cargo Pants", 2386, 3, 2, 12},
628 {"Black Jeans", 2386, 3, 3, 13},
629 {"Light Blue Jeans", 2386, 3, 3, 14},
630 {"Blue Jeans", 2386, 3, 3, 15},
631 {"Black Military Pants", 2386, 3, 6, 16},
632 {"Green Camo Military Pants", 2386, 3, 8, 17}
633
634};
635
636new BackpackItems [MAX_BACKPACK_ITEMS][backpack_items] =
637{
638 {"Child Backpack", 15, -2025, 0},
639 {"Child Backpack (Red)", 15, -2025, 1},
640 {"Child Backpack (Green)", 15, -2025, 2},
641 {"Gucci Bag", 23, -2029, 3},
642 {"Improvised Backpack 1", 12, 371, 4},
643 {"Improvised Backpack 2", 12, 371, 5},
644 {"Marine Backpack (Green)", 32, 371, 6},
645 {"Marine Backpack (Orange)", 32, 371, 7},
646 {"Marine Backpack (Red)", 32, 371, 8},
647 {"Marine Backpack (Yellow)", 32, 371, 9},
648 {"Marine Backpack (Black)", 32, 371, 10},
649 {"Military Backpack (Green)",40, 371, 11},
650 {"Military Backpack (Tan)", 40, 371, 12},
651 {"Mountain Backpack (Blue)", 60, 371, 13},
652 {"Mountain Backpack (Green)",60, 371, 14},
653 {"Mountain Backpack (Orange)",60,371, 15},
654 {"Mountain Backpack (Red)", 60, 371, 16},
655 {"Sport Backpack", 23, -2025, 17},
656 {"Taloon Backpack (Blue)", 26, 371, 18},
657 {"Taloon Backpack (Green)", 26, 371, 19},
658 {"Taloon Backpack (Orange)", 26, 371, 20}
659};
660
661new ArmourItems [MAX_ARMOUR_ITEMS][armour_items_data] =
662{
663 {"Police Armour", 1242, 70.0, 0},
664 {"Swat Armour", 19142, 100.0, 1}
665};
666
667enum craftable_items_data
668{
669 name [124],
670
671 item_type,
672 item_id,
673
674 item_recipes,
675 item_static_id
676};
677
678new CraftableItems [MAX_CRAFTABLE_ITEMS][craftable_items_data] =
679{
680 {"Camp Fire", 6, 0, 3, 0}
681};
682
683stock IsPlayerNearAnyVehicle (playerid)
684{
685 new Float: v_x, Float: v_y, Float: v_z;
686
687
688 for (new i = 0; i < MAX_VEHICLES; i++)
689 {
690 if (GetVehicleModel (i) != 0)
691 {
692 GetVehiclePos (i, v_x, v_y, v_z);
693
694 if (IsPlayerInRangeOfPoint (playerid, 2.5, v_x, v_y, v_z))
695 {
696 return i;
697 }
698 }
699 }
700
701 return -1;
702}
703
704stock GetRecipeString (i_static_id)
705{
706 new recipe_string [144 * 4];
707
708 switch (i_static_id)
709 {
710 case 0: format (recipe_string, sizeof (recipe_string), "4 1 5 -1 -1,4 0 10 -1 -1 || 4 1 5 -1 -1,4 3 5 -1 -1 || 4 1 5 -1 -1");
711 }
712
713 return recipe_string;
714}
715
716stock GetSpecificRecipe (recipe_string [], recipe_id)
717{
718 new possibilities [10][144];
719
720 strexplode (possibilities, recipe_string, " || ");
721
722 return possibilities [recipe_id];
723}
724
725stock ShowSelectedRecipe (playerid, possibility [])
726{
727 new recipe_part [5][100],
728
729 s_type, s_id, s_amount, s_ammo, s_state,
730
731 string [1420];
732
733 strexplode (recipe_part, possibility, ",");
734
735 strcat (string, "You will need the following things to craft the item. \n", sizeof (string));
736
737 for (new i = 0; i < 5; i++)
738 {
739 if (!sscanf (recipe_part [i], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
740 {
741 switch (s_type)
742 {
743 case 1: format (string, sizeof (string), "%s\n%s x%d", string, FoodItems [s_id][name], s_amount);
744 case 2: format (string, sizeof (string), "%s\n%s x%d", string, MedicalItems [s_id][name], s_amount);
745 case 3: format (string, sizeof (string), "%s\n%s x%d", string, CookableItems [s_id][name], s_amount);
746 case 4: format (string, sizeof (string), "%s\n%s x%d", string, ResourceItems [s_id][name], s_amount);
747 case 5: format (string, sizeof (string), "%s\n%s x%d", string, ToolItems [s_id][name], s_amount);
748 case 6: format (string, sizeof (string), "%s\n%s x%d", string, BigItems [s_id][name], s_amount);
749 case 7: format (string, sizeof (string), "%s\n%s x%d", string, MiscItems [s_id][name], s_amount);
750 case 8: format (string, sizeof (string), "%s\n%s x%d", string, WeaponItems [s_id][name], s_amount);
751 case 9: format (string, sizeof (string), "%s\n%s x%d", string, MeleeWeaponItems [s_id][name], s_amount);
752 case 10: format (string, sizeof (string), "%s\n%s x%d", string, AmmoItems [s_id][name], s_amount);
753 case 11: format (string, sizeof (string), "%s\n%s x%d", string, HeadWearableItems [s_id][name], s_amount);
754 case 12: format (string, sizeof (string), "%s\n%s x%d", string, BodyWearableItems [s_id][wearable_name], s_amount);
755 case 13: format (string, sizeof (string), "%s\n%s x%d", string, BackpackItems [s_id][name], s_amount);
756 case 14: format (string, sizeof (string), "%s\n%s x%d", string, ArmourItems [s_id][name], s_amount);
757 }
758 }
759 }
760
761 ShowPlayerDialog (playerid, CRAFTING_RECIPE_DIALOG_ID_2, DIALOG_STYLE_MSGBOX, ""SERVER_TAG" - Crafting Recipe", string, "Craft", "Cancel");
762 return 1;
763}
764
765new PlayerInventory [MAX_PLAYERS][MAX_SLOTS][slot_data];
766new PlayerWeaponInfo [MAX_PLAYERS][MAX_WEAPON_TYPES][player_weapon_data];
767
768new PlayerPMOFFList [MAX_PLAYERS][MAX_PM_OFF];
769
770new ItemInfo [MAX_OBJECTS][created_item_data];
771
772new Text:CookingTD;
773new Text:CraftingTD;
774
775////////////////////////////////////////////////////////////////////////////////
776////////////////////////////////////////////////////////////////////////////////
777////////////////////////////////////////////////////////////////////////////////
778
779main()
780{
781 WasteDeAMXersTime();
782
783 print ("||||||||||||||||||||||||||||||||||||||||||||||||");
784 print ("|| JUST : AFTERMATH (ZOMBIE ROLEPLAY) LOADED ||");
785 print ("||||||||||||||||||||||||||||||||||||||||||||||||");
786 print (" ");
787
788}
789
790////////////////////////////////////////////////////////////////////////////////
791// CALLBACKS ///////////////////////////////////////////////////////////////////
792////////////////////////////////////////////////////////////////////////////////
793
794public OnGameModeInit()
795{
796 /*
797
798 AddSimpleModel (-1, 2000, -2001, "ak47.dff", "ak47.txd");
799 AddSimpleModel (-1, 2000, -2002, "benelli_m4.dff", "benelli_m4.txd");
800 AddSimpleModel (-1, 2000, -2003, "beretta92fs.dff", "beretta92fs.txd");
801 AddSimpleModel (-1, 2000, -2004, "clot.dff", "clot.txd");
802 AddSimpleModel (-1, 2000, -2005, "fn-fal.dff", "fn-fal.txd");
803 AddSimpleModel (-1, 2000, -2006, "glock17.dff", "glock17.txd");
804 AddSimpleModel (-1, 2000, -2007, "jericho941.dff", "jericho941.txd");
805 AddSimpleModel (-1, 2000, -2008, "m4a1.dff", "m4a1.txd");
806 AddSimpleModel (-1, 2000, -2009, "m14.dff", "m14.txd");
807 AddSimpleModel (-1, 2000, -2010, "m16a1.dff", "m16a1.txd");
808 AddSimpleModel (-1, 2000, -2011, "m16a4.dff", "m16a4.txd");
809 AddSimpleModel (-1, 2000, -2012, "m1911.dff", "m1911.txd");
810 AddSimpleModel (-1, 2000, -2013, "mossberg590.dff", "mossberg590.txd");
811 AddSimpleModel (-1, 2000, -2014, "mp5.dff", "mp5.txd");
812 AddSimpleModel (-1, 2000, -2015, "remington700bdl.dff", "remington700bdl.txd");
813 AddSimpleModel (-1, 2000, -2016, "tec9.dff", "tec9.txd");
814 AddSimpleModel (-1, 2000, -2017, "winchester73.dff", "winchester73.txd");
815
816 AddSimpleModel (-1, 2000, -2018, "antibiotic.dff", "antibiotic.txd");
817 AddSimpleModel (-1, 2000, -2019, "bandage.dff", "bandage.txd");
818 AddSimpleModel (-1, 2000, -2020, "beans.dff", "beans.txd");
819 AddSimpleModel (-1, 2000, -2023, "bear_trap.dff", "bear_trap.txd");
820 AddSimpleModel (-1, 2000, -2024, "bikerhelmet.dff", "bikerhelmet.txd");
821 AddSimpleModel (-1, 2000, -2025, "c_bp.dff", "c_bp.txd");
822 AddSimpleModel (-1, 2000, -2026, "cola.dff", "cola.txd");
823 AddSimpleModel (-1, 2000, -2027, "cooked_meat.dff", "cooked_meat.txd");
824 AddSimpleModel (-1, 2000, -2028, "fuel_can.dff", "fuel_can.txd");
825 AddSimpleModel (-1, 2000, -2029, "g_bp.dff", "g_bp.txd");
826 AddSimpleModel (-1, 2000, -2030, "imp_bp.dff", "imp_bp_1.txd");
827 AddSimpleModel (-1, 2000, -2031, "imp_bp.dff", "imp_bp_2.txd");
828 AddSimpleModel (-1, 2000, -2032, "marine_bp.dff", "marine_green.txd");
829 AddSimpleModel (-1, 2000, -2033, "marine_bp.dff", "marine_orange.txd");
830 AddSimpleModel (-1, 2000, -2034, "marine_bp.dff", "marine_red.txd");
831 AddSimpleModel (-1, 2000, -2035, "marine_bp.dff", "marine_yellow.txd");
832 AddSimpleModel (-1, 2000, -2036, "marine_bp.dff", "marine_black.txd");
833 AddSimpleModel (-1, 2000, -2037, "matches.dff", "matches.txd");
834 AddSimpleModel (-1, 2000, -2038, "military_bp.dff", "military_green.txd");
835 AddSimpleModel (-1, 2000, -2039, "military_bp.dff", "military_tan.txd");
836 AddSimpleModel (-1, 2000, -2040, "morphine.dff", "morphine.txd");
837 AddSimpleModel (-1, 2000, -2041, "mount_bp.dff", "mount_bp_blue.txd");
838 AddSimpleModel (-1, 2000, -2042, "mount_bp.dff", "mount_bp_green.txd");
839 AddSimpleModel (-1, 2000, -2043, "mount_bp.dff", "mount_bp_orange.txd");
840 AddSimpleModel (-1, 2000, -2044, "mount_bp.dff", "mount_bp_red.txd");
841 AddSimpleModel (-1, 2000, -2045, "painkiller.dff", "painkiller.txd");
842 AddSimpleModel (-1, 2000, -2046, "raw_meat.dff", "raw_meat.txd");
843 AddSimpleModel (-1, 2000, -2047, "revolver_mag.dff", "revolver_mag.txd");
844 AddSimpleModel (-1, 2000, -2048, "sport_bp.dff", "sport_bp.txd");
845 AddSimpleModel (-1, 2000, -2049, "taloon_bp.dff", "taloon_bp_blue.txd");
846 AddSimpleModel (-1, 2000, -2050, "taloon_bp.dff", "taloon_bp_green.txd");
847 AddSimpleModel (-1, 2000, -2051, "taloon_bp.dff", "taloon_bp_orange.txd");
848 AddSimpleModel (-1, 2000, -2052, "toolbox.dff", "toolbox.txd");
849 AddSimpleModel (-1, 2000, -2053, "watch.dff", "watch.txd");
850 AddSimpleModel (-1, 2000, -2054, "wood_pile.dff", "wood_pile.txd");
851
852 */
853
854 // WasteDeAMXersTime();
855
856 AddPlayerClass (60, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
857
858 LoadServer ();
859 LoadVehicles ();
860
861 CA_Init ();
862
863 SetTimer ("UpdateVehiclesData", 1000, true);
864 return 1;
865}
866
867public OnGameModeExit()
868{
869 foreach (new i : Player)
870 {
871 OnPlayerDisconnect (i, 0);
872 }
873
874 OnRconCommand ("close");
875 return 1;
876}
877
878public OnRconCommand(cmd[])
879{
880 if (!strcmp (cmd, "close"))
881 {
882 SaveItems ();
883 SaveVehicles ();
884
885 foreach (new i : Player)
886 {
887 if (IsPlayerConnected (i))
888 {
889 OnPlayerDisconnect (i, 0);
890 }
891 }
892
893 SendRconCommand ("exit");
894 }
895 return 1;
896}
897
898public OnPlayerRequestClass(playerid, classid)
899{
900 Streamer_UpdateEx (playerid, -401.7249, -1445.7130, 26.0625, 0, 0);
901
902 //SetPlayerSpawnInfo, TogglePlayerSpectating
903
904 SetPlayerInterior (playerid, 0);
905 SetPlayerVirtualWorld (playerid, 0);
906 SetPlayerPos (playerid, -401.7249, -1445.7130, 26.0625);
907 SetPlayerFacingAngle (playerid, 179.5791);
908
909 SetPlayerCameraPos(playerid, -399.0214, -1456.2310, 25.7266);
910 SetPlayerCameraLookAt(playerid, -398.8493, -1438.2705, 25.7266);
911
912 TogglePlayerControllable (playerid, false);
913 return 1;
914}
915
916public OnPlayerConnect(playerid)
917{
918 if (IsPlayerNPC (playerid)) return 0;
919
920 new query [124];
921 mysql_format (mysql, query, sizeof (query), "SELECT * FROM `players` WHERE `NAME` = '%e' LIMIT 1", GetName (playerid));
922 mysql_pquery (mysql, query, "OnPlayerInit", "i", playerid);
923
924 CreatePlayerCookingBar (playerid);
925 HideCookingBar (playerid);
926
927 PlayerInfo [playerid][getting_chased] = -1;
928
929 for (new i = 0; i < MAX_PM_OFF; i++)
930 {
931 PlayerPMOFFList [playerid][i] = -1;
932 }
933 return 1;
934}
935
936public OnPlayerDisconnect(playerid, reason)
937{
938 GetPlayerPos (playerid, PlayerInfo [playerid][last_x], PlayerInfo [playerid][last_y], PlayerInfo [playerid][last_z]);
939
940 if (PlayerInfo [playerid][initiated] == 1 && PlayerInfo [playerid][logged_in] == 1)
941 {
942 SavePlayerData (playerid);
943 PlayerInfo [playerid][logged_in] = 0;
944 }
945
946 KillTimer (PlayerBarTimer [playerid]);
947 DestroyPlayerProgressBars (playerid);
948
949 PlayerInfo [playerid][spawned] = 0;
950
951 PlayerInfo [playerid][hunger] = 100.0;
952 PlayerInfo [playerid][thirst] = 100.0;
953
954 HideProgressBars (playerid);
955
956 for (new i = 0; i < 10; i++)
957 {
958 RemovePlayerAttachedObject (playerid, i);
959 }
960
961 HideCookingBar (playerid);
962 KillTimer (PlayerInfo [playerid][cooking_timer]);
963
964 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
965 {
966 PlayerWeaponInfo [playerid][i][slot_used] = 0;
967 PlayerWeaponInfo [playerid][i][weapon_id] = 0;
968 PlayerWeaponInfo [playerid][i][weapon_model_id] = 0;
969 PlayerWeaponInfo [playerid][i][weapon_static_id] = -1;
970 PlayerWeaponInfo [playerid][i][weapon_type] = -1;
971 PlayerWeaponInfo [playerid][i][weapon_ammo] = -1;
972 PlayerWeaponInfo [playerid][i][weapon_damage] = 0.0;
973 }
974
975 for (new i = 0; i < PlayerInfo [playerid][inventory_virtual_slots]; i++)
976 {
977 PlayerInventory [playerid][i][item][0] = EOS;
978 }
979
980 PlayerInfo [playerid][slots_used] = 0;
981 PlayerInfo [playerid][inventory_virtual_slots] = PlayerInfo [playerid][inventory_slots];
982 return 1;
983}
984
985public OnPlayerUpdate (playerid)
986{
987
988 if (GetPlayerState (playerid) == PLAYER_STATE_DRIVER)
989 {
990 if (VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_fuel] > 0.0)
991 {
992 new keys, vertical, horizontal;
993 GetPlayerKeys (playerid, keys, vertical, horizontal);
994
995 if (keys == 8)
996 {
997 VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_driving] = 1;
998 }
999 else VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_driving] = 0;
1000 }
1001 }
1002
1003 if (IsPlayerNPC (playerid)) return 0;
1004
1005 switch (GetPlayerWeapon (playerid))
1006 {
1007 case 24:
1008 {
1009 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1010 {
1011 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 0)
1012 {
1013 SetPlayerAttachedObject (playerid, 8, -2006, 6, -0.032999, -0.031000, -0.051999, 0.000000, 0.000000, 0.000000, 1.422999, 2.459001, 1.600999);
1014 }
1015 else if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 1)
1016 {
1017 SetPlayerAttachedObject (playerid, 8, -2006, 6, -0.032999, -0.031000, -0.051999, 0.000000, 0.000000, 0.000000, 1.422999, 2.459001, 1.600999);
1018 }
1019 else if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 2)
1020 {
1021 SetPlayerAttachedObject (playerid, 8, -2004, 6, -0.040000, -0.019000, -0.048000, 8.999994, 2.700001, 1.099999, 1.418999, 2.548000, 1.440000);
1022 }
1023 else if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 3)
1024 {
1025 SetPlayerAttachedObject (playerid, 8, -2004, 6, -0.040000, -0.019000, -0.048000, 8.999994, 2.700001, 1.099999, 1.418999, 2.548000, 1.440000);
1026 }
1027 }
1028 }
1029 case 25:
1030 {
1031 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1032 {
1033 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 4)
1034 {
1035 SetPlayerAttachedObject (playerid, 8, -2013, 6, 0.001000, -0.063999, 0.005999, 16.900001, -5.199998, 8.400013, 1.416000, 2.696001, 1.070001);
1036 }
1037 }
1038 }
1039 case 29:
1040 {
1041 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1042 {
1043 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 7)
1044 {
1045 SetPlayerAttachedObject (playerid, 8, -2014, 6, -0.038999, -0.018000, -0.012000, -2.599999, 6.400000, 4.599999, 1.164998, 1.851999, 1.408999);
1046 }
1047 }
1048 }
1049 case 30:
1050 {
1051 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1052 {
1053 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 13)
1054 {
1055 SetPlayerAttachedObject (playerid, 8, -2001, 6, -0.063000, -0.010999, -0.006000, 0.000000, 0.000000, 0.000000, 1.429999, 1.621999, 1.270999);
1056 }
1057 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 14)
1058 {
1059 SetPlayerAttachedObject (playerid, 8, -2005, 6, -0.063000, -0.010999, -0.006000, 0.000000, 0.000000, 0.000000, 1.429999, 1.621999, 1.270999);
1060 }
1061 }
1062 }
1063 case 31:
1064 {
1065 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1066 {
1067 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 11)
1068 {
1069 SetPlayerAttachedObject (playerid, 8, -2011, 6, 0.028999, -0.037000, -0.041999, 0.000000, 0.000000, 3.500000, 1.245999, 2.126000, 1.385999);
1070 }
1071 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 12)
1072 {
1073 SetPlayerAttachedObject (playerid, 8, -2008, 6, -0.019000, -0.030000, -0.029999, 0.000000, 4.399997, 2.999999, 1.391999, 1.877000, 1.402000);
1074 }
1075 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 17)
1076 {
1077 SetPlayerAttachedObject (playerid, 8, -2010, 6, 0.020000, -0.016999, -0.043000, -0.199999, 2.399998, 0.000000, 1.252999, 1.812000, 1.382999);
1078 }
1079 }
1080 }
1081 case 32:
1082 {
1083 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1084 {
1085 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 8)
1086 {
1087 SetPlayerAttachedObject (playerid, 8, -2016, 6, -0.007000, -0.034999, -0.030999, 0.000000, 2.800004, 0.000000, 1.002999, 1.899000, 1.483999);
1088 }
1089 }
1090 }
1091 case 33:
1092 {
1093 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1094 {
1095 if (PlayerWeaponInfo [playerid][i][weapon_static_id] == 16)
1096 {
1097 SetPlayerAttachedObject (playerid, 8, -2017, 6, 0.000000, -0.051000, 0.001999, 2.999997, 2.899997, 6.799992, 1.078999, 2.086000, 1.307000);
1098 }
1099 }
1100 }
1101 default: RemovePlayerAttachedObject (playerid, 8);
1102 }
1103 return 1;
1104}
1105
1106public OnPlayerSpawn (playerid)
1107{
1108 SetPlayerVirtualWorld (playerid, 1);
1109
1110 if (PlayerInfo [playerid][spawned] == 0) { PlayerInfo [playerid][spawned] = 1; }
1111
1112 if (PlayerInfo [playerid][data_loaded] == 0)
1113 {
1114 SetPlayerSkin (playerid, PlayerInfo [playerid][skin]);
1115
1116 SetPlayerHealth (playerid, PlayerInfo [playerid][health]);
1117 SetPlayerInterior (playerid, PlayerInfo [playerid][last_interior]);
1118 SetPlayerVirtualWorld (playerid, 1);
1119
1120 SetPlayerPos (playerid, PlayerInfo [playerid][last_x], PlayerInfo [playerid][last_y], PlayerInfo [playerid][last_z]);
1121
1122 PlayerInfo [playerid][data_loaded] = 1;
1123
1124 new s_type, s_id, s_amount, s_ammo, s_status;
1125
1126 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
1127 {
1128 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
1129 {
1130 if (s_type == 7)
1131 {
1132 if (s_status == -3)
1133 {
1134 SetPlayerAttachedObject (playerid, 0, HeadWearableItems [s_id][model_id], 2, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.200000, 1.200000, 1.200000);
1135 }
1136 }
1137 }
1138 }
1139
1140 }
1141 else if (PlayerInfo [playerid][data_loaded] == 1)
1142 {
1143 SpawnAtSelectedSpawnArea (playerid);
1144 }
1145
1146 if (PlayerInfo [playerid][logged_in] == 1)
1147 {
1148 ShowProgressBars (playerid);
1149 UpdatePlayerBars (playerid);
1150 }
1151 return 1;
1152}
1153
1154public OnPlayerDeath(playerid, killerid, reason)
1155{
1156
1157 if (PlayerInfo [playerid][getting_chased] == 1)
1158 {
1159 for (new i = ((SERVER_SLOTS - Zombies) - 1); i < MAX_ZOMBIES; i++)
1160 {
1161 if (ZombieInfo [i][chasing] == playerid)
1162 {
1163 ZombieInfo [i][chasing] = -1;
1164 ZombieInfo [i][chasing_range] = 25.0;
1165 FCNPC_StopAttack (i);
1166 FindGoToPoint (i);
1167 }
1168 }
1169
1170 PlayerInfo [playerid][zombies_chasing] = 0;
1171 PlayerInfo [playerid][player_zombies] = 0;
1172 }
1173
1174 if (IsPlayerNPC (playerid)) return 0;
1175
1176 PlayerInfo [playerid][spawned] = 0;
1177
1178 PlayerInfo [playerid][hunger] = 70.0;
1179 PlayerInfo [playerid][thirst] = 70.0;
1180
1181 HideProgressBars (playerid);
1182
1183 for (new i = 0; i < 10; i++)
1184 {
1185 RemovePlayerAttachedObject (playerid, i);
1186 }
1187
1188 HideCookingBar (playerid);
1189 KillTimer (PlayerInfo [playerid][cooking_timer]);
1190
1191 for (new i = 0; i < MAX_WEAPON_TYPES; i++)
1192 {
1193 PlayerWeaponInfo [playerid][i][slot_used] = 0;
1194 PlayerWeaponInfo [playerid][i][weapon_id] = 0;
1195 PlayerWeaponInfo [playerid][i][weapon_model_id] = 0;
1196 PlayerWeaponInfo [playerid][i][weapon_static_id] = -1;
1197 PlayerWeaponInfo [playerid][i][weapon_type] = -1;
1198 PlayerWeaponInfo [playerid][i][weapon_ammo] = -1;
1199 PlayerWeaponInfo [playerid][i][weapon_damage] = 0.0;
1200 }
1201
1202 for (new i = 0; i < PlayerInfo [playerid][inventory_virtual_slots]; i++)
1203 {
1204 PlayerInventory [playerid][i][item][0] = EOS;
1205 }
1206
1207 PlayerInfo [playerid][slots_used] = 0;
1208 PlayerInfo [playerid][inventory_virtual_slots] = PlayerInfo [playerid][inventory_slots];
1209
1210 /*
1211 new Float: x, Float: y, Float: z,
1212 Float: fa,
1213 actor;
1214
1215 GetPlayerPos (playerid, x, y, z);
1216 GetPlayerFacingAngle (playerid, fa);
1217
1218 actor = CreateActor (PlayerInfo [playerid][skin], x, y, z, fa);
1219
1220 new player_held_weapon = GetPlayerWeapon (playerid),
1221 player_held_weapon_ammo = GetPlayerAmmo (playerid),
1222
1223 Float: w_x, Float: w_y, Float: w_z,
1224
1225 created_weapon;
1226
1227 w_x = (x + (random (2) * 1.0));
1228 w_y = (y + (random (2) * 1.0));
1229
1230 MapAndreas_FindZ_For2DCoord (w_x, w_y, w_z);
1231
1232 created_weapon = CreateObject (weapon, w_x, w_y, w_z, 0.0, 0.0, 0.0);
1233
1234 ItemInfo [created_weapon][item_model_id] = weapon;
1235 ItemInfo [created_weapon][item_type
1236
1237
1238
1239 SetTimerEx ("CreatePlayerZombie", 30 * 1000, false, "fff", x, y, z);
1240
1241 */
1242 return 1;
1243}
1244
1245public OnPlayerStateChange(playerid, newstate, oldstate)
1246{
1247 if (newstate == PLAYER_STATE_DRIVER)
1248 {
1249 ShowFuelBar (playerid);
1250 }
1251
1252 if (oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
1253 {
1254 VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_driving] = 0;
1255 HideFuelBar (playerid);
1256 }
1257 return 1;
1258}
1259
1260public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
1261{
1262 if (issuerid != INVALID_PLAYER_ID)
1263 {
1264 if (IsPlayerConnected (issuerid))
1265 {
1266 if (bodypart == 9)
1267 {
1268 if (PlayerInfo [playerid][head_protection] <= 0)
1269 {
1270 SetPlayerHealth (playerid, 0.0);
1271 GameTextForPlayer (issuerid, "~r~HEADSHOT", 1000, 3);
1272 }
1273 else
1274 {
1275 PlayerInfo [playerid][head_protection]--;
1276
1277 switch (PlayerInfo [playerid][head_protection])
1278 {
1279 case 0: SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You helmet got shot and "COLOR_MAIN_HEX"broke. ");
1280 default: SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Your helmet for shot. ");
1281 }
1282 }
1283 }
1284 }
1285 }
1286
1287 if (FCNPC_IsValid (issuerid))
1288 {
1289 new Float: hp;
1290 GetPlayerHealth (playerid, hp);
1291 SetPlayerHealth (playerid, (hp - 25.0));
1292 }
1293 return 1;
1294}
1295
1296public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
1297{
1298 if (damagedid != INVALID_PLAYER_ID)
1299 {
1300 if (IsPlayerConnected (damagedid))
1301 {
1302 if (!IsPlayerNPC (playerid))
1303 {
1304 new Float: hp, slot;
1305 GetPlayerHealth (damagedid, hp);
1306
1307 for (new i = 0; i < MAX_WEAPON_SLOTS; i++)
1308 {
1309 if (PlayerWeaponInfo [playerid][i][weapon_id] == weaponid)
1310 {
1311 slot = i;
1312 }
1313 }
1314
1315 SetPlayerHealth (damagedid, (hp - PlayerWeaponInfo [playerid][slot][weapon_damage]));
1316 }
1317 }
1318 }
1319 return 1;
1320}
1321
1322/*
1323public OnPlayerEnterDynamicArea(playerid, areaid)
1324{
1325 new Float: x, Float: y, Float: z;
1326
1327 PlayerInfo [playerid][in_zombie_zone] = 1;
1328
1329 for (new i = ((SERVER_SLOTS - Zombies) - 1); i < MAX_ZOMBIES; i++)
1330 {
1331 if (Z_Zone [ZombieInfo [i][zone_id]] == areaid)
1332 {
1333 if (ZombieInfo [i][chasing] == 0)
1334 {
1335 FCNPC_GetPosition (i, x, y, z);
1336
1337 if (IsPlayerInRangeOfPoint (playerid, 15.0, x, y, z))
1338 {
1339 FCNPC_GoToPlayer (i, playerid, FCNPC_MOVE_TYPE_SPRINT, FCNPC_MOVE_SPEED_SPRINT);
1340 PlayerInfo [playerid][getting_chased] = 1;
1341 }
1342 }
1343 }
1344 }
1345 return 1;
1346}
1347
1348public OnPlayerLeaveDynamicArea(playerid, areaid)
1349{
1350 PlayerInfo [playerid][in_zombie_zone] = 0;
1351 return 1;
1352}
1353*/
1354
1355public OnVehicleDeath (vehicleid)
1356{
1357
1358 /*
1359
1360 enum vehicle_data
1361 {
1362 vehicle_model,
1363
1364 vehicle_color_1,
1365 vehicle_color_2,
1366
1367 Float: vehicle_health,
1368 Float: vehicle_fuel,
1369
1370 vehicle_engine,
1371 vehicle_lights,
1372 vehicle_alarm,
1373 vehicle_doors,
1374 vehicle_bonnet,
1375 vehicle_boot,
1376
1377 vehicle_driving,
1378
1379 Float: vehicle_x,
1380 Float: vehicle_y,
1381 Float: vehicle_z,
1382 Float: vehicle_a
1383 };
1384
1385
1386 */
1387
1388 DestroyVehicle (vehicleid);
1389
1390 VehicleInfo [vehicleid][vehicle_model] =
1391
1392 VehicleInfo [vehicleid][vehicle_color_1] =
1393 VehicleInfo [vehicleid][vehicle_color_2] =
1394
1395 VehicleInfo [vehicleid][vehicle_engine] =
1396 VehicleInfo [vehicleid][vehicle_lights] =
1397 VehicleInfo [vehicleid][vehicle_alarm] =
1398 VehicleInfo [vehicleid][vehicle_doors] =
1399 VehicleInfo [vehicleid][vehicle_bonnet] =
1400 VehicleInfo [vehicleid][vehicle_boot] =
1401
1402 VehicleInfo [vehicleid][vehicle_driving] = 0;
1403
1404 VehicleInfo [vehicleid][vehicle_x] =
1405 VehicleInfo [vehicleid][vehicle_y] =
1406 VehicleInfo [vehicleid][vehicle_z] =
1407 VehicleInfo [vehicleid][vehicle_a] =
1408
1409 VehicleInfo [vehicleid][vehicle_health] =
1410 VehicleInfo [vehicleid][vehicle_fuel] = 0.0;
1411 return 1;
1412}
1413
1414public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
1415{
1416 if(newkeys & KEY_JUMP && !(oldkeys & KEY_JUMP) && GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CUFFED) ApplyAnimation(playerid, "GYMNASIUM", "gym_jog_falloff",4.1,0,1,1,0,0);
1417
1418 if (PRESSING (newkeys, KEY_WALK))
1419 {
1420 PlayerInfo [playerid][walking] = 1;
1421 }
1422 else if (RELEASED (KEY_WALK))
1423 {
1424 PlayerInfo [playerid][walking] = 0;
1425 }
1426
1427 if (PRESSING (newkeys, KEY_SPRINT))
1428 {
1429 PlayerInfo [playerid][sprinting] = 1;
1430 }
1431 else if (RELEASED (KEY_SPRINT))
1432 {
1433 PlayerInfo [playerid][sprinting] = 0;
1434 }
1435
1436 return 1;
1437}
1438
1439public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
1440{
1441 if (GetWeaponType (weaponid) >= 1)
1442 {
1443 new slot,
1444
1445 s_type, s_id, s_amount, s_ammo, s_status,
1446
1447 added_weapon_ammo;
1448
1449 if (PlayerInfo [playerid][weapon_shot] == 0)
1450 {
1451 PlayerInfo [playerid][weapon_shot] = 1;
1452 SetTimerEx ("FadeWeaponShotSound", 1000, false, "i", playerid);
1453 }
1454
1455 for (new i = 0; i < MAX_WEAPON_SLOTS; i++)
1456 {
1457 if (PlayerWeaponInfo [playerid][i][weapon_id] == weaponid)
1458 {
1459 slot = i;
1460 break;
1461 }
1462 }
1463
1464 PlayerWeaponInfo [playerid][slot][weapon_ammo]--;
1465
1466 if (PlayerWeaponInfo [playerid][slot][weapon_ammo] == 0)
1467 {
1468 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Weapon ammo sole is empty. ");
1469
1470 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
1471 {
1472 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
1473 {
1474 if (s_type == 10)
1475 {
1476 if (s_id == PlayerWeaponInfo [playerid][slot][weapon_ammo])
1477 {
1478 if(s_status == slot)
1479 {
1480 RearrangePlayerInventorySlots (playerid, i);
1481 }
1482 if (!(s_status > 0)) // if (s_ammo != -1)
1483 {
1484 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Unpacking new ammo pack. ");
1485
1486 // RearrangePlayerInventorySlots (playerid, i);
1487
1488 format (PlayerInventory [playerid][i][item], 124, "10 %d %d -1 %d", s_id, s_amount, s_ammo, slot);
1489
1490 added_weapon_ammo = s_amount;
1491 break;
1492 }
1493 }
1494 }
1495 }
1496 }
1497
1498 if (added_weapon_ammo == 0)
1499 {
1500
1501 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
1502 {
1503 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
1504 {
1505 if (s_type == 8)
1506 {
1507 if (s_id == PlayerWeaponInfo [playerid][slot][weapon_static_id])
1508 {
1509 format (PlayerInventory [playerid][i][item], 124, "%d %d %d %d -2", s_type, s_id, s_amount, s_ammo);
1510 break;
1511 }
1512 }
1513 }
1514 }
1515
1516 PlayerWeaponInfo [playerid][slot][slot_used] = 0;
1517 PlayerWeaponInfo [playerid][slot][weapon_id] = 0;
1518 PlayerWeaponInfo [playerid][slot][weapon_model_id] = 0;
1519 PlayerWeaponInfo [playerid][slot][weapon_type] = -1;
1520 PlayerWeaponInfo [playerid][slot][weapon_ammo] = -1;
1521 PlayerWeaponInfo [playerid][slot][weapon_damage] = 0.0;
1522
1523 }
1524 else
1525 {
1526 PlayerWeaponInfo [playerid][slot][weapon_ammo] = added_weapon_ammo;
1527 GivePlayerWeapon (playerid, PlayerWeaponInfo [playerid][slot][weapon_id], added_weapon_ammo);
1528
1529 new string [150];
1530 format (string, sizeof (string), "[INFO] %sUnpacked %d bullets. ", COLOR_WHITE, added_weapon_ammo);
1531 SendClientMessage (playerid, COLOR_MAIN, string);
1532 }
1533 }
1534 }
1535 return 1;
1536}
1537
1538public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
1539{
1540 switch (dialogid)
1541 {
1542 case LOGIN_DIALOG_ID:
1543 {
1544 if (IsPlayerNPC (playerid)) return 0;
1545 if (!response) return ShowLoginDialog (playerid);
1546
1547 if (strcmp (inputtext, PlayerInfo [playerid][password]))
1548 {
1549
1550 PlayerInfo [playerid][login_attempts]++;
1551
1552 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You have entered a wrong password. ");
1553
1554 new string [50];
1555 format (string, sizeof (string), "[ERROR] {FFFFF}LOGIN ATTEMPTS: %s(%d/%d)", COLOR_MAIN, PlayerInfo [playerid][login_attempts], MAX_LOGIN_ATTEMPTS);
1556 SendClientMessage (playerid, COLOR_MAIN, string);
1557
1558 if (PlayerInfo [playerid][login_attempts] == MAX_LOGIN_ATTEMPTS)
1559 {
1560 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You have have failed all the login attempts. ");
1561
1562 Kick (playerid);
1563 return 0;
1564 }
1565
1566 ShowLoginDialog (playerid);
1567 return 0;
1568 }
1569 else if (strcmp (inputtext, PlayerInfo [playerid][password]) == 0)
1570 {
1571 KillTimer (PlayerInfo [playerid][kick_timer]);
1572
1573 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You have successfully logged in your account. ");
1574
1575 PlayerInfo [playerid][logged_in] = 1;
1576
1577 new query [124];
1578
1579 mysql_format (mysql, query, sizeof (query), "SELECT * FROM `players` WHERE `NAME` = '%e' LIMIT 1", GetName (playerid));
1580 mysql_pquery (mysql, query, "LoadPlayerData", "i", playerid);
1581
1582 mysql_format (mysql, query, sizeof (query), "SELECT * FROM `inventories` WHERE `ACCOUNT_ID` = %d", PlayerInfo [playerid][account_id]);
1583 mysql_pquery (mysql, query, "LoadPlayerInventory", "i", playerid);
1584
1585 PlayerBarTimer [playerid] = SetTimerEx ("UpdatePlayerBars", 10 * 1000, true, "i", playerid);
1586 }
1587 }
1588
1589 case SETUP_DIALOG_ID_1:
1590 {
1591 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_2, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Age", "Enter your age:", "Next", "");
1592 }
1593 case SETUP_DIALOG_ID_2:
1594 {
1595 if (!response) return ShowPlayerDialog (playerid, SETUP_DIALOG_ID_2, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Age", "Enter your age:", "Next", "");
1596
1597 if (strval (inputtext) > 99 || strval (inputtext) < 10)
1598 {
1599 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Enter your age less than 99 and more than 10. ");
1600 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_2, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Age", "Enter your age:", "Next", "");
1601 return 0;
1602 }
1603
1604 if (isnull (inputtext))
1605 {
1606 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You need to enter an age to proceed. ");
1607 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_2, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Age", "Enter your age (lower than 99):", "Next", "");
1608 return 0;
1609 }
1610
1611 PlayerInfo [playerid][age] = strval (inputtext);
1612
1613 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_3, DIALOG_STYLE_LIST, ""SERVER_TAG" - Gender Selection", "1. Male\n2. Female", "Select", "");
1614 }
1615 case SETUP_DIALOG_ID_3:
1616 {
1617 if (!response) return ShowPlayerDialog (playerid, SETUP_DIALOG_ID_3, DIALOG_STYLE_LIST, ""SERVER_TAG" - Gender Selection", "1. Male\n2. Female", "Select", "");
1618
1619 PlayerInfo [playerid][gender] = listitem;
1620
1621 new string [250];
1622 for (new i = 0; i < MAX_JOBS; i++)
1623 {
1624 if (i == 0) { format (string, sizeof (string), "%s\n", Jobs [i][name]); }
1625 else if (i == (MAX_JOBS - 1)) { format (string, sizeof (string), "%s\n%s", string, Jobs [i][name]); }
1626 else { format (string, sizeof (string), "%s\n%s\n", string, Jobs [i][name]); }
1627 }
1628
1629 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_4, DIALOG_STYLE_LIST, ""SERVER_TAG" - Job Selection", string, "Select", "");
1630 }
1631 case SETUP_DIALOG_ID_4:
1632 {
1633 if (!response)
1634 {
1635 new string [250];
1636 for (new i = 0; i < MAX_JOBS; i++)
1637 {
1638 if (i == 0) { format (string, sizeof (string), "%s\n", Jobs [i][name]); }
1639 else if (i == (MAX_JOBS - 1)) { format (string, sizeof (string), "%s\n%s", string, Jobs [i][name]); }
1640 else { format (string, sizeof (string), "%s\n%s\n", string, Jobs [i][name]); }
1641 }
1642
1643 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_4, DIALOG_STYLE_LIST, ""SERVER_TAG" - Job Selection", string, "Select", "");
1644 return 0;
1645 }
1646
1647 PlayerInfo [playerid][job] = listitem;
1648
1649 switch (PlayerInfo [playerid][job])
1650 {
1651 // Police
1652 case 0:
1653 {
1654 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "8 0 1 -1 -2");
1655 PlayerInfo [playerid][slots_used]++;
1656
1657 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "10 0 17 -1 -2");
1658 PlayerInfo [playerid][slots_used]++;
1659
1660 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "2 2 1 100 -1");
1661 PlayerInfo [playerid][slots_used]++;
1662
1663 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "5 0 1 -1 -1");
1664 PlayerInfo [playerid][slots_used]++;
1665
1666 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "5 1 1 -1 -1");
1667 PlayerInfo [playerid][slots_used]++;
1668 }
1669
1670 // Doctor
1671 case 1:
1672 {
1673 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "9 2 1 -1 -2");
1674 PlayerInfo [playerid][slots_used]++;
1675
1676 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "2 2 1 100 -1");
1677 PlayerInfo [playerid][slots_used]++;
1678
1679 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "2 3 1 2 -1");
1680 PlayerInfo [playerid][slots_used]++;
1681
1682 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "2 4 1 1 -1");
1683 PlayerInfo [playerid][slots_used]++;
1684
1685 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "2 5 1 2 -1");
1686 PlayerInfo [playerid][slots_used]++;
1687
1688 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "1 5 1 100 -1");
1689 PlayerInfo [playerid][slots_used]++;
1690 }
1691
1692 // Teacher
1693 case 2:
1694 {
1695 // Add PENCIL and BOOK here
1696 }
1697
1698 // Repairman
1699 case 3:
1700 {
1701 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "9 4 1 -1 -2");
1702 PlayerInfo [playerid][slots_used]++;
1703
1704 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "5 2 3 -1 -1");
1705 PlayerInfo [playerid][slots_used]++;
1706 }
1707
1708 // Cooker
1709 case 4:
1710 {
1711 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "7 2 1 -1 -1");
1712 PlayerInfo [playerid][slots_used]++;
1713
1714 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "9 4 1 -1 -2");
1715 PlayerInfo [playerid][slots_used]++;
1716
1717 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "1 5 1 100 -1");
1718 PlayerInfo [playerid][slots_used]++;
1719 }
1720
1721 // Worker
1722 case 5:
1723 {
1724 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "9 3 1 -1 -2");
1725 PlayerInfo [playerid][slots_used]++;
1726 }
1727
1728 // Hunter
1729 case 6:
1730 {
1731 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "8 16 1 -1 -2");
1732 PlayerInfo [playerid][slots_used]++;
1733
1734 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "10 4 20 -1 -2");
1735 PlayerInfo [playerid][slots_used]++;
1736
1737 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "12 6 1 -1 -2");
1738 PlayerInfo [playerid][slots_used]++;
1739
1740 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "9 1 1 -1 -2");
1741 PlayerInfo [playerid][slots_used]++;
1742 }
1743
1744 // Soldier
1745 case 7:
1746 {
1747 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "8 11 1 -1 -2");
1748 PlayerInfo [playerid][slots_used]++;
1749
1750 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "10 3 50 -1 -2");
1751 PlayerInfo [playerid][slots_used]++;
1752
1753 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "2 0 1 150 -1");
1754 PlayerInfo [playerid][slots_used]++;
1755
1756 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "1 6 1 120 -1");
1757 PlayerInfo [playerid][slots_used]++;
1758
1759 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "12 7 1 -1 -2");
1760 PlayerInfo [playerid][slots_used]++;
1761 }
1762 }
1763
1764 PlayerInfo [playerid][cooking] = Jobs [PlayerInfo [playerid][job]][cooking];
1765 PlayerInfo [playerid][hunting] = Jobs [PlayerInfo [playerid][job]][hunting];
1766 PlayerInfo [playerid][crafting] = Jobs [PlayerInfo [playerid][job]][crafting];
1767 PlayerInfo [playerid][learning] = Jobs [PlayerInfo [playerid][job]][learning];
1768 PlayerInfo [playerid][repairing] = Jobs [PlayerInfo [playerid][job]][repairing];
1769 PlayerInfo [playerid][strength] = Jobs [PlayerInfo [playerid][job]][strength];
1770 PlayerInfo [playerid][durability] = Jobs [PlayerInfo [playerid][job]][durability];
1771
1772 switch (PlayerInfo [playerid][durability])
1773 {
1774 case 1: PlayerInfo [playerid][inventory_slots] = 5;
1775 case 2: PlayerInfo [playerid][inventory_slots] = 8;
1776 case 3: PlayerInfo [playerid][inventory_slots] = 11;
1777 case 4: PlayerInfo [playerid][inventory_slots] = 14;
1778 case 5: PlayerInfo [playerid][inventory_slots] = 17;
1779 }
1780
1781 PlayerInfo [playerid][inventory_virtual_slots] = PlayerInfo [playerid][inventory_slots];
1782
1783 new string [1250];
1784
1785 if (PlayerInfo [playerid][gender] == 0)
1786 {
1787 for (new i = 0; i < sizeof (MaleSkins); i++)
1788 {
1789 format (string, sizeof (string), "%s\n%i(0.0, 0.0, 0.0)", string, MaleSkins[i]);
1790 }
1791 }
1792 else if (PlayerInfo [playerid][gender] == 1)
1793 {
1794 for (new i = 0; i < sizeof (FemaleSkins); i++)
1795 {
1796 format (string, sizeof (string), "%s\n%i(0.0, 0.0, 0.0)", string, FemaleSkins[i]);
1797 }
1798 }
1799 else if (PlayerInfo [playerid][gender] == 2)
1800 {
1801 for (new i = 0; i < 311; i++)
1802 {
1803 format (string, sizeof (string), "%s\n%d(0.0, 0.0, 0.0)", string, i);
1804 }
1805 }
1806
1807 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_5, DIALOG_STYLE_PREVIEW_MODEL, ""SERVER_TAG" - Skin Selection", string, "Select", "");
1808
1809 }
1810 case SETUP_DIALOG_ID_5:
1811 {
1812 if (!response)
1813 {
1814 new string [1250];
1815
1816 if (PlayerInfo [playerid][gender] == 0)
1817 {
1818 for (new i = 0; i < sizeof (MaleSkins); i++)
1819 {
1820 format (string, sizeof (string), "%s\n%i(0.0, 0.0, 0.0)", string, MaleSkins[i]);
1821 }
1822 }
1823 else if (PlayerInfo [playerid][gender] == 1)
1824 {
1825 for (new i = 0; i < sizeof (FemaleSkins); i++)
1826 {
1827 format (string, sizeof (string), "%s\n%i(0.0, 0.0, 0.0)", string, FemaleSkins[i]);
1828 }
1829 }
1830 else if (PlayerInfo [playerid][gender] == 2)
1831 {
1832 for (new i = 0; i < 311; i++)
1833 {
1834 format (string, sizeof (string), "%s\n%i(0.0, 0.0, 0.0)", string, i);
1835 }
1836 }
1837
1838 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_5, DIALOG_STYLE_PREVIEW_MODEL, ""SERVER_TAG" - Skin Selection", string, "Select", "");
1839 return 0;
1840 }
1841
1842 if (PlayerInfo [playerid][gender] == 0) { PlayerInfo [playerid][skin] = MaleSkins [listitem]; }
1843 else if (PlayerInfo [playerid][gender] == 1) { PlayerInfo [playerid][skin] = FemaleSkins [listitem]; }
1844 else if (PlayerInfo [playerid][gender] == 2) { PlayerInfo [playerid][skin] = listitem; }
1845
1846 SetPlayerSkin (playerid, PlayerInfo [playerid][skin]);
1847
1848 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_6, DIALOG_STYLE_LIST, ""SERVER_TAG" - Spawn Selection", "1. Los Santos\n2. Palomino Creek\n3. Montgomery\n4. Blueberry\n5. Dillimore", "Select", "");
1849 }
1850 case SETUP_DIALOG_ID_6:
1851 {
1852
1853 if (!response)
1854 {
1855 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You must select a spawn place in order to proceed. ");
1856 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_6, DIALOG_STYLE_LIST, ""SERVER_TAG" - Spawn Selection", "1. Los Santos\n2. Palomino Creek\n3. Montgomery\n4. Blueberry\n5. Dillimore", "Select", "");
1857 return 0;
1858 }
1859
1860 SetupPlayer (playerid);
1861 SpawnPlayer (playerid);
1862
1863 PlayerInfo [playerid][player_spawn] = listitem;
1864
1865 SpawnAtSelectedSpawnArea (playerid);
1866
1867 }
1868 case ADD_ITEM_DIALOG_ID_1:
1869 {
1870
1871 if (!response)
1872 {
1873 PlayerInfo [playerid][selected_item_type] = 0;
1874 PlayerInfo [playerid][selected_item_amount] = 0;
1875
1876 PlayerInfo [playerid][selected_item_model_id] = -1;
1877 PlayerInfo [playerid][selected_item_static_id] = -1;
1878 }
1879 else
1880 {
1881 new string [1024];
1882
1883 if (listitem == 0)
1884 {
1885 for (new i = 0; i < MAX_FOOD_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, FoodItems [i][name]); }
1886 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Food Items", string, "Select", "Back");
1887 }
1888 else if (listitem == 1)
1889 {
1890 for (new i = 0; i < MAX_MEDICAL_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, MedicalItems [i][name]); }
1891 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Medical Items", string, "Select", "Back");
1892 }
1893 else if (listitem == 2)
1894 {
1895 for (new i = 0; i < MAX_COOKABLE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, CookableItems [i][name]); }
1896 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Cookable Items", string, "Select", "Back");
1897 }
1898 else if (listitem == 3)
1899 {
1900 for (new i = 0; i < MAX_RESOURCE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, ResourceItems [i][name]); }
1901 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Resource Items", string, "Select", "Back");
1902 }
1903 else if (listitem == 4)
1904 {
1905 for (new i = 0; i < MAX_TOOL_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, ToolItems [i][name]); }
1906 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Tool Items", string, "Select", "Back");
1907 }
1908 else if (listitem == 5)
1909 {
1910 for (new i = 0; i < MAX_BIG_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, BigItems [i][name]); }
1911 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Big Items", string, "Select", "Back");
1912 }
1913 else if (listitem == 6)
1914 {
1915 for (new i = 0; i < MAX_MISC_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, MiscItems [i][name]); }
1916 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Misc Items", string, "Select", "Back");
1917 }
1918 else if (listitem == 7)
1919 {
1920 for (new i = 0; i < MAX_WEAPON_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, WeaponItems [i][name]); }
1921 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Weapons", string, "Select", "Back");
1922 }
1923 else if (listitem == 8)
1924 {
1925 for (new i = 0; i < MAX_MELEE_WEAPON_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, MeleeWeaponItems [i][name]); }
1926 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Melee Weapons", string, "Select", "Back");
1927 }
1928 else if (listitem == 9)
1929 {
1930 for (new i = 0; i < MAX_AMMO_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, AmmoItems [i][name]); }
1931 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Ammo", string, "Select", "Back");
1932 }
1933 else if (listitem == 10)
1934 {
1935 for (new i = 0; i < MAX_HEAD_WEARABLE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, HeadWearableItems [i][name]); }
1936 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Head Wearable Items", string, "Select", "Back");
1937 }
1938 else if (listitem == 11)
1939 {
1940 for (new i = 0; i < MAX_BODY_WEARABLE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, BodyWearableItems [i][wearable_name]); }
1941 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Body Wearable Items", string, "Select", "Back");
1942 }
1943 else if (listitem == 12)
1944 {
1945 for (new i = 0; i < MAX_BACKPACK_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, BackpackItems [i][name]); }
1946 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Backpacks", string, "Select", "Back");
1947 }
1948 else if (listitem == 13)
1949 {
1950 for (new i = 0; i < MAX_ARMOUR_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, ArmourItems [i][name]); }
1951 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Armours", string, "Select", "Back");
1952 }
1953
1954 PlayerInfo [playerid][selected_item_type] = (listitem + 1);
1955 }
1956 }
1957 case ADD_ITEM_DIALOG_ID_2:
1958 {
1959 if (!response)
1960 {
1961 PlayerInfo [playerid][selected_item_type] = 0;
1962 PlayerInfo [playerid][selected_item_amount] = 0;
1963
1964 PlayerInfo [playerid][selected_item_model_id] = -1;
1965 PlayerInfo [playerid][selected_item_static_id] = -1;
1966
1967 new string [2450];
1968
1969 strcat (string, ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Food Items\n", sizeof (string));
1970 strcat (string, ""COLOR_MAIN_HEX"2. "COLOR_WHITE"Medical Items\n", sizeof (string));
1971 strcat (string, ""COLOR_MAIN_HEX"3. "COLOR_WHITE"Cookable Items\n", sizeof (string));
1972 strcat (string, ""COLOR_MAIN_HEX"4. "COLOR_WHITE"Resource Items\n", sizeof (string));
1973 strcat (string, ""COLOR_MAIN_HEX"5. "COLOR_WHITE"Tool Items\n", sizeof (string));
1974 strcat (string, ""COLOR_MAIN_HEX"6. "COLOR_WHITE"Big Items\n", sizeof (string));
1975 strcat (string, ""COLOR_MAIN_HEX"7. "COLOR_WHITE"Misc Items\n", sizeof (string));
1976 strcat (string, ""COLOR_MAIN_HEX"8. "COLOR_WHITE"Ranged Weapons\n", sizeof (string));
1977 strcat (string, ""COLOR_MAIN_HEX"9. "COLOR_WHITE"Melee Weapons\n", sizeof (string));
1978 strcat (string, ""COLOR_MAIN_HEX"10. "COLOR_WHITE"Ammo\n", sizeof (string));
1979 strcat (string, ""COLOR_MAIN_HEX"11. "COLOR_WHITE"Head Wearable Items\n", sizeof (string));
1980 strcat (string, ""COLOR_MAIN_HEX"12. "COLOR_WHITE"Body Wearable Items\n", sizeof (string));
1981 strcat (string, ""COLOR_MAIN_HEX"13. "COLOR_WHITE"Backpacks\n", sizeof (string));
1982 strcat (string, ""COLOR_MAIN_HEX"13. "COLOR_WHITE"Armours", sizeof (string));
1983
1984 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_1, DIALOG_STYLE_LIST, ""SERVER_TAG" - Add Item", string, "Select", "Cancel");
1985 return 0;
1986 }
1987 else
1988 {
1989 if (PlayerInfo [playerid][selected_item_type] == 1) { PlayerInfo [playerid][selected_item_model_id] = FoodItems [listitem][model_id]; }
1990 else if (PlayerInfo [playerid][selected_item_type] == 2) { PlayerInfo [playerid][selected_item_model_id] = MedicalItems [listitem][model_id]; }
1991 else if (PlayerInfo [playerid][selected_item_type] == 3) { PlayerInfo [playerid][selected_item_model_id] = CookableItems [listitem][model_id]; }
1992 else if (PlayerInfo [playerid][selected_item_type] == 4) { PlayerInfo [playerid][selected_item_model_id] = ResourceItems [listitem][model_id]; }
1993 else if (PlayerInfo [playerid][selected_item_type] == 5) { PlayerInfo [playerid][selected_item_model_id] = ToolItems [listitem][model_id]; }
1994 else if (PlayerInfo [playerid][selected_item_type] == 6) { PlayerInfo [playerid][selected_item_model_id] = BigItems [listitem][model_id_1]; }
1995 else if (PlayerInfo [playerid][selected_item_type] == 7) { PlayerInfo [playerid][selected_item_model_id] = MiscItems [listitem][model_id]; }
1996 else if (PlayerInfo [playerid][selected_item_type] == 8) { PlayerInfo [playerid][selected_item_model_id] = WeaponItems [listitem][weapon_model_id]; }
1997 else if (PlayerInfo [playerid][selected_item_type] == 9) { PlayerInfo [playerid][selected_item_model_id] = MeleeWeaponItems [listitem][weapon_model_id]; }
1998 else if (PlayerInfo [playerid][selected_item_type] == 10) { PlayerInfo [playerid][selected_item_model_id] = 2040; }
1999 else if (PlayerInfo [playerid][selected_item_type] == 11) { PlayerInfo [playerid][selected_item_model_id] = HeadWearableItems [listitem][model_id]; }
2000 else if (PlayerInfo [playerid][selected_item_type] == 12) { PlayerInfo [playerid][selected_item_model_id] = BodyWearableItems [listitem][wearable_model_id]; }
2001 else if (PlayerInfo [playerid][selected_item_type] == 13) { PlayerInfo [playerid][selected_item_model_id] = BackpackItems [listitem][model_id]; }
2002 else if (PlayerInfo [playerid][selected_item_type] == 14) { PlayerInfo [playerid][selected_item_model_id] = ArmourItems [listitem][model_id]; }
2003
2004 PlayerInfo [playerid][selected_item_static_id] = listitem;
2005
2006 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_3, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Item amount", "Enter the item amount: ", "Add", "Back");
2007 }
2008 }
2009 case ADD_ITEM_DIALOG_ID_3:
2010 {
2011 if (!response)
2012 {
2013 new string [450];
2014
2015 if (listitem == 0)
2016 {
2017 for (new i = 0; i < MAX_FOOD_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, FoodItems [i][name]); }
2018 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Food Items", string, "Select", "Back");
2019 }
2020 else if (listitem == 1)
2021 {
2022 for (new i = 0; i < MAX_MEDICAL_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, MedicalItems [i][name]); }
2023 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Medical Items", string, "Select", "Back");
2024 }
2025 else if (listitem == 2)
2026 {
2027 for (new i = 0; i < MAX_COOKABLE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, CookableItems [i][name]); }
2028 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Cookable Items", string, "Select", "Back");
2029 }
2030 else if (listitem == 3)
2031 {
2032 for (new i = 0; i < MAX_RESOURCE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, ResourceItems [i][name]); }
2033 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Resource Items", string, "Select", "Back");
2034 }
2035 else if (listitem == 4)
2036 {
2037 for (new i = 0; i < MAX_TOOL_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, ToolItems [i][name]); }
2038 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Tool Items", string, "Select", "Back");
2039 }
2040 else if (listitem == 5)
2041 {
2042 for (new i = 0; i < MAX_BIG_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, BigItems [i][name]); }
2043 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Big Items", string, "Select", "Back");
2044 }
2045 else if (listitem == 6)
2046 {
2047 for (new i = 0; i < MAX_MISC_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, MiscItems [i][name]); }
2048 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Misc Items", string, "Select", "Back");
2049 }
2050 else if (listitem == 7)
2051 {
2052 for (new i = 0; i < MAX_WEAPON_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, WeaponItems [i][name]); }
2053 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Weapons", string, "Select", "Back");
2054 }
2055 else if (listitem == 8)
2056 {
2057 for (new i = 0; i < MAX_MELEE_WEAPON_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, MeleeWeaponItems [i][name]); }
2058 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Melee Weapons", string, "Select", "Back");
2059 }
2060 else if (listitem == 9)
2061 {
2062 for (new i = 0; i < MAX_AMMO_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, AmmoItems [i][name]); }
2063 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Ammo", string, "Select", "Back");
2064 }
2065 else if (listitem == 10)
2066 {
2067 for (new i = 0; i < MAX_HEAD_WEARABLE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, HeadWearableItems [i][name]); }
2068 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Head Wearable Items", string, "Select", "Back");
2069 }
2070 else if (listitem == 11)
2071 {
2072 for (new i = 0; i < MAX_BODY_WEARABLE_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, BodyWearableItems [i][wearable_name]); }
2073 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Body Wearable Items", string, "Select", "Back");
2074 }
2075 else if (listitem == 12)
2076 {
2077 for (new i = 0; i < MAX_BACKPACK_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, BackpackItems [i][name]); }
2078 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Backpacks", string, "Select", "Back");
2079 }
2080 else if (listitem == 13)
2081 {
2082 for (new i = 0; i < MAX_ARMOUR_ITEMS; i++) { format (string, sizeof (string), "%s\n%s", string, ArmourItems [i][name]); }
2083 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Armours", string, "Select", "Back");
2084 }
2085
2086 return 0;
2087 }
2088
2089 if (isnull (inputtext) || strval (inputtext) == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Invalid amount");
2090
2091 new items;
2092 for (new i = 0; i < MAX_OBJECTS; i++) { if (ItemInfo [i][item_type] != 0) { items++; } }
2093
2094 if (items == MAX_ITEMS)
2095 {
2096 PlayerInfo [playerid][selected_item_type] = 0;
2097 PlayerInfo [playerid][selected_item_amount] = 0;
2098
2099 PlayerInfo [playerid][selected_item_model_id] = -1;
2100 PlayerInfo [playerid][selected_item_static_id] = -1;
2101
2102 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"ITEMS LIMIT REACHED, CANNOT CREATE MORE ITEMS. ");
2103
2104 return 0;
2105 }
2106
2107 new created_object,
2108 Float: x, Float: y, Float: z;
2109
2110 PlayerInfo [playerid][selected_item_amount] = strval (inputtext);
2111
2112 GetPlayerPos (playerid, x, y, z);
2113 created_object = CreateObject (PlayerInfo [playerid][selected_item_model_id], x, y, z, 0.0, 0.0, 0.0);
2114
2115 ItemInfo [created_object][item_id] = items;
2116 ItemInfo [created_object][item_type] = PlayerInfo [playerid][selected_item_type];
2117 ItemInfo [created_object][item_amount] = PlayerInfo [playerid][selected_item_amount];
2118 ItemInfo [created_object][item_model_id] = PlayerInfo [playerid][selected_item_model_id];
2119 ItemInfo [created_object][item_static_id] = PlayerInfo [playerid][selected_item_static_id];
2120 ItemInfo [created_object][item_ammo] = -1;
2121 ItemInfo [created_object][item_unique_id] = -1;
2122
2123 if (ItemInfo [created_object][item_type] == 1)
2124 {
2125 ItemInfo [created_object][item_ammo] = FoodItems [ItemInfo [created_object][item_static_id]][item_ammo];
2126 }
2127
2128 if (ItemInfo [created_object][item_type] == 2)
2129 {
2130 ItemInfo [created_object][item_ammo] = MedicalItems [ItemInfo [created_object][item_static_id]][item_ammo];
2131 }
2132
2133 if (ItemInfo [created_object][item_type] == 6)
2134 {
2135 ItemInfo [created_object][item_ammo] = BigItems [ItemInfo [created_object][item_static_id]][item_ammo];
2136 }
2137
2138 if (ItemInfo [created_object][item_type] == 14)
2139 {
2140 ItemInfo [created_object][item_ammo] = floatround (ArmourItems [ItemInfo [created_object][item_static_id]][armour], floatround_round);
2141 }
2142
2143 PlayerInfo [playerid][selected_item_type] = 0;
2144 PlayerInfo [playerid][selected_item_amount] = 0;
2145
2146 PlayerInfo [playerid][selected_item_model_id] = -1;
2147 PlayerInfo [playerid][selected_item_static_id] = -1;
2148
2149 EditObject (playerid, created_object);
2150
2151 }
2152 case CAR_REPAIR_DIALOG_ID:
2153 {
2154 if(response)
2155 {
2156 new s_type, s_id, s_amount, s_ammo, s_state,
2157 vehicleid;
2158
2159 vehicleid = PlayerInfo [playerid][selected_vehicle];
2160
2161 switch (listitem)
2162 {
2163 case 0:
2164 {
2165 if (VehicleInfo [vehicleid][engine_usage] < 300) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"No problem found in the vehicle's engine. ");
2166 if (!sscanf (PlayerInfo [playerid][selected_inventory_slot], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
2167 {
2168 s_ammo -= MedicalItems [s_id][ammo_per_use];
2169
2170 SetVehicleHealth (vehicleid, 1000);
2171
2172 VehicleInfo [vehicleid][engine_usage] = 0;
2173
2174 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You successfully fixed the vehicle's engine using the tool kit. ");
2175
2176 RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]);
2177
2178 }
2179 }
2180 case 1:
2181 {
2182 if (VehicleInfo [vehicleid][wheel_usage] < 200) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"There are no damaged tires of the vehicle found. ");
2183
2184 new required_tires, tires_found;
2185
2186 switch (VehicleInfo [vehicleid][vehicle_d_tires])
2187 {
2188 case 0: required_tires = 0;
2189 case 1: required_tires = 1;
2190 case 2: required_tires = 1;
2191 case 3: required_tires = 2;
2192 case 4: required_tires = 1;
2193 case 5: required_tires = 2;
2194 case 6: required_tires = 2;
2195 case 7: required_tires = 3;
2196 case 8: required_tires = 1;
2197 case 9: required_tires = 2;
2198 case 10: required_tires = 2;
2199 case 11: required_tires = 3;
2200 case 12: required_tires = 2;
2201 case 13: required_tires = 3;
2202 case 14: required_tires = 3;
2203 case 15: required_tires = 4;
2204 }
2205
2206 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2207 {
2208 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
2209 {
2210 if (s_type == 4)
2211 {
2212 if (s_id == 9)
2213 {
2214 if (s_amount >= required_tires)
2215 {
2216 tires_found = 1;
2217 VehicleInfo [vehicleid][vehicle_d_tires] = 0;
2218 UpdateVehicleDamageStatus (vehicleid, VehicleInfo [vehicleid][vehicle_d_panels], VehicleInfo [vehicleid][vehicle_d_doors], VehicleInfo [vehicleid][vehicle_d_lights], VehicleInfo [vehicleid][vehicle_d_tires]);
2219 RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]);
2220 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You successfully repaired the damaged vehicle tire(s). ");
2221 break;
2222 }
2223 }
2224 }
2225 }
2226 }
2227
2228 if (tires_found == 0)
2229 {
2230 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You don't have enough tires. ");
2231 }
2232
2233 }
2234 }
2235 }
2236 }
2237 case PLAYER_INVENTORY_DIALOG_ID_1:
2238 {
2239 if (response)
2240 {
2241 if (listitem == PlayerInfo [playerid][slots_used]) return 0;
2242 if (listitem == (PlayerInfo [playerid][slots_used] + 1)) return ShowPlayerDialog (playerid, EQUIPPED_ITEMS_DIALOG_ID_1, DIALOG_STYLE_LIST, ""SERVER_TAG" - Equipped Items", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Equipped Weapons", "Select", "Back");
2243
2244 PlayerInfo [playerid][selected_inventory_slot] = listitem;
2245 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Inventory Item", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Use\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Equip/Unequip\n"COLOR_MAIN_HEX"3. "COLOR_WHITE"Drop\n"COLOR_MAIN_HEX"4. "COLOR_WHITE"Move UP\n"COLOR_MAIN_HEX"5. "COLOR_WHITE"Move DOWN", "Select", "Back");
2246 }
2247 }
2248 case PLAYER_INVENTORY_DIALOG_ID_2:
2249 {
2250 if (!response)
2251 {
2252 cmd_inv (playerid, "");
2253 return 0;
2254 }
2255 if (response)
2256 {
2257 new type, id, amount, ammo, status;
2258 sscanf (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], "iiiii", type, id, amount, ammo, status);
2259
2260 if (listitem == 0)
2261 {
2262 if (type == 1)
2263 {
2264
2265 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2266 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2267
2268 new i_type, i_id, i_amount, i_ammo, i_state,
2269 has_opener;
2270
2271 if (id == 9 || id == 10)
2272 {
2273 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2274 {
2275 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", i_type, i_id, i_amount, i_ammo, i_state))
2276 {
2277 if (i_type == 4 && i_id == 3)
2278 {
2279 has_opener = 1;
2280 }
2281 }
2282 }
2283
2284 if (has_opener == 0)
2285 {
2286 SendClientMessage (playerid, COLOR_MAIN, "[INFO] You need a can opener to use this item. ");
2287 return 0;
2288 }
2289 }
2290
2291 if (FoodItems [id][hunger] > FoodItems [id][thirst])
2292 {
2293 if ((FoodItems [id][hunger] + PlayerInfo [playerid][hunger]) > 100.0)
2294 {
2295 new string [200];
2296 format (string, sizeof (string), "[INFO] %sYou can use this item if your hunger level is lower than %d. ", COLOR_WHITE, floatround(100.0 - FoodItems [id][hunger], floatround_round));
2297 SendClientMessage (playerid, COLOR_MAIN, string);
2298 return 0;
2299 }
2300 }
2301 else
2302 {
2303 if ((FoodItems [id][thirst] + PlayerInfo [playerid][thirst]) > 100.0)
2304 {
2305 new string [200];
2306 format (string, sizeof (string), "[INFO] %sYou can use this item if your hydration level is lower than %d. ", COLOR_WHITE, floatround(100.0 - FoodItems [id][thirst], floatround_round));
2307 SendClientMessage (playerid, COLOR_MAIN, string);
2308 return 0;
2309 }
2310 }
2311
2312 PlayerInfo [playerid][hunger] = (PlayerInfo [playerid][hunger] + FoodItems [id][hunger]);
2313 PlayerInfo [playerid][thirst] = (PlayerInfo [playerid][thirst] + FoodItems [id][thirst]);
2314
2315 UpdatePlayerBars (playerid);
2316
2317 if (FoodItems [id][item_ammo] != -1)
2318 {
2319
2320 ammo -= FoodItems [id][ammo_per_use];
2321
2322 if (ammo <= 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
2323 else
2324 {
2325 new item_data [124];
2326 format (item_data, sizeof (item_data), "%d %d %d %d -1", type, id, amount, ammo);
2327 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "%s", item_data);
2328 }
2329 }
2330 else
2331 {
2332 amount--;
2333
2334 if (amount <= 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
2335 else
2336 {
2337 new item_data [124];
2338 format (item_data, sizeof (item_data), "%d %d %d %d -1", type, id, amount, ammo);
2339 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "%s", item_data);
2340 }
2341 }
2342
2343 }
2344 else if (type == 2)
2345 {
2346
2347 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2348 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2349
2350
2351 if (id == 1)
2352 {
2353 if (IsPlayerNearAnyVehicle (playerid) == -1) return SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You are not near any vehicle. ");
2354
2355 PlayerInfo [playerid][selected_vehicle] = IsPlayerNearAnyVehicle (playerid);
2356 ShowPlayerDialog (playerid, CAR_REPAIR_DIALOG_ID, DIALOG_STYLE_LIST, ""COLOR_WHITE"Car Repair Kit", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Repair Engine\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Repair tires", "Select", "Cancel");
2357
2358 return 0;
2359 }
2360
2361 if (id == 7)
2362 {
2363 if (IsPlayerNearAnyVehicle (playerid) == -1) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not near any vehicle. ");
2364
2365 new vehicleid = IsPlayerNearAnyVehicle (playerid);
2366
2367 if (VehicleInfo [vehicleid][vehicle_fuel] > 80.0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You can use this item if the vehicle's fuel is less than 80%. ");
2368
2369
2370 VehicleInfo [vehicleid][vehicle_fuel] += 20.0;
2371
2372 ammo -= MedicalItems [id][ammo_per_use];
2373
2374 if (ammo <= 0.0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
2375 else
2376 {
2377 new item_data [124];
2378 format (item_data, sizeof (item_data), "%d %d %d %d -1", type, id, amount, ammo);
2379 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "%s", item_data);
2380 }
2381
2382 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Vehicle Refueled. ");
2383
2384 return 0;
2385 }
2386
2387 new Float: hp;
2388 GetPlayerHealth (playerid, hp);
2389
2390 SetPlayerHealth (playerid, hp + MedicalItems [id][healing]);
2391
2392 if (MedicalItems [id][item_ammo] != -1)
2393 {
2394
2395 ammo -= MedicalItems [id][ammo_per_use];
2396
2397 if (ammo <= 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
2398 else
2399 {
2400 new item_data [124];
2401 format (item_data, sizeof (item_data), "%d %d %d %d -1", type, id, amount, ammo);
2402 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "%s", item_data);
2403 }
2404 }
2405 else
2406 {
2407 amount--;
2408
2409 if (amount <= 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
2410 else
2411 {
2412 new item_data [124];
2413 format (item_data, sizeof (item_data), "%d %d %d %d -1", type, id, amount, ammo);
2414 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "%s", item_data);
2415 }
2416 }
2417
2418 }
2419 else if (type == 3)
2420 {
2421 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2422 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2423 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_SMOKE_CIGGY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You need to (/stopsmoking) first in order to do other tasks. ");
2424
2425 if (PlayerInfo [playerid][player_action] == 2) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot cook and craft at the same time. ");
2426
2427 new near_campfire,
2428
2429 campfire_id,
2430
2431 Float: x, Float: y, Float: z;
2432
2433 for (new i = 0; i < MAX_OBJECTS; i++)
2434 {
2435 if (ItemInfo [i][item_type] == 6 && ItemInfo[i][item_static_id] == 0)
2436 {
2437 if (ItemInfo [i][item_attached] != -1)
2438 {
2439 GetObjectPos (i, x, y, z);
2440
2441 if (IsPlayerInRangeOfPoint (playerid, 1.5, x, y, z))
2442 {
2443 near_campfire = 1;
2444 campfire_id = i;
2445 }
2446 }
2447 }
2448 }
2449
2450 if (near_campfire == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not near any burning campfire. ");
2451
2452 new s_type, s_id, s_amount, s_ammo, s_state,
2453
2454 has_pan;
2455
2456 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2457 {
2458 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
2459 {
2460 if (s_type == 2 && s_id == 13)
2461 {
2462 has_pan = 1;
2463 }
2464 }
2465 }
2466
2467 if (has_pan == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You do not have a pan to cook. ");
2468
2469 switch (PlayerInfo [playerid][cooking])
2470 {
2471 case 1: PlayerInfo [playerid][cooking_time] = 60;
2472 case 2: PlayerInfo [playerid][cooking_time] = 58;
2473 case 3: PlayerInfo [playerid][cooking_time] = 56;
2474 case 4: PlayerInfo [playerid][cooking_time] = 54;
2475 case 5: PlayerInfo [playerid][cooking_time] = 52;
2476 case 6: PlayerInfo [playerid][cooking_time] = 50;
2477 case 7: PlayerInfo [playerid][cooking_time] = 48;
2478 case 8: PlayerInfo [playerid][cooking_time] = 46;
2479 case 9: PlayerInfo [playerid][cooking_time] = 44;
2480 case 10: PlayerInfo [playerid][cooking_time] = 42;
2481 }
2482
2483 PlayerInfo [playerid][player_action] = 1;
2484
2485 PlayerInfo [playerid][cooked] = 0;
2486
2487 ShowCookingBar (playerid);
2488
2489 PlayerInfo [playerid][cooking_timer] = SetTimerEx ("OnPlayerCookFood", 1000, true, "iii", playerid, id, campfire_id);
2490
2491 }
2492 else if (type == 5)
2493 {
2494 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2495 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2496
2497 switch (id)
2498 {
2499 case 0: ShowPlayerDialog (playerid, CUFF_PLAYER_DIALOG_ID, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Cuff Player", "Enter the id of player you want to cuff: ", "Ok", "Cancel");
2500 case 1: ShowPlayerDialog (playerid, UNCUFF_PLAYER_DIALOG_ID_1, DIALOG_STYLE_LIST, ""SERVER_TAG" - Uncuff Player", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Uncuff yourself\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Uncuff another player", "Select", "Cancel");
2501
2502 default:
2503 {
2504 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This item cannot be used. ");
2505 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Inventory Item", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Use\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Equip/Unequip\n"COLOR_MAIN_HEX"3. "COLOR_WHITE"Drop\n"COLOR_MAIN_HEX"4. "COLOR_WHITE"Move UP\n"COLOR_MAIN_HEX"5. "COLOR_WHITE"Move DOWN", "Select", "Back");
2506 }
2507 }
2508 }
2509 else if (type == 6)
2510 {
2511 new Float: x, Float: y, Float: z,
2512
2513 created_item,
2514 created_item_2,
2515
2516 items;
2517
2518 GetPlayerPos (playerid, x, y, z);
2519 MapAndreas_FindZ_For2DCoord (x, y, z);
2520
2521 for (new i = 0; i < MAX_OBJECTS; i++)
2522 {
2523 if (ItemInfo [i][item_type] >= 1)
2524 {
2525 items++;
2526 }
2527 }
2528
2529 created_item = CreateObject (BigItems [id][model_id_1], x, y, z, 0.0, 0.0, 0.0);
2530 ItemInfo [created_item][item_model_id] = BigItems [id][model_id_1];
2531
2532 if (BigItems [id][model_id_2] != -1)
2533 {
2534 created_item_2 = CreateObject (BigItems [id][model_id_2], x, y, z -0.35, 0.0, 0.0, 0.0);
2535 ItemInfo [created_item_2][item_model_id] = BigItems [id][model_id_2];
2536 }
2537
2538 AttachObjectToObject (created_item_2, created_item, 0.0, 0.0, -1.45, 0.0, 0.0, 0.0, 1);
2539
2540 ammo--;
2541
2542 RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]);
2543
2544 ItemInfo [created_item][item_static_id] = id;
2545 ItemInfo [created_item][item_ammo] = ammo;
2546
2547 if (ammo == 0)
2548 {
2549 ItemInfo [created_item][item_type] = 0;
2550 }
2551 else
2552 {
2553 ItemInfo [created_item][item_type] = type;
2554 }
2555
2556 ItemInfo [created_item][item_id] = items;
2557 ItemInfo [created_item][item_amount] = amount;
2558 ItemInfo [created_item][item_attached] = created_item_2;
2559 ItemInfo [created_item][item_timer] = SetTimerEx ("ExtinguishFire", 5 * 60 * 1000, false, "i", created_item);
2560
2561 RemovePlayerAttachedObject (playerid, 2);
2562 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_NONE);
2563
2564 EditObject (playerid, created_item);
2565
2566 }
2567 else if (type == 7)
2568 {
2569 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2570 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2571
2572 switch (id)
2573 {
2574 case 0:
2575 {
2576 new string [250];
2577 format (string, sizeof (string), "%s- Name: %s\n\n%s- Age: {FFFFFF}%d\n\n%s- Date of issue: {FFFFFF}%s", COLOR_MAIN_HEX, "Player Name", COLOR_MAIN_HEX, 24, COLOR_MAIN_HEX, "5/20/19");
2578 ShowPlayerDialog (playerid, DRIVING_LICENSE_DIALOG_ID, DIALOG_STYLE_MSGBOX, ""SERVER_TAG" - Driving License", string, "Ok", "");
2579 }
2580 case 1:
2581 {
2582 new query [250];
2583 mysql_format (mysql, query, sizeof (query), "SELECT * FROM `players` WHERE `ACCOUNT_ID` = %d", ammo);
2584 mysql_tquery (mysql, query, "OnPlayerCheckDrivingLicense", "i", playerid);
2585 }
2586 case 2:
2587 {
2588 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This item cannot be used. ");
2589 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Inventory Item", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Use\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Equip/Unequip\n"COLOR_MAIN_HEX"3. "COLOR_WHITE"Drop\n"COLOR_MAIN_HEX"4. "COLOR_WHITE"Move UP\n"COLOR_MAIN_HEX"5. "COLOR_WHITE"Move DOWN", "Select", "Back");
2590 }
2591 case 3:
2592 {
2593 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_SMOKE_CIGGY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are already smoking a ciggarette. ");
2594
2595
2596 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_SMOKE_CIGGY);
2597 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You lit up the cigarette to smoke it. ");
2598 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Use (/stopsmoking) to stop. ");
2599
2600 amount--;
2601
2602 if (amount >= 1) { format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "2 %d %d -1 -1", id ); }
2603 else if (amount == 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
2604 }
2605 case 8:
2606 {
2607 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You opened a box of cigarrete. ");
2608
2609 new s_type, s_id, s_amount, s_ammo, s_state,
2610 slot;
2611
2612 slot = -1;
2613
2614 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2615 {
2616 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
2617 {
2618 if (s_type == 7 && s_id == 3)
2619 {
2620 slot = i;
2621 }
2622 }
2623 }
2624
2625 if (slot == -1) { slot = PlayerInfo [playerid][selected_inventory_slot]; }
2626
2627 format (PlayerInventory [playerid][slot][item], 124, "7 3 20 -1 -2");
2628 }
2629 }
2630 }
2631 else if (type == 4 || type == 8 || type == 9 || type == 10 || type == 11 || type == 12 || type == 13 || type == 14)
2632 {
2633 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This item cannot be used. ");
2634 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Inventory Item", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Use\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Equip/Unequip\n"COLOR_MAIN_HEX"3. "COLOR_WHITE"Drop\n"COLOR_MAIN_HEX"4. "COLOR_WHITE"Move UP\n"COLOR_MAIN_HEX"5. "COLOR_WHITE"Move DOWN", "Select", "Back");
2635 return 0;
2636 }
2637 }
2638 else if (listitem == 1)
2639 {
2640 if (type == 1 || type == 2 || type == 3 || type == 4 || type == 5 || type == 6 || type == 7 || type == 10)
2641 {
2642 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This item cannot be equipped. ");
2643 return 0;
2644 }
2645 else if (type == 8)
2646 {
2647 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2648 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2649
2650 new s_type, s_id, s_amount, s_ammo, s_status,
2651 kill_process,
2652 found;
2653
2654 if (status == -3)
2655 {
2656
2657 new weaponid, slot;
2658
2659 switch (type)
2660 {
2661 case 3: weaponid = WeaponItems [id][weapon_id];
2662 case 4: weaponid = MeleeWeaponItems [id][weapon_id];
2663 }
2664
2665 for (new i = 0; i < MAX_WEAPON_SLOTS; i++)
2666 {
2667 if (PlayerWeaponInfo [playerid][i][slot_used] == 1)
2668 {
2669 if (PlayerWeaponInfo [playerid][i][weapon_id] == weaponid)
2670 {
2671 slot = i;
2672 }
2673 }
2674 }
2675
2676 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "8 %d 1 -1 -2", PlayerWeaponInfo [playerid][slot][weapon_static_id]);
2677
2678 new a_type, a_id, a_amount, a_ammo, a_status;
2679
2680 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2681 {
2682 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", a_type, a_id, a_amount, a_ammo, a_status))
2683 {
2684 if (a_type == 10 && a_id == WeaponItems [PlayerWeaponInfo [playerid][slot][weapon_static_id]][weapon_bullet_type] && status != -2)
2685 {
2686 format (PlayerInventory [playerid][i][item], 124, "10 %d %d -1 -2",
2687 WeaponItems [PlayerWeaponInfo [playerid][slot][weapon_static_id]][weapon_bullet_type],
2688 PlayerWeaponInfo [playerid][slot][weapon_ammo]);
2689 }
2690 else continue;
2691 }
2692
2693 }
2694
2695 RemovePlayerWeapon (playerid, PlayerWeaponInfo [playerid][slot][weapon_id]);
2696
2697 PlayerWeaponInfo [playerid][slot][slot_used] = 0;
2698 PlayerWeaponInfo [playerid][slot][weapon_id] = 0;
2699 PlayerWeaponInfo [playerid][slot][weapon_model_id] = 0;
2700 PlayerWeaponInfo [playerid][slot][weapon_static_id] = -1;
2701 PlayerWeaponInfo [playerid][slot][weapon_type] = 0;
2702 PlayerWeaponInfo [playerid][slot][weapon_damage] = 0.0;
2703 PlayerWeaponInfo [playerid][slot][weapon_ammo] = 0;
2704
2705 }
2706 else if (status == -2)
2707 {
2708
2709 for (new i = 0; i < MAX_WEAPON_SLOTS; i++)
2710 {
2711 if (PlayerWeaponInfo [playerid][i][weapon_id] == WeaponItems [id][weapon_id])
2712 {
2713 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot equip two weapons of same type. ");
2714 kill_process = 1;
2715 break;
2716 }
2717 }
2718
2719 if (kill_process == 1) return 0;
2720
2721 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2722 {
2723 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
2724 {
2725 if (s_type == 10)
2726 {
2727 if (s_id == WeaponItems [id][weapon_bullet_type])
2728 {
2729 found = 1;
2730
2731 for (new n = 0; n < MAX_WEAPON_SLOTS; n++)
2732 {
2733 if (PlayerWeaponInfo [playerid][n][slot_used] == 0)
2734 {
2735
2736 PlayerWeaponInfo [playerid][n][slot_used] = 1;
2737 PlayerWeaponInfo [playerid][n][weapon_id] = WeaponItems [id][weapon_id];
2738 PlayerWeaponInfo [playerid][n][weapon_model_id] = WeaponItems [id][weapon_model_id];
2739 PlayerWeaponInfo [playerid][n][weapon_static_id] = WeaponItems [id][item_static_id];
2740 PlayerWeaponInfo [playerid][n][weapon_damage] = WeaponItems [id][weapon_damage];
2741 PlayerWeaponInfo [playerid][n][weapon_ammo] = s_amount;
2742 PlayerWeaponInfo [playerid][n][weapon_type] = GetWeaponType (PlayerWeaponInfo [playerid][n][weapon_id]);
2743
2744 GivePlayerWeapon (playerid, PlayerWeaponInfo [playerid][n][weapon_id], PlayerWeaponInfo [playerid][n][weapon_ammo]);
2745
2746 format (PlayerInventory [playerid][i][item], 124, "10 %d -1 -1 %d", s_id, n);
2747 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "8 %d 1 -1 -3", id);
2748
2749 new string [250];
2750 format (string, sizeof (string), "[INFO] %sYou have equipped %s with %d bullets", COLOR_WHITE, WeaponItems [id][name], PlayerWeaponInfo [playerid][n][weapon_ammo]);
2751 SendClientMessage (playerid, COLOR_MAIN, string);
2752 break;
2753 }
2754
2755 if (n == (MAX_WEAPON_SLOTS - 1))
2756 {
2757 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE" No space to equip more weapons. ");
2758 }
2759 }
2760 break;
2761 }
2762 }
2763 }
2764 }
2765
2766 if (found == 0)
2767 {
2768 new error_message [175];
2769
2770 format (error_message, sizeof (error_message), "[ERROR] %sYou do not have %s for this weapon. ", COLOR_WHITE, AmmoItems [WeaponItems [id][weapon_bullet_type]][name]);
2771 SendClientMessage (playerid, COLOR_MAIN, error_message);
2772 }
2773 }
2774 }
2775 else if (type == 9)
2776 {
2777
2778 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2779 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2780
2781 for (new i = 0; i < MAX_WEAPON_SLOTS; i++)
2782 {
2783 if (!GetWeaponType (PlayerWeaponInfo [playerid][i][weapon_id]))
2784 {
2785 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot equip two or more weapons of same type.");
2786 return 0;
2787 }
2788 }
2789
2790 if (status == -3)
2791 {
2792 new weaponid, slot;
2793
2794 weaponid = MeleeWeaponItems [id][weapon_id];
2795
2796 for (new i = 0; i < MAX_WEAPON_SLOTS; i++)
2797 {
2798 if (PlayerWeaponInfo [playerid][i][weapon_id] == weaponid)
2799 {
2800 slot = i;
2801 }
2802 }
2803
2804 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "9 %d 1 -1 -2", PlayerWeaponInfo [playerid][slot][weapon_static_id]);
2805
2806 RemovePlayerWeapon (playerid, PlayerWeaponInfo [playerid][slot][weapon_id]);
2807
2808 PlayerWeaponInfo [playerid][slot][slot_used] = 0;
2809 PlayerWeaponInfo [playerid][slot][weapon_id] = 0;
2810 PlayerWeaponInfo [playerid][slot][weapon_model_id] = 0;
2811 PlayerWeaponInfo [playerid][slot][weapon_static_id] = -1;
2812 PlayerWeaponInfo [playerid][slot][weapon_type] = 0;
2813 PlayerWeaponInfo [playerid][slot][weapon_damage] = 0.0;
2814 PlayerWeaponInfo [playerid][slot][weapon_ammo] = 0;
2815
2816 }
2817 else if (status == -2)
2818 {
2819 for (new n = 0; n < MAX_WEAPON_SLOTS; n++)
2820 {
2821 if (PlayerWeaponInfo [playerid][n][slot_used] == 0)
2822 {
2823 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "9 %d 1 -1 -3", id);
2824
2825 PlayerWeaponInfo [playerid][n][slot_used] = 1;
2826 PlayerWeaponInfo [playerid][n][weapon_id] = MeleeWeaponItems [id][weapon_id];
2827 PlayerWeaponInfo [playerid][n][weapon_model_id] = MeleeWeaponItems [id][weapon_model_id];
2828 PlayerWeaponInfo [playerid][n][weapon_static_id] = MeleeWeaponItems [id][item_static_id];
2829 PlayerWeaponInfo [playerid][n][weapon_damage] = MeleeWeaponItems [id][weapon_damage];
2830 PlayerWeaponInfo [playerid][n][weapon_ammo] = 1;
2831 PlayerWeaponInfo [playerid][n][weapon_type] = 0;
2832
2833 GivePlayerWeapon (playerid, MeleeWeaponItems [id][weapon_id], 1);
2834
2835 new string [124];
2836 format (string, sizeof (string), "[INFO] %sYou equipped a/an %s%s", COLOR_WHITE, COLOR_MAIN_HEX, MeleeWeaponItems [id][name]);
2837 SendClientMessage (playerid, COLOR_MAIN, string);
2838 break;
2839 }
2840
2841 if (n == MAX_WEAPON_SLOTS)
2842 {
2843 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"No space to equip more weapons. ");
2844 }
2845 }
2846 }
2847 }
2848 else if (type == 11)
2849 {
2850 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2851 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2852
2853 if (status == -3)
2854 {
2855 new string [250];
2856
2857 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "11 %d 1 -1 -2", id);
2858 PlayerInfo [playerid][head_protection] = 0;
2859
2860 format (string, sizeof (string), "[INFO] %sYou have unequipped %s", COLOR_WHITE, HeadWearableItems [id][name]);
2861 SendClientMessage (playerid, COLOR_MAIN, string);
2862
2863 RemovePlayerAttachedObject (playerid, 0);
2864
2865 }
2866 else if (status == -2)
2867 {
2868
2869 if (PlayerInfo [playerid][head_protection] >= 1)
2870 {
2871 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are already wearing a helmet/hat. ");
2872 return 0;
2873 }
2874
2875 new string [250];
2876
2877 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "11 %d 1 -1 -3", id);
2878 PlayerInfo [playerid][head_protection] += HeadWearableItems [id][head_hits];
2879
2880 format (string, sizeof (string), "[INFO] %sYou have equipped %s", COLOR_WHITE, HeadWearableItems [id][name]);
2881 SendClientMessage (playerid, COLOR_MAIN, string);
2882
2883 SetPlayerAttachedObject (playerid, 0, HeadWearableItems [id][model_id], 2, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.200000, 1.200000, 1.200000);
2884
2885 }
2886 }
2887 else if (type == 12)
2888 {
2889 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2890 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2891
2892 if (status == -3)
2893 {
2894 if ((PlayerInfo [playerid][inventory_virtual_slots] - BodyWearableItems [id][wearable_slots]) < PlayerInfo [playerid][slots_used])
2895 {
2896 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This cloth cannot be un equipped while its containing other items. ");
2897 return 0;
2898 }
2899
2900 new string [250];
2901
2902 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "12 %d 1 -1 -2", id);
2903 PlayerInfo [playerid][inventory_virtual_slots] -= BodyWearableItems [id][wearable_slots];
2904
2905 format (string, sizeof (string), "[INFO] %sYou have unequipped %s", COLOR_WHITE, BodyWearableItems [id][wearable_name]);
2906 SendClientMessage (playerid, COLOR_MAIN, string);
2907
2908 }
2909 else if (status == -2)
2910 {
2911 new s_type, s_id, s_amount, s_ammo, s_status;
2912
2913 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2914 {
2915 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
2916 {
2917 if (s_type == 7 && s_id == id && s_status == -3)
2918 {
2919 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot equip two items of same type. ");
2920 return 0;
2921 }
2922 }
2923 }
2924
2925 new string [250];
2926
2927 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "12 %d 1 -1 -3", id);
2928 PlayerInfo [playerid][inventory_virtual_slots] += BodyWearableItems [id][wearable_slots];
2929
2930 format (string, sizeof (string), "[INFO] %sYou have equipped %s", COLOR_WHITE, BodyWearableItems [id][wearable_name]);
2931 SendClientMessage (playerid, COLOR_MAIN, string);
2932 }
2933
2934 }
2935 else if (type == 13)
2936 {
2937 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2938 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2939
2940 if (status == -3)
2941 {
2942
2943 if (PlayerInfo [playerid][slots_used] > (PlayerInfo [playerid][inventory_virtual_slots] - BackpackItems [id][slots]))
2944 {
2945 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This backpack cannot be un-equipped while its containing other items. ");
2946 return 0;
2947 }
2948
2949 new string [250];
2950
2951 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "13 %d 1 -1 -2", id);
2952 PlayerInfo [playerid][inventory_virtual_slots] -= BackpackItems [id][slots];
2953
2954 format (string, sizeof (string), "[INFO] %sYou have unequipped %s", COLOR_WHITE, BackpackItems [id][name]);
2955 SendClientMessage (playerid, COLOR_MAIN, string);
2956
2957 RemovePlayerAttachedObject (playerid, 1);
2958
2959 }
2960 else if (status == -2)
2961 {
2962 new s_type, s_id, s_amount, s_ammo, s_status;
2963
2964 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
2965 {
2966 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
2967 {
2968 if (s_type == 13 && s_status == -3)
2969 {
2970 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are already wearing a bag. ");
2971 return 0;
2972 }
2973 }
2974 }
2975
2976 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "13 %d 1 -1 -3", id);
2977
2978 PlayerInfo [playerid][inventory_virtual_slots] += BackpackItems [id][slots];
2979
2980 new string [250];
2981
2982 format (string, sizeof (string), "[INFO] %sYou have equipped %s", COLOR_WHITE, BackpackItems [id][name]);
2983 SendClientMessage (playerid, COLOR_MAIN, string);
2984
2985 switch (BackpackItems [id][model_id])
2986 {
2987 case -2025: SetPlayerAttachedObject (playerid, 1, BackpackItems [id][model_id], 1, 0.0, -0.1, 0.0, 0.0, 90.0, 0.0);
2988 default: SetPlayerAttachedObject (playerid, 1, BackpackItems [id][model_id], 1, -0.164999, -0.153999, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000);
2989 }
2990 }
2991 }
2992 else if (type == 14)
2993 {
2994 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while handcuffed. ");
2995 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot use items while carrying something. ");
2996
2997 if (status == -3)
2998 {
2999 new string [150],
3000 Float: a;
3001
3002 GetPlayerArmour (playerid, a);
3003
3004 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "14 %d 1 %d -2", id, floatround (a, floatround_round));
3005
3006 format (string, sizeof (string), "[INFO] %sYou have unequipped %s. ", COLOR_WHITE, ArmourItems [id][name]);
3007 SendClientMessage (playerid, COLOR_MAIN, string);
3008
3009 SetPlayerArmour (playerid, 0.0);
3010 }
3011 else if (status == -2)
3012 {
3013 new Float: a;
3014 GetPlayerArmour (playerid, a);
3015
3016 if (a > 0.0) return SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You cannot equip two armour jackers at once. ");
3017
3018 new string [150];
3019
3020 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "14 %d 1 -1 -3", id);
3021
3022 format (string, sizeof (string), "[INFO] %sYou have equipped %s. ", COLOR_WHITE, ArmourItems [id][name]);
3023 SendClientMessage (playerid, COLOR_MAIN, string);
3024
3025 SetPlayerArmour (playerid, ArmourItems [id][armour]);
3026 }
3027 }
3028
3029 }
3030 else if (listitem == 2)
3031 {
3032
3033 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot pickup items while handcuffed. ");
3034
3035 if (status == -3 || status >= 0)
3036 {
3037 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The item is equipped, it cannot be dropped. ");
3038 return 0;
3039 }
3040
3041 new Float: x, Float: y, Float: z,
3042 created_item,
3043 items;
3044
3045 GetPlayerPos (playerid, x, y, z);
3046
3047 MapAndreas_FindZ_For2DCoord (x, y, z);
3048
3049 for (new i = 0; i < MAX_OBJECTS; i++)
3050 {
3051 if (ItemInfo [i][item_type] >= 1)
3052 {
3053 items++;
3054 }
3055 }
3056
3057 if (type == 1)
3058 {
3059 created_item = CreateObject (FoodItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3060 ItemInfo [created_item][item_model_id] = FoodItems [id][model_id];
3061
3062 }
3063 else if (type == 2)
3064 {
3065 created_item = CreateObject (MedicalItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3066 ItemInfo [created_item][item_model_id] = MedicalItems [id][model_id];
3067
3068 }
3069 else if (type == 3)
3070 {
3071 created_item = CreateObject (CookableItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3072 ItemInfo [created_item][item_model_id] = CookableItems [id][model_id];
3073
3074 }
3075 else if (type == 4)
3076 {
3077 created_item = CreateObject (ResourceItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3078 ItemInfo [created_item][item_model_id] = ResourceItems [id][model_id];
3079
3080 }
3081 else if (type == 5)
3082 {
3083 created_item = CreateObject (ToolItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3084 ItemInfo [created_item][item_model_id] = ToolItems [id][model_id];
3085 }
3086 else if (type == 6)
3087 {
3088 created_item = CreateObject (BigItems [id][model_id_1], x, y, z, 0.0, 0.0, 0.0);
3089 ItemInfo [created_item][item_model_id] = BigItems [id][model_id_1];
3090
3091 PlayerInfo [playerid][carrying] = 0;
3092
3093 RemovePlayerAttachedObject (playerid, 2);
3094 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_NONE);
3095
3096 }
3097 else if (type == 7)
3098 {
3099 created_item = CreateObject (MiscItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3100 ItemInfo [created_item][item_model_id] = MiscItems [id][model_id];
3101 }
3102 else if (type == 8)
3103 {
3104 created_item = CreateObject (WeaponItems [id][weapon_model_id], x, y, z, 0.0, 0.0, 0.0);
3105 ItemInfo [created_item][item_model_id] = WeaponItems [id][weapon_model_id];
3106 }
3107 else if (type == 9)
3108 {
3109 created_item = CreateObject (MeleeWeaponItems [id][weapon_model_id], x, y, z, 0.0, 0.0, 0.0);
3110 ItemInfo [created_item][item_model_id] = MeleeWeaponItems [id][weapon_model_id];
3111 }
3112 else if (type == 10)
3113 {
3114 created_item = CreateObject (2040, x, y, z, 0.0, 0.0, 0.0);
3115 ItemInfo [created_item][item_model_id] = 2040;
3116 }
3117 else if (type == 11)
3118 {
3119 created_item = CreateObject (HeadWearableItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3120 ItemInfo [created_item][item_model_id] = HeadWearableItems [id][model_id];
3121 }
3122 else if (type == 12)
3123 {
3124 if (PlayerInfo [playerid][slots_used] >= (PlayerInfo [playerid][inventory_virtual_slots] - BodyWearableItems [id][wearable_slots]))
3125 {
3126 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This cloth contains items. It cannot be dropped. ");
3127 return 0;
3128 }
3129
3130 created_item = CreateObject (BodyWearableItems [id][wearable_model_id], x, y, z, 0.0, 0.0, 0.0);
3131 ItemInfo [created_item][item_model_id] = BodyWearableItems [id][wearable_model_id];
3132
3133 }
3134 else if (type == 13)
3135 {
3136 if (PlayerInfo [playerid][slots_used] >= (PlayerInfo [playerid][inventory_virtual_slots] - BackpackItems [id][slots]))
3137 {
3138 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The backpack contains items, you cannot drop it. ");
3139 return 0;
3140 }
3141
3142 created_item = CreateObject (BackpackItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3143 ItemInfo [created_item][item_model_id] = BackpackItems [id][model_id];
3144 }
3145 else if (type == 14)
3146 {
3147 created_item = CreateObject (ArmourItems [id][model_id], x, y, z, 0.0, 0.0, 0.0);
3148 ItemInfo [created_item][item_model_id] = ArmourItems [id][model_id];
3149 }
3150
3151
3152 RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]);
3153
3154 ItemInfo [created_item][item_static_id] = id;
3155 ItemInfo [created_item][item_ammo] = ammo;
3156 ItemInfo [created_item][item_type] = type;
3157 ItemInfo [created_item][item_id] = items;
3158 ItemInfo [created_item][item_amount] = amount;
3159
3160 EditObject (playerid, created_item);
3161
3162 }
3163 else if (listitem == 3)
3164 {
3165
3166 if (PlayerInfo [playerid][selected_inventory_slot] == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Item cannot be moved up. ");
3167
3168 new slot_item [124];
3169
3170 format (slot_item, 124, PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item]);
3171
3172 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot] - 1][item]);
3173 format (PlayerInventory [playerid][(PlayerInfo [playerid][selected_inventory_slot] - 1)][item], 124, slot_item);
3174
3175 PlayerInfo [playerid][selected_inventory_slot]--;
3176
3177 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Item moved UP. ");
3178
3179 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Inventory Item", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Use\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Equip/Unequip\n"COLOR_MAIN_HEX"3. "COLOR_WHITE"Drop\n"COLOR_MAIN_HEX"4. "COLOR_WHITE"Move UP\n"COLOR_MAIN_HEX"5. "COLOR_WHITE"Move DOWN", "Select", "Back");
3180
3181 }
3182 else if (listitem == 4)
3183 {
3184 if (PlayerInfo [playerid][selected_inventory_slot] == (PlayerInfo [playerid][slots_used] - 1)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Item cannot be moved down. ");
3185
3186 new slot_item [124];
3187
3188 format (slot_item, 124, PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item]);
3189
3190 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot] + 1][item]);
3191 format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot] + 1][item], 124, slot_item);
3192
3193 PlayerInfo [playerid][selected_inventory_slot]++;
3194
3195 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Item moved DOWN. ");
3196
3197 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Inventory Item", ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Use\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Equip/Unequip\n"COLOR_MAIN_HEX"3. "COLOR_WHITE"Drop\n"COLOR_MAIN_HEX"4. "COLOR_WHITE"Move UP\n"COLOR_MAIN_HEX"5. "COLOR_WHITE"Move DOWN", "Select", "Back");
3198
3199 }
3200 }
3201
3202 }
3203 case NEARBY_ITEMS_DIALOG_ID_1:
3204 {
3205 if (!response)
3206 {
3207 for (new i = 0; i < 64; i++) { PlayerInfo [playerid][nearby_items][i] = -1; }
3208 return 0;
3209 }
3210 else if (response)
3211 {
3212 new string [250];
3213
3214 PlayerInfo [playerid][selected_nearby_item] = PlayerInfo [playerid][nearby_items][listitem];
3215
3216 switch (ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_type])
3217 {
3218 case 1: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, FoodItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3219 case 2: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MedicalItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3220 case 3: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, CookableItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3221 case 4: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ResourceItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3222 case 5: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ToolItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3223 case 6: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BigItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3224 case 7: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MiscItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3225 case 8: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, WeaponItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3226 case 9: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MeleeWeaponItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3227 case 10: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, AmmoItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3228 case 11: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, HeadWearableItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3229 case 12: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BodyWearableItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][wearable_name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3230 case 13: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BackpackItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3231 case 14: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ArmourItems [ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][listitem]][item_amount]);
3232 }
3233
3234 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_2, DIALOG_STYLE_LIST, string, ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Pickup All\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Enter an amount", "Select", "Back");
3235 }
3236 }
3237 case NEARBY_ITEMS_DIALOG_ID_2:
3238 {
3239 if (!response)
3240 {
3241 cmd_pickup (playerid, "");
3242 return 0;
3243 }
3244 else if (response)
3245 {
3246 if (listitem == 0)
3247 {
3248 PickupItem (playerid, PlayerInfo [playerid][selected_nearby_item], -1);
3249 }
3250 else if (listitem == 1)
3251 {
3252 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_3, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Pickup", "Enter an amount: ", "Pickup", "Back");
3253 }
3254 }
3255 }
3256 case NEARBY_ITEMS_DIALOG_ID_2_PART:
3257 {
3258 if (!response)
3259 {
3260 return 0;
3261 }
3262 else if (response)
3263 {
3264 if (listitem == 0)
3265 {
3266 PickupItem (playerid, PlayerInfo [playerid][selected_nearby_item], -1);
3267 }
3268 else if (listitem == 1)
3269 {
3270 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_3, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Pickup", "Enter an amount: ", "Pickup", "Back");
3271 }
3272 }
3273 }
3274 case NEARBY_ITEMS_DIALOG_ID_3:
3275 {
3276 if (!response)
3277 {
3278 new string [250];
3279
3280 switch (ItemInfo[PlayerInfo [playerid][selected_nearby_item]][item_type])
3281 {
3282 case 1: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, FoodItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3283 case 2: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MedicalItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3284 case 3: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, CookableItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3285 case 4: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ResourceItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3286 case 5: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ToolItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3287 case 6: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BigItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3288 case 7: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MiscItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3289 case 8: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, WeaponItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3290 case 9: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MeleeWeaponItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3291 case 10: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, AmmoItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3292 case 11: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, HeadWearableItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3293 case 12: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BodyWearableItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][wearable_name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3294 case 13: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BackpackItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3295 case 14: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ArmourItems [ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount]);
3296 }
3297
3298 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_2, DIALOG_STYLE_LIST, string, ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Pickup All\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Enter an amount", "Pickup", "Back");
3299 return 0;
3300 }
3301 else if (response)
3302 {
3303 if (isnull (inputtext) || !strval (inputtext))
3304 {
3305 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_3, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Pickup", "Enter an amount: ", "Pickup", "Back");
3306 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Please enter a valid amount. ");
3307 return 0;
3308 }
3309
3310 if (strval (inputtext) > ItemInfo [PlayerInfo [playerid][selected_nearby_item]][item_amount])
3311 {
3312 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_3, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Pickup", "Enter an amount: ", "Pickup", "Back");
3313 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The amount cannot be greater than than the items present. ");
3314 return 0;
3315 }
3316
3317 PickupItem (playerid, PlayerInfo [playerid][selected_nearby_item], strval (inputtext));
3318
3319 }
3320 }
3321 case CUFF_PLAYER_DIALOG_ID:
3322 {
3323 if (isnull (inputtext) || strval (inputtext) == INVALID_PLAYER_ID || !IsPlayerConnected (strval (inputtext))) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] The specified player is not connected. ");
3324 if (GetPlayerSpecialAction(strval (inputtext)) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The player is already cuffed. ");
3325 if (strval (inputtext) == playerid) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot uncuff yourself. ");
3326
3327 new targetid,
3328 Float: x, Float: y, Float: z;
3329
3330 targetid = strval (inputtext);
3331 GetPlayerPos (playerid, x, y, z);
3332
3333 if (!IsPlayerInRangeOfPoint (targetid, 1.5, x, y, z)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The player is not near you. ");
3334
3335 if (GetPlayerSpecialAction (targetid) == SPECIAL_ACTION_CARRY)
3336 {
3337 switch (PlayerInfo [targetid][carrying])
3338 {
3339 case 1:
3340 {
3341 new created_item,
3342 items;
3343
3344 GetPlayerPos (targetid, x, y, z);
3345
3346 MapAndreas_FindZ_For2DCoord (x, y, z);
3347
3348 for (new i = 0; i < MAX_OBJECTS; i++)
3349 {
3350 if (ItemInfo [i][item_type] >= 1)
3351 {
3352 items++;
3353 }
3354 }
3355
3356 created_item = CreateObject (BigItems [0][model_id_1], x, y, z, 0.0, 0.0, 0.0);
3357 ItemInfo [created_item][item_model_id] = BigItems [0][model_id_1];
3358
3359 RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]);
3360
3361 ItemInfo [created_item][item_static_id] = 6;
3362 ItemInfo [created_item][item_ammo] = -1;
3363 ItemInfo [created_item][item_type] = 2;
3364 ItemInfo [created_item][item_id] = items;
3365 ItemInfo [created_item][item_amount] = 1;
3366
3367 PlayerInfo [targetid][carrying] = 0;
3368 }
3369 }
3370 }
3371
3372 SetPlayerSpecialAction (targetid, SPECIAL_ACTION_NONE);
3373 SetPlayerSpecialAction (targetid, SPECIAL_ACTION_CUFFED);
3374
3375 new o_type, o_id, o_amount, o_ammo, o_state;
3376
3377 if (!sscanf (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], "iiiii", o_type, o_id, o_amount, o_ammo, o_state))
3378 {
3379 o_amount--;
3380
3381 if (o_amount >= 1) { format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "2 %d %d -1 -1", o_id, o_amount); }
3382 else if (o_amount == 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
3383
3384 }
3385
3386 new string [200];
3387
3388 format (string, sizeof (string), "[INFO] {FFFFFF}You have been handcuffed by %s (%d). ", GetName (playerid), playerid);
3389 SendClientMessage (targetid, COLOR_MAIN, string);
3390
3391 format (string, sizeof (string), "[INFO] {FFFFFF}You have cuffed %s (%d). ", GetName (targetid), targetid);
3392 SendClientMessage (playerid, COLOR_MAIN, string);
3393
3394 }
3395 case UNCUFF_PLAYER_DIALOG_ID_1:
3396 {
3397 if (listitem == 0)
3398 {
3399 if (GetPlayerSpecialAction (playerid) != SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not cuffed. ");
3400
3401 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_NONE);
3402 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You used your handcuff key to uncuff yourself. ");
3403
3404 }
3405 else if (listitem == 1)
3406 {
3407 ShowPlayerDialog (playerid, UNCUFF_PLAYER_DIALOG_ID_2, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Uncuff Player", "Enter the id of player you want to uncuff: ", "Ok", "Cancel");
3408 }
3409 }
3410 case UNCUFF_PLAYER_DIALOG_ID_2:
3411 {
3412 if (isnull (inputtext) || strval (inputtext) == INVALID_PLAYER_ID || !IsPlayerConnected (strval (inputtext))) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] The specified player is not connected. ");
3413 if (GetPlayerSpecialAction (strval (inputtext)) != SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The specified player is not cuffed. ");
3414 if (strval (inputtext) == playerid) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot uncuff yourself. ");
3415
3416 new targetid,
3417 Float: x, Float: y, Float: z;
3418
3419 targetid = strval (inputtext);
3420 GetPlayerPos (playerid, x, y, z);
3421
3422 if (!IsPlayerInRangeOfPoint (targetid, 1.5, x, y, z)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The specified player is not near you. ");
3423
3424 SetPlayerSpecialAction (targetid, SPECIAL_ACTION_NONE);
3425
3426 new string [200];
3427
3428 format (string, sizeof (string), "[INFO] {FFFFFF}You have been uncuffed by %s (%d). ", GetName (playerid), playerid);
3429 SendClientMessage (targetid, COLOR_MAIN, string);
3430
3431 format (string, sizeof (string), "[INFO] {FFFFFF}You have uncuffed %s (%d), ", GetName (targetid), targetid);
3432 SendClientMessage (playerid, COLOR_MAIN, string);
3433
3434 }
3435 case LOOTING_ACTOR_DIALOG_ID_1:
3436 {
3437 if (response)
3438 {
3439 if (PlayerInfo [playerid][slots_used] == PlayerInfo [playerid][inventory_virtual_slots]) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Your inventory is full. ");
3440
3441 PlayerInfo [playerid][selected_inventory_slot] = listitem;
3442 ShowPlayerDialog (playerid, LOOTING_ACTOR_DIALOG_ID_2, DIALOG_STYLE_LIST, ""SERVER_TAG" - Loot", "1. Pickup all", "Select", "Cancel");
3443 }
3444 }
3445 case LOOTING_ACTOR_DIALOG_ID_2:
3446 {
3447 if (response)
3448 {
3449 new s_type, s_id, s_amount, s_ammo, s_state,
3450
3451 slot;
3452
3453 switch (listitem)
3454 {
3455 case 0:
3456 {
3457 sscanf (ActorInventory [PlayerInfo [playerid][selected_actor]][PlayerInfo [playerid][selected_inventory_slot]][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state);
3458
3459 if (s_ammo == -1 && s_type != 8 && s_type != 9 && s_type != 11 && s_type != 12 && s_type != 13)
3460 {
3461 new a_type, a_id, a_amount, a_ammo, a_state;
3462
3463 slot = -1;
3464
3465 for (new i = 0; i < PlayerInfo [playerid][slots_used]; i++)
3466 {
3467 if (!sscanf (PlayerInventory [playerid][i][item], "%d %d %d %d %d", a_type, a_id, a_amount, a_ammo, a_state))
3468 {
3469 if (a_type == s_type)
3470 {
3471 if (a_id == s_id)
3472 {
3473 slot = i;
3474 }
3475 }
3476
3477 }
3478 }
3479
3480 if (slot == -1) { slot = PlayerInfo [playerid][slots_used]; }
3481
3482 format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d %d", s_type, s_id, (s_amount + a_amount), s_ammo, s_state);
3483 PlayerInfo [playerid][slots_used]++;
3484 }
3485 else
3486 {
3487
3488 slot = PlayerInfo [playerid][slots_used];
3489
3490 for (new i = 0; i < s_amount; i++)
3491 {
3492 switch (s_type)
3493 {
3494 case 8, 9, 11, 12, 13, 14: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -2", s_type, s_id, s_amount, s_ammo);
3495 default: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -1", s_type, s_id, s_amount, s_ammo);
3496 }
3497
3498 PlayerInfo [playerid][slots_used]++;
3499 }
3500 }
3501
3502 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Picked up item. ");
3503 RearrangeActorInventorySlots (PlayerInfo [playerid][selected_actor], PlayerInfo [playerid][selected_inventory_slot]);
3504 }
3505 case 1:
3506 {
3507 sscanf (ActorInventory [PlayerInfo [playerid][selected_actor]][PlayerInfo [playerid][selected_inventory_slot]][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state);
3508
3509 ShowPlayerDialog (playerid, LOOTING_ACTOR_DIALOG_ID_3, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Loot", "Enter the amount you want to pickup: ", "Ok", "Cancel");
3510
3511 PlayerInfo [playerid][selected_item_type] = s_type;
3512 PlayerInfo [playerid][selected_item_static_id] = s_id;
3513 PlayerInfo [playerid][selected_item_amount] = s_amount;
3514 PlayerInfo [playerid][selected_item_ammo] = s_ammo;
3515 PlayerInfo [playerid][selected_item_state] = s_state;
3516 }
3517 }
3518 }
3519 }
3520 case LOOTING_ACTOR_DIALOG_ID_3:
3521 {
3522 if (strval (inputtext) <= 0 || strval (inputtext) > PlayerInfo [playerid][selected_item_amount]) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Invalid amount. ");
3523
3524 format (ActorInventory [PlayerInfo [playerid][selected_actor]][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "%d %d %d %d %d",
3525 PlayerInfo [playerid][selected_item_type],
3526 PlayerInfo [playerid][selected_item_static_id],
3527 PlayerInfo [playerid][selected_item_amount],
3528 PlayerInfo [playerid][selected_item_ammo],
3529 PlayerInfo [playerid][selected_item_state]);
3530
3531 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You picked up an item. ");
3532
3533 PlayerInfo [playerid][selected_inventory_slot] = -1;
3534 PlayerInfo [playerid][selected_item_type] = 0;
3535 PlayerInfo [playerid][selected_item_static_id] = -1;
3536 PlayerInfo [playerid][selected_item_amount] = -1;
3537 PlayerInfo [playerid][selected_item_ammo] = -1;
3538 PlayerInfo [playerid][selected_item_state] = -1;
3539 }
3540 case CRAFTABLE_ITEMS_DIALOG_ID:
3541 {
3542 if (response)
3543 {
3544 PlayerInfo [playerid][selected_item_static_id] = listitem;
3545
3546 new string [250];
3547
3548 for (new i = 0; i < CraftableItems [listitem][item_recipes]; i++)
3549 {
3550 format (string, sizeof (string), "%s\nMethod %d", string, (i + 1));
3551 }
3552
3553 ShowPlayerDialog (playerid, CRAFTING_RECIPE_DIALOG_ID, DIALOG_STYLE_LIST, ""SERVER_TAG" - Crafting Recipes", string, "Select", "Cancel");
3554 }
3555 }
3556 case CRAFTING_RECIPE_DIALOG_ID:
3557 {
3558 if (response)
3559 {
3560 ShowSelectedRecipe (playerid, GetSpecificRecipe (GetRecipeString (PlayerInfo [playerid][selected_item_static_id]), listitem));
3561 format (PlayerInfo [playerid][crafting_method], 144, GetSpecificRecipe (GetRecipeString (PlayerInfo [playerid][selected_item_static_id]), listitem));
3562 PlayerInfo [playerid][selected_recipe_method] = listitem;
3563 }
3564 else
3565 {
3566 PlayerInfo [playerid][selected_item_static_id] = -1;
3567 PlayerInfo [playerid][selected_item_type] = -1;
3568 }
3569 }
3570 case CRAFTING_RECIPE_DIALOG_ID_2:
3571 {
3572 if (response)
3573 {
3574 new split_recipe [5][50],
3575
3576 s_type, s_id, s_amount, s_ammo, s_state,
3577 i_type, i_id, i_amount, i_ammo, i_state,
3578
3579 can_craft;
3580
3581 strexplode (split_recipe, GetSpecificRecipe (GetRecipeString (PlayerInfo [playerid][selected_item_static_id]), PlayerInfo [playerid][selected_recipe_method]), ",");
3582
3583 for (new i = 0; i < 5; i++)
3584 {
3585 if (!sscanf (split_recipe [i], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
3586 {
3587 for (new n = 0; n < PlayerInfo [playerid][slots_used]; n++)
3588 {
3589 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", i_type, i_id, i_amount, i_ammo, i_state))
3590 {
3591 if (i_type == s_type && i_id == s_id && i_amount >= s_amount && i_ammo >= s_ammo)
3592 {
3593 can_craft = 1;
3594 }
3595 }
3596 }
3597 }
3598 }
3599
3600 if (!can_craft) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You do not have the resources to craft the item. ");
3601 else
3602 {
3603 if (PlayerInfo [playerid][player_action] == 1)
3604 {
3605 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot craft and cook at the same time. ");
3606
3607 PlayerInfo [playerid][selected_item_type] = -1;
3608 PlayerInfo [playerid][selected_item_static_id] = -1;
3609 PlayerInfo [playerid][selected_recipe_method] = -1;
3610 return 0;
3611 }
3612
3613 // Checkpoint
3614 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot craft items while being cuffed. ");
3615 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot craft items while carrying something. ");
3616
3617 switch (PlayerInfo [playerid][crafting])
3618 {
3619 case 1: PlayerInfo [playerid][crafting_time] = 56;
3620 case 2: PlayerInfo [playerid][crafting_time] = 54;
3621 case 3: PlayerInfo [playerid][crafting_time] = 52;
3622 case 4: PlayerInfo [playerid][crafting_time] = 50;
3623 case 5: PlayerInfo [playerid][crafting_time] = 48;
3624 case 6: PlayerInfo [playerid][crafting_time] = 46;
3625 case 7: PlayerInfo [playerid][crafting_time] = 44;
3626 case 8: PlayerInfo [playerid][crafting_time] = 42;
3627 case 9: PlayerInfo [playerid][crafting_time] = 40;
3628 case 10: PlayerInfo [playerid][crafting_time] = 38;
3629 }
3630
3631 PlayerInfo [playerid][crafted] = 0;
3632
3633 ShowCraftingBar (playerid);
3634 PlayerInfo [playerid][crafting_timer] = SetTimerEx ("OnPlayerCraft", 1000, true, "i", playerid);
3635
3636 }
3637 }
3638 else
3639 {
3640 PlayerInfo [playerid][selected_item_type] = -1;
3641 PlayerInfo [playerid][selected_item_static_id] = -1;
3642 PlayerInfo [playerid][selected_recipe_method] = -1;
3643 }
3644 }
3645 }
3646 return 1;
3647}
3648
3649public OnPlayerClickPlayer(playerid, clickedplayerid, source)
3650{
3651 return 1;
3652}
3653
3654public OnPlayerClickTextDraw(playerid, Text:clickedid)
3655{
3656 return 1;
3657}
3658
3659public OnPlayerRequestSpawn(playerid)
3660{
3661 SetPlayerVirtualWorld (playerid, 0);
3662
3663 if (PlayerInfo [playerid][logged_in] == 0)
3664 {
3665 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You need to login in in order to play on this server. ");
3666 ShowLoginDialog (playerid);
3667 return 0;
3668 }
3669
3670 if (PlayerInfo [playerid][initiated] == 0)
3671 {
3672 TogglePlayerControllable (playerid, false);
3673 // ShowPlayerDialog (playerid, SETUP_DIALOG_ID_1, DIALOG_STYLE_MSGBOX, ""SERVER_TAG" - Intro", "Welcome to the "SERVER_NAME" server.\n\nThe main aim of this server is to survive. Find resources, craft items,\nbuild a shelter, make friends and enemies and explore the world together with endless possibilities.", "Next", "");
3674 ShowPlayerDialog (playerid, SETUP_DIALOG_ID_2, DIALOG_STYLE_INPUT, ""SERVER_TAG" - Age", "Enter your age:", "Next", "");
3675 return 0;
3676 }
3677 return 1;
3678}
3679
3680public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
3681{
3682
3683 if (ItemInfo [objectid][item_type] == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This object cannot be picked up. ");
3684 if (PlayerInfo [playerid][slots_used] >= PlayerInfo [playerid][inventory_virtual_slots]) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You inventory is full. ");
3685
3686 CancelEdit (playerid);
3687
3688 new string [250];
3689
3690 PlayerInfo [playerid][selected_nearby_item] = objectid;
3691
3692 switch (ItemInfo [objectid][item_type])
3693 {
3694 case 1: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, FoodItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3695 case 2: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MedicalItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3696 case 3: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, CookableItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3697 case 4: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ResourceItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3698 case 5: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ToolItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3699 case 6: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BigItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3700 case 7: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MiscItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3701 case 8: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, WeaponItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3702 case 9: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, MeleeWeaponItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3703 case 10: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, AmmoItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3704 case 11: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, HeadWearableItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3705 case 12: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BodyWearableItems [ItemInfo [objectid][item_static_id]][wearable_name], ItemInfo [objectid][item_amount]);
3706 case 13: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, BackpackItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3707 case 14: format (string, sizeof (string), "%s %s>%s %s (%d)", SERVER_TAG, COLOR_MAIN_HEX, COLOR_WHITE, ArmourItems [ItemInfo [objectid][item_static_id]][name], ItemInfo [objectid][item_amount]);
3708 }
3709
3710 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_2_PART, DIALOG_STYLE_LIST, string, ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Pickup All\n"COLOR_MAIN_HEX"2. "COLOR_WHITE"Enter an amount", "Pickup", "Cancel");
3711 return 1;
3712}
3713
3714public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
3715{
3716 SetObjectPos (objectid, fX, fY, fZ);
3717 SetObjectRot (objectid, fRotX, fRotY, fRotZ);
3718 return 1;
3719}
3720
3721public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
3722{
3723 if (response == EDIT_RESPONSE_FINAL || response == EDIT_RESPONSE_CANCEL)
3724 {
3725
3726 SetPlayerAttachedObject (playerid, 0, modelid, 6, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ);
3727 printf ("OFFSET (%d) : %f, %f, %f, %f, %f, %f, %f, %f, %f", modelid, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ);
3728
3729 }
3730 return 1;
3731}
3732
3733
3734////////////////////////////////////////////////////////////////////////////////
3735// COMMANDS ////////////////////////////////////////////////////////////////////
3736////////////////////////////////////////////////////////////////////////////////
3737
3738stock SendMessageToNearbyPlayers (playerid, message [], Float: message_range)
3739{
3740 new Float: x, Float: y, Float: z;
3741 GetPlayerPos (playerid, x, y, z);
3742
3743 foreach (new i : Player)
3744 {
3745 if (IsPlayerInRangeOfPoint (i, message_range, x, y, z))
3746 {
3747 SendClientMessage (i, 0xC2A2DAAA, message);
3748 }
3749 }
3750 return 1;
3751}
3752
3753stock IsPlayerNearVehicleTrunk (playerid, vehicleid)
3754{
3755 new Float: x, Float: y, Float: z;
3756
3757 GetPosBehindVehicle (vehicleid, x, y, z);
3758
3759 if (IsPlayerInRangeOfPoint (playerid, 1.0, x, y, z))
3760 {
3761 return 1;
3762 }
3763
3764 return 0;
3765}
3766
3767stock GetPosBehindVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5)
3768{
3769 new Float:vehicleSize[3], Float:vehiclePos[3];
3770 GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
3771 GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
3772 GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
3773 x = vehiclePos[0];
3774 y = vehiclePos[1];
3775 z = vehiclePos[2];
3776 return 1;
3777}
3778
3779GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)
3780{
3781 new Float:a;
3782 GetVehiclePos(vehicleid, q, w, a);
3783 GetVehicleZAngle(vehicleid, a);
3784 q += (distance * -floatsin(-a, degrees));
3785 w += (distance * -floatcos(-a, degrees));
3786}
3787
3788CMD:engine(playerid, params [])
3789{
3790 if (!IsPlayerInAnyVehicle (playerid)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not in any vehicle. ");
3791 if (GetPlayerState (playerid) != PLAYER_STATE_DRIVER) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not on the driver's seat. ");
3792 if (VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_fuel] <= 0.0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The vehicle's fuel tank is empty. ");
3793 if (VehicleInfo [GetPlayerVehicleID (playerid)][engine_usage] >= 300) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The vehicle engine failed to start. ");
3794
3795 switch (VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_engine])
3796 {
3797 case 0:
3798 {
3799 VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_engine] = 1;
3800 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Vehicle engine started. ");
3801 }
3802 case 1:
3803 {
3804 VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_engine] = 0;
3805 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Vehicle engine turned off. ");
3806 }
3807 }
3808
3809 UpdateVehicleParams (GetPlayerVehicleID (playerid));
3810 return 1;
3811}
3812
3813CMD:addvehicle(playerid, params[])
3814{
3815 new add_vehicle_id;
3816 if (sscanf (params, "i", add_vehicle_id)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /addvehicle [vehicle id]");
3817
3818 new Float: x, Float: y, Float: z, Float: a,
3819 created_vehicle,
3820 color_1, color_2;
3821
3822 GetPlayerPos (playerid, x, y, z);
3823 GetPlayerFacingAngle (playerid, a);
3824
3825 color_1 = random (256);
3826 color_2 = random (256);
3827
3828 created_vehicle = CreateVehicle (add_vehicle_id, x, y, z, a, color_1, color_2, -1);
3829 SetVehicleVirtualWorld (created_vehicle, 1);
3830
3831 PutPlayerInVehicle (playerid, created_vehicle, 0);
3832
3833 VehicleInfo [created_vehicle][vehicle_color_1] = color_1;
3834 VehicleInfo [created_vehicle][vehicle_color_2] = color_2;
3835
3836 new objective;
3837
3838 GetVehicleParamsEx (created_vehicle,
3839 VehicleInfo [created_vehicle][vehicle_engine],
3840 VehicleInfo [created_vehicle][vehicle_lights],
3841 VehicleInfo [created_vehicle][vehicle_alarm],
3842 VehicleInfo [created_vehicle][vehicle_doors],
3843 VehicleInfo [created_vehicle][vehicle_bonnet],
3844 VehicleInfo [created_vehicle][vehicle_boot], objective);
3845
3846
3847 GetVehicleDamageStatus (created_vehicle,
3848 VehicleInfo [created_vehicle][vehicle_d_panels],
3849 VehicleInfo [created_vehicle][vehicle_d_doors],
3850 VehicleInfo [created_vehicle][vehicle_d_lights],
3851 VehicleInfo [created_vehicle][vehicle_d_tires]);
3852
3853 VehicleInfo [created_vehicle][vehicle_fuel] = 100;
3854
3855 new query [750];
3856
3857 mysql_format (mysql, query, sizeof (query), "INSERT INTO `vehicles` (`model`, `color_1`, `color_2`, `engine`, `lights`, `alarms`, `doors`, `bonnet`, `boot`, `d_panels`, `d_doors`, `d_lights`, `d_tires`, `health`, `fuel`, `last_x`, `last_y`, `last_z`, `last_a`) VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %f, %f, %f, %f)",
3858 add_vehicle_id,
3859 VehicleInfo [created_vehicle][vehicle_color_1], VehicleInfo [created_vehicle][vehicle_color_2],
3860
3861 VehicleInfo [created_vehicle][vehicle_engine],
3862 VehicleInfo [created_vehicle][vehicle_lights],
3863 VehicleInfo [created_vehicle][vehicle_alarm],
3864 VehicleInfo [created_vehicle][vehicle_doors],
3865 VehicleInfo [created_vehicle][vehicle_bonnet],
3866 VehicleInfo [created_vehicle][vehicle_boot],
3867
3868 VehicleInfo [created_vehicle][vehicle_d_panels],
3869 VehicleInfo [created_vehicle][vehicle_d_doors],
3870 VehicleInfo [created_vehicle][vehicle_d_lights],
3871 VehicleInfo [created_vehicle][vehicle_d_tires],
3872
3873 1000.0, 100.0, x, y, z, a);
3874
3875 mysql_query (mysql, query);
3876
3877 new string [250];
3878 format (string, sizeof (string), "[INFO] {FFFFFF}CREATED VEHICLE: (Vehicle ID: %d, Model ID: %d)", created_vehicle, add_vehicle_id);
3879 SendClientMessage (playerid, COLOR_MAIN, string);
3880 return 1;
3881}
3882
3883stock LoadVehicles ()
3884{
3885 mysql_tquery (mysql, "SELECT * FROM `vehicles` WHERE 1", "OnVehiclesLoad");
3886 return 1;
3887}
3888
3889stock GetVehicleDriver (vehicleid)
3890{
3891 new player;
3892 foreach (new playerid : Player)
3893 {
3894 if (IsPlayerConnected (playerid))
3895 {
3896 if (IsPlayerInAnyVehicle (playerid))
3897 {
3898 if (GetPlayerState (playerid) == PLAYER_STATE_DRIVER)
3899 {
3900 if (GetPlayerVehicleID (playerid) == vehicleid)
3901 {
3902 player = playerid;
3903 break;
3904 }
3905 }
3906 }
3907 }
3908 }
3909 return player;
3910}
3911
3912stock UpdateVehicleParams (vehicleid)
3913{
3914 SetVehicleParamsEx (vehicleid,
3915 VehicleInfo [vehicleid][vehicle_engine],
3916 VehicleInfo [vehicleid][vehicle_lights],
3917 VehicleInfo [vehicleid][vehicle_alarm],
3918 VehicleInfo [vehicleid][vehicle_doors],
3919 VehicleInfo [vehicleid][vehicle_bonnet],
3920 VehicleInfo [vehicleid][vehicle_boot], 0);
3921 return 1;
3922}
3923
3924stock UpdateVehicleDamageStatusEx (vehicleid)
3925{
3926 UpdateVehicleDamageStatus (vehicleid,
3927 VehicleInfo [vehicleid][vehicle_d_panels],
3928 VehicleInfo [vehicleid][vehicle_d_doors],
3929 VehicleInfo [vehicleid][vehicle_d_lights],
3930 VehicleInfo [vehicleid][vehicle_d_tires]);
3931 return 1;
3932}
3933
3934forward UpdateVehiclesData ();
3935public UpdateVehiclesData ()
3936{
3937 for (new i = 0; i < MAX_VEHICLES; i++)
3938 {
3939 if (GetVehicleModel (i) != 0)
3940 {
3941
3942 if (VehicleInfo [i][vehicle_driving] == 1)
3943 {
3944 if (VehicleInfo [i][vehicle_fuel] > 0.0) { VehicleInfo [i][vehicle_fuel] -= 1.0; }
3945 if (VehicleInfo [i][engine_usage] < 301) { VehicleInfo [i][engine_usage] += 1; }
3946 if (VehicleInfo [i][wheel_usage] < 201) { VehicleInfo [i][wheel_usage] += 1; }
3947
3948 if (VehicleInfo [i][vehicle_fuel] == 0.0)
3949 {
3950 VehicleInfo [i][vehicle_engine] = 0;
3951
3952 UpdateVehicleParams (i);
3953
3954 SendClientMessage (GetVehicleDriver (i), COLOR_MAIN, "[INFO] "COLOR_WHITE"There is no more fuel in the vehicle. ");
3955 }
3956
3957 if (VehicleInfo [i][engine_usage] == 300)
3958 {
3959 VehicleInfo [i][vehicle_engine] = 0;
3960
3961 UpdateVehicleParams (i);
3962
3963 SendClientMessage (GetVehicleDriver (i), COLOR_MAIN, "[INFO] "COLOR_WHITE"The vehicle engine is jammed. ");
3964 }
3965
3966 if (VehicleInfo [i][wheel_usage] == 200)
3967 {
3968 VehicleInfo [i][vehicle_d_tires] = random (16);
3969
3970 UpdateVehicleDamageStatusEx (i);
3971
3972 SendClientMessage (GetVehicleDriver (i), COLOR_MAIN, "[INFO] "COLOR_WHITE"The tires of the vehicles have been over used. ");
3973 }
3974 }
3975 }
3976 }
3977
3978 foreach (new playerid : Player)
3979 {
3980 if (IsPlayerConnected (playerid))
3981 {
3982 if (IsPlayerInAnyVehicle (playerid) && GetPlayerState (playerid) == PLAYER_STATE_DRIVER)
3983 {
3984 UpdateFuelBar (playerid);
3985 ShowFuelBar (playerid);
3986 }
3987 }
3988 }
3989
3990 return 1;
3991}
3992
3993forward OnVehiclesLoad ();
3994public OnVehiclesLoad ()
3995{
3996 for (new i = 0; i < cache_num_rows (); i++)
3997 {
3998 new created_vehicle,
3999
4000 model,
4001
4002 color_1, color_2,
4003
4004 Float: vlast_x, Float: vlast_y, Float: vlast_z,
4005 Float: vlast_a;
4006
4007 cache_get_value_name_int (i, "model", model);
4008
4009 cache_get_value_name_int (i, "color_1", color_1);
4010 cache_get_value_name_int (i, "color_2", color_2);
4011
4012 cache_get_value_name_float (i, "last_x", vlast_x);
4013 cache_get_value_name_float (i, "last_y", vlast_y);
4014 cache_get_value_name_float (i, "last_z", vlast_z);
4015 cache_get_value_name_float (i, "last_a", vlast_a);
4016
4017 created_vehicle = CreateVehicle (model,
4018
4019 vlast_x,
4020 vlast_y,
4021 vlast_z,
4022 vlast_a,
4023
4024 color_1,
4025 color_2,
4026
4027 -1);
4028
4029
4030 VehicleInfo [created_vehicle][vehicle_model] = model;
4031
4032 VehicleInfo [created_vehicle][vehicle_x] = vlast_x;
4033 VehicleInfo [created_vehicle][vehicle_y] = vlast_y;
4034 VehicleInfo [created_vehicle][vehicle_z] = vlast_z;
4035 VehicleInfo [created_vehicle][vehicle_a] = vlast_a;
4036
4037 VehicleInfo [created_vehicle][vehicle_color_1] = color_1;
4038 VehicleInfo [created_vehicle][vehicle_color_2] = color_2;
4039
4040 cache_get_value_name_float (i, "health", VehicleInfo [created_vehicle][vehicle_health]);
4041 cache_get_value_name_float (i, "fuel", VehicleInfo [created_vehicle][vehicle_fuel]);
4042
4043 SetVehicleHealth (created_vehicle, VehicleInfo [created_vehicle][vehicle_health]);
4044
4045 cache_get_value_name_int (i, "engine", VehicleInfo [created_vehicle][vehicle_engine]);
4046 cache_get_value_name_int (i, "lights", VehicleInfo [created_vehicle][vehicle_lights]);
4047 cache_get_value_name_int (i, "alarms", VehicleInfo [created_vehicle][vehicle_alarm]);
4048 cache_get_value_name_int (i, "doors", VehicleInfo [created_vehicle][vehicle_doors]);
4049 cache_get_value_name_int (i, "bonnet", VehicleInfo [created_vehicle][vehicle_bonnet]);
4050 cache_get_value_name_int (i, "boot", VehicleInfo [created_vehicle][vehicle_boot]);
4051
4052 UpdateVehicleParams (created_vehicle);
4053
4054 cache_get_value_name_int (i, "d_panels", VehicleInfo [created_vehicle][vehicle_d_panels]);
4055 cache_get_value_name_int (i, "d_doors", VehicleInfo [created_vehicle][vehicle_d_doors]);
4056 cache_get_value_name_int (i, "d_lights", VehicleInfo [created_vehicle][vehicle_d_lights]);
4057 cache_get_value_name_int (i, "d_tires", VehicleInfo [created_vehicle][vehicle_d_tires]);
4058
4059 UpdateVehicleDamageStatus (created_vehicle,
4060 VehicleInfo [created_vehicle][vehicle_d_panels],
4061 VehicleInfo [created_vehicle][vehicle_d_doors],
4062 VehicleInfo [created_vehicle][vehicle_d_lights],
4063 VehicleInfo [created_vehicle][vehicle_d_tires]);
4064
4065 }
4066 return 1;
4067}
4068
4069stock SaveItems ()
4070{
4071 new Float: px, Float: py, Float: pz,
4072 Float: rx, Float: ry, Float: rz,
4073
4074 string [450],
4075
4076 File: file;
4077
4078 file = fopen (CREATED_ITEMS_FILE, io_write);
4079
4080 for (new i = 0; i < MAX_OBJECTS; i++)
4081 {
4082 if (ItemInfo [i][item_type] > 0)
4083 {
4084 GetObjectPos (i, px, py, pz);
4085 GetObjectRot (i, rx, ry, rz);
4086
4087 format (string, sizeof (string), "%d %d %d %d %d %d %f %f %f %f %f %f\r\n",
4088 i,
4089 ItemInfo [i][item_static_id],
4090 ItemInfo [i][item_type],
4091 ItemInfo [i][item_amount],
4092 ItemInfo [i][item_ammo],
4093 ItemInfo [i][item_model_id],
4094 px, py, pz,
4095 rx, ry, rz );
4096
4097 fwrite (file, string);
4098 }
4099 }
4100
4101 fclose (file);
4102 return 1;
4103}
4104
4105stock SaveVehicles ()
4106{
4107 new query [1024], extra;
4108
4109 mysql_format (mysql, query, sizeof (query), "DELETE FROM `vehicles` WHERE 1");
4110 mysql_query (mysql, query);
4111
4112 for (new vehicleid = 0; vehicleid < MAX_VEHICLES; vehicleid++)
4113 {
4114 if (GetVehicleModel (vehicleid) != 0)
4115 {
4116 query [0] = '\0';
4117
4118 GetVehicleHealth (vehicleid, VehicleInfo [vehicleid][vehicle_health]);
4119
4120 GetVehiclePos (vehicleid, VehicleInfo [vehicleid][vehicle_x], VehicleInfo [vehicleid][vehicle_y], VehicleInfo [vehicleid][vehicle_z]);
4121 GetVehicleZAngle (vehicleid, VehicleInfo [vehicleid][vehicle_a]);
4122
4123 GetVehicleParamsEx (vehicleid,
4124 VehicleInfo [vehicleid][vehicle_engine],
4125 VehicleInfo [vehicleid][vehicle_lights],
4126 VehicleInfo [vehicleid][vehicle_alarm],
4127 VehicleInfo [vehicleid][vehicle_doors],
4128 VehicleInfo [vehicleid][vehicle_bonnet],
4129 VehicleInfo [vehicleid][vehicle_boot], extra);
4130
4131 GetVehicleDamageStatus (vehicleid,
4132 VehicleInfo [vehicleid][vehicle_d_panels],
4133 VehicleInfo [vehicleid][vehicle_d_doors],
4134 VehicleInfo [vehicleid][vehicle_d_lights],
4135 VehicleInfo [vehicleid][vehicle_d_tires]);
4136
4137 mysql_format (mysql, query, sizeof (query), "INSERT INTO `vehicles` (`model`, `color_1`, `color_2`, `engine`, `lights`, `alarms`, `doors`, `bonnet`, `boot`, `d_panels`, `d_doors`, `d_lights`, `d_tires`, `health`, `fuel`, `last_x`, `last_y`, `last_z`, `last_a`) VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %f, %f, %f, %f)",
4138
4139 VehicleInfo [vehicleid][vehicle_model],
4140
4141 VehicleInfo [vehicleid][vehicle_color_1],
4142 VehicleInfo [vehicleid][vehicle_color_2],
4143
4144 VehicleInfo [vehicleid][vehicle_engine],
4145 VehicleInfo [vehicleid][vehicle_lights],
4146 VehicleInfo [vehicleid][vehicle_alarm],
4147 VehicleInfo [vehicleid][vehicle_doors],
4148 VehicleInfo [vehicleid][vehicle_bonnet],
4149 VehicleInfo [vehicleid][vehicle_boot],
4150
4151 VehicleInfo [vehicleid][vehicle_d_panels],
4152 VehicleInfo [vehicleid][vehicle_d_doors],
4153 VehicleInfo [vehicleid][vehicle_d_lights],
4154 VehicleInfo [vehicleid][vehicle_d_tires],
4155
4156 VehicleInfo [vehicleid][vehicle_health],
4157 VehicleInfo [vehicleid][vehicle_fuel],
4158
4159 VehicleInfo [vehicleid][vehicle_x],
4160 VehicleInfo [vehicleid][vehicle_y],
4161 VehicleInfo [vehicleid][vehicle_z],
4162 VehicleInfo [vehicleid][vehicle_a]);
4163
4164 mysql_pquery (mysql, query);
4165
4166 print (query);
4167 }
4168 }
4169
4170
4171 return 1;
4172}
4173
4174CMD:weapon(playerid, params [])
4175{
4176 new weaponid;
4177 if (!sscanf (params, "i", weaponid))
4178 {
4179 ResetPlayerWeapons (playerid);
4180 GivePlayerWeapon (playerid, weaponid, 999999);
4181 }
4182 return 1;
4183}
4184
4185CMD:spineobject(playerid, params [])
4186{
4187 new object_id;
4188 if (!sscanf (params, "i", object_id))
4189 {
4190 SetPlayerAttachedObject (playerid, 1, object_id, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
4191 EditAttachedObject (playerid, 0);
4192 }
4193 return 1;
4194}
4195
4196CMD:editspine(playerid, params [])
4197{
4198 EditAttachedObject (playerid, 1);
4199 return 1;
4200}
4201
4202CMD:handobject(playerid, params [])
4203{
4204 new object_id;
4205 if (!sscanf (params, "i", object_id))
4206 {
4207 SetPlayerAttachedObject (playerid, 0, object_id, 6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
4208 EditAttachedObject (playerid, 0);
4209 }
4210 return 1;
4211}
4212
4213CMD:edithand(playerid, params [])
4214{
4215 EditAttachedObject (playerid, 0);
4216 return 1;
4217}
4218
4219CMD:craft(playerid, params [])
4220{
4221 if (PlayerInfo [playerid][player_action] == 2) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are already crafting an item. ");
4222
4223 new string [1024];
4224
4225 for (new i = 0; i < MAX_CRAFTABLE_ITEMS; i++)
4226 {
4227 format (string, sizeof (string), "%s\%s", string, CraftableItems [i][name]);
4228 }
4229
4230 ShowPlayerDialog (playerid, CRAFTABLE_ITEMS_DIALOG_ID, DIALOG_STYLE_LIST, ""SERVER_TAG" - Craft", string, "Select", "Cancel");
4231 return 1;
4232}
4233
4234CMD:worldtime(playerid, params [])
4235{
4236 new world_time;
4237 if (sscanf (params, "i", world_time)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] SYNTAX: /worldtime [0 - 23] (0 = 12:00 AM || 12 = 12:00 PM)");
4238 if (world_time < 0 || world_time > 23) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] Wrong time. ");
4239
4240 SetWorldTime (world_time);
4241 return 1;
4242}
4243
4244CMD:ooc(playerid, params [])
4245{
4246 new message [250];
4247 if (sscanf (params, "s[250]", message)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /ooc [text]");
4248
4249 new string [275];
4250 format (string, sizeof (string), "%s : %s", GetName (playerid), playerid);
4251
4252 SendMessageToNearbyPlayers (playerid, string, 30.0);
4253 return 1;
4254}
4255
4256CMD:ame(playerid, params [])
4257{
4258 new action [250];
4259 if (sscanf (params, "s[250]", action)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /ame [text]");
4260
4261 new string [275];
4262 format (string, sizeof (string), "* %s[AME]%s %s %s", COLOR_MAIN_HEX, COLOR_WHITE, GetName (playerid), action);
4263
4264 SendMessageToNearbyPlayers (playerid, string, 15.0);
4265
4266 SetPlayerChatBubble (playerid, string, 0xFFFFFFFF, 100.0, 10 * 1000);
4267 return 1;
4268}
4269
4270CMD:ado(playerid, params [])
4271{
4272 new action [250];
4273 if (sscanf (params, "s[250]", action)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /ame [text]");
4274
4275 new string [275];
4276 format (string, sizeof (string), "* %s[ADO]%s %s %s", COLOR_MAIN_HEX, COLOR_WHITE, GetName (playerid), action);
4277
4278 SendMessageToNearbyPlayers (playerid, string, 15.0);
4279
4280 SetPlayerChatBubble (playerid, string, 0xFFFFFFFF, 100.0, 10 * 1000);
4281 return 1;
4282}
4283
4284CMD:me(playerid, params [])
4285{
4286 new action [250];
4287 if (sscanf (params, "s[250]", action)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /me [action]");
4288
4289 new string [275];
4290 format (string, sizeof (string), "* %s %s", GetName (playerid), action);
4291
4292 SendMessageToNearbyPlayers (playerid, string, 30.0);
4293 return 1;
4294}
4295
4296CMD:do(playerid, params [])
4297{
4298 new action [250];
4299 if (sscanf (params, "s[250]", action)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /do [action]");
4300
4301 new string [175];
4302
4303 format (string, sizeof (string), "* %s (( %s ))", action, GetName (playerid));
4304
4305 SendMessageToNearbyPlayers (playerid, string, 30.0);
4306 return 1;
4307}
4308
4309CMD:melow(playerid, params [])
4310{
4311 new action [250];
4312 if (sscanf (params, "s[250]", action)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /melow [action]");
4313
4314 new string [275];
4315 format (string, sizeof (string), "* %s %s", GetName (playerid), action);
4316
4317 SendMessageToNearbyPlayers (playerid, string, 15.0);
4318 return 1;
4319}
4320
4321CMD:dolow(playerid, params [])
4322{
4323 new action [250];
4324 if (sscanf (params, "s[250]", action)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /dolow [action]");
4325
4326 new string [175];
4327
4328 format (string, sizeof (string), "* %s (( %s ))", action, GetName (playerid));
4329
4330 SendMessageToNearbyPlayers (playerid, string, 15.0);
4331 return 1;
4332}
4333
4334CMD:cw(playerid, params [])
4335{
4336 new message [250];
4337 if (sscanf (params, "s[250]", message)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /cw [message]");
4338
4339 new string [275];
4340 format (string, sizeof (string), "* %s[IN-CAR]%s %s : %s", COLOR_MAIN_HEX, COLOR_WHITE, GetName (playerid), message);
4341
4342 foreach (new i : Player)
4343 {
4344 if (IsPlayerInVehicle (i, GetPlayerVehicleID (playerid)))
4345 {
4346 SendClientMessage (i, 0xFFFFFFFF, string);
4347 }
4348 }
4349 return 1;
4350}
4351
4352CMD:shout(playerid, params [])
4353{
4354 new message [250];
4355 if (sscanf (params, "s[250]", message)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /s(cream) [message]");
4356
4357 new string [275];
4358 format (string, sizeof (string), "* %s shouts %s", GetName (playerid), message);
4359
4360 SendMessageToNearbyPlayers (playerid, string, 50.0);
4361 return 1;
4362}
4363
4364CMD:s(playerid, params [])
4365{
4366 cmd_shout (playerid, params);
4367 return 1;
4368}
4369
4370CMD:character(playerid, params [])
4371{
4372 new player_name [2][16];
4373
4374 strexplode (player_name, GetName (playerid), " ");
4375
4376 new string [1024];
4377 format (string, sizeof (string), "- First Name: %s\n\n- Last Name: %s\n\nAge: %d\n\nFaction: N/A\n\nJob: %s",
4378 player_name [0], player_name [1],
4379 PlayerInfo [playerid][age],
4380 Jobs [PlayerInfo [playerid][job]][name]);
4381
4382 ShowPlayerDialog (playerid, CHARACTER_INFO_DIALOG_ID, DIALOG_STYLE_MSGBOX, ""SERVER_TAG" - Character", string, "Ok", "");
4383 return 1;
4384}
4385
4386CMD:kill(playerid, params[])
4387{
4388 SetPlayerHealth (playerid, 0.0);
4389 return 1;
4390}
4391
4392CMD:stopsmoking(playerid, params[])
4393{
4394 if (GetPlayerSpecialAction (playerid) != SPECIAL_ACTION_SMOKE_CIGGY) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not smoking any cigarette. ");
4395
4396 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_NONE);
4397 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You disposed your cigarette. ");
4398 return 1;
4399}
4400
4401CMD:additem(playerid, params[])
4402{
4403 if (PlayerInfo [playerid][item_added] == 1) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] Wait before adding another item. ");
4404 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot pickup items while handcuffed. ");
4405
4406 new string [2450];
4407
4408 strcat (string, ""COLOR_MAIN_HEX"1. "COLOR_WHITE"Food Items\n", sizeof (string));
4409 strcat (string, ""COLOR_MAIN_HEX"2. "COLOR_WHITE"Medical Items\n", sizeof (string));
4410 strcat (string, ""COLOR_MAIN_HEX"3. "COLOR_WHITE"Cookable Items\n", sizeof (string));
4411 strcat (string, ""COLOR_MAIN_HEX"4. "COLOR_WHITE"Resource Items\n", sizeof (string));
4412 strcat (string, ""COLOR_MAIN_HEX"5. "COLOR_WHITE"Tool Items\n", sizeof (string));
4413 strcat (string, ""COLOR_MAIN_HEX"6. "COLOR_WHITE"Big Items\n", sizeof (string));
4414 strcat (string, ""COLOR_MAIN_HEX"7. "COLOR_WHITE"Misc Items\n", sizeof (string));
4415 strcat (string, ""COLOR_MAIN_HEX"8. "COLOR_WHITE"Ranged Weapons\n", sizeof (string));
4416 strcat (string, ""COLOR_MAIN_HEX"9. "COLOR_WHITE"Melee Weapons\n", sizeof (string));
4417 strcat (string, ""COLOR_MAIN_HEX"10. "COLOR_WHITE"Ammo\n", sizeof (string));
4418 strcat (string, ""COLOR_MAIN_HEX"11. "COLOR_WHITE"Head Wearable Items\n", sizeof (string));
4419 strcat (string, ""COLOR_MAIN_HEX"12. "COLOR_WHITE"Body Wearable Items\n", sizeof (string));
4420 strcat (string, ""COLOR_MAIN_HEX"13. "COLOR_WHITE"Backpacks\n", sizeof (string));
4421 strcat (string, ""COLOR_MAIN_HEX"13. "COLOR_WHITE"Armours", sizeof (string));
4422
4423 ShowPlayerDialog (playerid, ADD_ITEM_DIALOG_ID_1, DIALOG_STYLE_LIST, ""SERVER_TAG" - Add Item", string, "Select", "Cancel");
4424 return 1;
4425}
4426
4427CMD:pickup(playerid, params[])
4428{
4429 if (PlayerInfo [playerid][inventory_virtual_slots] == PlayerInfo [playerid][slots_used]) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"There is no inventory space. ");
4430 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CUFFED) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot pickup items while handcuffed. ");
4431
4432 for (new i = 0; i < 64; i++) { PlayerInfo [playerid][nearby_items][i] = -1; }
4433
4434 new Float: x, Float: y, Float: z;
4435 new total_items;
4436
4437 for (new i = 0; i < MAX_OBJECTS; i++)
4438 {
4439 if (ItemInfo [i][item_type] > 0)
4440 {
4441 GetObjectPos (i, x, y, z);
4442
4443 if (IsPlayerInRangeOfPoint (playerid, 2.5, x, y, z))
4444 {
4445 PlayerInfo [playerid][nearby_items][total_items] = i;
4446 total_items++;
4447 }
4448 }
4449 }
4450
4451 if (total_items == 0) return SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"There is no pickable item near you. ");
4452
4453 new string [500];
4454
4455 for (new i = 0; i < total_items; i++)
4456 {
4457 if (PlayerInfo [playerid][nearby_items][i] != -1)
4458 {
4459 switch(ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_type])
4460 {
4461 case 1: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, FoodItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4462 case 2: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MedicalItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4463 case 3: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, CookableItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4464 case 4: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, ResourceItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4465 case 5: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, ToolItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4466 case 6: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, BigItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4467 case 7: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MiscItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4468 case 8: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, WeaponItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4469 case 9: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MeleeWeaponItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4470 case 10: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, AmmoItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4471 case 11: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, HeadWearableItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4472 case 12: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, BodyWearableItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][wearable_name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4473 case 13: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, BackpackItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4474 case 14: format (string, sizeof (string), "%s\n%s%d. %s%s (%d)\n", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, ArmourItems [ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_static_id]][name], ItemInfo [PlayerInfo [playerid][nearby_items][i]][item_amount]);
4475 }
4476 }
4477 }
4478
4479 ShowPlayerDialog (playerid, NEARBY_ITEMS_DIALOG_ID_1, DIALOG_STYLE_LIST, ""SERVER_TAG" - Nearby Items", string, "Select", "Cancel");
4480 return 1;
4481}
4482
4483CMD:pup(playerid, params[])
4484{
4485 if (PlayerInfo [playerid][inventory_virtual_slots] == PlayerInfo [playerid][slots_used]) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"There is no inventory space. ");
4486
4487 SelectObject (playerid);
4488 return 1;
4489}
4490
4491CMD:loot(playerid, params [])
4492{
4493 new s_state,
4494
4495 loot_found,
4496
4497 Float: x, Float: y, Float: z,
4498
4499 type, id, amount, ammo,
4500
4501 string [1024];
4502
4503 #pragma unused s_state
4504
4505 strcat (string, "Item\tValue", sizeof (string));
4506
4507 for (new i = 0; i < MAX_ACTORS; i++)
4508 {
4509 GetActorPos (i, x, y, z);
4510
4511 if (IsPlayerInRangeOfPoint (playerid, 5.0, x, y, z))
4512 {
4513 for (new n = 0; n < ActorSlotsUsed [i]; n++)
4514 {
4515 if(!sscanf (ActorInventory [i][n][item], "iiiii", type, id, amount, ammo, s_state))
4516 {
4517 loot_found = 1;
4518
4519 switch (type)
4520 {
4521 case 1:
4522 {
4523 if (ammo == -1)
4524 {
4525 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, FoodItems [id][name], amount);
4526 }
4527 else
4528 {
4529 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, FoodItems [id][name], ammo);
4530 }
4531 }
4532 case 2:
4533 {
4534 if (ammo == -1)
4535 {
4536 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, MedicalItems [id][name], amount);
4537 }
4538 else
4539 {
4540 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, MedicalItems [id][name], ammo);
4541 }
4542 }
4543 case 3: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, CookableItems [id][name], amount);
4544 case 4: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, ResourceItems [id][name], amount);
4545 case 5: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, ToolItems [id][name], amount);
4546 case 6: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, BigItems [id][name], amount);
4547 case 7: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, MiscItems [id][name], amount);
4548 case 8: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, WeaponItems [id][name], amount);
4549 case 9: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, MeleeWeaponItems [id][name], amount);
4550 case 10:
4551 {
4552 new amount_string [12];
4553
4554 if (amount == -1) { amount_string = "-"; }
4555 else { valstr (amount_string, amount); }
4556
4557 format (string, sizeof (string), "%s\n%s%d. %s%s\t%s", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, AmmoItems [id][name], amount_string);
4558 }
4559 case 11: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, HeadWearableItems [id][name], amount);
4560 case 12: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, BodyWearableItems [id][wearable_name], amount);
4561 case 13: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, BackpackItems [id][name], amount);
4562 case 14:
4563 {
4564 new ammo_string [12];
4565
4566 if (ammo == -1) { ammo_string = "-"; }
4567 else { valstr (ammo_string, ammo); }
4568
4569 format (string, sizeof (string), "%s\n%s%d. %s%s\t%s", string, COLOR_MAIN_HEX, (n + 1), COLOR_WHITE, ArmourItems [id][name], ammo_string);
4570 }
4571 default: continue;
4572 }
4573
4574 PlayerInfo [playerid][selected_actor] = i;
4575 }
4576 }
4577
4578 break;
4579 }
4580 }
4581
4582 if (loot_found == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not near any dead bodies. ");
4583 ShowPlayerDialog (playerid, LOOTING_ACTOR_DIALOG_ID_1, DIALOG_STYLE_TABLIST_HEADERS, ""SERVER_TAG" - Loot", string, "Select", "Cancel");
4584 return 1;
4585}
4586
4587CMD:opentrunk(playerid, params [])
4588{
4589 if (IsPlayerNearAnyVehicle (playerid) == -1) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not near any vehicle. ");
4590 if (!IsPlayerNearVehicleTrunk (playerid, IsPlayerNearAnyVehicle (playerid))) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You are not near the vehicle's trunk. ");
4591
4592 new s_type, s_id, s_amount, s_ammo, s_state,
4593
4594 vehicleid,
4595
4596 string [1024];
4597
4598 vehicleid = IsPlayerNearAnyVehicle (playerid);
4599
4600 for (new i = 0; i < MAX_VEHICLE_SLOTS; i++)
4601 {
4602 if (!sscanf (VehicleInventory [vehicleid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
4603 {
4604
4605 switch (s_type)
4606 {
4607 case 1:
4608 {
4609 switch (s_ammo)
4610 {
4611 case -1: format (string, sizeof (string), "%d. %s\t%d", (i + 1), FoodItems [i][name], s_amount);
4612 default: format (string, sizeof (string), "%d. %s\t%d", (i + 1), FoodItems [i][name], s_ammo);
4613 }
4614 }
4615 case 2:
4616 {
4617 switch (s_ammo)
4618 {
4619 case -1: format (string, sizeof (string), "%d. %s\t%d", (i + 1), MedicalItems [i][name], s_amount);
4620 default: format (string, sizeof (string), "%d. %s\t%d", (i + 1), MedicalItems [i][name], s_ammo);
4621 }
4622 }
4623 case 3: format (string, sizeof (string), "%d. %s\t%d", (i + 1), CookableItems [i][name], s_amount);
4624 case 4: format (string, sizeof (string), "%d. %s\t%d", (i + 1), ResourceItems [i][name], s_amount);
4625 case 5: format (string, sizeof (string), "%d. %s\t%d", (i + 1), ToolItems [i][name], s_amount);
4626 case 6: format (string, sizeof (string), "%d. %s\t%d", (i + 1), BigItems [i][name], s_amount);
4627 case 7: format (string, sizeof (string), "%d. %s\t%d", (i + 1), MiscItems [i][name], s_amount);
4628 case 8: format (string, sizeof (string), "%d. %s\t%d", (i + 1), WeaponItems [i][name], s_amount);
4629 case 9: format (string, sizeof (string), "%d. %s\t%d", (i + 1), MeleeWeaponItems [i][name], s_amount);
4630 case 10: format (string, sizeof (string), "%d. %s\t%d", (i + 1), HeadWearableItems [i][name], s_amount);
4631 case 11: format (string, sizeof (string), "%d. %s\t%d", (i + 1), BodyWearableItems [i][wearable_name], s_amount);
4632 case 12: format (string, sizeof (string), "%d. %s\t%d", (i + 1), BackpackItems [i][name], s_amount);
4633 case 13: format (string, sizeof (string), "%d. %s\t%d", (i + 1), ArmourItems [i][name], s_amount);
4634 }
4635
4636 }
4637 }
4638
4639 ShowPlayerDialog (playerid, VEHICLE_INVENTORY_DIALOG_ID, DIALOG_STYLE_TABLIST, ""COLOR_WHITE"Vehicle Trunk", string, "Select", "Cancel");
4640 return 1;
4641}
4642
4643CMD:inv(playerid, params[])
4644{
4645 if (PlayerInventory [playerid][0][item][0] == EOS) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Your inventory is empty. ");
4646
4647 new type, id, amount, ammo, status, status_string [44],
4648 string [2500];
4649
4650 strcat (string, "Item\tValue\tStatus\n", sizeof (string));
4651
4652 for (new i = 0; i < (PlayerInfo [playerid][inventory_virtual_slots] + 1); i++)
4653 {
4654
4655 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", type, id, amount, ammo, status))
4656 {
4657 switch (status)
4658 {
4659 case -1: status_string = "{FFFFFF}N/A";
4660 case -2: status_string = "{FFFFFF}Not Equipped";
4661 case -3: status_string = "{00FF00}Equipped";
4662
4663 case 0, 1, 2, 3, 4:
4664 {
4665 switch (PlayerWeaponInfo [playerid][status][weapon_type])
4666 {
4667 case 0: format (status_string, sizeof (status_string), "{00FF00}Loaded {FFFFFF}(%s)", MeleeWeaponItems [PlayerWeaponInfo [playerid][status][weapon_static_id]][name]);
4668 default: format (status_string, sizeof (status_string), "{00FF00}Loaded {FFFFFF}(%s)", WeaponItems [PlayerWeaponInfo [playerid][status][weapon_static_id]][name]);
4669 }
4670 }
4671 }
4672
4673 switch (type)
4674 {
4675 case 1:
4676 {
4677 if (ammo == -1)
4678 {
4679 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, FoodItems [id][name], amount, status_string);
4680 }
4681 else
4682 {
4683 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, FoodItems [id][name], ammo, status_string);
4684 }
4685 }
4686 case 2:
4687 {
4688 if (ammo == -1)
4689 {
4690 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MedicalItems [id][name], amount, status_string);
4691 }
4692 else
4693 {
4694 format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MedicalItems [id][name], ammo, status_string);
4695 }
4696 }
4697 case 3: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, CookableItems [id][name], amount, status_string);
4698 case 4: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, ResourceItems [id][name], amount, status_string);
4699 case 5: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, ToolItems [id][name], amount, status_string);
4700 case 6: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, BigItems [id][name], amount, status_string);
4701 case 7: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MiscItems [id][name], amount, status_string);
4702 case 8: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, WeaponItems [id][name], amount, status_string);
4703 case 9: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, MeleeWeaponItems [id][name], amount, status_string);
4704 case 10:
4705 {
4706 new amount_string [12];
4707
4708 if (amount == -1) { amount_string = "-"; }
4709 else { valstr (amount_string, amount); }
4710
4711 format (string, sizeof (string), "%s\n%s%d. %s%s\t%s\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, AmmoItems [id][name], amount_string, status_string);
4712 }
4713 case 11: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, HeadWearableItems [id][name], amount, status_string);
4714 case 12: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, BodyWearableItems [id][wearable_name], amount, status_string);
4715 case 13: format (string, sizeof (string), "%s\n%s%d. %s%s\t%d\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, BackpackItems [id][name], amount, status_string);
4716 case 14:
4717 {
4718 new ammo_string [12];
4719
4720 if (ammo == -1) { ammo_string = "-"; }
4721 else { valstr (ammo_string, ammo); }
4722
4723 format (string, sizeof (string), "%s\n%s%d. %s%s\t%s\t%s", string, COLOR_MAIN_HEX, (i + 1), COLOR_WHITE, ArmourItems [id][name], ammo_string, status_string);
4724 }
4725 default: continue;
4726 }
4727 }
4728 }
4729
4730 new title [124];
4731 format (title, sizeof (title), "{FFFFFF}Inventory %s(%d/%d)", COLOR_MAIN_HEX, PlayerInfo [playerid][slots_used], PlayerInfo [playerid][inventory_virtual_slots]);
4732 ShowPlayerDialog (playerid, PLAYER_INVENTORY_DIALOG_ID_1, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Select", "Close");
4733 return 1;
4734}
4735
4736CMD:inventory(playerid, params[])
4737{
4738 cmd_inv(playerid, params);
4739 return 1;
4740}
4741
4742CMD:pm(playerid, params[])
4743{
4744 new id, message;
4745 if (sscanf (params, "is[125]", id, message)) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"SYNTAX: /pm [player id] [message]");
4746 else
4747 {
4748 if (!IsPlayerConnected (playerid) || id == INVALID_PLAYER_ID) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The specified player is offline.");
4749 if (PlayerInfo [id][private_messages] == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Player has their private messages turned off. ");
4750 if (id == playerid) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You cannot send private messages to yourself. ");
4751
4752 for (new i = 0; i < MAX_PM_OFF; i++)
4753 {
4754 if (PlayerPMOFFList [playerid][i] == playerid) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The player has blocked your PMs. ");
4755 }
4756
4757 new string [125];
4758 format (string, sizeof (string), "[PM] %s (%d): %s", GetName (playerid), playerid, message);
4759 SendClientMessage (id, COLOR_PM, string);
4760 }
4761 return 1;
4762}
4763
4764CMD:pmoff(playerid, params[])
4765{
4766 new id;
4767 if (sscanf (params, "i", id))
4768 {
4769 if (PlayerInfo [playerid][private_messages] == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Private messages are already off. ");
4770
4771 PlayerInfo [playerid][private_messages] = 0;
4772 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Private messages turned off. ");
4773
4774 }
4775 else
4776 {
4777 if (!IsPlayerConnected (playerid) || id == INVALID_PLAYER_ID) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The specified player is offline.");
4778
4779 for (new i = 0; i < MAX_PM_OFF; i++)
4780 {
4781 if (PlayerPMOFFList [playerid][i] == id)
4782 {
4783 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Private Messages are already blocked from that player. ");
4784 }
4785
4786 if (PlayerPMOFFList [playerid][i] == -1)
4787 {
4788 new string [125];
4789 format (string, sizeof (string), "[INFO] {FFFFFF}Private messages blocked from %s (%d). ", GetName (playerid), playerid);
4790 PlayerPMOFFList [playerid][i] = id;
4791 break;
4792 }
4793 }
4794
4795 }
4796 return 1;
4797}
4798
4799CMD:pmofflist(playerid, params[])
4800{
4801 new string [450];
4802
4803 for (new i = 0; i < MAX_PM_OFF; i++)
4804 {
4805 if (i != -1)
4806 {
4807 format (string, sizeof (string), "%s\n%s (%d)", string, GetName (i), i);
4808 }
4809 }
4810
4811 ShowPlayerDialog (playerid, PM_OFF_LIST_DIALOG_ID, DIALOG_STYLE_LIST, ""SERVER_TAG" - Private Messages Block List", string, "Close", "");
4812 return 1;
4813}
4814
4815CMD:pmon(playerid, params[])
4816{
4817 new id;
4818 if (sscanf (params, "i", id))
4819 {
4820 if (PlayerInfo [playerid][private_messages] == 1) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Private messages are already on. ");
4821
4822 PlayerInfo [playerid][private_messages] = 1;
4823 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Private messages turned on. ");
4824
4825 }
4826 else
4827 {
4828 if (!IsPlayerConnected (playerid) || id == INVALID_PLAYER_ID) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"The specified player is offline.");
4829
4830 for (new i = 0; i < MAX_PM_OFF; i++)
4831 {
4832 if (PlayerPMOFFList [playerid][i] == id)
4833 {
4834 new string [125];
4835 format (string, sizeof (string), "[INFO] {FFFFFF}Private messages enabled from %s (%d). ", GetName (playerid), playerid);
4836 PlayerPMOFFList [playerid][i] = -1;
4837 break;
4838 }
4839 }
4840
4841 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Private Messages are already enabled from that player. ");
4842
4843 }
4844 return 1;
4845}
4846
4847
4848////////////////////////////////////////////////////////////////////////////////
4849// CUSTOM CALLBACKS ////////////////////////////////////////////////////////////
4850////////////////////////////////////////////////////////////////////////////////
4851
4852forward UpdateWorldTime ();
4853public UpdateWorldTime ()
4854{
4855 if (WORLD_TIME == 23) { WORLD_TIME = 0; }
4856 else { WORLD_TIME++; }
4857
4858 SetWorldTime (WORLD_TIME);
4859 return 1;
4860}
4861
4862forward OnZombieCheckSurroundings ();
4863public OnZombieCheckSurroundings ()
4864{
4865
4866 new Float: x, Float: y, Float: z,
4867
4868 Float: p_x, Float: p_y, Float: p_z,
4869
4870 Float: out_x, Float: out_y, Float: out_z,
4871
4872 Float: range, zombie_animation,
4873
4874 Float: ray_x, Float: ray_y, Float: ray_z,
4875
4876 Float: a;
4877
4878 #pragma unused ray_x, ray_y, ray_z, out_x, out_y, out_z, a
4879
4880 for (new i = (SERVER_SLOTS - Zombies); i < MAX_ZOMBIES; i++)
4881 {
4882 if (ZombieInfo [i][spawned] == 1)
4883 {
4884 // a = FCNPC_GetAngle (i);
4885
4886 FCNPC_GetPosition (i, x, y, z);
4887 FCNPC_GetAnimation (i, zombie_animation);
4888
4889 // ray_x = (x + (2.5 * floatsin(-a, degrees)));
4890 // ray_y = (y + (2.5 * floatcos(-a, degrees)));
4891
4892 /*
4893 if (CA_RayCastLine (x, y, z, ray_x, ray_y, z, out_x, out_y, out_z))
4894 {
4895 FindGoToPoint (i);
4896 continue;
4897 }
4898 */
4899
4900 ray_x = ray_y = ray_z = 0.0;
4901
4902 if (zombie_animation == 1132)
4903 {
4904 MapAndreas_FindZ_For2DCoord (x, y, z);
4905 FCNPC_GoTo (i, x, y, (z + 1.25), 2, 3.0);
4906
4907 continue;
4908 }
4909
4910 if (ZombieInfo [i][chasing] == -1)
4911 {
4912
4913 if (range == 0.0) { range = 25.0; }
4914
4915 foreach (new playerid : Player)
4916 {
4917 if (!IsPlayerConnected (playerid)) { continue; }
4918
4919 if (PlayerInfo [playerid][zombies_chasing] >= 2) { continue; }
4920 if (IsPlayerInDynamicArea (playerid, SafeZone_1)) { continue; }
4921
4922 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_DUCK)
4923 {
4924 range = 7.5;
4925 }
4926
4927 if (PlayerInfo [playerid][walking] == 1)
4928 {
4929 range = 13.5;
4930 }
4931
4932 GetPlayerPos (playerid, ray_x, ray_y, ray_z);
4933
4934 /*
4935
4936 CA_RayCastLine (x, y, z, ray_x, ray_y, z, out_x, out_y, out_z);
4937
4938 if (ray_x != 0.0 || ray_y != 0.0 || ray_z != 0.0)
4939 {
4940 FindGoToPoint (i);
4941 continue;
4942 }
4943
4944 */
4945
4946 if (IsPlayerInAnyVehicle (playerid))
4947 {
4948 new Float: v_x, Float: v_y, Float: v_z;
4949
4950 GetVehicleVelocity (GetPlayerVehicleID (playerid), v_x, v_y, v_z);
4951
4952 if (v_x != 0.0 || v_y != 0.0 || v_z != 0.0)
4953 {
4954 range = 25.0;
4955 }
4956 }
4957
4958 if (PlayerInfo [playerid][weapon_shot] == 1)
4959 {
4960 range = 150.0;
4961 }
4962
4963 if (IsPlayerInRangeOfPoint (playerid, range, x, y, z))
4964 {
4965 GetPlayerPos (playerid, p_x, p_y, p_z);
4966
4967 if ((z - p_z) > -0.75)
4968 {
4969 FCNPC_ClearAnimations (playerid);
4970 FCNPC_GoTo (i, p_x, p_y, p_z, FCNPC_MOVE_TYPE_SPRINT, FCNPC_MOVE_SPEED_SPRINT);
4971
4972 ZombieInfo [i][chasing] = playerid;
4973 ZombieInfo [i][chasing_range] = range;
4974
4975 PlayerInfo [playerid][getting_chased] = i;
4976 PlayerInfo [playerid][zombies_chasing]++;
4977 }
4978 }
4979 else { FindGoToPoint (i); }
4980 }
4981 }
4982 else
4983 {
4984
4985 if (!IsPlayerInRangeOfPoint (ZombieInfo [i][chasing], ZombieInfo [i][chasing_range], x, y, z))
4986 {
4987
4988 PlayerInfo [ZombieInfo [i][chasing]][getting_chased] = -1;
4989 PlayerInfo [ZombieInfo [i][chasing]][zombies_chasing]--;
4990
4991 ZombieInfo [i][chasing] = -1;
4992 ZombieInfo [i][chasing_range] = 25.0;
4993
4994 FCNPC_ResetAnimation (i);
4995 FCNPC_GetPosition (i, x, y, z);
4996
4997 if (IsPointInDynamicArea (Z_Zone [ZombieInfo [i][zone_id]], x, y, z))
4998 {
4999 FindGoToPoint (i);
5000 }
5001 else
5002 {
5003 if (ZombieInfo [i][zone_id] == -1)
5004 {
5005 FindGoToPoint (i);
5006 }
5007 else
5008 {
5009 ReturnPath (i);
5010 }
5011 }
5012 }
5013 else
5014 {
5015
5016 new npcid = i;
5017
5018 FCNPC_GetPosition (npcid, x, y, z);
5019 GetPlayerPos (ZombieInfo [npcid][chasing], p_x, p_y, p_z);
5020
5021 if (((z - p_z) < -0.75)
5022
5023 || IsPlayerInDynamicArea (ZombieInfo [npcid][chasing], SafeZone_1)
5024 || IsPlayerInDynamicArea (ZombieInfo [npcid][chasing], SafeZone_2))
5025 {
5026
5027 // PlayerInfo [ZombieInfo [npcid][chasing]][zombies_chasing]--;
5028 // ZombieInfo [npcid][chasing] = -1;
5029 // FindGoToPoint (npcid);
5030
5031 ZombieInfo [npcid][waiting_timer] = SetTimerEx ("OnZombieDetectHeight", 1000, false, "i", npcid);
5032 return 0;
5033 }
5034
5035 FCNPC_StopAim (npcid);
5036 FCNPC_StopAttack (npcid);
5037 FCNPC_ClearAnimations (npcid);
5038 FCNPC_GoTo (npcid, p_x, p_y, p_z, FCNPC_MOVE_TYPE_SPRINT, FCNPC_MOVE_SPEED_SPRINT);
5039 if (IsPlayerInRangeOfPoint (ZombieInfo [npcid][chasing], 2.5, x, y, z)) { FCNPC_MeleeAttack (npcid, 1000); } else { FCNPC_StopAttack (npcid); }
5040
5041 /*
5042 if (ZombieInfo [i][chasing_range] == 100.0)
5043 {
5044 if (IsPlayerInRangeOfPoint (ZombieInfo [i][chasing], 25.0, x, y, z))
5045 {
5046 ZombieInfo [i][chasing_range] = 25.0;
5047 }
5048 }
5049 */
5050
5051 }
5052 }
5053 }
5054 }
5055
5056 return 1;
5057}
5058
5059forward FadeWeaponShotSound (playerid);
5060public FadeWeaponShotSound (playerid)
5061{
5062 PlayerInfo [playerid][weapon_shot] = 0;
5063 return 1;
5064}
5065
5066forward ExtinguishFire (objectid);
5067public ExtinguishFire (objectid)
5068{
5069 DestroyObject (ItemInfo [objectid][item_attached]);
5070 ItemInfo [objectid][item_attached] = -1;
5071
5072 if (ItemInfo [objectid][item_ammo] == 0)
5073 {
5074 ItemInfo [objectid][item_id] = -1;
5075 ItemInfo [objectid][item_static_id] = -1;
5076 ItemInfo [objectid][item_type] = -1;
5077 ItemInfo [objectid][item_amount] = -1;
5078 ItemInfo [objectid][item_ammo] = -1;
5079 ItemInfo [objectid][item_attached] = -1;
5080
5081 DestroyObject (objectid);
5082 }
5083 return 1;
5084}
5085
5086forward OnPlayerCraft (playerid);
5087public OnPlayerCraft (playerid)
5088{
5089 PlayerInfo [playerid][crafted]++;
5090 UpdateCraftingBar (playerid);
5091
5092 if (PlayerInfo [playerid][crafted] == PlayerInfo [playerid][crafting_time])
5093 {
5094 new s_type, s_id, s_amount, s_ammo, s_state,
5095
5096 p_type, p_id, p_amount, p_ammo, p_state,
5097
5098 string_parts [5][64],
5099
5100 needed, found;
5101
5102 strexplode (string_parts, PlayerInfo [playerid][crafting_method]);
5103
5104 for (new i = 0; i < 5; i++)
5105 {
5106 if (!sscanf (string_parts [i], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
5107 {
5108 needed++;
5109
5110 for (new n = 0; i < PlayerInfo [playerid][slots_used]; i++)
5111 {
5112 if (!sscanf (PlayerInventory [playerid][n][item], "iiiii", p_type, p_id, p_amount, p_ammo, p_state))
5113 {
5114 if (s_type == p_type && s_id == p_id && p_amount >= s_amount && p_ammo >= s_ammo)
5115 {
5116 found++;
5117 }
5118 }
5119 }
5120 }
5121 }
5122
5123 if (found == needed)
5124 {
5125 for (new i = 0; i < 5; i++)
5126 {
5127 if (!sscanf (string_parts [i], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
5128 {
5129 for (new n = 0; i < PlayerInfo [playerid][slots_used]; i++)
5130 {
5131 if (!sscanf (PlayerInventory [playerid][n][item], "iiiii", p_type, p_id, p_amount, p_ammo, p_state))
5132 {
5133 if (s_type == p_type && s_id == p_id && p_amount >= s_amount && p_ammo >= s_ammo)
5134 {
5135 p_amount -= s_amount;
5136
5137 if (p_amount <= 0)
5138 {
5139 RearrangePlayerInventorySlots (playerid, n);
5140
5141 continue;
5142 }
5143 else { format (PlayerInventory [playerid][n][item], 144, "%d %d %d %d %d", p_type, p_id, p_amount, p_ammo, p_state); }
5144
5145
5146 switch (CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_type])
5147 {
5148 case 6:
5149 {
5150 if (GetPlayerSpecialAction (playerid) == SPECIAL_ACTION_CARRY)
5151 {
5152
5153 new Float: x, Float: y, Float: z,
5154 created_item,
5155 items;
5156
5157 for (new m = 0; m < MAX_OBJECTS; m++) { if (ItemInfo [m][item_type] != 0) { items++; } }
5158
5159 GetPlayerPos (playerid, x, y, z);
5160 MapAndreas_FindZ_For2DCoord (x, y, z);
5161
5162 created_item = CreateObject (BigItems [CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_id]][model_id_1], x, y, z, 0.0, 0.0, 0.0);
5163
5164 ItemInfo [created_item][item_static_id] = CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_id];
5165 ItemInfo [created_item][item_ammo] = 3;
5166 ItemInfo [created_item][item_type] = CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_type];
5167 ItemInfo [created_item][item_id] = items;
5168 ItemInfo [created_item][item_amount] = 1;
5169
5170 }
5171 else
5172 {
5173 SetPlayerAttachedObject (playerid, 2, BigItems [CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_id]][model_id_1], 5, 0.0, 0.0, 0.0, 90.0, 190.0, 110.0, 0.25, 0.25, 0.25);
5174 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_CARRY);
5175
5176 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "6 %d 1 %d -1", CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_id], BigItems [CraftableItems [PlayerInfo [playerid][selected_item_static_id]][item_id]][item_ammo]);
5177 PlayerInfo [playerid][slots_used]++;
5178 }
5179 }
5180 }
5181
5182 }
5183 }
5184 }
5185 }
5186 }
5187 }
5188 else
5189 {
5190 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Crafting failed. ");
5191 SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"You don't have the resources to craft the item. ");
5192 }
5193
5194 KillTimer (PlayerInfo [playerid][crafting_timer]);
5195 HideCraftingBar (playerid);
5196 }
5197 return 1;
5198}
5199
5200forward OnPlayerCookFood (playerid, cookable_item, campfire_id);
5201public OnPlayerCookFood (playerid, cookable_item, campfire_id)
5202{
5203
5204 new Float: x, Float: y, Float: z;
5205 GetObjectPos (campfire_id, x, y, z);
5206
5207 if (!IsPlayerInRangeOfPoint (playerid, 1.5, x, y, z))
5208 {
5209 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You moved away from campfire, cooking cancelled. ");
5210
5211 KillTimer (PlayerInfo [playerid][cooking_timer]);
5212
5213 HideCookingBar (playerid);
5214
5215 return 0;
5216 }
5217
5218 PlayerInfo [playerid][cooked]++;
5219 UpdateCookingBar (playerid);
5220
5221 if (PlayerInfo [playerid][cooked] == PlayerInfo[playerid][cooking_time])
5222 {
5223
5224 KillTimer (PlayerInfo [playerid][cooking_timer]);
5225 HideCookingBar (playerid);
5226
5227 new s_type, s_id, s_amount, s_ammo, s_state;
5228 if (!sscanf (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_state))
5229 {
5230 s_amount--;
5231
5232 if (s_type == 2)
5233 {
5234 if (s_id == cookable_item)
5235 {
5236 switch (cookable_item)
5237 {
5238 case 16:
5239 {
5240 if (s_amount <= 0) { RearrangePlayerInventorySlots (playerid, PlayerInfo [playerid][selected_inventory_slot]); }
5241 else { format (PlayerInventory [playerid][PlayerInfo [playerid][selected_inventory_slot]][item], 124, "2 16 %d -1 -1", s_amount); }
5242
5243 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "1 15 1 -1 -1");
5244
5245 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You have cooked 1 raw meat. ");
5246 }
5247 }
5248 }
5249 }
5250 }
5251 }
5252 return 1;
5253}
5254
5255forward ResetItemAddedVarValue (playerid);
5256public ResetItemAddedVarValue (playerid)
5257{
5258 PlayerInfo [playerid][item_added] = 0;
5259 return 1;
5260}
5261
5262forward UpdatePlayerBars (playerid);
5263public UpdatePlayerBars (playerid)
5264{
5265 if (PlayerInfo [playerid][spawned] == 1 && PlayerInfo [playerid][loaded] == 1)
5266 {
5267 PlayerInfo [playerid][hunger] -= 2.0;
5268 PlayerInfo [playerid][thirst] -= 4.5;
5269
5270 if (PlayerInfo [playerid][hunger] <= 0.0) { PlayerInfo [playerid][hunger] = 0.0; }
5271 if (PlayerInfo [playerid][thirst] <= 0.0) { PlayerInfo [playerid][thirst] = 0.0; }
5272
5273 SetPlayerProgressBarValue (playerid, HungerBar [playerid], PlayerInfo [playerid][hunger]);
5274 SetPlayerProgressBarValue (playerid, ThirstBar [playerid], PlayerInfo [playerid][thirst]);
5275
5276 ShowPlayerProgressBar (playerid, HungerBar [playerid]);
5277 ShowPlayerProgressBar (playerid, ThirstBar [playerid]);
5278
5279 new Float: HP;
5280 GetPlayerHealth (playerid, HP);
5281
5282 if (PlayerInfo [playerid][hunger] < 25.0) { SetPlayerHealth (playerid, (HP - 2.5)); }
5283 if (PlayerInfo [playerid][thirst] < 25.0) { SetPlayerHealth (playerid, (HP - 2.5)); }
5284 }
5285 return 1;
5286}
5287
5288forward OnPlayerInit (playerid);
5289public OnPlayerInit (playerid)
5290{
5291 if (cache_num_rows () == 0)
5292 {
5293 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"In order to play on this server you need to register your account. ");
5294 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"If you don't already have an account, you can register here: "SERVER_WEBSITE"");
5295
5296 SetTimerEx ("KickPlayer", 1000, false, "i", playerid);
5297 }
5298 else
5299 {
5300 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"This name is registered in the database. ");
5301 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Enter the password to login this account. ");
5302
5303 cache_get_value_name (0, "PASSWORD", PlayerInfo [playerid][password], 32);
5304 cache_get_value_name_int (0, "ACCOUNT_ID", PlayerInfo [playerid][account_id]);
5305
5306 PlayerInfo [playerid][kick_timer] = SetTimerEx ("KickPlayer", strval(LOGIN_TIME_LIMIT) * 1000, false, "i", playerid);
5307
5308 ShowLoginDialog (playerid);
5309 }
5310 return 1;
5311}
5312
5313forward LoadPlayerData (playerid);
5314public LoadPlayerData (playerid)
5315{
5316 // GENERAL PLAYER DATA //
5317 cache_get_value_name_int (0, "ACCOUNT_ID", PlayerInfo [playerid][account_id]);
5318
5319 cache_get_value_name_int (0, "INITIATED", PlayerInfo [playerid][initiated]);
5320
5321 cache_get_value_name_int (0, "GENDER", PlayerInfo [playerid][gender]);
5322 cache_get_value_name_int (0, "AGE", PlayerInfo [playerid][age]);
5323 cache_get_value_name_int (0, "SKIN", PlayerInfo [playerid][skin]);
5324
5325 cache_get_value_name_float (0, "HEALTH", PlayerInfo [playerid][health]);
5326 cache_get_value_name_float (0, "HUNGER", PlayerInfo [playerid][hunger]);
5327 cache_get_value_name_float (0, "THIRST", PlayerInfo [playerid][thirst]);
5328
5329 cache_get_value_name_int (0, "JOB", PlayerInfo [playerid][job]);
5330
5331 cache_get_value_name_float (0, "LAST_X", PlayerInfo [playerid][last_x]);
5332 cache_get_value_name_float (0, "LAST_Y", PlayerInfo [playerid][last_y]);
5333 cache_get_value_name_float (0, "LAST_Z", PlayerInfo [playerid][last_z]);
5334
5335 cache_get_value_name_int (0, "LAST_INTERIOR", PlayerInfo [playerid][last_interior]);
5336
5337 cache_get_value_name_int (0, "PLAYER_SPAWN", PlayerInfo [playerid][player_spawn]);
5338
5339 CreatePlayerProgressBars (playerid);
5340
5341 PlayerInfo [playerid][loaded] = 1;
5342 return 1;
5343}
5344
5345forward LoadPlayerInventory (playerid);
5346public LoadPlayerInventory (playerid)
5347{
5348 cache_get_value_name_int (0, "MAX_SLOTS", PlayerInfo [playerid][inventory_slots]);
5349 cache_get_value_name_int (0, "MAX_VIRTUAL_SLOTS", PlayerInfo [playerid][inventory_virtual_slots]);
5350 cache_get_value_name_int (0, "USED_SLOTS", PlayerInfo [playerid][slots_used]);
5351
5352 cache_get_value_name (0, "SLOT_1", PlayerInventory [playerid][0][item], 124);
5353 cache_get_value_name (0, "SLOT_2", PlayerInventory [playerid][1][item], 124);
5354 cache_get_value_name (0, "SLOT_3", PlayerInventory [playerid][2][item], 124);
5355 cache_get_value_name (0, "SLOT_4", PlayerInventory [playerid][3][item], 124);
5356 cache_get_value_name (0, "SLOT_5", PlayerInventory [playerid][4][item], 124);
5357 cache_get_value_name (0, "SLOT_6", PlayerInventory [playerid][5][item], 124);
5358 cache_get_value_name (0, "SLOT_7", PlayerInventory [playerid][6][item], 124);
5359 cache_get_value_name (0, "SLOT_8", PlayerInventory [playerid][7][item], 124);
5360 cache_get_value_name (0, "SLOT_9", PlayerInventory [playerid][8][item], 124);
5361 cache_get_value_name (0, "SLOT_10", PlayerInventory [playerid][9][item], 124);
5362 cache_get_value_name (0, "SLOT_11", PlayerInventory [playerid][10][item], 124);
5363 cache_get_value_name (0, "SLOT_12", PlayerInventory [playerid][11][item], 124);
5364 cache_get_value_name (0, "SLOT_13", PlayerInventory [playerid][12][item], 124);
5365 cache_get_value_name (0, "SLOT_14", PlayerInventory [playerid][13][item], 124);
5366 cache_get_value_name (0, "SLOT_15", PlayerInventory [playerid][14][item], 124);
5367 cache_get_value_name (0, "SLOT_16", PlayerInventory [playerid][15][item], 124);
5368 return 1;
5369}
5370
5371forward SavePlayerData (playerid);
5372public SavePlayerData (playerid)
5373{
5374 new query [1500], string [500];
5375
5376 GetPlayerHealth (playerid, PlayerInfo [playerid][health]);
5377
5378 PlayerInfo [playerid][last_interior] = GetPlayerInterior (playerid);
5379
5380 // GENERAL PLAYER DATA //
5381 mysql_format (mysql, string, sizeof (string), "UPDATE `players` SET ");
5382 strcat (query, string, sizeof (string));
5383
5384 mysql_format (mysql, string, sizeof (string), "`INITIATED` = %d, ", PlayerInfo [playerid][initiated]);
5385 strcat (query, string, sizeof (string));
5386
5387 mysql_format (mysql, string, sizeof (string), "`GENDER` = %d, ", PlayerInfo [playerid][gender]);
5388 strcat (query, string, sizeof (string));
5389
5390 mysql_format (mysql, string, sizeof (string), "`AGE` = %d, ", PlayerInfo [playerid][age]);
5391 strcat (query, string, sizeof (string));
5392
5393 mysql_format (mysql, string, sizeof (string), "`SKIN` = %d, ", PlayerInfo [playerid][skin]);
5394 strcat (query, string, sizeof (string));
5395
5396 mysql_format (mysql, string, sizeof (string), "`HEALTH` = %f, ", PlayerInfo [playerid][health]);
5397 strcat (query, string, sizeof (string));
5398
5399 mysql_format (mysql, string, sizeof (string), "`HUNGER` = %f, ", PlayerInfo [playerid][hunger]);
5400 strcat (query, string, sizeof (string));
5401
5402 mysql_format (mysql, string, sizeof (string), "`THIRST` = %f, ", PlayerInfo [playerid][thirst]);
5403 strcat (query, string, sizeof (string));
5404
5405 mysql_format (mysql, string, sizeof (string), "`JOB` = %d ", PlayerInfo [playerid][job]);
5406 strcat (query, string, sizeof (string));
5407
5408 mysql_format (mysql, string, sizeof (string), "WHERE `ACCOUNT_ID` = %d", PlayerInfo [playerid][account_id]);
5409 strcat (query, string, sizeof (string));
5410
5411 mysql_pquery (mysql, query);
5412
5413 // MORE PAYER DATA //
5414
5415 mysql_format (mysql, query, sizeof (query), "UPDATE `players` SET ");
5416
5417 mysql_format (mysql, string, sizeof (string), "`LAST_X` = %f,", PlayerInfo [playerid][last_x]);
5418 strcat (query, string, sizeof (string));
5419
5420 mysql_format (mysql, string, sizeof (string), "`LAST_Y` = %f,", PlayerInfo [playerid][last_y]);
5421 strcat (query, string, sizeof (string));
5422
5423 mysql_format (mysql, string, sizeof (string), "`LAST_Z` = %f,", PlayerInfo [playerid][last_z]);
5424 strcat (query, string, sizeof (string));
5425
5426 mysql_format (mysql, string, sizeof (string), "`LAST_INTERIOR` = %d,", PlayerInfo [playerid][last_interior]);
5427 strcat (query, string, sizeof (string));
5428
5429 mysql_format (mysql, string, sizeof (string), "`PLAYER_SPAWN` = %d ", PlayerInfo [playerid][player_spawn]);
5430 strcat (query, string, sizeof (string));
5431
5432 mysql_format (mysql, string, sizeof (string), "WHERE `ACCOUNT_ID` = %d", PlayerInfo [playerid][account_id]);
5433 strcat (query, string, sizeof (string));
5434
5435 mysql_pquery (mysql, query);
5436
5437
5438 query [0] = '\0';
5439
5440 // INVENTORY //
5441 mysql_format (mysql, string, sizeof (string), "UPDATE `inventories` SET ");
5442 strcat (query, string);
5443
5444 mysql_format (mysql, string, sizeof (string), "`MAX_SLOTS` = %d, ", PlayerInfo [playerid][inventory_slots]);
5445 strcat (query, string);
5446
5447 mysql_format (mysql, string, sizeof (string), "`MAX_VIRUTAL_SLOTS` = %d, ", PlayerInfo [playerid][inventory_virtual_slots]);
5448 strcat (query, string);
5449
5450 mysql_format (mysql, string, sizeof (string), "`USED_SLOTS` = %d, ", PlayerInfo [playerid][slots_used]);
5451 strcat (query, string);
5452
5453 for (new i = 0; i < PlayerInfo [playerid][inventory_virtual_slots]; i++)
5454 {
5455
5456 mysql_format (mysql, string, sizeof (string), "`SLOT_%d` = '%e'%s ", (i + 1), PlayerInventory [playerid][i][item], (i == (PlayerInfo [playerid][inventory_virtual_slots] - 1) ? ("") : (",")));
5457 strcat (query, string);
5458 }
5459
5460 mysql_format (mysql, string, sizeof (string), "WHERE `ACCOUNT_ID` = %d", PlayerInfo [playerid][account_id]);
5461 strcat (query, string);
5462
5463 mysql_pquery (mysql, query);
5464
5465 return 1;
5466}
5467
5468////////////////////////////////////////////////////////////////////////////////
5469// STOCKS //////////////////////////////////////////////////////////////////////
5470////////////////////////////////////////////////////////////////////////////////
5471
5472stock CreateTables ()
5473{
5474 new string [2500], part [200];
5475
5476 // PLAYER DATA TABLE
5477
5478 strcat (string, "CREATE TABLE IF NOT EXISTS `players` ", sizeof (string));
5479 strcat (string, "(`ACCOUNT_ID` INT (32) NOT NULL AUTO_INCREMENT PRIMARY KEY, ", sizeof (string));
5480 strcat (string, "`NAME` VARCHAR (24), ", sizeof (string));
5481 strcat (string, "`PASSWORD` VARCHAR (32), ", sizeof (string));
5482 strcat (string, "`INITIATED` INT (12) NOT NULL, ", sizeof (string));
5483 strcat (string, "`GENDER` INT (4), ", sizeof (string));
5484 strcat (string, "`AGE` INT (12), ", sizeof (string));
5485 strcat (string, "`SKIN` INT (24), ", sizeof (string));
5486 strcat (string, "`HEALTH` FLOAT (24), ", sizeof (string));
5487 strcat (string, "`HUNGER` FLOAT (24), ", sizeof (string));
5488 strcat (string, "`THIRST` FLOAT (24), ", sizeof (string));
5489 strcat (string, "`JOB` INT (12), ", sizeof (string));
5490 strcat (string, "`LAST_X` FLOAT (16), ", sizeof (string));
5491 strcat (string, "`LAST_Y` FLOAT (16), ", sizeof (string));
5492 strcat (string, "`LAST_Z` FLOAT (16), ", sizeof (string));
5493 strcat (string, "`LAST_INTERIOR` INT (12), ", sizeof (string));
5494 strcat (string, "`PLAYER_SPAWN` INT (12))", sizeof (string));
5495
5496 mysql_query (mysql, string);
5497
5498 string [0] = EOS;
5499
5500 // PLAYER INVENTORY TABLE
5501 strcat (string, "CREATE TABLE IF NOT EXISTS `inventories` ", sizeof (string));
5502
5503 strcat (string, "(`ACCOUNT_ID` INT (32), ", sizeof (string));
5504
5505 strcat (string, "`MAX_SLOTS` INT (16), ", sizeof (string));
5506 strcat (string, "`MAX_VIRTUAL_SLOTS` INT (16), ", sizeof (string));
5507 strcat (string, "`USED_SLOTS` INT (16), ", sizeof (string));
5508
5509
5510 for (new i = 0; i < (MAX_SLOTS); i++)
5511 {
5512 part [0] = '\0';
5513 format (part, sizeof (part), "`SLOT_%d` VARCHAR (32)%s ", (i + 1), ((i == (MAX_SLOTS - 1)) ? (")") : (",")));
5514 strcat (string, part, sizeof (string));
5515 }
5516
5517 mysql_query (mysql, string);
5518
5519 string [0] = EOS;
5520
5521 // VEHICLES
5522 strcat (string, "CREATE TABLE IF NOT EXISTS `vehicles`", sizeof (string));
5523
5524 strcat (string, "(`model` INT (16), ", sizeof (string));
5525
5526 strcat (string, "`color_1` INT (12), ", sizeof (string));
5527 strcat (string, "`color_2` INT (12), ", sizeof (string));
5528
5529 strcat (string, "`engine` INT (12), ", sizeof (string));
5530 strcat (string, "`lights` INT (12), ", sizeof (string));
5531 strcat (string, "`alarms` INT (12), ", sizeof (string));
5532 strcat (string, "`doors` INT (12), ", sizeof (string));
5533 strcat (string, "`bonnet` INT (12), ", sizeof (string));
5534 strcat (string, "`boot` INT (12), ", sizeof (string));
5535
5536 strcat (string, "`d_panels` INT (12), ", sizeof (string));
5537 strcat (string, "`d_doors` INT (12), ", sizeof (string));
5538 strcat (string, "`d_lights` INT (12), ", sizeof (string));
5539 strcat (string, "`d_tires` INT (12), ", sizeof (string));
5540
5541 strcat (string, "`health` FLOAT (16), ", sizeof (string));
5542 strcat (string, "`fuel` FLOAT (16), ", sizeof (string));
5543
5544 strcat (string, "`last_x` FLOAT (16), ", sizeof (string));
5545 strcat (string, "`last_y` FLOAT (16), ", sizeof (string));
5546 strcat (string, "`last_z` FLOAT (16), ", sizeof (string));
5547 strcat (string, "`last_a` FLOAT (16)) ", sizeof (string));
5548
5549 mysql_query (mysql, string);
5550
5551 return 1;
5552}
5553
5554forward OnPlayerCheckDrivingLicense (playerid);
5555public OnPlayerCheckDrivingLicense (playerid)
5556{
5557 new player_name [MAX_PLAYER_NAME + 1];
5558 cache_get_value_name (0, "NAME", player_name, sizeof (player_name));
5559
5560 new string [250];
5561 format (string, sizeof (string), ""COLOR_MAIN_HEX"\n- Badge Owner: "COLOR_WHITE"%s\n", player_name);
5562
5563 ShowPlayerDialog (playerid, PLAYER_BADGE_DIALOG_ID, DIALOG_STYLE_MSGBOX, ""SERVER_TAG" - Player Badge", string, "Ok", "");
5564 return 1;
5565}
5566
5567stock GetServerSlots ()
5568{
5569
5570 if (!fexist ("../../server.cfg"))
5571 {
5572 SERVER_SLOTS = 1000;
5573 return 0;
5574 }
5575
5576 new File: file = fopen ("../../server.cfg", io_read);
5577
5578 new line [124],
5579
5580 cfg_text [24],
5581 data;
5582
5583 while (fread (file, line))
5584 {
5585 if (strfind (line, "maxplayers"))
5586 {
5587 if (!sscanf (line, "s[24]i", cfg_text, data))
5588 {
5589 SERVER_SLOTS = data;
5590 }
5591 }
5592 }
5593
5594 fclose (file);
5595
5596 return 1;
5597}
5598
5599stock ShowLoginDialog (playerid)
5600{
5601 ShowPlayerDialog (playerid, LOGIN_DIALOG_ID, DIALOG_STYLE_PASSWORD, ""SERVER_TAG" - Login", "Password:\n\n(You have "LOGIN_TIME_LIMIT" seconds to login)", "Login", "");
5602 return 1;
5603}
5604
5605stock SetupPlayer (playerid)
5606{
5607
5608 new query [250];
5609 mysql_format (mysql, query, sizeof (query), "INSERT INTO `inventories` (`ACCOUNT_ID`, `MAX_SLOTS`, `MAX_VIRTUAL_SLOTS`, `USED_SLOTS`) VALUES (%d, %d, %d, 0)",
5610 PlayerInfo [playerid][account_id],
5611 PlayerInfo [playerid][inventory_slots],
5612 PlayerInfo [playerid][inventory_virtual_slots]);
5613
5614 mysql_query (mysql, query);
5615
5616 PlayerInfo [playerid][health] = 100.0;
5617 PlayerInfo [playerid][hunger] = 100.0;
5618 PlayerInfo [playerid][thirst] = 100.0;
5619
5620 PlayerInfo [playerid][data_loaded] = 1;
5621
5622 SetPlayerInterior (playerid, 0);
5623 SetPlayerVirtualWorld (playerid, 0);
5624
5625 PlayerInfo [playerid][initiated] = 1;
5626
5627 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"You are all set up, enjoy your survival. ");
5628 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Need help ? Use (/help) for information about the server. ");
5629 SendClientMessage (playerid, COLOR_MAIN, "[INFO] "COLOR_WHITE"Don't forget to read the (/rules). ");
5630 return 1;
5631}
5632
5633stock SpawnAtSelectedSpawnArea (playerid)
5634{
5635 if (PlayerInfo [playerid][player_spawn] == 0)
5636 {
5637 new selected_spawn = random (18);
5638 SetPlayerPos (playerid, LosSantosSpawns [selected_spawn][0], LosSantosSpawns [selected_spawn][1], LosSantosSpawns [selected_spawn][2]);
5639 SetPlayerFacingAngle (playerid, LosSantosSpawns [selected_spawn][3]);
5640 }
5641 else if (PlayerInfo [playerid][player_spawn] == 1)
5642 {
5643 new selected_spawn = random (6);
5644 SetPlayerPos (playerid, PalominoCreekSpawns [selected_spawn][0], PalominoCreekSpawns [selected_spawn][1], PalominoCreekSpawns [selected_spawn][2]);
5645 SetPlayerFacingAngle (playerid, PalominoCreekSpawns [selected_spawn][3]);
5646 }
5647 else if (PlayerInfo [playerid][player_spawn] == 2)
5648 {
5649 new selected_spawn = random (6);
5650 SetPlayerPos (playerid, MontgomerySpawns [selected_spawn][0], MontgomerySpawns [selected_spawn][1], MontgomerySpawns [selected_spawn][2]);
5651 SetPlayerFacingAngle (playerid, MontgomerySpawns [selected_spawn][3]);
5652 }
5653 else if (PlayerInfo [playerid][player_spawn] == 3)
5654 {
5655 new selected_spawn = random (6);
5656 SetPlayerPos (playerid, BlueberrySpawns [selected_spawn][0], BlueberrySpawns [selected_spawn][1], BlueberrySpawns [selected_spawn][2]);
5657 SetPlayerFacingAngle (playerid, BlueberrySpawns [selected_spawn][3]);
5658 }
5659 else if (PlayerInfo [playerid][player_spawn] == 4)
5660 {
5661 new selected_spawn = random (5);
5662 SetPlayerPos (playerid, DillimoreSpawns [selected_spawn][0], DillimoreSpawns [selected_spawn][1], DillimoreSpawns [selected_spawn][2]);
5663 SetPlayerFacingAngle (playerid, DillimoreSpawns [selected_spawn][3]);
5664 }
5665 return 1;
5666}
5667
5668stock ShowProgressBars (playerid)
5669{
5670 if (PlayerInfo [playerid][loaded] == 1)
5671 {
5672 ShowPlayerProgressBar (playerid, HungerBar [playerid]);
5673 ShowPlayerProgressBar (playerid, ThirstBar [playerid]);
5674 }
5675 return 1;
5676}
5677
5678stock HideProgressBars (playerid)
5679{
5680 if (PlayerInfo [playerid][loaded] == 1)
5681 {
5682 HidePlayerProgressBar (playerid, HungerBar [playerid]);
5683 HidePlayerProgressBar (playerid, ThirstBar [playerid]);
5684 }
5685 return 1;
5686}
5687
5688stock UpdateCookingBar (playerid)
5689{
5690 SetPlayerProgressBarValue (playerid, CookingBar [playerid], (100 * PlayerInfo [playerid][cooked] / PlayerInfo [playerid][cooking_time]) * 1.0);
5691 ShowPlayerProgressBar (playerid, CookingBar [playerid]);
5692 return 1;
5693}
5694
5695stock ShowCookingBar (playerid)
5696{
5697 TextDrawShowForPlayer (playerid, CookingTD);
5698 ShowPlayerProgressBar (playerid, CookingBar [playerid]);
5699 return 1;
5700}
5701
5702stock HideCookingBar (playerid)
5703{
5704 TextDrawHideForPlayer (playerid, CookingTD);
5705 HidePlayerProgressBar (playerid, CookingBar [playerid]);
5706 return 1;
5707}
5708
5709stock UpdateCraftingBar (playerid)
5710{
5711 SetPlayerProgressBarValue (playerid, CraftingBar [playerid], (100 * PlayerInfo [playerid][crafted] / PlayerInfo [playerid][crafting_time]) * 1.0);
5712 ShowPlayerProgressBar (playerid, CraftingBar [playerid]);
5713 return 1;
5714}
5715
5716stock ShowCraftingBar (playerid)
5717{
5718 TextDrawShowForPlayer (playerid, CraftingTD);
5719 ShowPlayerProgressBar (playerid, CraftingBar [playerid]);
5720 return 1;
5721}
5722
5723stock HideCraftingBar (playerid)
5724{
5725 TextDrawHideForPlayer (playerid, CraftingTD);
5726 HidePlayerProgressBar (playerid, CraftingBar [playerid]);
5727 return 1;
5728}
5729
5730stock UpdateFuelBar (playerid)
5731{
5732 SetPlayerProgressBarValue (playerid, FuelBar [playerid], VehicleInfo [GetPlayerVehicleID (playerid)][vehicle_fuel]);
5733 return 1;
5734}
5735
5736stock ShowFuelBar (playerid)
5737{
5738 ShowPlayerProgressBar (playerid, FuelBar [playerid]);
5739 return 1;
5740}
5741
5742stock HideFuelBar (playerid)
5743{
5744 HidePlayerProgressBar (playerid, FuelBar [playerid]);
5745 return 1;
5746}
5747
5748stock CreatePlayerProgressBars (playerid)
5749{
5750 HungerBar [playerid] = CreatePlayerProgressBar (playerid, 548, 26.75, 56.5, 5.0, COLOR_HUNGER, 100.0);
5751 ThirstBar [playerid] = CreatePlayerProgressBar (playerid, 548, 36.75, 56.5, 5.0, COLOR_THIRST, 100.0);
5752
5753 SetPlayerProgressBarValue (playerid, HungerBar [playerid], PlayerInfo [playerid][hunger]);
5754 SetPlayerProgressBarValue (playerid, ThirstBar [playerid], PlayerInfo [playerid][thirst]);
5755 return 1;
5756}
5757
5758stock CreatePlayerCookingBar (playerid)
5759{
5760 CookingBar [playerid] = CreatePlayerProgressBar (playerid, 435, 90.0, 56.5, 5.0, COLOR_MAIN, 100.0);
5761 SetPlayerProgressBarValue (playerid, CookingBar [playerid], 0.0);
5762 return 1;
5763}
5764
5765stock CreatePlayerCraftingBar (playerid)
5766{
5767 CraftingBar [playerid] = CreatePlayerProgressBar (playerid, 435, 90.0, 56.5, 5.0, COLOR_MAIN, 100.0);
5768 SetPlayerProgressBarValue (playerid, CookingBar [playerid], 0.0);
5769 return 1;
5770}
5771
5772stock CreatePlayerFuelBar (playerid)
5773{
5774 CreatePlayerProgressBar (playerid, 435, 90.0, 56.5, 5.0, COLOR_MAIN, 100.0);
5775 SetPlayerProgressBarValue (playerid, FuelBar [playerid], 0.0);
5776 return 1;
5777}
5778
5779stock DestroyPlayerProgressBars (playerid)
5780{
5781 DestroyPlayerProgressBar (playerid, HungerBar [playerid]);
5782 DestroyPlayerProgressBar (playerid, ThirstBar [playerid]);
5783 DestroyPlayerProgressBar (playerid, CookingBar [playerid]);
5784 DestroyPlayerProgressBar (playerid, CraftingBar [playerid]);
5785 DestroyPlayerProgressBar (playerid, FuelBar [playerid]);
5786 return 1;
5787}
5788
5789stock CreateGlobalTextDraws ()
5790{
5791 CookingTD = TextDrawCreate(432.666595, 75.511100, "COOKING");
5792 TextDrawLetterSize(CookingTD, 0.347111, 1.346133);
5793 TextDrawAlignment(CookingTD, 1);
5794 TextDrawColor(CookingTD, -5963521);
5795 TextDrawSetShadow(CookingTD, 0);
5796 TextDrawSetOutline(CookingTD, 0);
5797 TextDrawBackgroundColor(CookingTD, 255);
5798 TextDrawFont(CookingTD, 2);
5799 TextDrawSetProportional(CookingTD, 1);
5800 TextDrawSetShadow(CookingTD, 0);
5801
5802 CraftingTD = TextDrawCreate(432.666595, 75.511100, "CRAFTING");
5803 TextDrawLetterSize(CookingTD, 0.347111, 1.346133);
5804 TextDrawAlignment(CookingTD, 1);
5805 TextDrawColor(CookingTD, -5963521);
5806 TextDrawSetShadow(CookingTD, 0);
5807 TextDrawSetOutline(CookingTD, 0);
5808 TextDrawBackgroundColor(CookingTD, 255);
5809 TextDrawFont(CookingTD, 2);
5810 TextDrawSetProportional(CookingTD, 1);
5811 TextDrawSetShadow(CookingTD, 0);
5812 return 1;
5813}
5814
5815stock PickupItem (playerid, itemid, itemamount)
5816{
5817
5818 new message [250],
5819
5820 amount, ammo,
5821
5822 slot, destroy,
5823
5824 s_id, s_type, s_amount, s_ammo, s_status,
5825
5826 items_pickedup;
5827
5828
5829 if (ItemInfo [itemid][item_type] == 6)
5830 {
5831 if (ItemInfo [itemid][item_static_id] == 0)
5832 {
5833 if (ItemInfo [itemid][item_ammo] == 0) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"This item cannot be picked up. ");
5834
5835 format (PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item], 124, "6 0 1 %d -1", ItemInfo [itemid][item_ammo]);
5836 PlayerInfo [playerid][slots_used]++;
5837
5838 SetPlayerAttachedObject (playerid, 2, ItemInfo [itemid][item_model_id], 5, 0.0, 0.0, 0.0, 90.0, 190.0, 110.0, 0.25, 0.25, 0.25);
5839 SetPlayerSpecialAction (playerid, SPECIAL_ACTION_CARRY);
5840
5841 amount = 1;
5842
5843 format (message, sizeof (message), "[INFO] %sYou picked up %d %s", COLOR_WHITE, amount, BigItems [ItemInfo [itemid][item_static_id]][name]);
5844 SendClientMessage (playerid, COLOR_MAIN, message);
5845
5846 ItemInfo [itemid][item_amount]--;
5847
5848 if (ItemInfo [itemid][item_amount] <= 0)
5849 {
5850
5851 DestroyObject (ItemInfo [itemid][item_attached]);
5852
5853 ItemInfo [itemid][item_id] = -1;
5854 ItemInfo [itemid][item_static_id] = -1;
5855 ItemInfo [itemid][item_type] = -1;
5856 ItemInfo [itemid][item_amount] = -1;
5857 ItemInfo [itemid][item_ammo] = -1;
5858 ItemInfo [itemid][item_attached] = -1;
5859
5860 DestroyObject (itemid);
5861
5862 KillTimer (ItemInfo [itemid][item_timer]);
5863 }
5864 }
5865
5866 PlayerInfo [playerid][carrying] = 1;
5867 return 0;
5868 }
5869
5870 if (itemamount == -1)
5871 {
5872 if (ItemInfo [itemid][item_ammo] == -1 && ItemInfo [itemid][item_type] != 8 && ItemInfo [itemid][item_type] != 9 && ItemInfo [itemid][item_type] != 11 && ItemInfo [itemid][item_type] != 12 && ItemInfo [itemid][item_type] != 13)
5873 {
5874 for (new i = 0; i < PlayerInfo [playerid][inventory_virtual_slots]; i++)
5875 {
5876 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
5877 {
5878 if (s_type == ItemInfo [itemid][item_type])
5879 {
5880 if (s_id == ItemInfo [itemid][item_static_id])
5881 {
5882 slot = i;
5883 amount = (s_amount + ItemInfo [itemid][item_amount]);
5884 }
5885 }
5886 }
5887
5888 if (i == PlayerInfo [playerid][slots_used] && amount == 0)
5889 {
5890 slot = PlayerInfo [playerid][slots_used];
5891 amount = ItemInfo [itemid][item_amount];
5892
5893 PlayerInfo [playerid][slots_used]++;
5894 break;
5895 }
5896 }
5897
5898 items_pickedup = 1;
5899
5900 switch (ItemInfo [itemid][item_type])
5901 {
5902 case 8, 9, 11, 12, 13, 14: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -2", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
5903 default: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -1", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
5904 }
5905
5906 }
5907 else
5908 {
5909 if (itemamount > (PlayerInfo [playerid][inventory_virtual_slots] - PlayerInfo [playerid][slots_used])) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Not enough inventory space. ");
5910
5911 slot = PlayerInfo [playerid][slots_used];
5912
5913 amount = 1;
5914 items_pickedup = ItemInfo [itemid][item_amount];
5915 ammo = ItemInfo [itemid][item_ammo];
5916
5917 for (new i = 0; i < items_pickedup; i++)
5918 {
5919 PlayerInfo [playerid][slots_used]++;
5920
5921 switch (ItemInfo [itemid][item_type])
5922 {
5923 case 8, 9, 11, 12, 13, 14: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -2", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
5924 default: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -1", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
5925 }
5926
5927 slot++;
5928 }
5929
5930 }
5931
5932 switch (ItemInfo [itemid][item_type])
5933 {
5934 case 1: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, FoodItems [ItemInfo [itemid][item_static_id]][name]);
5935 case 2: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, MedicalItems [ItemInfo [itemid][item_static_id]][name]);
5936 case 3: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, CookableItems [ItemInfo [itemid][item_static_id]][name]);
5937 case 4: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, ResourceItems [ItemInfo [itemid][item_static_id]][name]);
5938 case 5: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, ToolItems [ItemInfo [itemid][item_static_id]][name]);
5939 case 6: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, BigItems [ItemInfo [itemid][item_static_id]][name]);
5940 case 7: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, MiscItems [ItemInfo [itemid][item_static_id]][name]);
5941 case 8: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, WeaponItems [ItemInfo [itemid][item_static_id]][name]);
5942 case 9: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, MeleeWeaponItems [ItemInfo [itemid][item_static_id]][name]);
5943 case 10: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, AmmoItems [ItemInfo [itemid][item_static_id]][name]);
5944 case 11: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, HeadWearableItems [ItemInfo [itemid][item_static_id]][name]);
5945 case 12: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, BodyWearableItems [ItemInfo [itemid][item_static_id]][wearable_name]);
5946 case 13: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, BackpackItems [ItemInfo [itemid][item_static_id]][name]);
5947 case 14: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, ArmourItems [ItemInfo [itemid][item_static_id]][name]);
5948 }
5949
5950 destroy = 1;
5951 }
5952 else
5953 {
5954 if (ItemInfo [itemid][item_ammo] == -1 && ItemInfo [itemid][item_type] != 8 && ItemInfo [itemid][item_type] != 9 && ItemInfo [itemid][item_type] != 11 && ItemInfo [itemid][item_type] != 12 && ItemInfo [itemid][item_type] != 13)
5955 {
5956 for (new i = 0; i < PlayerInfo [playerid][inventory_virtual_slots]; i++)
5957 {
5958 if (!sscanf (PlayerInventory [playerid][i][item], "iiiii", s_type, s_id, s_amount, s_ammo, s_status))
5959 {
5960 if (s_type == ItemInfo [itemid][item_type])
5961 {
5962 if (s_id == ItemInfo [itemid][item_static_id])
5963 {
5964 slot = i;
5965 amount = (s_amount + itemamount);
5966 }
5967 }
5968 }
5969
5970 if (i == PlayerInfo [playerid][slots_used] && amount == 0)
5971 {
5972 slot = PlayerInfo [playerid][slots_used];
5973 amount = itemamount;
5974
5975 PlayerInfo [playerid][slots_used]++;
5976 break;
5977 }
5978 }
5979
5980 items_pickedup = 1;
5981
5982 switch (ItemInfo [itemid][item_type])
5983 {
5984 case 8, 9, 11, 12, 13, 14: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -2", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
5985 default: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -1", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
5986 }
5987
5988 }
5989 else
5990 {
5991 if (ItemInfo [itemid][item_amount] > (PlayerInfo [playerid][inventory_virtual_slots] - PlayerInfo [playerid][slots_used])) return SendClientMessage (playerid, COLOR_MAIN, "[ERROR] "COLOR_WHITE"Not enough inventory space. ");
5992
5993 slot = PlayerInfo [playerid][slots_used];
5994
5995 amount = 1;
5996 items_pickedup = itemamount;
5997 ammo = ItemInfo [itemid][item_ammo];
5998
5999 ItemInfo [itemid][item_amount] -= amount;
6000 if (ItemInfo [itemid][item_amount] <= 0) { destroy = 1; }
6001
6002 for (new i = 0; i < items_pickedup; i++)
6003 {
6004 PlayerInfo [playerid][slots_used]++;
6005
6006 switch (ItemInfo [itemid][item_type])
6007 {
6008 case 8, 9, 11, 12, 13, 14: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -2", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
6009 default: format (PlayerInventory [playerid][slot][item], 124, "%d %d %d %d -1", ItemInfo [itemid][item_type], ItemInfo [itemid][item_static_id], amount, ammo);
6010 }
6011
6012 slot++;
6013 }
6014
6015 }
6016
6017 switch (ItemInfo [itemid][item_type])
6018 {
6019 case 1: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, FoodItems [ItemInfo [itemid][item_static_id]][name]);
6020 case 2: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, MedicalItems [ItemInfo [itemid][item_static_id]][name]);
6021 case 3: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, CookableItems [ItemInfo [itemid][item_static_id]][name]);
6022 case 4: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, ResourceItems [ItemInfo [itemid][item_static_id]][name]);
6023 case 5: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, ToolItems [ItemInfo [itemid][item_static_id]][name]);
6024 case 6: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, BigItems [ItemInfo [itemid][item_static_id]][name]);
6025 case 7: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, MiscItems [ItemInfo [itemid][item_static_id]][name]);
6026 case 8: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, WeaponItems [ItemInfo [itemid][item_static_id]][name]);
6027 case 9: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, MeleeWeaponItems [ItemInfo [itemid][item_static_id]][name]);
6028 case 10: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, AmmoItems [ItemInfo [itemid][item_static_id]][name]);
6029 case 11: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, HeadWearableItems [ItemInfo [itemid][item_static_id]][name]);
6030 case 12: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, BodyWearableItems [ItemInfo [itemid][item_static_id]][wearable_name]);
6031 case 13: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, BackpackItems [ItemInfo [itemid][item_static_id]][name]);
6032 case 14: format (message, sizeof (message), "[INFO] %sYou picked up %s", COLOR_WHITE, ArmourItems [ItemInfo [itemid][item_static_id]][name]);
6033 }
6034 }
6035
6036 SendClientMessage (playerid, COLOR_MAIN, message);
6037
6038 if (destroy == 1)
6039 {
6040 ItemInfo [itemid][item_id] = -1;
6041 ItemInfo [itemid][item_static_id] = -1;
6042 ItemInfo [itemid][item_type] = -1;
6043 ItemInfo [itemid][item_amount] = -1;
6044 ItemInfo [itemid][item_ammo] = -1;
6045 DestroyObject (itemid);
6046 }
6047 return 1;
6048}
6049
6050stock LoadItems ()
6051{
6052 if (!fexist (CREATED_ITEMS_FILE))
6053 {
6054 new File: file = fopen (CREATED_ITEMS_FILE, io_write);
6055 fclose (file);
6056 }
6057 else
6058 {
6059 new File: file = fopen (CREATED_ITEMS_FILE, io_read),
6060
6061 line [400],
6062
6063 id,
6064 type,
6065 ammo,
6066 model,
6067 amount,
6068 static_id,
6069 Float: p_x,
6070 Float: p_y,
6071 Float: p_z,
6072 Float: r_x,
6073 Float: r_y,
6074 Float: r_z,
6075
6076 item_count,
6077 created_object;
6078
6079 while (fread (file, line))
6080 {
6081 if (!sscanf (line, "iiiiiiffffff", id, static_id, type, amount, ammo, model, p_x, p_y, p_z, r_x, r_y, r_z))
6082 {
6083
6084 created_object = CreateObject (model, p_x, p_y, p_z, r_x, r_y, r_z);
6085
6086 ItemInfo [created_object][item_id] = id;
6087 ItemInfo [created_object][item_type] = type;
6088 ItemInfo [created_object][item_amount] = amount;
6089 ItemInfo [created_object][item_static_id] = static_id;
6090 ItemInfo [created_object][item_model_id] = model;
6091 ItemInfo [created_object][item_ammo] = ammo;
6092
6093 item_count++;
6094 }
6095 }
6096
6097 fclose (file);
6098 }
6099 return 1;
6100}
6101
6102stock RearrangePlayerInventorySlots (playerid, empty_slot)
6103{
6104 PlayerInventory [playerid][empty_slot][item][0] = EOS;
6105
6106 for (new i = empty_slot; i < PlayerInfo [playerid][slots_used]; i++)
6107 {
6108 PlayerInventory [playerid][i][item][0] = EOS;
6109 format (PlayerInventory [playerid][i][item], 124, "%s", PlayerInventory [playerid][i + 1][item]);
6110 }
6111
6112 PlayerInventory [playerid][PlayerInfo [playerid][slots_used]][item] = EOS;
6113 PlayerInfo [playerid][slots_used]--;
6114 return 1;
6115}
6116
6117stock RearrangeActorInventorySlots (actorid, empty_slot)
6118{
6119 ActorInventory [actorid][empty_slot][item][0] = EOS;
6120
6121 for (new i = empty_slot; i < ActorSlotsUsed [actorid]; i++)
6122 {
6123 ActorInventory [actorid][i][item][0] = EOS;
6124 format (ActorInventory [actorid][i][item], 124, "%s", ActorInventory [actorid][i + 1][item]);
6125 }
6126
6127 ActorInventory [actorid][ActorSlotsUsed [actorid]][item][0] = EOS;
6128 ActorSlotsUsed [actorid]--;
6129
6130 if (ActorSlotsUsed [actorid] == 0)
6131 {
6132 DestroyActor (actorid);
6133 }
6134 return 1;
6135}
6136
6137stock IsPointInRangeOfPoint(Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, Float:range)
6138{
6139 x2 -= x;
6140 y2 -= y;
6141 z2 -= z;
6142 return ((x2 * x2) + (y2 * y2) + (z2 * z2)) < (range * range);
6143}