· 7 years ago · Jan 06, 2019, 08:00 PM
1
2
3/*
4 Knogles Last Bed Standing Masterpiece for SA-MP
5 Fork of Minecrafts Bedwars
6 Little TDM Gamemode
7 Published under GNU GPL Public License.
8 Copyright (C) 2017 Fabian Druschke
9 Contact: webmaster@knogleinsi.de
10 Mail: Postfach 32 22 50147 Kerpen Germany
11
12 This program is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see http://www.gnu.org/licenses/
24
25*/
26
27#include <a_samp>
28#include <sscanf2>
29#include <a_mysql>
30#include <YSI\y_ini>
31
32#define MYSQL_HOST "debian " // Change this to your MySQL Remote IP or "localhost".
33#define MYSQL_USER "server" // Change this to your MySQL Database username.
34#define MYSQL_PASS "Hollywood" // Change this to your MySQL Database password.
35#define MYSQL_DATABASE "samp" // Change this to your MySQL Database name.
36
37
38#define DIALOG_REGISTER (0)
39#define DIALOG_LOGIN (1)
40
41
42new MySQL: Database, Corrupt_Check[MAX_PLAYERS];
43
44enum
45{
46 CHILLIAD,
47 SAN_FIERRO_DOCKS,
48 BONE_COUNTY,
49 MAD_DOGGS,
50 COUNTRYSIDE_1,
51 GREEN_PALMS,
52 COUNTRYSIDE_2
53};
54
55
56enum pInfo
57{
58 ID,
59 pName[25],
60
61 pPass[65],
62 Salt[11],
63 pAdmin,
64 pPassFails,
65
66 pKills,
67 pDeaths,
68
69 pBeds,
70 pBombs,
71
72 Cache: Player_Cache,
73 bool:LoggedIn
74}
75
76new playerdataInfo[MAX_PLAYERS][pInfo];
77
78enum
79{
80 INVALID_PICKUP_TYPE,
81 MONEY_TYPE,
82 ACTOR_TYPE,
83 INFO_TYPE
84};
85enum weather_info
86{
87 wt_id,
88 wt_text[255]
89};
90
91#define MAPTYPE BONE_COUNTY
92
93#define PATH "/Users/%s.ini"
94#define PRESSED(%0) \
95 (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
96
97#define FIRST_TEAM 0
98#define SECOND_TEAM 1
99#define THIRD_TEAM 2
100#define FOURTH_TEAM 3
101#define FIFTH_TEAM 4
102#define SIXTH_TEAM 5
103#define TEAM_SPECTATOR 6
104
105#define ADMIN_SPEC_TYPE_NONE 0
106#define ADMIN_SPEC_TYPE_PLAYER 1
107#define ADMIN_SPEC_TYPE_VEHICLE 2
108#define COLOR_WHITE 0xFFFFFFFF
109#define COLOR_NORMAL_PLAYER 0xFFBB7777
110#define COLOR_GREY 0xAFAFAFAA
111#define COLOR_RED 0xAA3333AA
112#define COLOR_GREEN 0x33AA33AA
113#define COLOR_YELLOW 0xFFFF0055
114#define COLOR_BLUE 0x0000BBAA
115#define COLOR_NAVY 0x000080AA
116
117#define SPECTATOR_TEAM_COLOR_TAG "{FFFFFF}SPECTATOR"
118
119#define MoneyVal 1000
120#define UnusedVehTimer 300000 //time in ms to respawn unoccupied vehicles
121#define SCORESYSTEM 1
122
123
124
125
126#define DIALOG_REGISTER (0)
127#define DIALOG_LOGIN (1)
128
129//Register/Login system is enabled by default
130
131
132
133
134//----------------------------------------------------------
135forward WeatherTimer();
136forward GMX();
137forward RespawnAllVehicles();
138forward RandomWeather();
139forward SaveUser_data(playerid);
140forward ResetPlayerData(playerid);
141forward warpcount(playerid);
142forward TeleportPlayerToBase(playerid);
143forward reveal(playerid);
144forward quickSort(array[], left, right);
145forward PrepareToBlowUp(playerid);
146forward GetPickupType(pickupid, &index);
147forward Float:frandom(Float:max, Float:min = 0.0, dp = 4);
148forward GetXYInFrontOfActor(actorid, &Float:x, &Float:y, Float:distance);
149forward GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);
150forward Float:GetDistance( Float:a1, Float:b1, Float:c1, Float:a2, Float:b2, Float:c2 );
151forward GenerateRandomPickup(modelid,type,Float:x_max,Float:x_min,Float:y_max,Float:y_min,Float:z_max,Float:z_min,virtualworld);
152forward LoadUser_data(playerid,name[],value[]);
153forward MONEY_MAIN();
154forward TEAM_MONEY();
155forward BlowUpThisBed();
156forward SendTeamMessage(teamid, color, const message[]);
157forward SellPlayerFightingStyle(playerid,cost,style);
158forward SellPlayerWeapon(playerid,cost,weaponid,ammo);
159forward SpecPlayer(playerid,targetplayer);
160forward UpdateTimeAndWeather();
161forward CountDown();
162//----------------------------------------------------------
163new Warppowder[MAX_PLAYERS];
164new PBeds[MAX_PLAYERS];
165new PKills[MAX_PLAYERS];
166new PSkill[MAX_PLAYERS];
167new PBomb[MAX_PLAYERS];
168new LastMoney[MAX_PLAYERS];
169new PStealth[MAX_PLAYERS];
170new Float:SpecX[MAX_PLAYERS], Float:SpecY[MAX_PLAYERS], Float:SpecZ[MAX_PLAYERS], vWorld[MAX_PLAYERS], Inter[MAX_PLAYERS];
171new IsSpecing[MAX_PLAYERS], Name[MAX_PLAYER_NAME], IsBeingSpeced[MAX_PLAYERS],spectatorid[MAX_PLAYERS];
172new Float:pX[MAX_PLAYERS];
173new Float:pY[MAX_PLAYERS];
174new Float:pZ[MAX_PLAYERS];
175new Float:wX[MAX_PLAYERS];
176new Float:wY[MAX_PLAYERS];
177new Float:wZ[MAX_PLAYERS];
178new SpectatingPlayer[MAX_PLAYERS];
179new PBombID[MAX_PLAYERS];
180new Beam[MAX_PLAYERS];
181new gPlayerTeamSelection[MAX_PLAYERS];
182new gPlayerHasTeamSelected[MAX_PLAYERS];
183new gPlayerLastTeamSelectionTick[MAX_PLAYERS];
184new PlayerInfo[MAX_PLAYERS][pInfo];
185new Helmet[MAX_PLAYERS];
186new BombObject[MAX_PLAYERS];
187new timestr[32];
188new timestrex[32];
189new delay=1000;// only allow new selection every ~1000 ms; may differ due to server load
190new bombtimer=5000;// time in ms to blow up closest bed
191new MoneyDropTimer=2500;// Time to generate new moneypickups
192new Shop_Counter;
193
194//--------------------------------------------------------------
195
196new totaltime;
197new gRandomWeatherIDs[][weather_info] =
198{
199 {1,"Sunny"},
200 {8,"Stormy"},
201 {9,"Foggy Sky"},
202 {11,"Extreme Sunny"},
203 {16,"Rainy"},
204 {19,"Thunderstorm"},
205 {20,"Foggy"}
206};
207
208
209
210//--------------------------------------------------------------
211new Menu:infomenu;
212new Menu:fightstyles;
213new Menu:shotguns;
214new Menu:items;
215new Menu:smg;
216new Menu:rifles;
217new Menu:yesno;
218new Menu:assaultrifle;
219new Menu:Grenades;
220new Menu:melee;
221new Menu:special;
222new Menu:shopmenu;
223new Menu:ammunation;
224new Menu:pistols;
225new Menu:microsmg;
226//--------------------------------------------------------------
227new Text:txtSpectatorHelper;
228new Text:txtClassSelHelper;
229new Text:txtTimeDisp;
230new Text:Textcover;
231new PlayerText:TeamCover[MAX_PLAYERS];
232new PlayerText:TeamText[MAX_PLAYERS];
233new PlayerText:LocText[MAX_PLAYERS];
234//--------------------------------------------------------------
235new moneyval;
236new maxmoney;
237new Float:x1, Float:y1, Float:z1;
238new running;
239new CountDownVar = 4;
240new WarpVar[MAX_PLAYERS];
241new WarpTimer;
242new CountDownTimer;
243new hour, minute;
244//--------------------------------------------------------------
245stock udb_hash(buf[]) {
246 new length=strlen(buf);
247 new s1 = 1;
248 new s2 = 0;
249 new n;
250 for (n=0; n<length; n++)
251 {
252 s1 = (s1 + buf[n]) % 65521;
253 s2 = (s2 + s1) % 65521;
254 }
255 return (s2 << 16) + s1;
256}
257
258#if defined MAPTYPE
259#if MAPTYPE==CHILLIAD
260#include <chilliad.pwn>
261#elseif MAPTYPE==BONE_COUNTY
262#include <bone_county.pwn>
263#elseif MAPTYPE==SAN_FIERRO_DOCKS
264#include <../../gamemodes/san_fierro_docks.pwn>
265#elseif MAPTYPE==MAD_DOGGS
266#include <mad_doggs.pwn>
267#elseif MAPTYPE==GREEN_PALMS
268#include <green_palms.pwn>
269#elseif MAPTYPE==COUNTRYSIDE_1
270#include <countryside_1.pwn>
271#elseif MAPTYPE==COUNTRYSIDE_2
272#include <countryside_2.pwn>
273#endif
274#endif
275
276#if defined TEAMSIZE
277#if TEAMSIZE > 6
278#error Amount of Teams is limited to 6!
279#endif
280#if TEAMSIZE < 2
281#error Minimum Amount of Teams is limited to 2!
282#endif
283#endif
284#if defined SCORESYSTEM
285#if SCORESYSTEM > 1
286#error Scoresystem val must be 0 or 1 (false true)
287#endif
288#if SCORESYSTEM < 0
289#error Scoresystem val must be 0 or 1 (false true)
290#endif
291#endif
292
293#define getInv(%0) (((%0)>>8)<<8)
294
295#define COLOR_TEAM_ONE_STEALTH getInv(COLOR_TEAM_ONE) //Brown
296#define COLOR_TEAM_TWO_STEALTH getInv(COLOR_TEAM_TWO) //Jade
297#define COLOR_TEAM_THREE_STEALTH getInv(COLOR_TEAM_THREE) //Olive
298#define COLOR_TEAM_FOUR_STEALTH getInv(COLOR_TEAM_FOUR) //Aqua
299#define COLOR_TEAM_FIVE_STEALTH getInv(COLOR_TEAM_FIVE) //Olive
300#define COLOR_TEAM_SIX_STEALTH getInv(COLOR_TEAM_SIX) //Aqua
301
302//Never change these lines below if you don't know what to do
303new ActorPickups[sizeof(GlobalActors)];
304new InfoPickups[sizeof(PlayerInfoPickups)];
305new MoneyPickups[MAX_PICKUPS-sizeof(ActorPickups)-sizeof(InfoPickups)-1];
306//
307
308#define BYTECOUNT (cellbits / 8)
309
310stock binarysearch(a[],key,l,r)
311{
312 new k;
313 while(r >=l)
314 {
315 k = (l+r)/2;
316 if(key == a[k])
317 {
318 return k;
319 }
320 if(key < a[k])
321 {
322 r = k-1;
323 }
324 else
325 {
326 l= k+1;
327 }
328 }
329 return -1;
330}
331stock binarysearch2(a[][],idx,key,l,r)
332{
333 new k;
334 while(r >=l)
335 {
336 k = (l+r)/2;
337 if(key == a[k][idx])
338 {
339 return k;
340 }
341 if(key < a[k][idx])
342 {
343 r = k-1;
344 }
345 else
346 {
347 l= k+1;
348 }
349 }
350 return -1;
351}
352
353stock SendClientMessageEx(playerid, color, fstring[], {Float, _}:...)
354{
355 static const
356 ARGC = 3;
357 new n = (numargs() - ARGC) * BYTECOUNT;
358 if (n)
359 {
360 new message[128], arg_start, arg_end;
361 #emit CONST.alt fstring
362 #emit LCTRL 5
363 #emit ADD
364 #emit STOR.S.pri arg_start
365 #emit LOAD.S.alt n
366 #emit ADD
367 #emit STOR.S.pri arg_end
368 do
369 {
370 #emit LOAD.I
371 #emit PUSH.pri
372 arg_end -= BYTECOUNT;
373 #emit LOAD.S.pri arg_end
374 }
375 while (arg_end > arg_start);
376 #emit PUSH.S fstring
377 #emit PUSH.C 128
378 #emit PUSH.ADR message
379 n += BYTECOUNT * 3;
380 #emit PUSH.S n
381 #emit SYSREQ.C format
382 n += BYTECOUNT;
383 #emit LCTRL 4
384 #emit LOAD.S.alt n
385 #emit ADD
386 #emit SCTRL 4
387 return SendClientMessage(playerid, color, message);
388 }
389 else
390 {
391 return SendClientMessage(playerid, color, fstring);
392 }
393}
394
395new TEAM_ZONE_ONE;
396new TEAM_ZONE_TWO;
397
398#if defined TEAMSIZE
399#if TEAMSIZE >=3
400new TEAM_ZONE_THREE;
401#endif
402#endif
403#if defined TEAMSIZE
404#if TEAMSIZE >=4
405new TEAM_ZONE_FOUR;
406#endif
407#endif
408#if defined TEAMSIZE
409#if TEAMSIZE >=5
410new TEAM_ZONE_FIVE;
411#endif
412#endif
413#if defined TEAMSIZE
414#if TEAMSIZE == 6
415new TEAM_ZONE_SIX;
416#endif
417#endif
418
419
420new BED_STATE_TEAM_ONE;
421new BED_STATE_TEAM_TWO;
422
423#if defined TEAMSIZE
424#if TEAMSIZE >=3
425new BED_STATE_TEAM_THREE;
426#endif
427#endif
428#if defined TEAMSIZE
429#if TEAMSIZE >=4
430new BED_STATE_TEAM_FOUR;
431#endif
432#endif
433#if defined TEAMSIZE
434#if TEAMSIZE >=5
435new BED_STATE_TEAM_FIVE;
436#endif
437#endif
438#if defined TEAMSIZE
439#if TEAMSIZE ==6
440new BED_STATE_TEAM_SIX;
441#endif
442#endif
443
444public OnGameModeExit()
445{
446 for(new i = 0; i < MAX_PLAYERS; i++)
447 {
448 if(IsPlayerConnected(i)) // Checking if the players stored in "i" are connected.
449 {
450 OnPlayerDisconnect(i, 1); // We do that so players wouldn't lose their data upon server's close.
451 }
452 }
453
454 mysql_close(Database); // Closing the database.
455 return 1;
456}
457public OnGameModeInit()
458{
459 CreateObject(1829,243.1000100,1804.9000000,6.9000000,0.0000000,0.0000000,0.0000000); //object(man_safenew) (1) //Generic skin selection
460
461 mysql_log(ALL);
462 new MySQLOpt: option_id = mysql_init_options();
463 mysql_set_option(option_id, AUTO_RECONNECT, true); // We will set that option to automatically reconnect on timeouts.
464 mysql_set_option(option_id,SERVER_PORT,3306);
465
466 Database = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DATABASE, option_id); // Setting up the "Database" handle on the given MySQL details above.
467
468 if(Database == MYSQL_INVALID_HANDLE || mysql_errno(Database) != 0) // Checking if the database connection is invalid to shutdown.
469 {
470 print("I couldn't connect to the MySQL server, closing."); // Printing a message to the log.
471
472 sleep(5);
473
474 SendRconCommand("exit"); // Sending console command to shut down server.
475 return 1;
476 }
477
478 print("I have connected to the MySQL server."); // If the given MySQL details were all okay, this message prints to the log.
479
480 // Now, we will set up the information table of the player's information.
481
482 mysql_tquery(Database, "CREATE TABLE IF NOT EXISTS `PLAYERS` (`ID` int(11) NOT NULL AUTO_INCREMENT,`USERNAME` varchar(24) NOT NULL,`PASSWORD` char(65) NOT NULL,`SALT` char(11) NOT NULL,`BEDS` mediumint(7), `KILLS` mediumint(7), `BOMBS` mediumint(7) NOT NULL DEFAULT '0',`DEATHS` mediumint(7) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), UNIQUE KEY `USERNAME` (`USERNAME`))");
483
484
485
486 #if defined MAPTYPE
487 #if MAPTYPE==CHILLIAD
488 #tryinclude <chilliad_vehicles.txt>
489 #tryinclude <chilliad_objects.txt>
490 #elseif MAPTYPE==BONE_COUNTY
491 #tryinclude <bone_vehicles.txt>
492 #tryinclude <bone_objects.txt>
493 #elseif MAPTYPE==MAD_DOGGS
494 #tryinclude <md_vehicles.txt>
495 #tryinclude <md_objects.txt>
496 #elseif MAPTYPE==SAN_FIERRO_DOCKS
497 #tryinclude <sf_vehicles.txt>
498 #tryinclude <sf_objects.txt>
499 #elseif MAPTYPE==GREEN_PALMS
500 #tryinclude <gp_vehicles.txt>
501 #tryinclude <gp_objects.txt>
502 #elseif MAPTYPE==COUNTRYSIDE_1
503 #tryinclude <cs_vehicles.txt>
504 #tryinclude <cs_objects.txt>
505 #elseif MAPTYPE==COUNTRYSIDE_2
506 #tryinclude <cs2_vehicles.txt>
507 #tryinclude <cs2_objects.txt>
508 #endif
509 #endif
510
511
512
513 for(new t;t<sizeof(MoneyPickups);t++)
514 {
515 MoneyPickups[t]=-1;
516 }
517 for(new d;d<sizeof(ActorPickups);d++)
518 {
519 ActorPickups[d]=-1;
520 }
521 for(new f;f<sizeof(InfoPickups);f++)
522 {
523 InfoPickups[f]=-1;
524 }
525
526 SendRconCommand("mapname "#MAPTYPE);
527
528 SetTimer("RespawnAllVehicles",UnusedVehTimer, 1);
529 SetTimer("RandomWeather", 300000, 1);
530
531 #if defined TEAMSIZE
532 #if TEAMSIZE >=2
533 TEAM_ZONE_ONE = GangZoneCreate(GlobalZones[0][0],GlobalZones[0][1],GlobalZones[0][2],GlobalZones[0][3]);
534 TEAM_ZONE_TWO = GangZoneCreate(GlobalZones[1][0],GlobalZones[1][1],GlobalZones[1][2],GlobalZones[1][3]);
535 #endif
536 #endif
537 #if defined TEAMSIZE
538 #if TEAMSIZE >=3
539 TEAM_ZONE_THREE = GangZoneCreate(GlobalZones[2][0],GlobalZones[2][1],GlobalZones[2][2],GlobalZones[2][3]);
540 #endif
541 #endif
542 #if defined TEAMSIZE
543 #if TEAMSIZE >=4
544 TEAM_ZONE_FOUR = GangZoneCreate(GlobalZones[3][0],GlobalZones[3][1],GlobalZones[3][2],GlobalZones[3][3]);
545 #endif
546 #endif
547 #if defined TEAMSIZE
548 #if TEAMSIZE >=5
549 TEAM_ZONE_FIVE = GangZoneCreate(GlobalZones[4][0],GlobalZones[4][1],GlobalZones[4][2],GlobalZones[4][3]);
550 #endif
551 #endif
552 #if defined TEAMSIZE
553 #if TEAMSIZE >=6
554 TEAM_ZONE_SIX = GangZoneCreate(GlobalZones[5][0],GlobalZones[5][1],GlobalZones[5][2],GlobalZones[5][3]);
555 #endif
556 #endif
557
558 for(new g=0;g<sizeof(GlobalActors);g++)
559 {
560 CreateGlobalActor(g+1,274,GlobalActors[g][0],GlobalActors[g][1],GlobalActors[g][2],GlobalActors[g][3],3.0,g);
561 SetActorInvulnerable(g+1, true);
562 }
563 for(new t=0;t<sizeof(InfoPickups);t++)
564 {
565 InfoPickups[t]=CreatePickup(1239,2,PlayerInfoPickups[t][0],PlayerInfoPickups[t][1],PlayerInfoPickups[t][2],0);
566 }
567
568
569
570
571 infomenu = CreateMenu("Information", 1,20,200,200);
572 if(IsValidMenu(infomenu)){
573 AddMenuItem(infomenu, 0, "How to play");
574 AddMenuItem(infomenu, 0, "FAQ");
575 AddMenuItem(infomenu, 0, "Rules");
576 }
577 shopmenu = CreateMenu("Ammu-Nation", 1,20,200,200);
578 if(IsValidMenu(shopmenu)){
579 AddMenuItem(shopmenu, 0, "Weapons");
580 AddMenuItem(shopmenu, 0, "Improve Skill");
581 AddMenuItem(shopmenu, 0, "Stealth $85000");
582 AddMenuItem(shopmenu, 0, "Bomb $100000");
583 AddMenuItem(shopmenu, 0, "Warpkit $50000");
584 AddMenuItem(shopmenu, 0, "Helmet $5000");
585 AddMenuItem(shopmenu, 0, "Suicide");
586 }
587 yesno=CreateMenu("~w~Confirmation",1,20,150,150);
588 if(IsValidMenu(yesno)){
589 SetMenuColumnHeader(yesno, 0, "Suicide");
590 AddMenuItem(yesno, 0, "Yes");
591 AddMenuItem(yesno, 0, "No");
592 AddMenuItem(yesno, 0, "Back");
593 }
594 ammunation=CreateMenu("~w~Weaponlist",1,20,150,150);
595 if(IsValidMenu(ammunation)){
596 SetMenuColumnHeader(ammunation, 0, "Weapon Type");
597 AddMenuItem(ammunation,0," Pistols");
598 AddMenuItem(ammunation,0," Micro SMG");
599 AddMenuItem(ammunation,0," Shotguns");
600 AddMenuItem(ammunation,0," Misc");
601 AddMenuItem(ammunation,0," SMG");
602 AddMenuItem(ammunation,0," Rifles");
603 AddMenuItem(ammunation,0," Assault rifle");
604 AddMenuItem(ammunation,0," Grenades");
605 AddMenuItem(ammunation,0," Hand Guns");
606 AddMenuItem(ammunation,0," Special");
607 AddMenuItem(ammunation, 0, "Back");
608 }
609 pistols=CreateMenu("~w~Ammu-Nation",1,20,150,150);
610 if(IsValidMenu(pistols)){
611 SetMenuColumnHeader(pistols, 0, "Pistole");
612 AddMenuItem(pistols,0," 9mm $1500");
613 AddMenuItem(pistols,0," 9mm Silenced $2500");
614 AddMenuItem(pistols,0," Desert Eagle $2500");
615 AddMenuItem(pistols, 0, "Back");
616 }
617 microsmg=CreateMenu("~w~Ammu-Nation",1,20,150,150);
618 if(IsValidMenu(microsmg)){
619 SetMenuColumnHeader(microsmg, 0, "Micro SMG");
620 AddMenuItem(microsmg,0," Tec9 $5500");
621 AddMenuItem(microsmg,0," Micro SMG $5000");
622 AddMenuItem(microsmg, 0, "Back");
623 }
624 shotguns=CreateMenu("~w~Ammu-Nation",1,20,150,150);
625 if(IsValidMenu(shotguns)){
626 SetMenuColumnHeader(shotguns, 0, "Shotguns");
627 AddMenuItem(shotguns,0," Shotgun $12500");
628 AddMenuItem(shotguns,0," Sawn Off $15500");
629 AddMenuItem(shotguns,0," Combat Shotgun $55500");
630 AddMenuItem(shotguns, 0, "Back");
631 }
632 items=CreateMenu("~w~Ammu-Nation",1,20,150,150);
633 if(IsValidMenu(items)){
634 SetMenuColumnHeader(items, 0, "Item");
635 AddMenuItem(items,0," Armour $2500");
636 AddMenuItem(items,0," Parachute $2500");
637 AddMenuItem(items,0," Spraycan $2500");
638 AddMenuItem(items,0," Camera $2500");
639 AddMenuItem(items,0," Health $2500");
640 AddMenuItem(items,0," Fightstyles");
641 AddMenuItem(items,0,"Back");
642 }
643 fightstyles=CreateMenu("~w~Ammu-Nation",1,20,150,150);
644 if(IsValidMenu(fightstyles)){
645 SetMenuColumnHeader(fightstyles, 0, "Fightstyles");
646 AddMenuItem(fightstyles,0," Kung Fu $2500");
647 AddMenuItem(fightstyles,0," Kneehead $2500");
648 AddMenuItem(fightstyles,0," Boxing $2500");
649 AddMenuItem(fightstyles,0," Grabkick $2500");
650 AddMenuItem(fightstyles,0," Elbow $2500");
651 AddMenuItem(fightstyles,0," Normal");
652 AddMenuItem(fightstyles,0,"Back");
653 }
654 smg=CreateMenu("~w~Ammu-Nation",1,30,150,150);
655 if(IsValidMenu(smg)){
656 SetMenuColumnHeader(smg, 0, "SMG");
657 AddMenuItem(smg,0," SMG $20000");
658 AddMenuItem(smg, 0, "Back");
659 }
660 rifles=CreateMenu("~w~Ammu-Nation",1,20,150,150);
661 if(IsValidMenu(rifles)){
662 SetMenuColumnHeader(rifles, 0, "Rifle");
663 AddMenuItem(rifles,0," Cunt Gun $12500");
664 AddMenuItem(rifles,0," Sniper Rifle $40000");
665 AddMenuItem(rifles, 0, "Back");
666 }
667 assaultrifle=CreateMenu("~w~Ammu-Nation",1,20,150,150);
668 if(IsValidMenu(assaultrifle)){
669 SetMenuColumnHeader(assaultrifle, 0, "Assault Rifle");
670 AddMenuItem(assaultrifle,0," AK-47 $40000");
671 AddMenuItem(assaultrifle,0," M4 $45000");
672 AddMenuItem(assaultrifle, 0, "Back");
673 }
674 special=CreateMenu("~w~Ammu-Nation",1,20,150,150);
675 if(IsValidMenu(special)){
676 SetMenuColumnHeader(special, 0, "special");
677 AddMenuItem(special,0," Minigun $2000000");
678 AddMenuItem(special,0," Bazooka $250000");
679 AddMenuItem(special,0," Flame Thrower $250000");
680 AddMenuItem(special, 0, "Back");
681 }
682 melee=CreateMenu("~w~Ammu-Nation",1,20,150,150);
683 if(IsValidMenu(melee)){
684 SetMenuColumnHeader(melee, 0, "Hand Guns");
685 AddMenuItem(melee,0," Baseball");
686 AddMenuItem(melee,0," Dildo");
687 AddMenuItem(melee,0," Chainsaw $100000");
688 AddMenuItem(melee,0," Katana");
689 AddMenuItem(melee,0," Pool cue");
690 AddMenuItem(melee,0," Knife");
691 AddMenuItem(melee,0," Night Stick");
692 AddMenuItem(melee,0," Golf Club");
693 AddMenuItem(melee, 0, "Back");
694 }
695 Grenades=CreateMenu("~w~Ammu-Nation",1,20,150,150);
696 if(IsValidMenu(Grenades)){
697 SetMenuColumnHeader(Grenades, 0, "Grenades");
698 AddMenuItem(Grenades,0," Grenades $125000");
699 AddMenuItem(Grenades,0," Tear Gas $25000");
700 AddMenuItem(Grenades,0," Molotovs $25000");
701 AddMenuItem(Grenades, 0, "Back");
702 }
703
704
705 SetTimer("TEAM_MONEY", MoneyDropTimer, true);
706 SetTimer("MONEY_MAIN", 1000, true);
707
708
709
710
711
712 UpdateTimeAndWeather();
713 SetTimer("UpdateTimeAndWeather",1000 * 60,1);
714 SetGameModeText("Bedwars");
715 ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL);
716 ShowNameTags(1);
717 SetNameTagDrawDistance(40.0);
718 EnableStuntBonusForAll(0);
719 SetWeather(2);
720
721
722 UsePlayerPedAnims();
723
724
725 ClassSel_InitTextDraws();
726
727 // Player Classes/
728 for(new a=299; a!=0;a--)
729 {
730 AddPlayerClass(a,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
731 }
732
733 txtSpectatorHelper = TextDrawCreate(10.0, 415.0,
734 " Press ~b~~k~~GO_LEFT~ ~w~or ~b~~k~~GO_RIGHT~ ~w~to switch between players.");
735 TextDrawUseBox(txtSpectatorHelper, 1);
736 TextDrawBoxColor(txtSpectatorHelper,0x22222266);
737 TextDrawLetterSize(txtSpectatorHelper,0.3,1.0);
738 TextDrawTextSize(txtSpectatorHelper,400.0,40.0);
739 TextDrawFont(txtSpectatorHelper, 2);
740 TextDrawSetShadow(txtSpectatorHelper,0);
741 TextDrawSetOutline(txtSpectatorHelper,1);
742 TextDrawBackgroundColor(txtSpectatorHelper,0x000000FF);
743 TextDrawColor(txtSpectatorHelper,0xFFFFFFFF);
744
745 txtTimeDisp = TextDrawCreate(605.0,25.0,"00:00");
746 TextDrawUseBox(txtTimeDisp, 0);
747 TextDrawFont(txtTimeDisp, 3);
748 TextDrawSetShadow(txtTimeDisp,0); // no shadow
749 TextDrawSetOutline(txtTimeDisp,2); // thickness 1
750 TextDrawBackgroundColor(txtTimeDisp,0x000000FF);
751 TextDrawColor(txtTimeDisp,0xFFFFFFFF);
752 TextDrawAlignment(txtTimeDisp,3);
753 TextDrawLetterSize(txtTimeDisp,0.5,1.5);
754 return 1;
755}
756stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
757{
758 new Float:a;
759 GetPlayerPos(playerid, x, y, a);
760 GetPlayerFacingAngle(playerid, a);
761 if (GetPlayerVehicleID(playerid))
762 {
763 GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
764 }
765 x += (distance * floatsin(-a, degrees));
766 y += (distance * floatcos(-a, degrees));
767}
768stock Float:frandom(Float:max, Float:min = 0.0, dp = 4)
769{
770 new
771Float:mul = floatpower(10.0, dp),
772 imin = floatround(min * mul),
773 imax = floatround(max * mul);
774 return float(random(imax - imin) + imin) / mul;
775}
776
777public RandomWeather()
778{
779 new rand = random(sizeof(gRandomWeatherIDs));
780 new strout[256];
781 format(strout, sizeof(strout), "Weather changed to %s", gRandomWeatherIDs[rand][wt_text]);
782 SetWeather(gRandomWeatherIDs[rand][wt_id]);
783 SendClientMessageToAll(COLOR_WHITE,strout);
784 print(strout);
785}
786
787
788stock TeleportPlayerToBase(playerid)
789{
790 #if defined TEAMSIZE
791 #if TEAMSIZE >= 2
792 new randSpawn=0;
793 switch(gPlayerTeamSelection[playerid])
794 {
795 case FIRST_TEAM:
796 {
797 new str[80];
798 randSpawn = random(sizeof(gSpawnsTeam_TEAM_ONE));
799 format(str,sizeof(str),"SERVER: You have been teleported to the base of your team "#FIRST_TEAM_COLOR_TAG);
800 SendClientMessage(playerid,COLOR_WHITE,str);
801 SetPlayerPos(playerid,
802 gSpawnsTeam_TEAM_ONE[randSpawn][0],
803 gSpawnsTeam_TEAM_ONE[randSpawn][1],
804 gSpawnsTeam_TEAM_ONE[randSpawn][2]);
805 }
806 case SECOND_TEAM:
807 {
808 new str[80];
809 randSpawn = random(sizeof(gSpawnsTeam_TEAM_TWO));
810 format(str,sizeof(str),"SERVER: You have been teleported to the base of your team "#SECOND_TEAM_COLOR_TAG);
811 SendClientMessage(playerid,COLOR_WHITE,str);
812 SetPlayerPos(playerid,
813 gSpawnsTeam_TEAM_TWO[randSpawn][0],
814 gSpawnsTeam_TEAM_TWO[randSpawn][1],
815 gSpawnsTeam_TEAM_TWO[randSpawn][2]);
816 }
817
818
819 #endif
820 #endif
821 #if defined TEAMSIZE
822 #if TEAMSIZE >= 3
823
824
825 case THIRD_TEAM:
826 {
827 new str[80];
828 randSpawn = random(sizeof(gSpawnsTeam_TEAM_THREE));
829 format(str,sizeof(str),"SERVER: You have been teleported to the base of your team "#THIRD_TEAM_COLOR_TAG);
830 SendClientMessage(playerid,COLOR_WHITE,str);
831 SetPlayerPos(playerid,
832 gSpawnsTeam_TEAM_THREE[randSpawn][0],
833 gSpawnsTeam_TEAM_THREE[randSpawn][1],
834 gSpawnsTeam_TEAM_THREE[randSpawn][2]);
835 }
836
837
838 #endif
839 #endif
840 #if defined TEAMSIZE
841 #if TEAMSIZE >= 4
842
843
844 case FOURTH_TEAM:
845 {
846 new str[80];
847 randSpawn = random(sizeof(gSpawnsTeam_TEAM_FOUR));
848 format(str,sizeof(str),"SERVER: You have been teleported to the base of your team "#FOURTH_TEAM_COLOR_TAG);
849 SendClientMessage(playerid,COLOR_WHITE,str);
850 SetPlayerPos(playerid,
851 gSpawnsTeam_TEAM_FOUR[randSpawn][0],
852 gSpawnsTeam_TEAM_FOUR[randSpawn][1],
853 gSpawnsTeam_TEAM_FOUR[randSpawn][2]);
854 }
855
856 #endif
857 #endif
858 #if defined TEAMSIZE
859 #if TEAMSIZE >= 5
860
861
862 case FIFTH_TEAM:
863 {
864 new str[80];
865 randSpawn = random(sizeof(gSpawnsTeam_TEAM_FIVE));
866 format(str,sizeof(str),"SERVER: You have been teleported to the base of your team "#FIFTH_TEAM_COLOR_TAG);
867 SendClientMessage(playerid,COLOR_WHITE,str);
868 SetPlayerPos(playerid,
869 gSpawnsTeam_TEAM_FIVE[randSpawn][0],
870 gSpawnsTeam_TEAM_FIVE[randSpawn][1],
871 gSpawnsTeam_TEAM_FIVE[randSpawn][2]);
872 }
873
874 #endif
875 #endif
876 #if defined TEAMSIZE
877 #if TEAMSIZE == 6
878
879
880 case SIXTH_TEAM:
881 {
882 new str[80];
883 randSpawn = random(sizeof(gSpawnsTeam_TEAM_SIX));
884 format(str,sizeof(str),"SERVER: You have been teleported to the base of your team "#SIXTH_TEAM_COLOR_TAG);
885 SendClientMessage(playerid,COLOR_WHITE,str);
886 SetPlayerPos(playerid,
887 gSpawnsTeam_TEAM_SIX[randSpawn][0],
888 gSpawnsTeam_TEAM_SIX[randSpawn][1],
889 gSpawnsTeam_TEAM_SIX[randSpawn][2]);
890 }
891
892 #endif
893 #endif
894
895 }
896
897
898
899}
900stock SpecPlayer(playerid,targetplayer)
901{
902 new String[128];
903 GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
904 Inter[playerid] = GetPlayerInterior(playerid);
905 vWorld[playerid] = GetPlayerVirtualWorld(playerid);
906 TogglePlayerSpectating(playerid, true);
907 if(IsPlayerInAnyVehicle(targetplayer))
908 {
909 if(GetPlayerInterior(targetplayer) > 0)
910 {
911 SetPlayerInterior(playerid,GetPlayerInterior(targetplayer));
912 }
913 if(GetPlayerVirtualWorld(targetplayer) > 0)
914 {
915 SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(targetplayer));
916 }
917 PlayerSpectateVehicle(playerid,GetPlayerVehicleID(targetplayer));
918 }
919 else
920 {
921 if(GetPlayerInterior(targetplayer) > 0)
922 {
923 SetPlayerInterior(playerid,GetPlayerInterior(targetplayer));
924 }
925 if(GetPlayerVirtualWorld(targetplayer) > 0)
926 {
927 SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(targetplayer));
928 }
929 PlayerSpectatePlayer(playerid,targetplayer);
930 }
931 GetPlayerName(targetplayer, Name, sizeof(Name));
932 format(String, sizeof(String),"SERVER: You have started to spectate %s.",Name);
933 SendClientMessage(playerid,COLOR_WHITE,String);
934
935 IsSpecing[playerid] = 1;
936 IsBeingSpeced[targetplayer] = 1;
937 spectatorid[playerid] = targetplayer;
938}
939
940stock SpecRandomPlayer(playerid)
941{
942 new randoms[MAX_PLAYERS],idx;
943 for(new i=GetPlayerPoolSize(); i!=-1; i--)
944 {
945 if(IsPlayerConnected(i) && gPlayerTeamSelection[i] != TEAM_SPECTATOR && playerid != i)
946 {
947 randoms[idx++]=i;
948 }
949 }
950 TextDrawShowForPlayer(playerid,txtSpectatorHelper);
951 if(!idx) return 0; // INVALID_PLAYER_ID
952 SpecPlayer(playerid, randoms[random(idx)]);
953 return 1;
954}
955
956public reveal(playerid)
957{
958
959 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You are visible again!");
960 if(PStealth[playerid] == -1 && (gPlayerTeamSelection[playerid] == FIRST_TEAM))
961 {
962 PStealth[playerid]=0;
963 SetPlayerColor(playerid,COLOR_TEAM_ONE);
964
965 }
966 if(PStealth[playerid] == -1 && (gPlayerTeamSelection[playerid] == SECOND_TEAM))
967 {
968 PStealth[playerid]=0;
969 SetPlayerColor(playerid,COLOR_TEAM_TWO);
970
971 }
972 #if defined TEAMSIZE
973 #if TEAMSIZE >= 3
974 if(PStealth[playerid] == -1 && (gPlayerTeamSelection[playerid] == THIRD_TEAM))
975 {
976 PStealth[playerid]=0;
977 SetPlayerColor(playerid,COLOR_TEAM_THREE);
978
979 }
980 #endif
981 #endif
982 #if defined TEAMSIZE
983 #if TEAMSIZE >= 4
984 if(PStealth[playerid] == -1 && (gPlayerTeamSelection[playerid] == FOURTH_TEAM))
985 {
986 PStealth[playerid]=0;
987 SetPlayerColor(playerid,COLOR_TEAM_FOUR);
988
989 }
990 #endif
991 #endif
992 #if defined TEAMSIZE
993 #if TEAMSIZE >= 5
994 if(PStealth[playerid] == -1 && (gPlayerTeamSelection[playerid] == FIFTH_TEAM))
995 {
996 PStealth[playerid]=0;
997 SetPlayerColor(playerid,COLOR_TEAM_FIVE);
998
999 }
1000 #endif
1001 #endif
1002 #if defined TEAMSIZE
1003 #if TEAMSIZE == 6
1004 if(PStealth[playerid] == -1 && (gPlayerTeamSelection[playerid] == SIXTH_TEAM))
1005 {
1006 PStealth[playerid]=0;
1007 SetPlayerColor(playerid,COLOR_TEAM_SIX);
1008
1009 }
1010 #endif
1011 #endif
1012
1013}
1014
1015stock SellPlayerWeapon(playerid,cost,weaponid,ammo)
1016{
1017 if(GetPlayerMoney(playerid) >= cost)
1018 {
1019
1020 new spentstring[128];
1021 format(spentstring,sizeof(spentstring),"SERVER: You spent $%d to purchase this weapon!",cost);
1022 SendClientMessage(playerid,COLOR_WHITE,spentstring);
1023 printf("%d spent %d to purchase weapon %d",playerid,cost,weaponid);
1024 GivePlayerWeapon(playerid,weaponid,ammo);
1025 GivePlayerMoneyText(playerid,-cost);
1026 TogglePlayerControllable(playerid,true);
1027 }
1028 else
1029 {
1030 new leftmoney = (GetPlayerMoney(playerid)-cost);
1031 new insufstring[128];
1032 format(insufstring,sizeof(insufstring),"SERVER: You still need $%d to purchase this weapon!",-leftmoney);
1033 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this weapon!");
1034 printf("%d tried to purchase weapon %d but still needs %d",playerid,weaponid,-leftmoney);
1035 SendClientMessage(playerid,COLOR_WHITE,insufstring);
1036 TogglePlayerControllable(playerid,true);
1037 }
1038}
1039
1040stock SellPlayerFightingStyle(playerid,cost,style)
1041{
1042 if(GetPlayerMoney(playerid) >= cost)
1043 {
1044
1045 new spentstring[128];
1046 format(spentstring,sizeof(spentstring),"SERVER: You spent $%d to purchase this style!",cost);
1047 SendClientMessage(playerid,COLOR_WHITE,spentstring);
1048 SetPlayerFightingStyle(playerid,style);
1049 GivePlayerMoneyText(playerid,-cost);
1050 TogglePlayerControllable(playerid,true);
1051 }
1052 else
1053 {
1054 new leftmoney = (GetPlayerMoney(playerid)-cost);
1055 new insufstring[128];
1056 format(insufstring,sizeof(insufstring),"SERVER: You still need $%d to purchase this fightstyle!",-leftmoney);
1057 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this fightstyle!");
1058 SendClientMessage(playerid,COLOR_WHITE,insufstring);
1059 TogglePlayerControllable(playerid,true);
1060 }
1061}
1062stock GenerateRandomPickup(modelid,type,Float:x_max,Float:x_min,Float:y_max,Float:y_min,Float:z_max,Float:z_min,virtualworld)
1063{
1064 if(maxmoney <= sizeof(MoneyPickups))
1065 {
1066
1067 moneyval= moneyval+1000;
1068 new Float:rx1=((frandom((floatabs(x_max-x_min)))+x_min));
1069 new Float:ry2=((frandom((floatabs(y_max-y_min)))+y_min));
1070 new Float:rz3=((frandom((floatabs(z_max-z_min)))+z_min));
1071 maxmoney = maxmoney +1;
1072 MoneyPickups[maxmoney] = CreatePickup(modelid,type,rx1,ry2,rz3,virtualworld);
1073 HeapSort(MoneyPickups);
1074
1075 }
1076
1077
1078}
1079
1080public CountDown()
1081{
1082 CountDownVar--;
1083 for(new i = 0; i < MAX_PLAYERS; i++)
1084 {
1085 if(CountDownVar == 0)
1086 {
1087 KillTimer(CountDownTimer);
1088 CountDownVar = 4;
1089 PlayerPlaySound(i,7419,0,0,0);
1090 }
1091 if(CountDownVar == 1)
1092 {
1093 PlayerPlaySound(i,7418,0,0,0);
1094 }
1095 if(CountDownVar == 2)
1096 {
1097 PlayerPlaySound(i,7417,0,0,0);
1098 }
1099 }
1100 return 1;
1101}
1102
1103public warpcount(playerid)
1104{
1105 WarpVar[playerid]--;
1106 new Float:x,Float:y,Float:z;
1107 GetPlayerPos(playerid,x,y,z);
1108
1109 if(WarpVar[playerid] == 0)
1110 {
1111 if(!IsPlayerInRangeOfPoint(playerid,2.0,wX[playerid],wY[playerid],wZ[playerid]))
1112 {
1113 KillTimer(WarpTimer);
1114 WarpVar[playerid] = 4;
1115 Warppowder[playerid]=1;
1116 if(IsValidObject(Beam[playerid]))
1117 DestroyObject(Beam[playerid]);
1118 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You moved right away! Teleport aborted.");
1119 }
1120 if(IsValidObject(Beam[playerid]))
1121 DestroyObject(Beam[playerid]);
1122 TeleportPlayerToBase(playerid);
1123
1124 WarpVar[playerid] = 4;
1125 KillTimer(WarpTimer);
1126 PlayerPlaySound(playerid,1137,x,y,z);
1127 }
1128 if(WarpVar[playerid] == 1)
1129 {
1130 if(!IsPlayerInRangeOfPoint(playerid,2.0,wX[playerid],wY[playerid],wZ[playerid]))
1131 {
1132 KillTimer(WarpTimer);
1133 WarpVar[playerid] = 4;
1134 Warppowder[playerid]=1;
1135 if(IsValidObject(Beam[playerid]))
1136 DestroyObject(Beam[playerid]);
1137 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You moved right away! Teleport aborted.");
1138
1139 }
1140 PlayerPlaySound(playerid,1137,x,y,z);
1141
1142 }
1143 if(WarpVar[playerid] == 2)
1144 {
1145 if(!IsPlayerInRangeOfPoint(playerid,2.0,wX[playerid],wY[playerid],wZ[playerid]))
1146 {
1147 KillTimer(WarpTimer);
1148 WarpVar[playerid] = 4;
1149 Warppowder[playerid]=1;
1150 if(IsValidObject(Beam[playerid]))
1151 DestroyObject(Beam[playerid]);
1152 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You moved right away! Teleport aborted.");
1153 }
1154 PlayerPlaySound(playerid,1137,x,y,z);
1155
1156 }
1157 if(WarpVar[playerid] == 3)
1158 {
1159 if(!IsPlayerInRangeOfPoint(playerid,2.0,wX[playerid],wY[playerid],wZ[playerid]))
1160 {
1161 KillTimer(WarpTimer);
1162 WarpVar[playerid] = 4;
1163 Warppowder[playerid]=1;
1164 if(IsValidObject(Beam[playerid]))
1165 DestroyObject(Beam[playerid]);
1166 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You moved right away! Teleport aborted.");
1167 }
1168 PlayerPlaySound(playerid,1137,x,y,z);
1169
1170 }
1171
1172
1173 return 1;
1174}
1175
1176
1177
1178public SendTeamMessage(teamid, color, const message[])
1179{
1180 for(new i; i < MAX_PLAYERS; i++)
1181 {
1182 if(!IsPlayerConnected(i)) continue;
1183 if(gPlayerTeamSelection[i] != teamid) continue;
1184
1185 SendClientMessage(i, color, message);
1186 }
1187 return 1;
1188}
1189
1190public OnPlayerExitedMenu(playerid)
1191{
1192 TogglePlayerControllable(playerid,true);
1193 return 1;
1194}
1195/*
1196stock DropPlayerWeaponPickup(weaponid,ammo,Float:x,Float:y,Float:z)
1197{
1198
1199}
1200*/
1201public OnPlayerPickUpPickup(playerid, pickupid)
1202{
1203 new index;
1204 switch(GetPickupType(pickupid,index))
1205 {
1206 case INVALID_PICKUP_TYPE:
1207 {
1208 }
1209 case MONEY_TYPE:
1210 {
1211 maxmoney -= 1;
1212 GivePlayerMoney(playerid, MoneyVal);
1213 MoneyPickups[index]=-1;
1214 quickSort(MoneyPickups,0,sizeof(MoneyPickups)-1);
1215 DestroyPickup(pickupid);
1216 }
1217 case ACTOR_TYPE:
1218 {
1219 ShowMenuForPlayer(shopmenu,playerid);
1220 TogglePlayerControllable(playerid,false);
1221 }
1222 case INFO_TYPE:
1223 {
1224 ShowMenuForPlayer(infomenu,playerid);
1225 TogglePlayerControllable(playerid,false);
1226 }
1227 }
1228 return 1;
1229}
1230
1231
1232
1233
1234stock GetPickupType(pickupid, &index)
1235{
1236 new mres = binarysearch(MoneyPickups,pickupid,0,sizeof(MoneyPickups)-1);
1237 if(mres > -1 && MoneyPickups[mres] == pickupid) return index=mres,MONEY_TYPE;
1238 new ares = binarysearch(ActorPickups,pickupid,0,sizeof(ActorPickups)-1);
1239 if(ares > -1 && ActorPickups[ares] == pickupid) return index=ares,ACTOR_TYPE;
1240 new ires = binarysearch(InfoPickups,pickupid,0,sizeof(InfoPickups)-1);
1241 if(ires > -1 && InfoPickups[ires] == pickupid) return index=ires,INFO_TYPE;
1242
1243
1244
1245 return INVALID_PICKUP_TYPE;
1246}
1247
1248public UpdateTimeAndWeather()
1249{
1250
1251
1252
1253 gettime(hour, minute);
1254
1255 format(timestr,32,"%02d:%02d",hour,minute);
1256 format(timestrex,32,"Time: %02d:%02d",hour,minute);
1257 TextDrawSetString(txtTimeDisp,timestr);
1258
1259
1260 for(new i;i<MAX_PLAYERS;i++)
1261 {
1262 if(!IsPlayerConnected(i)) continue;
1263 if(IsPlayerAdmin(i))
1264 PlayerInfo[i][pAdmin]=1;
1265 }
1266
1267
1268 SetWorldTime(hour);
1269
1270 new x=0;
1271 while(x!=MAX_PLAYERS) {
1272 if(IsPlayerConnected(x)) {
1273 SetPlayerTime(x,hour,minute);
1274 }
1275 x++;
1276 }
1277
1278
1279}
1280main()
1281{
1282 print(" Knogles Last Bed Standing Masterpiece for SA-MP");
1283 print(" Fork of Minecrafts Bedwars");
1284 print(" Little TDM Gamemode");
1285 print(" Published under GNU GPL Public License.");
1286 print(" Copyright (C) 2017 Fabian Druschke");
1287 print(" Contact: webmaster@knogleinsi.de");
1288 print(" Mail: Postfach 32 22 50147 Kerpen Germany");
1289 print(" \n This program is free software: you can redistribute it and/or modify");
1290 print(" it under the terms of the GNU General Public License as published by");
1291 print(" the Free Software Foundation, either version 3 of the License, or");
1292 print(" (at your option) any later version.");
1293 print(" \n This program is distributed in the hope that it will be useful,");
1294 print(" but WITHOUT ANY WARRANTY; without even the implied warranty of");
1295 print(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the");
1296 print(" GNU General Public License for more details.");
1297 print(" \n You should have received a copy of the GNU General Public License");
1298 print(" along with this program. If not, see http://www.gnu.org/licenses/");
1299 printf("\n\nHeapspace: %i kilobytes", heapspace() / 1024);
1300
1301}
1302
1303//----------------------------------------------------------
1304
1305stock Float:GetDistance( Float:a1, Float:b1, Float:c1, Float:a2, Float:b2, Float:c2 )
1306{
1307 return floatsqroot(((a1-a2)*(a1-a2))+((b1-b2)*(b1-b2))+((c1-c2)*(c1-c2)));
1308}
1309
1310stock HeapSort (array [], n = sizeof (array))
1311{
1312 new i;
1313 for (i = n / 2; i > 0; --i) // Make heap
1314 SinkDown (array, i, n);
1315
1316 for (i = n; i > 1; --i)
1317 {
1318 Swap (array [i - 1], array [0]);
1319 SinkDown (array, 1, i - 1);
1320 }
1321}
1322/*
1323stock strcpy(dest[], src[], size = sizeof(dest))
1324{
1325 dest[0] = EOS;
1326 return strcat(dest, src, size);
1327}
1328*/
1329stock quickSort(array[], left, right)
1330{
1331 new
1332 tempLeft = left,
1333 tempRight = right,
1334 pivot = array[(left + right) / 2],
1335 tempVar
1336 ;
1337 while(tempLeft <= tempRight)
1338 {
1339 while(array[tempLeft] < pivot) tempLeft++;
1340 while(array[tempRight] > pivot) tempRight--;
1341
1342 if(tempLeft <= tempRight)
1343 {
1344 tempVar = array[tempLeft], array[tempLeft] = array[tempRight], array[tempRight] = tempVar;
1345 tempLeft++, tempRight--;
1346 }
1347 }
1348 if(left < tempRight) quickSort(array, left, tempRight);
1349 if(tempLeft < right) quickSort(array, tempLeft, right);
1350}
1351
1352
1353
1354//----------------------------------------------------------
1355
1356static stock SinkDown (array [], i, m)
1357{
1358 new j;
1359 while (2 * i <= m)
1360 {
1361 j = 2 * i;
1362 if (j < m && array [j - 1] < array [j])
1363 ++j;
1364
1365 if (array [i - 1] < array [j - 1])
1366 {
1367 Swap (array [i - 1], array [j - 1]);
1368 i = j;
1369 }
1370 else
1371 i = m;
1372 }
1373}
1374
1375//----------------------------------------------------------
1376
1377static stock Swap (&a, &b)
1378{
1379 new s;
1380 s = a;
1381 a = b;
1382 b = s;
1383}
1384
1385//----------------------------------------------------------
1386stock PreloadAnimLib(playerid, animlib[])
1387{
1388 ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
1389}
1390
1391
1392public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
1393{
1394 switch (dialogid)
1395 {
1396 case DIALOG_LOGIN:
1397 {
1398 if(!response) return Kick(playerid);
1399
1400 new Salted_Key[65];
1401 SHA256_PassHash(inputtext, playerdataInfo[playerid][Salt], Salted_Key, 65);
1402
1403 if(strcmp(Salted_Key, playerdataInfo[playerid][pPass]) == 0)
1404 {
1405 // Now, password should be correct as well as the strings
1406 // Matched with each other, so nothing is wrong until now.
1407
1408 // We will activate the cache of player to make use of it e.g.
1409 // Retrieve their data.
1410
1411 cache_set_active(playerdataInfo[playerid][Player_Cache]);
1412
1413 // Okay, we are retrieving the information now..
1414 cache_get_value_int(0, "ID", playerdataInfo[playerid][ID]);
1415
1416 cache_get_value_int(0, "KILLS", playerdataInfo[playerid][pKills]);
1417 cache_get_value_int(0, "DEATHS", playerdataInfo[playerid][pDeaths]);
1418
1419 cache_get_value_int(0, "SCORE", playerdataInfo[playerid][pBeds]);
1420 cache_get_value_int(0, "CASH", playerdataInfo[playerid][pBombs]);
1421
1422 SetPlayerScore(playerid, playerdataInfo[playerid][pBeds]);
1423
1424 ResetPlayerMoney(playerid);
1425 GivePlayerMoney(playerid, playerdataInfo[playerid][pBombs]);
1426
1427 // So, we have successfully retrieved data? Now deactivating the cache.
1428
1429 cache_delete(playerdataInfo[playerid][Player_Cache]);
1430 playerdataInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE;
1431
1432 playerdataInfo[playerid][LoggedIn] = true;
1433 SendClientMessage(playerid, 0x00FF00FF, "Logged in to the account.");
1434 }
1435 else
1436 {
1437 new String[150];
1438
1439 playerdataInfo[playerid][pPassFails] += 1;
1440 printf("%s has been failed to login. (%d)", playerdataInfo[playerid][pName], playerdataInfo[playerid][pPassFails]);
1441 // Printing the message that someone has failed to login to his account.
1442
1443 if (playerdataInfo[playerid][pPassFails] >= 3) // If the fails exceeded the limit we kick the player.
1444 {
1445 format(String, sizeof(String), "%s has been kicked Reason: {FF0000}(%d/3) Login fails.", playerdataInfo[playerid][pName], playerdataInfo[playerid][pPassFails]);
1446 SendClientMessageToAll(0x969696FF, String);
1447 Kick(playerid);
1448 }
1449 else
1450 {
1451 // If the player didn't exceed the limits we send him a message that the password is wrong.
1452 format(String, sizeof(String), "Wrong password, you have %d out of 3 tries.", playerdataInfo[playerid][pPassFails]);
1453 SendClientMessage(playerid, 0xFF0000FF, String);
1454
1455 format(String, sizeof(String), "{FFFFFF}Welcome back, %s.\n\n{0099FF}This account is already registered.\n\
1456 {0099FF}Please, input your password below to proceed to the game.\n\n", playerdataInfo[playerid][pName]);
1457 ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login System", String, "Login", "Leave");
1458 }
1459 }
1460 }
1461 case DIALOG_REGISTER:
1462 {
1463 if(!response) return Kick(playerid);
1464
1465 if(strlen(inputtext) <= 5 || strlen(inputtext) > 60)
1466 {
1467 // If the password length is less than or equal to 5 and more than 60
1468 // It repeats the process and shows error message as seen below.
1469
1470 SendClientMessage(playerid, 0x969696FF, "Invalid password length, should be 5 - 60.");
1471
1472 new String[150];
1473
1474 format(String, sizeof(String), "{FFFFFF}Welcome %s.\n\n{0099FF}This account is not registered.\n\
1475 {0099FF}Please, input your password below to proceed.\n\n", playerdataInfo[playerid][pName]);
1476 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration System", String, "Register", "Leave");
1477 }
1478 else
1479 {
1480
1481 // Salting the player's password using SHA256 for a better security.
1482
1483 for (new i = 0; i < 10; i++)
1484 {
1485 playerdataInfo[playerid][Salt][i] = random(79) + 47;
1486 }
1487
1488 playerdataInfo[playerid][Salt][10] = 0;
1489 SHA256_PassHash(inputtext, playerdataInfo[playerid][Salt], playerdataInfo[playerid][pPass], 65);
1490
1491 new DB_Query[225];
1492
1493 // Storing player's information if everything goes right.
1494 mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `PLAYERS` (`USERNAME`, `PASSWORD`, `SALT`, `SCORE`, `KILLS`, `CASH`, `DEATHS`)\
1495 VALUES ('%e', '%s', '%e', '20', '0', '0', '0')", playerdataInfo[playerid][pName], playerdataInfo[playerid][pPass], playerdataInfo[playerid][Salt]);
1496 mysql_tquery(Database, DB_Query, "OnPlayerRegister", "d", playerid);
1497 }
1498 }
1499 }
1500 return 1;
1501}
1502
1503forward public OnPlayerDataCheck(playerid, corrupt_check);
1504public OnPlayerDataCheck(playerid, corrupt_check)
1505{
1506 if (corrupt_check != Corrupt_Check[playerid]) return Kick(playerid);
1507 // You'd have asked already what's corrput_check and how it'd benefit me?
1508 // Well basically MySQL query takes long, incase a player leaves while its not proceeded
1509 // With ID 1 for example, then another player comes as ID 1 it'll basically corrupt the data
1510 // So, once the query is done, the player will have the wrong data assigned for himself.
1511
1512 new String[150];
1513
1514 if(cache_num_rows() > 0)
1515 {
1516 // If the player exists, everything is okay and nothing is wrongly detected
1517 // The player's password and Saltion key gets stored as seen below
1518 // So we won't have to get a headache just to match player's password.
1519
1520 cache_get_value(0, "PASSWORD", playerdataInfo[playerid][pPass], 65);
1521 cache_get_value(0, "SALT", playerdataInfo[playerid][Salt], 11);
1522
1523 playerdataInfo[playerid][Player_Cache] = cache_save();
1524 // ^ Storing the cache ID of the player for further use later.
1525
1526 format(String, sizeof(String), "{FFFFFF}Welcome back, %s.\n\n{0099FF}This account is already registered.\n\
1527 {0099FF}Please, input your password below to proceed to the game.\n\n", playerdataInfo[playerid][pName]);
1528 ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login System", String, "Login", "Leave");
1529 }
1530 else
1531 {
1532 format(String, sizeof(String), "{FFFFFF}Welcome %s.\n\n{0099FF}This account is not registered.\n\
1533 {0099FF}Please, input your password below to proceed to the game.\n\n", playerdataInfo[playerid][pName]);
1534 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration System", String, "Register", "Leave");
1535 }
1536 return 1;
1537}
1538
1539forward public OnPlayerRegister(playerid);
1540public OnPlayerRegister(playerid)
1541{
1542 // This gets called only when the player registers a new account.
1543 SendClientMessage(playerid, 0x00FF00FF, "You are now registered and has been logged in.");
1544 playerdataInfo[playerid][LoggedIn] = true;
1545 return 1;
1546}
1547public OnPlayerConnect(playerid)
1548{
1549 WarpVar[playerid]=4;
1550 PreloadAnimLib(playerid,"BOMBER");
1551
1552 SetPlayerMapIcon(playerid, 12,Center[0][0],Center[0][1],Center[0][2], 52, 0, MAPICON_GLOBAL);
1553
1554 new DB_Query[115];
1555
1556 //Resetting player information.
1557 playerdataInfo[playerid][pKills] = 0;
1558 playerdataInfo[playerid][pDeaths] = 0;
1559 playerdataInfo[playerid][pPassFails] = 0;
1560
1561 GetPlayerName(playerid, playerdataInfo[playerid][pName], MAX_PLAYER_NAME); // Getting the player's name.
1562 Corrupt_Check[playerid]++;
1563
1564 mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `PLAYERS` WHERE `USERNAME` = '%e' LIMIT 1", playerdataInfo[playerid][pName]);
1565 mysql_tquery(Database, DB_Query, "OnPlayerDataCheck", "ii", playerid, Corrupt_Check[playerid]);
1566 RemoveBuildingForPlayer(playerid, 694,-2406.2607,-1949.2020,303.7252, 200.0);
1567 RemoveBuildingForPlayer(playerid, 784,-2406.2607,-1949.2020,303.7252, 200.0);
1568 RemoveBuildingForPlayer(playerid, 3636, 1220.2734375,2590.296875,16.4453125, 10000.0);
1569 RemoveBuildingForPlayer(playerid,3683, 2377.390625,1743.234375,16.5390625,10000);
1570 RemoveBuildingForPlayer(playerid, 3673, -2137.1953125,70.28125,42.3125, 10000.0);
1571 RemoveBuildingForPlayer(playerid, 3682,1249.5546875,-905.4609375,45.03125,10000);
1572 RemoveBuildingForPlayer(playerid, 3259,1249.5546875,-905.4609375,45.03125,10000);
1573 RemoveBuildingForPlayer(playerid, 3424, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1574 RemoveBuildingForPlayer(playerid, 3674, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1575 RemoveBuildingForPlayer(playerid, 3675, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1576 RemoveBuildingForPlayer(playerid, 3256, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1577 RemoveBuildingForPlayer(playerid, 3258, 1220.2734375,2590.296875,16.4453125, 10000.0);
1578 RemoveBuildingForPlayer(playerid,3673, 2377.390625,1743.234375,16.5390625,10000);
1579 RemoveBuildingForPlayer(playerid, 3255, -2137.1953125,70.28125,42.3125, 10000.0);
1580 RemoveBuildingForPlayer(playerid, 3257,1249.5546875,-905.4609375,45.03125,10000);
1581
1582 RemoveBuildingForPlayer(playerid, 3290, 1220.2734375,2590.296875,16.4453125, 10000.0);
1583 RemoveBuildingForPlayer(playerid,3289, 2377.390625,1743.234375,16.5390625,10000);
1584 RemoveBuildingForPlayer(playerid, 3682, -2137.1953125,70.28125,42.3125, 10000.0);
1585 RemoveBuildingForPlayer(playerid, 3682,1249.5546875,-905.4609375,45.03125,10000);
1586 RemoveBuildingForPlayer(playerid, 3291,1249.5546875,-905.4609375,45.03125,10000);
1587 RemoveBuildingForPlayer(playerid, 3288, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1588 RemoveBuildingForPlayer(playerid, 3291, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1589 RemoveBuildingForPlayer(playerid, 3683, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1590 RemoveBuildingForPlayer(playerid, 16086, 1568.2890625,-1677.78125,10.8203125, 10000.0);
1591 PStealth[playerid]=0;
1592 LastMoney[playerid]=0;
1593 new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
1594 GetPlayerName(playerid, pname, sizeof(pname));
1595 format(string, sizeof(string), "%s (%d) has joined the server.", pname,playerid);
1596 SendClientMessageToAll(0xAAAAAAAA, string);
1597 PlayerPlaySound(playerid,1185,0,0,0);
1598 GameTextForPlayer(playerid,"~w~Last Bed Standing",3000,4);
1599 SendClientMessage(playerid,COLOR_WHITE,"Welcome to {88AA88}B{FFFFFF}ed {88AA88}W{FFFFFF}ars");
1600 gPlayerTeamSelection[playerid] = -1;
1601 gPlayerHasTeamSelected[playerid] = 0;
1602 gPlayerLastTeamSelectionTick[playerid] = GetTickCount();
1603 return 1;
1604}
1605stock ClassSel_SetupCharSelection(playerid)
1606{
1607 TextDrawHideForPlayer(playerid,Textcover);
1608 if(gPlayerTeamSelection[playerid] > -1)
1609 {
1610 SetPlayerVirtualWorld(playerid,1);
1611 SetPlayerPos(playerid,243.1261,1805.2798,8.3794);
1612 SetPlayerFacingAngle(playerid,180.0);
1613 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
1614 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
1615
1616 #if defined TEAMSIZE
1617 #if TEAMSIZE >= 2
1618
1619
1620 switch(gPlayerTeamSelection[playerid])
1621 {
1622 case FIRST_TEAM:
1623 {
1624 SetPlayerColor(playerid,COLOR_TEAM_ONE);
1625 }
1626 case SECOND_TEAM:
1627 {
1628 SetPlayerColor(playerid,COLOR_TEAM_TWO);
1629 }
1630
1631
1632 #endif
1633 #endif
1634 #if defined TEAMSIZE
1635 #if TEAMSIZE >= 3
1636 case THIRD_TEAM:
1637 {
1638 SetPlayerColor(playerid,COLOR_TEAM_THREE);
1639 }
1640 #endif
1641 #endif
1642 #if defined TEAMSIZE
1643 #if TEAMSIZE >= 4
1644
1645 case FOURTH_TEAM:
1646 {
1647 SetPlayerColor(playerid,COLOR_TEAM_FOUR);
1648 }
1649
1650
1651 #endif
1652 #endif
1653 #if defined TEAMSIZE
1654 #if TEAMSIZE >= 5
1655
1656
1657
1658 case FIFTH_TEAM:
1659 {
1660 SetPlayerColor(playerid,COLOR_TEAM_FIVE);
1661 }
1662
1663
1664 #endif
1665 #endif
1666 #if defined TEAMSIZE
1667 #if TEAMSIZE >= 6
1668
1669
1670
1671 case SIXTH_TEAM:
1672 {
1673 SetPlayerColor(playerid,COLOR_TEAM_SIX);
1674 }
1675
1676
1677 #endif
1678 #endif
1679 }
1680 }
1681}
1682
1683stock ClassSel_InitTeamNameText(playerid,PlayerText:txtInit)
1684{
1685 PlayerTextDrawBackgroundColor(playerid,txtInit,0x000000ff);
1686 PlayerTextDrawFont(playerid,txtInit,2);
1687 PlayerTextDrawLetterSize(playerid,txtInit,0.399999,1.500000);
1688 PlayerTextDrawColor(playerid,txtInit,0xffffffff);
1689 PlayerTextDrawSetOutline(playerid,txtInit,1);
1690 PlayerTextDrawSetProportional(playerid,txtInit,1);
1691 PlayerTextDrawSetShadow(playerid,txtInit,1);
1692 PlayerTextDrawBackgroundColor(playerid,txtInit,0x000000ff);
1693 PlayerTextDrawFont(playerid,txtInit,2);
1694 PlayerTextDrawLetterSize(playerid,txtInit,0.399999,1.500000);
1695 PlayerTextDrawColor(playerid,txtInit,0xffffffff);
1696 PlayerTextDrawSetOutline(playerid,txtInit,1);
1697 PlayerTextDrawSetProportional(playerid,txtInit,1);
1698 PlayerTextDrawSetShadow(playerid,txtInit,1);
1699}
1700
1701stock ClassSel_SwitchToNextTeam(playerid)
1702{
1703 gPlayerTeamSelection[playerid]++;
1704
1705
1706 switch(TEAMSIZE)
1707 {
1708 case 2:
1709 {
1710 if(gPlayerTeamSelection[playerid] > SECOND_TEAM)
1711 {
1712 gPlayerTeamSelection[playerid] = FIRST_TEAM;
1713 }
1714 }
1715 case 3:
1716 {
1717 if(gPlayerTeamSelection[playerid] > THIRD_TEAM)
1718 {
1719 gPlayerTeamSelection[playerid] = FIRST_TEAM;
1720 }
1721 }
1722 case 4:
1723 {
1724 if(gPlayerTeamSelection[playerid] > FOURTH_TEAM)
1725 {
1726 gPlayerTeamSelection[playerid] = FIRST_TEAM;
1727 }
1728 }
1729 case 5:
1730 {
1731 if(gPlayerTeamSelection[playerid] > FIFTH_TEAM)
1732 {
1733 gPlayerTeamSelection[playerid] = FIRST_TEAM;
1734 }
1735 }
1736 case 6:
1737 {
1738 if(gPlayerTeamSelection[playerid] > SIXTH_TEAM)
1739 {
1740 gPlayerTeamSelection[playerid] = FIRST_TEAM;
1741 }
1742 }
1743 }
1744 PlayerPlaySound(playerid,1052,0.0,0.0,0.0);
1745 gPlayerLastTeamSelectionTick[playerid] = GetTickCount();
1746 ClassSel_SetupSelectedTeam(playerid);
1747}
1748
1749
1750stock ClassSel_SwitchToPreviousTeam(playerid)
1751{
1752 gPlayerTeamSelection[playerid]--;
1753
1754 switch(TEAMSIZE)
1755 {
1756 case 2:
1757 {
1758 if(gPlayerTeamSelection[playerid] < FIRST_TEAM)
1759 {
1760 gPlayerTeamSelection[playerid] = SECOND_TEAM;
1761 }
1762 }
1763 case 3:
1764 {
1765 if(gPlayerTeamSelection[playerid] < FIRST_TEAM)
1766 {
1767 gPlayerTeamSelection[playerid] = THIRD_TEAM;
1768 }
1769 }
1770 case 4:
1771 {
1772 if(gPlayerTeamSelection[playerid] < FIRST_TEAM)
1773 {
1774 gPlayerTeamSelection[playerid] = FOURTH_TEAM;
1775 }
1776 }
1777 case 5:
1778 {
1779 if(gPlayerTeamSelection[playerid] < FIRST_TEAM)
1780 {
1781 gPlayerTeamSelection[playerid] = FIFTH_TEAM;
1782 }
1783 }
1784 case 6:
1785 {
1786 if(gPlayerTeamSelection[playerid] < FIRST_TEAM)
1787 {
1788 gPlayerTeamSelection[playerid] = SIXTH_TEAM;
1789 }
1790 }
1791 }
1792 PlayerPlaySound(playerid,1053,0.0,0.0,0.0);
1793 gPlayerLastTeamSelectionTick[playerid] = GetTickCount();
1794 ClassSel_SetupSelectedTeam(playerid);
1795}
1796
1797stock getActingPlayer(playerid,&idx)
1798{
1799 new randoms[MAX_PLAYERS],tmp;
1800 for(new i=GetPlayerPoolSize(); i!=-1; i--)
1801 {
1802 if(IsPlayerConnected(i) && gPlayerTeamSelection[i] != TEAM_SPECTATOR && playerid != i)
1803 {
1804 randoms[tmp++]=i;
1805 }
1806 }
1807 if(!tmp) return INVALID_PLAYER_ID;
1808 if(idx>tmp) idx=0;
1809 if(idx<0) idx=tmp-1;
1810 return randoms[idx];
1811}
1812stock HandlePlayerSpectating(playerid)
1813{
1814 if( (GetTickCount() - gPlayerLastTeamSelectionTick[playerid]) < delay ) return 1;
1815 new Keys,ud,lr;
1816 GetPlayerKeys(playerid,Keys,ud,lr);
1817 if(lr == KEY_RIGHT)
1818 {
1819 SpectatingPlayer[playerid]++;
1820 ud = getActingPlayer(playerid,SpectatingPlayer[playerid]);
1821 if(ud == INVALID_PLAYER_ID)
1822 {
1823 SpectatingPlayer[playerid]--;
1824 return 1;
1825 }
1826 SpecPlayer(playerid,ud);
1827 }
1828 else if(lr == KEY_LEFT)
1829 {
1830 SpectatingPlayer[playerid]--;
1831 ud = getActingPlayer(playerid,SpectatingPlayer[playerid]);
1832 if(ud == INVALID_PLAYER_ID)
1833 {
1834 SpectatingPlayer[playerid]++;
1835 return 1;
1836 }
1837 SpecPlayer(playerid,ud);
1838 }
1839 return 1;
1840}
1841stock ClassSel_HandleTeamSelection(playerid)
1842{
1843
1844 new Keys,ud,lr;
1845 GetPlayerKeys(playerid,Keys,ud,lr);
1846
1847 if(gPlayerTeamSelection[playerid] == -1) {
1848 ClassSel_SwitchToNextTeam(playerid);
1849 return;
1850 }
1851
1852
1853 if( (GetTickCount() - gPlayerLastTeamSelectionTick[playerid]) < delay ) return;
1854
1855 if(Keys & KEY_FIRE) {
1856 gPlayerHasTeamSelected[playerid] = 1;
1857
1858 PlayerTextDrawHide(playerid,TeamText[playerid]);
1859 PlayerTextDrawHide(playerid,LocText[playerid]);
1860 PlayerTextDrawHide(playerid,TeamCover[playerid]);
1861 TextDrawHideForPlayer(playerid,txtClassSelHelper);//Observer textdraw
1862 TogglePlayerSpectating(playerid,0);
1863 return;
1864 }
1865 printf("ClassSel_HandleTeamSelection");
1866 if(lr > 0) {
1867 ClassSel_SwitchToNextTeam(playerid);
1868 }
1869 else if(lr < 0) {
1870 ClassSel_SwitchToPreviousTeam(playerid);
1871 }
1872
1873}
1874
1875
1876public OnPlayerRequestClass(playerid, classid)
1877{
1878 if(IsPlayerNPC(playerid)) return 1;
1879 printf("OnPlayerRequestClass");
1880 if(gPlayerHasTeamSelected[playerid]) {
1881 ClassSel_SetupCharSelection(playerid);
1882 return 1;
1883 }
1884 else
1885 {
1886 if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING) {
1887 TogglePlayerSpectating(playerid,1);
1888 TextDrawShowForPlayer(playerid, txtClassSelHelper);
1889 gPlayerTeamSelection[playerid] = -1;
1890 }
1891 }
1892
1893 return 0;
1894}
1895
1896//----------------------------------------------------------
1897public OnPlayerSelectedMenuRow(playerid, row)
1898{
1899 new Menu:CurrentMenu = GetPlayerMenu(playerid);
1900 new Menu:Current= GetPlayerMenu(playerid);
1901 TogglePlayerControllable(playerid,false);
1902 if(Current==infomenu)
1903 {
1904 TogglePlayerControllable(playerid,false);
1905 switch(row)
1906 {
1907 case 0:
1908 {
1909 TogglePlayerControllable(playerid,true);
1910 SendClientMessage(playerid,COLOR_WHITE,"SERVER: How to play");
1911 SendClientMessage(playerid,COLOR_WHITE,"The goal of this mode, is to destroy the enemie's bed and wipe out all the remaining players to determine the winner team.");
1912 SendClientMessage(playerid,COLOR_WHITE,"You can use the /blowup command to destroy and enemies bed!");
1913 }
1914 case 1:
1915 {
1916 TogglePlayerControllable(playerid,true);
1917 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Q: How to destroy a bed?");
1918 SendClientMessage(playerid,COLOR_WHITE,"SERVER: A: Get close to the enemie's bed and use /blowup to destroy it!");
1919 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Q: What can i do if i am unable to respawn due to a destroyed bed?");
1920 SendClientMessage(playerid,COLOR_WHITE,"SERVER: A: You can use the command /spec [playerid] to spectate other players!");
1921 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Q: When does the game ends?");
1922 SendClientMessage(playerid,COLOR_WHITE,"SERVER: A: After a winning team is determined, means if only one team remains.");
1923 }
1924 case 2:
1925 {
1926 TogglePlayerControllable(playerid,true);
1927 SendClientMessage(playerid,COLOR_WHITE,"SERVER: If you commit one of these things it will get you banned!");
1928 SendClientMessage(playerid,COLOR_WHITE,"SERVER: NO Cheating");
1929 SendClientMessage(playerid,COLOR_WHITE,"SERVER: NO Spamming");
1930 SendClientMessage(playerid,COLOR_WHITE,"SERVER: NO Quitting to avoid anything! Better die in honor for a honorable cause!");
1931 SendClientMessage(playerid,COLOR_WHITE,"SERVER: NEVER kill your own team mates, it will get you banned!");
1932 SendClientMessage(playerid,COLOR_WHITE,"SERVER: NEVER exploit bugs in any way! Report them instead!");
1933 }
1934 }
1935 }
1936 if(Current==ammunation) {
1937 TogglePlayerControllable(playerid,false);
1938 switch(row) {
1939 case 0: {
1940 ShowMenuForPlayer(pistols,playerid);
1941 }
1942 case 1: {
1943 ShowMenuForPlayer(microsmg,playerid);
1944 }
1945 case 2: {
1946 ShowMenuForPlayer(shotguns,playerid);
1947 }
1948 case 3: {
1949 ShowMenuForPlayer(items,playerid);
1950 }
1951 case 4: {
1952 ShowMenuForPlayer(smg,playerid);
1953 }
1954 case 5: {
1955 ShowMenuForPlayer(rifles,playerid);
1956 }
1957 case 6: {
1958 ShowMenuForPlayer(assaultrifle,playerid);
1959 }
1960 case 7: {
1961 ShowMenuForPlayer(Grenades,playerid);
1962 }
1963 case 8: {
1964 ShowMenuForPlayer(melee,playerid);
1965 }
1966 case 9: {
1967 ShowMenuForPlayer(special,playerid);
1968 }
1969 case 10: {
1970 HideMenuForPlayer(ammunation,playerid);
1971 ShowMenuForPlayer(shopmenu,playerid);
1972
1973 }
1974 default: {
1975 print("Fail");
1976 }
1977 }
1978 }
1979 else if(Current==pistols) {
1980 ShowMenuForPlayer(pistols,playerid);
1981 switch(row) {
1982 case 0:
1983 {
1984 SellPlayerWeapon(playerid,1500,22,50);
1985 }
1986 case 1:
1987 {
1988 SellPlayerWeapon(playerid,2500,23,50);
1989
1990
1991 }
1992 case 2:
1993
1994 {
1995 SellPlayerWeapon(playerid,2500,24,50);
1996 }
1997 case 3: {
1998
1999 HideMenuForPlayer(pistols,playerid);
2000 ShowMenuForPlayer(ammunation,playerid);
2001 }
2002 default: {
2003 print("Fail");
2004 }
2005 }
2006 }
2007 else if(Current==microsmg) {
2008 ShowMenuForPlayer(microsmg,playerid);
2009 switch(row) {
2010 case 0:
2011
2012
2013 {
2014 SellPlayerWeapon(playerid,5500,32,50);
2015
2016 }
2017
2018 case 1:
2019
2020 {
2021 SellPlayerWeapon(playerid,5000,28,50);
2022
2023 }
2024 case 2: {
2025 HideMenuForPlayer(microsmg,playerid);
2026 ShowMenuForPlayer(ammunation,playerid);
2027 }
2028 default: {
2029 print("Fail");
2030 }
2031 }
2032 }
2033 else if(Current==shotguns) {
2034 ShowMenuForPlayer(shotguns,playerid);
2035 switch(row) {
2036 case 0: {
2037 SellPlayerWeapon(playerid,12500,25,50);
2038
2039 }
2040 case 1: {
2041 SellPlayerWeapon(playerid,15500,26,50);
2042
2043 }
2044 case 2: {
2045 SellPlayerWeapon(playerid,55500,27,50);
2046 }
2047 case 3: {
2048 HideMenuForPlayer(shotguns,playerid);
2049 ShowMenuForPlayer(ammunation,playerid);
2050 }
2051 default: {
2052 print("Fail");
2053 }
2054 }
2055 }
2056 else if(Current==items) {
2057 ShowMenuForPlayer(items,playerid);
2058 switch(row) {
2059 case 0:
2060 if(GetPlayerMoney(playerid) >= 2500)
2061 {
2062 GivePlayerMoneyText(playerid,-2500);
2063 SetPlayerArmour(playerid,100.0);
2064 }
2065 else
2066 {
2067 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2068 }
2069 case 1: {
2070 SellPlayerWeapon(playerid,2500,46,1);
2071 }
2072 case 2: {
2073 SellPlayerWeapon(playerid,2500,41,100);
2074 }
2075 case 3: {
2076 SellPlayerWeapon(playerid,2500,43,50);
2077
2078 }
2079
2080 case 4: if(GetPlayerMoney(playerid) >= 2500)
2081 {
2082 GivePlayerMoneyText(playerid,-2500);
2083 SetPlayerHealth(playerid,100.0);
2084 }
2085 else
2086 {
2087 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2088 }
2089 case 5:
2090 {
2091 HideMenuForPlayer(items,playerid);
2092 ShowMenuForPlayer(fightstyles,playerid);
2093 }
2094 case 6: {
2095 HideMenuForPlayer(items,playerid);
2096 ShowMenuForPlayer(ammunation,playerid);
2097 }
2098 default: {
2099 print("Fail");
2100 }
2101 }
2102 }
2103
2104 else if(Current==fightstyles) {
2105 ShowMenuForPlayer(fightstyles,playerid);
2106 switch(row) {
2107 case 0:
2108
2109 {
2110 SellPlayerFightingStyle (playerid,2500, FIGHT_STYLE_KUNGFU);
2111 }
2112 case 1: {
2113 SellPlayerFightingStyle (playerid,2500, FIGHT_STYLE_KNEEHEAD);
2114
2115 }
2116 case 2:
2117 {
2118 SellPlayerFightingStyle (playerid,2500, FIGHT_STYLE_BOXING);
2119 }
2120 case 3:
2121 {
2122 SellPlayerFightingStyle (playerid,2500, FIGHT_STYLE_GRABKICK);
2123 }
2124 case 4:
2125 {
2126 SellPlayerFightingStyle (playerid,2500, FIGHT_STYLE_ELBOW);
2127 }
2128 case 5:
2129 {
2130 SetPlayerFightingStyle (playerid, FIGHT_STYLE_NORMAL);
2131 }
2132 case 6:
2133 {
2134 HideMenuForPlayer(fightstyles,playerid);
2135 ShowMenuForPlayer(items,playerid);
2136 }
2137 default: {
2138 print("Fail");
2139 }
2140 }
2141 }
2142 else if(Current==smg) {
2143 ShowMenuForPlayer(smg,playerid);
2144 switch(row) {
2145 case 0:
2146
2147 {
2148 SellPlayerWeapon(playerid,20000,29,50);
2149
2150
2151
2152 }
2153 case 1: {
2154 HideMenuForPlayer(smg,playerid);
2155 ShowMenuForPlayer(ammunation,playerid);
2156
2157 }
2158 default: {
2159 print("Fail");
2160 }
2161 }
2162 }
2163
2164 else if(Current==assaultrifle) {
2165 ShowMenuForPlayer(assaultrifle,playerid);
2166 switch(row) {
2167 case 0:
2168 {
2169 SellPlayerWeapon(playerid,40000,30,500);
2170 }
2171
2172 case 1: {
2173 SellPlayerWeapon(playerid,45000,31,500);
2174
2175 }
2176 case 2: {
2177 HideMenuForPlayer(assaultrifle,playerid);
2178 ShowMenuForPlayer(ammunation,playerid);
2179 }
2180 default: {
2181 print("Fail");
2182 }
2183 }
2184 }
2185 else if(Current==rifles) {
2186 ShowMenuForPlayer(rifles,playerid);
2187 switch(row) {
2188 case 0: {
2189 SellPlayerWeapon(playerid,12500,33,50);
2190
2191
2192 }
2193 case 1: {
2194 SellPlayerWeapon(playerid,40000,34,50);
2195 }
2196 case 2: {
2197 HideMenuForPlayer(rifles,playerid);
2198 ShowMenuForPlayer(ammunation,playerid);
2199
2200 }
2201 default: {
2202 print("Fail");
2203 }
2204 }
2205 }
2206 else if(Current==Grenades) {
2207 ShowMenuForPlayer(Grenades,playerid);
2208 switch(row) {
2209 case 0: {
2210 SellPlayerWeapon(playerid,125000,16,50);
2211 }
2212 case 1: {
2213 SellPlayerWeapon(playerid,25000,17,50);
2214 }
2215 case 2: {
2216 SellPlayerWeapon(playerid,25000,18,50);
2217 }
2218 case 3: {
2219 HideMenuForPlayer(Grenades,playerid);
2220 ShowMenuForPlayer(ammunation,playerid);
2221 }
2222 default: {
2223 print("Fail");
2224 }
2225 }
2226 }
2227 else if(Current==yesno) {
2228 ShowMenuForPlayer(yesno,playerid);
2229 switch(row) {
2230 case 0: {
2231 SetPlayerHealth(playerid,0.0);
2232 SendDeathMessage(playerid, playerid, 22);
2233 }
2234 case 1: {
2235 HideMenuForPlayer(yesno,playerid);
2236 TogglePlayerControllable(playerid,true);
2237 }
2238 case 2: {
2239 HideMenuForPlayer(yesno,playerid);
2240 ShowMenuForPlayer(shopmenu,playerid);
2241 }
2242 default: {
2243 print("Fail");
2244 }
2245 }
2246 }
2247 else if(Current==melee) {
2248 ShowMenuForPlayer(melee,playerid);
2249 switch(row) {
2250 case 0: {
2251 GivePlayerWeapon(playerid,5,1);
2252 }
2253 case 1: {
2254 GivePlayerWeapon(playerid,11,1);
2255 }
2256 case 2: {
2257 SellPlayerWeapon(playerid,100000,9,1);
2258 }
2259 case 3: {
2260 GivePlayerWeapon(playerid,8,1);
2261 }
2262 case 4: {
2263 GivePlayerWeapon(playerid,7,1);
2264 }
2265 case 5: {
2266 GivePlayerWeapon(playerid,4,1);
2267 }
2268 case 6: {
2269 GivePlayerWeapon(playerid,3,1);
2270 }
2271 case 7: {
2272 GivePlayerWeapon(playerid,2,1);
2273 }
2274 case 8: {
2275 HideMenuForPlayer(melee,playerid);
2276 ShowMenuForPlayer(ammunation,playerid);
2277 }
2278 default: {
2279 print("Fail");
2280 }
2281 }
2282 }
2283 else if(Current==special) {
2284 ShowMenuForPlayer(special,playerid);
2285 switch(row) {
2286 case 0: {
2287 SellPlayerWeapon(playerid,2000000,38,1000);
2288 }
2289 case 1: {
2290 SellPlayerWeapon(playerid,250000,35,5);
2291 }
2292 case 2: {
2293 SellPlayerWeapon(playerid,250000,37,300);
2294
2295 }
2296 case 3: {
2297 HideMenuForPlayer(special,playerid);
2298 ShowMenuForPlayer(ammunation,playerid);
2299 }
2300 default: {
2301 print("Fail");
2302 }
2303 }
2304 }
2305 if(CurrentMenu == shopmenu)
2306 {
2307
2308 switch(row)
2309 {
2310 case 0:
2311 {
2312 TogglePlayerControllable(playerid,false);
2313 HideMenuForPlayer(shopmenu,playerid);
2314 ShowMenuForPlayer(ammunation,playerid);
2315
2316 }
2317 case 1:
2318 {
2319 if(GetPlayerMoney(playerid) > 10000 && PSkill[playerid] == 0)
2320 {
2321 PSkill[playerid]=1;
2322 GivePlayerMoneyText(playerid,-10000);
2323 SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Skill upgraded");
2324 SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,1000);
2325 SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL_SILENCED,1000);
2326 SetPlayerSkillLevel(playerid,WEAPONSKILL_DESERT_EAGLE,1000);
2327 SetPlayerSkillLevel(playerid,WEAPONSKILL_SHOTGUN,1000);
2328 SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,1000);
2329 SetPlayerSkillLevel(playerid,WEAPONSKILL_SPAS12_SHOTGUN,1000);
2330 SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,1000);
2331 SetPlayerSkillLevel(playerid,WEAPONSKILL_MP5,1000);
2332 SetPlayerSkillLevel(playerid,WEAPONSKILL_AK47,1000);
2333 SetPlayerSkillLevel(playerid,WEAPONSKILL_M4,1000);
2334 SetPlayerSkillLevel(playerid,WEAPONSKILL_SNIPERRIFLE,1000);
2335 ShowMenuForPlayer(shopmenu,playerid);
2336 }
2337 else if(GetPlayerMoney(playerid) < 10000)
2338 {
2339 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2340 ShowMenuForPlayer(shopmenu,playerid);
2341 TogglePlayerControllable(playerid,false);
2342 }
2343 else if(PSkill[playerid] != 0)
2344 {
2345 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You already bought this item!");
2346 TogglePlayerControllable(playerid,true);
2347 }
2348
2349 }
2350 case 2:
2351 {
2352 if(GetPlayerMoney(playerid) >= 85000)
2353 {
2354 PStealth[playerid]=1;
2355 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You are equipped with a stealth kit. You can use /stealth to hide yourself");
2356 GivePlayerMoneyText(playerid,-85000);
2357 TogglePlayerControllable(playerid,1);
2358 }
2359 else
2360 {
2361 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2362 TogglePlayerControllable(playerid,1);
2363 }
2364
2365 }
2366 case 3: if(GetPlayerMoney(playerid) >= 100000 && PBomb[playerid] == 0)
2367 {
2368 PBomb[playerid]=1;
2369 SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: You have bought a bomb! Now you can place bombs by using /dropbomb!");
2370 ShowMenuForPlayer(shopmenu,playerid);
2371 TogglePlayerControllable(playerid,false);
2372 GivePlayerMoneyText(playerid,-100000);
2373 }
2374 else if(PBomb[playerid] != 0)
2375 {
2376 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You already bought this item!");
2377 TogglePlayerControllable(playerid,1);
2378 }
2379 else if(GetPlayerMoney(playerid) < 100000)
2380 {
2381 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2382 ShowMenuForPlayer(shopmenu,playerid);
2383 TogglePlayerControllable(playerid,false);
2384 }
2385 case 4: if(GetPlayerMoney(playerid) >= 50000 && Warppowder[playerid] == 0)
2386
2387 {
2388 Warppowder[playerid]=1;
2389 SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: You have bought a Warpkit! You can teleport yourself back to your base by using /warp");
2390 ShowMenuForPlayer(shopmenu,playerid);
2391 TogglePlayerControllable(playerid,false);
2392 GivePlayerMoneyText(playerid,-50000);
2393 }
2394 else if(Warppowder[playerid] != 0)
2395 {
2396 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You already bought this item!");
2397 TogglePlayerControllable(playerid,1);
2398 }
2399 else if(GetPlayerMoney(playerid) < 50000)
2400 {
2401 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2402 ShowMenuForPlayer(shopmenu,playerid);
2403 TogglePlayerControllable(playerid,false);
2404 }
2405 case 5: if(GetPlayerMoney(playerid) >= 5000 && Helmet[playerid] == 0)
2406
2407 {
2408 Helmet[playerid]=1;
2409 SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: You have bought a Helmet! You are now protected against headshots!");
2410 ShowMenuForPlayer(shopmenu,playerid);
2411 TogglePlayerControllable(playerid,false);
2412 GivePlayerMoneyText(playerid,-5000);
2413 }
2414 else if(Helmet[playerid] != 0)
2415 {
2416 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You already bought this item!");
2417 TogglePlayerControllable(playerid,1);
2418 }
2419 else if(GetPlayerMoney(playerid) < 5000)
2420 {
2421 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Insufficient balance! You can not afford this item!");
2422 ShowMenuForPlayer(shopmenu,playerid);
2423 TogglePlayerControllable(playerid,false);
2424 }
2425 case 6:
2426 {
2427 HideMenuForPlayer(shopmenu,playerid);
2428 ShowMenuForPlayer(yesno,playerid);
2429 }
2430
2431 }
2432 }
2433}
2434
2435stock GetTeamPlayerCount(teamid)
2436{
2437 new playercount = 0;
2438 for(new i = 0; i < MAX_PLAYERS; i++)
2439 {
2440 if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
2441 if(gPlayerTeamSelection[i] != teamid) continue;
2442 playercount++;
2443 }
2444 return playercount;
2445}
2446stock GetActiveTeamCount()
2447{
2448 new i=0,count=0;
2449 while(i<TEAMSIZE)
2450 {
2451 if(GetTeamPlayerCount(i) > 0)
2452 {
2453 count++;
2454 }
2455 i++;
2456 }
2457 return count;
2458
2459}
2460
2461
2462public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
2463{
2464 if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9 && Helmet[playerid] != 1)
2465 {
2466 // One shot to the head to kill with sniper rifle
2467 SetPlayerHealth(playerid, 0.0);
2468 }
2469 return 1;
2470}
2471
2472
2473stock TeamsAlive(bool:value)
2474{
2475 new i=0,count=0;
2476 while(i<TEAMSIZE)
2477 {
2478 if(GetTeamPlayerCount(i) > 0)
2479 {
2480 count++;
2481 }
2482 i++;
2483 }
2484 if(bool:value == false)
2485 switch(count)
2486 {
2487 case 1:
2488 {
2489 switch(TeamsAlive(true))
2490 {
2491 case FIRST_TEAM:
2492 {
2493 for(new d;d<MAX_PLAYERS;d++)
2494 {
2495 SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
2496 }
2497 }
2498 case SECOND_TEAM:
2499 {
2500 for(new d;d<MAX_PLAYERS;d++)
2501 {
2502 SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
2503 }
2504 }
2505 #if defined TEAMSIZE
2506 #if TEAMSIZE >= 3
2507 case THIRD_TEAM:
2508 {
2509 for(new d;d<MAX_PLAYERS;d++)
2510 {
2511 SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
2512 }
2513 }
2514 #endif
2515 #endif
2516 #if defined TEAMSIZE
2517 #if TEAMSIZE >= 4
2518 case FOURTH_TEAM:
2519 {
2520 for(new d;d<MAX_PLAYERS;d++)
2521 {
2522 SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);
2523 }
2524 }
2525 #endif
2526 #endif
2527 #if defined TEAMSIZE
2528 #if TEAMSIZE >= 5
2529 case FIFTH_TEAM:
2530 {
2531 for(new d;d<MAX_PLAYERS;d++)
2532 {
2533 SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);
2534 }
2535 }
2536 #endif
2537 #endif
2538 #if defined TEAMSIZE
2539 #if TEAMSIZE == 6
2540 case SIXTH_TEAM:
2541 {
2542 for(new d;d<MAX_PLAYERS;d++)
2543 {
2544 SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SIXTH_TEAM_COLOR_TAG);
2545 }
2546 }
2547 #endif
2548 #endif
2549
2550
2551 }
2552 for(new o;o<MAX_PLAYERS;o++)
2553 {
2554 ResetPlayerData(o);
2555 }
2556 SetTimer("GMX",500,false);
2557 }
2558 }
2559 if(bool:value == true && count == 1)//Returns the ID of the remaining team
2560 return i;
2561 return 1;
2562
2563}
2564public GMX()
2565{
2566 SendClientMessageToAll(COLOR_WHITE,"SERVER: Game over! Map is changing. Please standby..");
2567 printf("Total game time: %d",totaltime);
2568 SendRconCommand("gmx");
2569}
2570public OnPlayerDisconnect(playerid, reason)
2571{
2572 Corrupt_Check[playerid]++;
2573
2574 new DB_Query[256];
2575 //Running a query to save the player's data using the stored stuff.
2576 mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `PLAYERS` SET `SCORE` = %d, `CASH` = %d, `KILLS` = %d, `DEATHS` = %d WHERE `ID` = %d LIMIT 1",
2577 playerdataInfo[playerid][pBeds], playerdataInfo[playerid][pBombs], playerdataInfo[playerid][pKills], playerdataInfo[playerid][pDeaths], playerdataInfo[playerid][ID]);
2578
2579 mysql_tquery(Database, DB_Query);
2580
2581 if(cache_is_valid(playerdataInfo[playerid][Player_Cache])) //Checking if the player's cache ID is valid.
2582 {
2583 cache_delete(playerdataInfo[playerid][Player_Cache]); // Deleting the cache.
2584 playerdataInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; // Setting the stored player Cache as invalid.
2585 }
2586
2587 playerdataInfo[playerid][LoggedIn] = false;
2588 print("OnPlayerDisconnect has been called."); // Sending message once OnPlayerDisconnect is called.
2589 //SaveUser_data(playerid);
2590 LastMoney[playerid]=0;
2591 new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
2592 GetPlayerName(playerid, pname, sizeof(pname));
2593 ResetPlayerData(playerid);
2594 if(IsBeingSpeced[playerid] == 1)
2595 {
2596 for(new i;i<MAX_PLAYERS;i++)
2597 {
2598 if(spectatorid[i] == playerid)
2599 {
2600 SpecRandomPlayer(i);
2601 }
2602 }
2603 }
2604 TextDrawHideForPlayer(playerid,txtSpectatorHelper);
2605 switch(reason)
2606 {
2607 case 0: format(string, sizeof(string), "%s (%d) has left the server. (Lost Connection)", pname,playerid);
2608 case 1: format(string, sizeof(string), "%s (%d) has left the server. (Leaving)", pname,playerid);
2609 case 2: format(string, sizeof(string), "%s (%d) has left the server. (Kicked)", pname,playerid);
2610 }
2611 SendClientMessageToAll(0xAAAAAAAA, string);
2612 return 1;
2613}
2614
2615stock GetPlayerTeamColorTag(playerid)
2616{
2617 new gTeam[144];
2618 switch(gPlayerTeamSelection[playerid])
2619 {
2620 case FIRST_TEAM: strcpy(gTeam,FIRST_TEAM_COLOR_TAG);
2621 case SECOND_TEAM: strcpy(gTeam,SECOND_TEAM_COLOR_TAG);
2622 #if defined TEAMSIZE
2623 #if TEAMSIZE >= 3
2624 case THIRD_TEAM: strcpy(gTeam,THIRD_TEAM_COLOR_TAG);
2625 #endif
2626 #endif
2627 #if defined TEAMSIZE
2628 #if TEAMSIZE >= 4
2629 case FOURTH_TEAM: strcpy(gTeam,FOURTH_TEAM_COLOR_TAG);
2630 #endif
2631 #endif
2632 #if defined TEAMSIZE
2633 #if TEAMSIZE >= 5
2634 case FIFTH_TEAM: strcpy(gTeam,FIFTH_TEAM_COLOR_TAG);
2635 #endif
2636 #endif
2637 #if defined TEAMSIZE
2638 #if TEAMSIZE == 6
2639 case SIXTH_TEAM: strcpy(gTeam,SIXTH_TEAM_COLOR_TAG);
2640 #endif
2641 #endif
2642 case TEAM_SPECTATOR: strcpy(gTeam,SPECTATOR_TEAM_COLOR_TAG);
2643 }
2644 return gTeam;
2645}
2646public OnPlayerUpdate(playerid)
2647{
2648
2649 if(IsPlayerNPC(playerid)) return 1;
2650
2651 if(IsSpecing[playerid] == 1)
2652 {
2653 HandlePlayerSpectating(playerid);
2654 return 1;
2655 }
2656 // changing teams by inputs
2657 if( !gPlayerHasTeamSelected[playerid] && GetPlayerState(playerid) == PLAYER_STATE_SPECTATING )
2658 {
2659 ClassSel_HandleTeamSelection(playerid);
2660 return 1;
2661 }
2662 return 1;
2663
2664}
2665
2666public OnPlayerClickPlayer(playerid, clickedplayerid, source)
2667{
2668 new deaths = PlayerInfo[clickedplayerid][pDeaths];
2669 new kills = PlayerInfo[clickedplayerid][pKills];
2670 if(deaths == 0)
2671 {
2672 deaths = 1;
2673 }
2674 deaths = PlayerInfo[clickedplayerid][pDeaths];
2675 kills = PlayerInfo[clickedplayerid][pKills];
2676 new Float:kd = floatdiv(kills,deaths);
2677 new name[MAX_PLAYER_NAME];
2678 GetPlayerName(clickedplayerid, name, sizeof(name));
2679 SendClientMessageEx(playerid, COLOR_WHITE,"SERVER: Player Stats of %s(%d) Team: %s ",name,clickedplayerid,GetPlayerTeamColorTag(clickedplayerid));
2680 SendClientMessageEx(playerid, COLOR_WHITE,"Kills:%d Deaths:%d Ratio:%0.2f Blown beds:%d Bombs detonated:%d",kills,deaths,kd,PlayerInfo[clickedplayerid][pBeds],PlayerInfo[clickedplayerid][pBombs]);
2681 return 1;
2682}
2683public OnPlayerCommandText(playerid, cmdtext[])
2684{
2685 new cmd[32], idx;
2686 sscanf(cmdtext,"s[32]d",cmd,idx);
2687 if(strcmp(cmd, "/weather", true) == 0)
2688 {
2689 if(!IsPlayerAdmin(playerid))
2690 return 0;
2691 new targetweatherid;
2692 if(sscanf(cmdtext[strlen("/weather")+1], "i", targetweatherid))
2693 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /weather [weatherid]");
2694 new wres = binarysearch2(gRandomWeatherIDs,0,targetweatherid,0,sizeof(gRandomWeatherIDs)-1);
2695 if(wres == -1)
2696 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Invalid weather ID, check weather array for valid IDs");
2697 new strout[64];
2698 format(strout, sizeof(strout), "Weather changed to %s", gRandomWeatherIDs[targetweatherid][wt_text]);
2699 SetWeather(gRandomWeatherIDs[targetweatherid][wt_id]);
2700 SendClientMessageToAll(COLOR_WHITE,strout);
2701 print(strout);
2702 }
2703 if(strcmp(cmd, "/search", true) == 0)
2704 {
2705 new targetid;
2706 if(sscanf(cmdtext[strlen("/search")+1], "i", targetid))
2707 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /search [key]");
2708 new mres = binarysearch(MoneyPickups,targetid,0,sizeof(MoneyPickups)-1);
2709 new astring[54];
2710 format(astring,sizeof(astring),"Index of key: %d",mres);
2711 new ares = binarysearch(ActorPickups,targetid,0,sizeof(ActorPickups)-1);
2712 SendClientMessage(playerid,COLOR_WHITE,astring);
2713 format(astring,sizeof(astring),"Index of key: %d",ares);
2714 SendClientMessage(playerid,COLOR_WHITE,astring);
2715
2716 }
2717 if(strcmp(cmd, "/compare", true) == 0)
2718 {
2719 HeapSort(MoneyPickups);
2720 HeapSort(ActorPickups);
2721 for(new i;i<sizeof(ActorPickups);i++)
2722 {
2723 new mres = binarysearch(MoneyPickups,ActorPickups[i],0,sizeof(MoneyPickups)-1);
2724 if(mres > -1)
2725 {
2726 SendClientMessage(playerid,COLOR_WHITE,"Match found! MoneyPickups contains values of ActorPickups");
2727 new tstring[144];
2728 format(tstring,sizeof(tstring),"MoneyPickups Val: %d Index: %d matchs ActorPickups Val: %d Index :%d",MoneyPickups[mres],mres,ActorPickups[i],i);
2729 SendClientMessage(playerid,-1,tstring);
2730 break;
2731
2732 }
2733 }
2734
2735 }
2736 if(strcmp(cmd, "/getplayerteam", true) == 0)
2737 {
2738 new targetplayer;
2739 if(sscanf(cmdtext[strlen("/getplayerteam")+1], "i", targetplayer))
2740 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /getplayerteam [playerid]");
2741 if(!IsPlayerConnected(targetplayer))
2742 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
2743 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Player %d is part of Team: %s",targetplayer,GetPlayerTeamColorTag(targetplayer));
2744 }
2745 if(strcmp(cmd, "/stealth", true) == 0)
2746 {
2747 if(PStealth[playerid] == 1)
2748 {
2749 PStealth[playerid]=-1;
2750 SendClientMessage(playerid,COLOR_WHITE,"SERVER: You are now invisible for 60 seconds!");
2751 SetTimerEx("reveal", 60000, false,"i",playerid);
2752 }
2753 else
2754 {
2755 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You do not have a stealth package!");
2756 }
2757 #if defined TEAMSIZE
2758 #if TEAMSIZE >= 2
2759
2760 {
2761 switch(gPlayerTeamSelection[playerid])
2762 {
2763 case 0:
2764 {
2765 SetPlayerColor(playerid,COLOR_TEAM_ONE_STEALTH);
2766 }
2767 case 1:
2768 {
2769 SetPlayerColor(playerid,COLOR_TEAM_TWO_STEALTH);
2770 }
2771 }
2772 }
2773 #endif
2774 #endif
2775 #if defined TEAMSIZE
2776 #if TEAMSIZE >= 3
2777
2778 {
2779 switch(gPlayerTeamSelection[playerid])
2780 {
2781 case 2:
2782 {
2783 SetPlayerColor(playerid,COLOR_TEAM_THREE_STEALTH);
2784 }
2785 }
2786 }
2787 #endif
2788 #endif
2789 #if defined TEAMSIZE
2790 #if TEAMSIZE >= 4
2791
2792 {
2793 switch(gPlayerTeamSelection[playerid])
2794 {
2795 case 3:
2796 {
2797 SetPlayerColor(playerid,COLOR_TEAM_FOUR_STEALTH);
2798 }
2799 }
2800 }
2801 #endif
2802 #endif
2803 #if defined TEAMSIZE
2804 #if TEAMSIZE >= 5
2805
2806 {
2807 switch(gPlayerTeamSelection[playerid])
2808 {
2809 case 4:
2810 {
2811 SetPlayerColor(playerid,COLOR_TEAM_FIVE_STEALTH);
2812 }
2813 }
2814 }
2815 #endif
2816 #endif
2817 #if defined TEAMSIZE
2818 #if TEAMSIZE >= 6
2819
2820 {
2821 switch(gPlayerTeamSelection[playerid])
2822 {
2823 case 5:
2824 {
2825 SetPlayerColor(playerid,COLOR_TEAM_SIX_STEALTH);
2826 }
2827 }
2828 }
2829 #endif
2830 #endif
2831
2832 return 1;
2833 }
2834 if(strcmp(cmd, "/warp", true) == 0) //Warppowder
2835 {
2836 if(Warppowder[playerid] == 1 && !IsPlayerInAnyVehicle(playerid))
2837 {
2838 Warppowder[playerid]=0;
2839 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Warning! Don't move until teleport!");
2840 WarpTimer = SetTimerEx("warpcount", 1000, true,"i",playerid);
2841 new Float:x,Float:y,Float:z;
2842 GetPlayerPos(playerid,x,y,z);
2843 wX[playerid]=x;
2844 wY[playerid]=y;
2845 wZ[playerid]=z;
2846 Beam[playerid] = CreateObject(18671,x,y,z-1,0,0,0,300.0);
2847 }
2848 else if(Warppowder[playerid] != 1)
2849 {
2850 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You do not have Warppowder!");
2851 }
2852 else if(IsPlayerInAnyVehicle(playerid))
2853 {
2854 return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You can not use Warpkits inside of vehicles");
2855 }
2856
2857 return 1;
2858 }
2859 if(strcmp(cmd, "/jetpack", true) == 0) {
2860 if(!IsPlayerAdmin(playerid))
2861 {
2862 return 0;
2863 }
2864 SendClientMessage(playerid,COLOR_WHITE, "SERVER: Jetpack activated!");
2865 SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
2866 return 1;
2867 }
2868 if(strcmp(cmd, "/sound", true) == 0)
2869 {
2870 new targetsoundid;
2871 if(sscanf(cmdtext[strlen("/sound")+1], "i", targetsoundid))
2872 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sound [soundid]");
2873
2874 for(new i = 0; i < MAX_PLAYERS; i++)
2875 {
2876 PlayerPlaySound(i, targetsoundid, 0,0,0);
2877 }
2878 printf("Playing SoundID: %i",targetsoundid);
2879 return 1;
2880
2881
2882 }
2883
2884
2885 if(strcmp(cmd, "/spec", true) == 0)
2886 {
2887 if(!IsPlayerAdmin(playerid)) return 0;
2888 new targetplayer;
2889 if(sscanf(cmdtext[strlen("/spec")+1], "u", targetplayer))
2890 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [playerid]");
2891 if(!IsPlayerConnected(targetplayer))
2892 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
2893 if(playerid == targetplayer)
2894 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot spectate yourself!");
2895 if(gPlayerTeamSelection[playerid] == TEAM_SPECTATOR || IsPlayerAdmin(playerid) )
2896 {
2897
2898 SpecPlayer(playerid,targetplayer);
2899 }
2900 else
2901 {
2902 return 0;
2903 }
2904 return 1;
2905 }
2906 if(strcmp(cmd, "/specoff", true) == 0)
2907 {
2908 if(!IsPlayerAdmin(playerid)) return 0;
2909 if(IsSpecing[playerid] == 0)return SendClientMessage(playerid,COLOR_WHITE,"SERVER: You are not spectating");
2910 TogglePlayerSpectating(playerid, 0);
2911 return 1;
2912 }
2913 // Prototyp
2914 if(strcmp(cmd, "/dropmoney", true) == 0)
2915 {
2916 new dropval;
2917 if(sscanf(cmdtext[strlen("/dropmoney")+1], "i", dropval))
2918 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /dropmoney [value]");
2919 if(GetPlayerMoney(playerid) < dropval)
2920 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You do not have enough money.");
2921 if(maxmoney >= 4000 && dropval > 0 && dropval <= 100000 && (maxmoney+(dropval/MoneyVal))<(MAX_PICKUPS-sizeof(ActorPickups)-sizeof(InfoPickups)-1-((dropval/MoneyVal)+maxmoney)) && dropval != 0 && !IsPlayerInAnyVehicle(playerid))
2922 {
2923 if(dropval%MoneyVal == 0)
2924 {
2925 new dropstring[32];
2926 format(dropstring,sizeof(dropstring),"SERVER: Dropped $%d",dropval);
2927 SendClientMessage(playerid, COLOR_WHITE, dropstring);
2928 GivePlayerMoneyText(playerid,-dropval);
2929
2930 for(new i; i <dropval/MoneyVal; i++)
2931 {
2932
2933 maxmoney = maxmoney +1;
2934 new Float:x, Float:y, Float:z;
2935 GetPlayerPos(playerid,x,y,z);
2936 GetXYInFrontOfPlayer(playerid,x,y,4);
2937 GenerateRandomPickup(1212,19,x+0.5,x-0.5,y+0.5,y-0.5,z+0.5,z-0.5,0);
2938 }
2939
2940 }
2941 else
2942 {
2943
2944 if(dropval%MoneyVal != 0)
2945 {
2946 SendClientMessageEx(playerid, COLOR_WHITE, "SERVER: The desired value must be divisible by $%d",MoneyVal);
2947 }
2948
2949 }
2950
2951 }
2952 else
2953 {
2954 if(GetPlayerMoney(playerid) < dropval )
2955 {
2956 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You do not have enough money.");
2957 }
2958 if(dropval > 100000)
2959 {
2960
2961 SendClientMessage(playerid, COLOR_WHITE, "SERVER: The desired value has to be $100000 or less");
2962 }
2963 if(dropval==0)
2964 {
2965
2966 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You can not drop nothing!");
2967 }
2968 if((maxmoney+dropval/MoneyVal)>=4095 && dropval <= 100000)
2969 {
2970 new allowmoney[128];
2971 format(allowmoney,sizeof(allowmoney),"SERVER: Because of limitations you can not drop more than $%d right now!",(4095-maxmoney)*MoneyVal);
2972 SendClientMessage(playerid,COLOR_WHITE,allowmoney);
2973 printf("Player may only drop %d",(4095-maxmoney)*MoneyVal);
2974 }
2975 if(maxmoney > 4000)
2976 {
2977 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Due to limitations you can not drop anything right now. Try again later.");
2978 }
2979 }
2980
2981 }
2982 if(strcmp(cmd, "/freeze", true) == 0)
2983 {
2984 new target;
2985 if(!sscanf(cmdtext[strlen("/freeze")+1], "u", target))
2986 {
2987 if(IsPlayerAdmin(playerid))
2988 {
2989 if(!IsPlayerConnected(target))
2990 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
2991 TogglePlayerControllable(target,false);
2992 }
2993 }
2994 else
2995 {
2996 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /freeze [playerid]");
2997
2998 }
2999 }
3000 if(strcmp(cmd, "/kill", true) == 0)
3001 {
3002 if(IsPlayerAdmin(playerid))
3003 {
3004 new targetplayer;
3005 if(sscanf(cmdtext[strlen("/kill")+1], "u", targetplayer))
3006 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kill [playerid]");
3007 if(!IsPlayerConnected(targetplayer))
3008 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3009 if(gPlayerTeamSelection[targetplayer] == TEAM_SPECTATOR)
3010 return SendClientMessageEx(playerid, COLOR_WHITE,"SERVER: Cannot kill Player %d, player %d is part of Team %s",targetplayer,targetplayer,GetPlayerTeamColorTag(targetplayer));
3011 SetPlayerHealth(targetplayer,0.0);
3012 }
3013 }
3014 if(strcmp(cmd, "/givecash", true) == 0)
3015 {
3016 if(IsPlayerAdmin(playerid))
3017 {
3018 new targetplayer,moneyamount;
3019 new tname[MAX_PLAYER_NAME];
3020 new aname[MAX_PLAYER_NAME];
3021 new givemoneystring[128];
3022 if(sscanf(cmdtext[strlen("/givecash")+1], "ui", targetplayer,moneyamount))
3023 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
3024 if(!IsPlayerConnected(targetplayer))
3025 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3026 GivePlayerMoneyText(targetplayer,moneyamount);
3027 GetPlayerName(targetplayer,tname,sizeof(tname));
3028 GetPlayerName(playerid,aname,sizeof(aname));
3029 format(givemoneystring,sizeof(givemoneystring),"SERVER: Admin %s (%d) gave %s (%d) $%d.",aname,playerid,tname,targetplayer,moneyamount);
3030 SendClientMessageToAll(COLOR_WHITE,givemoneystring);
3031 }
3032 }
3033 if(strcmp(cmd, "/slap", true) == 0)
3034 {
3035 if(IsPlayerAdmin(playerid))
3036 {
3037 new targetplayer;
3038 new Float:a, Float:b, Float:c;
3039 if(sscanf(cmdtext[strlen("/slap")+1], "u", targetplayer))
3040 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /slap [playerid]");
3041 if(!IsPlayerConnected(targetplayer))
3042 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3043 GetPlayerPos(targetplayer,a,b,c);
3044 SetPlayerPos(targetplayer,a,b,c+10);
3045 }
3046 }
3047 if(strcmp(cmd, "/reset", true) == 0)
3048 {
3049 if(IsPlayerAdmin(playerid))
3050 {
3051 new targetplayer;
3052 if(sscanf(cmdtext[strlen("/reset")+1], "u", targetplayer))
3053 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /reset [playerid]");
3054 if(!IsPlayerConnected(targetplayer))
3055 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3056 if(gPlayerHasTeamSelected[targetplayer] == -1)
3057 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player is still in team selection!");
3058 ResetPlayerData(targetplayer);
3059 ResetPlayerMoney(targetplayer);
3060 TeleportPlayerToBase(targetplayer);
3061 }
3062 }
3063 if(strcmp(cmd, "/checkmoney", true) == 0)
3064 {
3065 if(IsPlayerAdmin(playerid))
3066 {
3067 new targetplayer;
3068 new tname[144];
3069 if(sscanf(cmdtext[strlen("/checkmoney")+1], "u", targetplayer))
3070 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /checkmoney [playerid]");
3071 if(!IsPlayerConnected(targetplayer))
3072 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3073 if(gPlayerHasTeamSelected[targetplayer] == -1)
3074 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player is still in team selection!");
3075 GetPlayerName(targetplayer,tname,sizeof(tname));
3076 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Player %s(%d) is in posession of $%d at this moment",tname,targetplayer,GetPlayerMoney(targetplayer));
3077 }
3078 }
3079 if(strcmp(cmd, "/spawn", true) == 0)
3080 {
3081 if(IsPlayerAdmin(playerid))
3082 {
3083 new targetplayer;
3084 if(sscanf(cmdtext[strlen("/spawn")+1], "u", targetplayer))
3085 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spawn [playerid]");
3086 if(!IsPlayerConnected(targetplayer))
3087 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3088 if(gPlayerHasTeamSelected[targetplayer] == -1)
3089 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player is still in team selection!");
3090 TeleportPlayerToBase(targetplayer);
3091 }
3092 }
3093 if(strcmp(cmd, "/unfreeze", true) == 0)
3094 {
3095 if(IsPlayerAdmin(playerid))
3096 {
3097 new targetplayer;
3098 if(sscanf(cmdtext[strlen("/unfreeze")+1], "u", targetplayer))
3099 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unfreeze [playerid]");
3100 if(!IsPlayerConnected(targetplayer))
3101 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3102 TogglePlayerControllable(targetplayer,true);
3103 }
3104 }
3105 if(strcmp(cmd, "/getmoneycount", true) == 0)
3106 {
3107 new moneyvalstring[128];
3108 format(moneyvalstring,sizeof(moneyvalstring),"SERVER: $%d have been generated.%d money pickups have been created",moneyval,maxmoney);
3109 SendClientMessage(playerid,COLOR_WHITE,moneyvalstring);
3110 }
3111 if(strcmp(cmd, "/goto", true) == 0)
3112 {
3113 if(IsPlayerAdmin(playerid))
3114 {
3115 new targetplayer;
3116 if(sscanf(cmdtext[strlen("/goto")+1], "u", targetplayer))
3117 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goto [playerid]");
3118 if(!IsPlayerConnected(targetplayer))
3119 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3120 if(playerid == targetplayer)
3121 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot goto yourself!");
3122 if(IsPlayerConnected(targetplayer))
3123 {
3124 new Float:x, Float:y, Float:z;
3125 GetPlayerPos(targetplayer, x, y, z);
3126 SetPlayerInterior(playerid,GetPlayerInterior(targetplayer));
3127 SetPlayerPos(playerid, x+1, y+1, z);
3128 return 1;
3129 }
3130 }
3131 else
3132 {
3133 return 0;
3134 }
3135 }
3136 if(strcmp(cmd, "/acmds", true) == 0)
3137 {
3138 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Commands for admin use only below.");
3139 SendClientMessage(playerid,COLOR_WHITE,"SERVER: /goto [playerid] /playertoplayer [playerid] [targetplayerid]");
3140 SendClientMessage(playerid,COLOR_WHITE,"SERVER: /getmoneycount /get [playerid] /netstats [playerid]");
3141 SendClientMessage(playerid,COLOR_WHITE,"SERVER: /kill [playerid] /spawn [playerid] /slap [playerid]");
3142 SendClientMessage(playerid,COLOR_WHITE,"SERVER: /givecash [playerid] [value] /freeze [playerid] /unfreeze [playerid]");
3143 SendClientMessage(playerid,COLOR_WHITE,"SERVER: /sound [soundid] /spec [playerid]");
3144 }
3145 if(strcmp(cmd, "/playertoplayer", true) == 0)
3146 {
3147 if(IsPlayerAdmin(playerid))
3148 {
3149 new targetplayer1,targetplayer2;
3150 if(sscanf(cmdtext[strlen("/playertoplayer")+1], "uu", targetplayer1,targetplayer2))
3151 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /playertoplayer [playerid] [playerid]");
3152 if(!IsPlayerConnected(targetplayer1) || !IsPlayerConnected(targetplayer2))
3153 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3154 if(playerid == targetplayer1 && playerid == targetplayer2 )
3155 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot teleport yourself to yourself!");
3156 new Float:d1,Float:d2,Float:d3;
3157 GetPlayerPos(targetplayer2,d1,d2,d3);
3158 SetPlayerPos(targetplayer1,d1,d2,d3);
3159
3160 }
3161 else
3162 {
3163 return 0;
3164 }
3165 }
3166 if(strcmp(cmd, "/getmoneycount", true) == 0)
3167 {
3168 new moneyvalstring[128];
3169 format(moneyvalstring,sizeof(moneyvalstring),"SERVER: $%d have been generated.%d money pickups have been created",moneyval,maxmoney);
3170 SendClientMessage(playerid,COLOR_WHITE,moneyvalstring);
3171 }
3172 if(strcmp(cmd, "/get", true) == 0)
3173 {
3174
3175 if(IsPlayerAdmin(playerid))
3176 {
3177 new targetplayer;
3178 if(sscanf(cmdtext[strlen("/get")+1], "u", targetplayer))
3179 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /get [playerid]");
3180 if(!IsPlayerConnected(targetplayer))
3181 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3182 if(playerid == targetplayer)
3183 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot get yourself!");
3184 if(IsPlayerConnected(targetplayer))
3185 {
3186 new Float:x, Float:y, Float:z;
3187 GetPlayerPos(playerid, x, y, z);
3188 SetPlayerInterior(targetplayer,GetPlayerInterior(playerid));
3189 SetPlayerPos(targetplayer, x+1, y+1, z);
3190 return 1;
3191 }
3192 }
3193 else
3194 {
3195 return 0;
3196 }
3197 }
3198 if(strcmp(cmd, "/dropbomb", true) == 0)
3199 {
3200 if(PBomb[playerid] == 1 && GetPlayerInterior(playerid) == 0 && !IsPlayerInAnyVehicle(playerid))
3201 {
3202 ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 1);
3203 PBombID[playerid]=1;
3204 PBomb[playerid]=-1;
3205 GetPlayerPos(playerid,pX[playerid],pY[playerid],pZ[playerid]);
3206 BombObject[playerid] = CreateObject(363,pX[playerid],pY[playerid],(pZ[playerid]-0.4),0,0,0);//Bomb object
3207 SendClientMessage(playerid, COLOR_WHITE, "SERVER: Bomb placed! Use ~k~~CONVERSATION_YES~ or /detonate to blow it up!");
3208 for(new k;k<sizeof(beds[]);k++)
3209 {
3210 new Float:dist = floatabs(GetDistance(pX[playerid],pY[playerid],pZ[playerid],beds[k][0],beds[k][1],beds[k][2]));
3211 {
3212 if(dist < 8)
3213 {
3214 new distancestring[128];
3215 format(distancestring,sizeof(distancestring),"SERVER: Distance of dropped bomb to closest bed: %fm",dist);
3216 }
3217 }
3218 }
3219 }
3220 else if(GetPlayerInterior(playerid) != 0)
3221 {
3222 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot use /dropbomb inside of interiors.");
3223 }
3224 else if(PBomb[playerid] != 1)
3225 {
3226 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You have to buy a bomb to use this command.");
3227 }
3228 }
3229 if(strcmp(cmd, "/detonate", true) == 0)
3230 {
3231 if(PBomb[playerid] == -1 && PBombID[playerid] == 1 && IsPlayerInRangeOfPoint(playerid,150,pX[playerid],pY[playerid],pZ[playerid]))
3232 {
3233 PlayerInfo[playerid][pBombs]++;
3234 PBombID[playerid]=0;
3235 PBomb[playerid]=0;
3236 CreateExplosion(pX[playerid],pY[playerid],pZ[playerid],7,10);
3237 CreateExplosion(pX[playerid],pY[playerid],pZ[playerid],9,10);
3238 SendClientMessage(playerid, COLOR_WHITE, "SERVER: Bomb detonated!");
3239 PlayerPlaySound(playerid, 21001, 0, 0, 0);
3240 DestroyObject(BombObject[playerid]);
3241 for(new i = 0; i < sizeof(beds[]); i++)
3242 {
3243 new Float:health;
3244 GetPlayerHealth(playerid,health);
3245 new Float:dist = GetDistance(beds[i][0],beds[i][1],beds[i][2],pX[playerid],pY[playerid],pZ[playerid]);
3246 if(dist < 4)
3247 {
3248 running = 1;
3249 if(!(i == 0 && gPlayerTeamSelection[playerid] == FIRST_TEAM) || !(i == 1 && gPlayerTeamSelection[playerid] == THIRD_TEAM) || !(i == 2 && gPlayerTeamSelection[playerid] == SECOND_TEAM))
3250 PBeds[playerid]+=1;
3251
3252
3253 if(i == 0 && BED_STATE_TEAM_ONE !=-1 )
3254 {
3255 BED_STATE_TEAM_ONE=-1;
3256 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#FIRST_TEAM_COLOR_TAG);
3257 }
3258 if(i == 1 && BED_STATE_TEAM_TWO !=-1 )
3259 {
3260 BED_STATE_TEAM_THREE=-1;
3261 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#SECOND_TEAM_COLOR_TAG);
3262 }
3263
3264 #if defined TEAMSIZE
3265 #if TEAMSIZE >=3
3266 if(i == 2 && BED_STATE_TEAM_THREE !=-1 )
3267 {
3268 BED_STATE_TEAM_TWO=-1;
3269 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#THIRD_TEAM_COLOR_TAG);
3270 }
3271 #endif
3272 #endif
3273 #if defined TEAMSIZE
3274 #if TEAMSIZE >=4
3275 if(i == 3 && BED_STATE_TEAM_FOUR !=-1 )
3276 {
3277 BED_STATE_TEAM_FOUR=-1;
3278 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#FOURTH_TEAM_COLOR_TAG);
3279 }
3280 #endif
3281 #endif
3282 #if defined TEAMSIZE
3283 #if TEAMSIZE >=5
3284 if(i == 4 && BED_STATE_TEAM_FIVE !=-1 )
3285 {
3286 BED_STATE_TEAM_FIVE=-1;
3287 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#FIFTH_TEAM_COLOR_TAG);
3288 }
3289 #endif
3290 #endif
3291 #if defined TEAMSIZE
3292 #if TEAMSIZE >=6
3293 if(i == 5 && BED_STATE_TEAM_SIX !=-1 )
3294 {
3295 BED_STATE_TEAM_SIX=-1;
3296 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#SIXTH_TEAM_COLOR_TAG);
3297 }
3298 #endif
3299 #endif
3300 SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
3301 x1=pX[playerid];
3302 y1=pY[playerid];
3303 z1=pZ[playerid];
3304 ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 1);
3305 SetTimer("BlowUpThisBed", 130, false);
3306 return 1;
3307 }
3308
3309 }
3310 }
3311 }
3312 if(strcmp(cmd, "/netstats", true) == 0)
3313 {
3314 new stats[400+1];
3315 new targetplayer;
3316 if(sscanf(cmdtext[strlen("/netstats")+1], "u", targetplayer))
3317 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /netstats [playerid]");
3318 if(!IsPlayerConnected(targetplayer))
3319 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3320
3321 GetPlayerNetworkStats(targetplayer, stats, sizeof(stats)); // get a players networkstats
3322 ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Networkstats", stats, "Okay", "");
3323 }
3324 if(strcmp(cmd, "/stats", true) == 0)
3325 {
3326 new targetplayer;
3327 if(sscanf(cmdtext[strlen("/stats")+1], "u", targetplayer))
3328 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /stats [playerid]");
3329 if(!IsPlayerConnected(targetplayer))
3330 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3331 new statsstring1[128];
3332 new statsstring2[256];
3333 new deaths = PlayerInfo[targetplayer][pDeaths];
3334 new kills = PlayerInfo[targetplayer][pKills];
3335 if(deaths == 0)
3336 {
3337 deaths = 1;
3338 }
3339 deaths = PlayerInfo[targetplayer][pDeaths];
3340 kills = PlayerInfo[targetplayer][pKills];
3341 new Float:kd = floatdiv(kills,deaths);
3342 new name[MAX_PLAYER_NAME];
3343 GetPlayerName(targetplayer, name, sizeof(name));
3344 format(statsstring1,sizeof(statsstring1),"SERVER: Player stats of %s(%d) below.",name,targetplayer);
3345 SendClientMessage(playerid, COLOR_WHITE,statsstring1);
3346 format(statsstring2,sizeof(statsstring2),"Kills:%d Deaths:%d Ratio:%0.2f Blown beds:%d Bombs detonated:%d",kills,deaths,kd,PlayerInfo[targetplayer][pBeds],PlayerInfo[targetplayer][pBombs]);
3347 SendClientMessage(playerid, COLOR_WHITE,statsstring2);
3348 }
3349 if(strcmp(cmd, "/pm", true) == 0)
3350 {
3351 new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
3352 if(sscanf(cmdtext[strlen("/pm")+1], "us", id, str2))
3353 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pm <id> <message>");
3354 if(!IsPlayerConnected(id))
3355 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
3356 if(playerid == id)
3357 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot pm yourself!");
3358
3359 GetPlayerName(playerid, Name1, sizeof(Name1));
3360 GetPlayerName(id, Name2, sizeof(Name2));
3361 format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
3362 SendClientMessage(playerid, COLOR_YELLOW, str);
3363 format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
3364 SendClientMessage(id, COLOR_YELLOW, str);
3365 return 1;
3366 }
3367 if(strcmp(cmd, "/r", true) == 0)
3368 {
3369 new str[256], str2[256], Name1[MAX_PLAYER_NAME];
3370 if(sscanf(cmdtext[strlen("/r")+1], "s", str2))
3371 return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /r <message>");
3372 GetPlayerName(playerid, Name1, sizeof(Name1));
3373 format(str, sizeof(str), "[%s{FFFFFF}]%s(%d): %s",GetPlayerTeamColorTag(playerid), Name1, playerid, str2);
3374 SendTeamMessage(gPlayerTeamSelection[playerid],COLOR_WHITE,str);
3375 return 1;
3376 }
3377 if(strcmp(cmdtext, "/blowup", true) == 0)
3378 {
3379 for(new i = 0; i < sizeof(beds); i++)
3380 {
3381 new Float:health;
3382 GetPlayerHealth(playerid,health);
3383
3384 if(running !=1 && IsPlayerInRangeOfPoint(playerid,3.0,beds[i][0],beds[i][1],beds[i][2]) && health > 0 && !IsPlayerInAnyVehicle(playerid)) // In this script we deal with players only
3385 {
3386 if((i == 0 && gPlayerTeamSelection[playerid] == FIRST_TEAM) || (i == 1 && gPlayerTeamSelection[playerid] == SECOND_TEAM) || (i == 2 && gPlayerTeamSelection[playerid] == THIRD_TEAM) || (i == 3 && gPlayerTeamSelection[playerid] == FOURTH_TEAM) || (i == 4 && gPlayerTeamSelection[playerid] == FIFTH_TEAM) || (i == 5 && gPlayerTeamSelection[playerid] == SIXTH_TEAM))
3387 return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot blow up the bed of your own team!");
3388 running = 1;
3389 SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
3390 PlayerInfo[playerid][pBeds]=GetPlayerScore(playerid);
3391 SetTimer("BlowUpThisBed", bombtimer, false);
3392 if(i == 0 && BED_STATE_TEAM_ONE !=-1 )
3393 {
3394 BED_STATE_TEAM_ONE=-1;
3395 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team "#FIRST_TEAM_COLOR_TAG);
3396 }
3397 if(i == 1 && BED_STATE_TEAM_TWO !=-1 )
3398 {
3399 BED_STATE_TEAM_TWO=-1;
3400 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team "#SECOND_TEAM_COLOR_TAG);
3401 }
3402
3403 #if defined TEAMSIZE
3404 #if TEAMSIZE >=3
3405 if(i == 2 && BED_STATE_TEAM_THREE !=-1 )
3406 {
3407 BED_STATE_TEAM_THREE=-1;
3408 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team "#THIRD_TEAM_COLOR_TAG);
3409 }
3410 #endif
3411 #endif
3412 #if defined TEAMSIZE
3413 #if TEAMSIZE >=4
3414 if(i == 3 && BED_STATE_TEAM_FOUR !=-1 )
3415 {
3416 BED_STATE_TEAM_FOUR=-1;
3417 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team "#FOURTH_TEAM_COLOR_TAG);
3418 }
3419 #endif
3420 #endif
3421 #if defined TEAMSIZE
3422 #if TEAMSIZE >=5
3423 if(i == 4 && BED_STATE_TEAM_FIVE !=-1 )
3424 {
3425 BED_STATE_TEAM_FIVE=-1;
3426 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team "#FIFTH_TEAM_COLOR_TAG);
3427 }
3428 #endif
3429 #endif
3430 #if defined TEAMSIZE
3431 #if TEAMSIZE >=6
3432 if(i == 5 && BED_STATE_TEAM_SIX !=-1 )
3433 {
3434 BED_STATE_TEAM_SIX=-1;
3435 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team "#SIXTH_TEAM_COLOR_TAG);
3436 }
3437 #endif
3438 #endif
3439 PBeds[playerid]+=1;
3440 SendClientMessage(playerid, COLOR_WHITE, "SERVER: Planted Bomb Successfully. Lets Blow This Bed Up!");
3441 SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
3442 SendClientMessage(playerid, COLOR_WHITE, "SERVER: Keep Running! Bed Will Blow Up In 5 seconds!");
3443
3444 GetPlayerPos(playerid, x1, y1, z1);
3445 ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 1);
3446 for(new k = 0; k < MAX_PLAYERS; k++)
3447 {
3448 PlayerPlaySound(k,7416,x1,y1,z1);
3449 }
3450 CountDownTimer = SetTimer("CountDown", 1000, true);
3451 new Float:dist = GetDistance(beds[i][0],beds[i][1],beds[i][2],x1,y1,z1);
3452 printf("Distance to closest bed: %f, Index: %d", dist, i);
3453
3454
3455
3456 return 1;
3457
3458 }
3459
3460
3461
3462 }
3463 return 0;
3464
3465 }
3466 return 1;
3467
3468}
3469public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
3470{
3471 if(PRESSED(KEY_YES) && PBomb[playerid] == -1 && PBombID[playerid] == 1 && IsPlayerInRangeOfPoint(playerid,150,pX[playerid],pY[playerid],pZ[playerid]))
3472 {
3473 PlayerInfo[playerid][pBombs]++;
3474 PBombID[playerid]=0;
3475 PBomb[playerid]=0;
3476 CreateExplosion(pX[playerid],pY[playerid],pZ[playerid],7,10);
3477 CreateExplosion(pX[playerid],pY[playerid],pZ[playerid],9,10);
3478 SendClientMessage(playerid, COLOR_WHITE, "SERVER: Bomb detonated!");
3479 PlayerPlaySound(playerid, 21001, 0, 0, 0);
3480 DestroyObject(BombObject[playerid]);
3481 for(new i = 0; i < sizeof(beds[]); i++)
3482 {
3483 new Float:health;
3484 GetPlayerHealth(playerid,health);
3485 new Float:dist = GetDistance(beds[i][0],beds[i][1],beds[i][2],pX[playerid],pY[playerid],pZ[playerid]);
3486 if(dist < 4)
3487 {
3488 running = 1;
3489 if(!(i == 0 && gPlayerTeamSelection[playerid] == FIRST_TEAM) || !(i == 1 && gPlayerTeamSelection[playerid] == THIRD_TEAM) || !(i == 2 && gPlayerTeamSelection[playerid] == SECOND_TEAM))
3490 PBeds[playerid]+=1;
3491
3492
3493 if(i == 0 && BED_STATE_TEAM_ONE !=-1 )
3494 {
3495 BED_STATE_TEAM_ONE=-1;
3496 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#FIRST_TEAM_COLOR_TAG);
3497 }
3498 if(i == 1 && BED_STATE_TEAM_TWO !=-1 )
3499 {
3500 BED_STATE_TEAM_THREE=-1;
3501 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#SECOND_TEAM_COLOR_TAG);
3502 }
3503
3504 #if defined TEAMSIZE
3505 #if TEAMSIZE >=3
3506 if(i == 2 && BED_STATE_TEAM_THREE !=-1 )
3507 {
3508 BED_STATE_TEAM_TWO=-1;
3509 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#THIRD_TEAM_COLOR_TAG);
3510 }
3511 #endif
3512 #endif
3513 #if defined TEAMSIZE
3514 #if TEAMSIZE >=4
3515 if(i == 3 && BED_STATE_TEAM_FOUR !=-1 )
3516 {
3517 BED_STATE_TEAM_FOUR=-1;
3518 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#FOURTH_TEAM_COLOR_TAG);
3519 }
3520 #endif
3521 #endif
3522 #if defined TEAMSIZE
3523 #if TEAMSIZE >=5
3524 if(i == 4 && BED_STATE_TEAM_FIVE !=-1 )
3525 {
3526 BED_STATE_TEAM_FIVE=-1;
3527 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#FIFTH_TEAM_COLOR_TAG);
3528 }
3529 #endif
3530 #endif
3531 #if defined TEAMSIZE
3532 #if TEAMSIZE >=6
3533 if(i == 5 && BED_STATE_TEAM_SIX !=-1 )
3534 {
3535 BED_STATE_TEAM_SIX=-1;
3536 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You blew up the bed of Team "#SIXTH_TEAM_COLOR_TAG);
3537 }
3538 #endif
3539 #endif
3540 SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
3541 x1=pX[playerid];
3542 y1=pY[playerid];
3543 z1=pZ[playerid];
3544 ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 1);
3545 SetTimer("BlowUpThisBed", 130, false);
3546
3547
3548
3549
3550 return 1;
3551 }
3552
3553 }
3554 }
3555 return 1;
3556}
3557public OnPlayerDeath(playerid, killerid, reason)
3558{
3559 PlayerInfo[playerid][pDeaths]++;
3560 if(killerid != INVALID_PLAYER_ID) PlayerInfo[killerid][pKills]++;
3561 ResetPlayerData(playerid);
3562
3563 new pname[MAX_PLAYER_NAME];
3564 GetPlayerName(playerid, pname, sizeof(pname));
3565 new matediedstringgrey[128];
3566 new matediedstringred[128];
3567 new matediedstringblue[128];
3568
3569 HideMenuForPlayer(ammunation,playerid);
3570 HideMenuForPlayer(pistols,playerid);
3571 HideMenuForPlayer(microsmg,playerid);
3572 HideMenuForPlayer(shotguns,playerid);
3573 HideMenuForPlayer(items,playerid);
3574 HideMenuForPlayer(smg,playerid);
3575 HideMenuForPlayer(rifles,playerid);
3576 HideMenuForPlayer(assaultrifle,playerid);
3577 HideMenuForPlayer(Grenades,playerid);
3578 HideMenuForPlayer(melee,playerid);
3579 HideMenuForPlayer(special,playerid);
3580 HideMenuForPlayer(shopmenu,playerid);
3581 HideMenuForPlayer(yesno,playerid);
3582
3583
3584 if(GetPlayerWeapon(playerid) == 16)
3585 {
3586 new Float:x, Float:y, Float:z;
3587 GetPlayerPos(playerid,x,y,z);
3588 CreateExplosion(x,y,z,7,10);
3589 CreateExplosion(x,y,z,9,10);
3590 }
3591
3592 if(BED_STATE_TEAM_ONE != 0 && gPlayerTeamSelection[playerid] == FIRST_TEAM)
3593 {
3594 format(matediedstringgrey,sizeof(matediedstringgrey),"SERVER: %s (%d) has been killed, watch out! %d players left in Team "#FIRST_TEAM_COLOR_TAG,pname,playerid,GetTeamPlayerCount(FIRST_TEAM)-1);
3595 SendClientMessageToAll(COLOR_WHITE,matediedstringgrey);
3596 }
3597 if(BED_STATE_TEAM_TWO != 0 && gPlayerTeamSelection[playerid] == SECOND_TEAM)
3598 {
3599 format(matediedstringred,sizeof(matediedstringred),"SERVER: %s (%d) has been killed, watch out! %d players left in Team "#SECOND_TEAM_COLOR_TAG,pname,playerid,GetTeamPlayerCount(SECOND_TEAM)-1);
3600 SendClientMessageToAll(COLOR_WHITE,matediedstringred);
3601 }
3602 #if defined TEAMSIZE
3603 #if TEAMSIZE >=3
3604 if(BED_STATE_TEAM_THREE != 0 && gPlayerTeamSelection[playerid] == THIRD_TEAM)
3605 {
3606 format(matediedstringblue,sizeof(matediedstringblue),"SERVER: %s (%d) has been killed, watch out! %d players left in Team "#THIRD_TEAM_COLOR_TAG,pname,playerid,GetTeamPlayerCount(THIRD_TEAM)-1);
3607 SendClientMessageToAll(COLOR_WHITE,matediedstringblue);
3608 }
3609 #endif
3610 #endif
3611 #if defined TEAMSIZE
3612 #if TEAMSIZE >=4
3613 if(BED_STATE_TEAM_FOUR != 0 && gPlayerTeamSelection[playerid] == FOURTH_TEAM)
3614 {
3615 format(matediedstringgrey,sizeof(matediedstringgrey),"SERVER: %s (%d) has been killed, watch out! %d players left in Team "#FOURTH_TEAM_COLOR_TAG,pname,playerid,GetTeamPlayerCount(FOURTH_TEAM)-1);
3616 SendClientMessageToAll(COLOR_WHITE,matediedstringgrey);
3617 }
3618 #endif
3619 #endif
3620 #if defined TEAMSIZE
3621 #if TEAMSIZE >=5
3622 if(BED_STATE_TEAM_FIVE != 0 && gPlayerTeamSelection[playerid] == FIFTH_TEAM)
3623 {
3624 format(matediedstringred,sizeof(matediedstringred),"SERVER: %s (%d) has been killed, watch out! %d players left in Team "#FIFTH_TEAM_COLOR_TAG,pname,playerid,GetTeamPlayerCount(FIFTH_TEAM)-1);
3625 SendClientMessageToAll(COLOR_WHITE,matediedstringred);
3626 }
3627 #endif
3628 #endif
3629 #if defined TEAMSIZE
3630 #if TEAMSIZE ==6
3631 if(BED_STATE_TEAM_SIX != 0 && gPlayerTeamSelection[playerid] == SIXTH_TEAM)
3632 {
3633 format(matediedstringblue,sizeof(matediedstringblue),"SERVER: %s (%d) has been killed, watch out! %d players left in Team "#SIXTH_TEAM_COLOR_TAG,pname,playerid,GetTeamPlayerCount(SIXTH_TEAM)-1);
3634 SendClientMessageToAll(COLOR_WHITE,matediedstringblue);
3635 }
3636 #endif
3637 #endif
3638 new playercash;
3639 playercash = GetPlayerMoney(playerid);
3640 SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
3641 gPlayerHasTeamSelected[playerid] = 0;
3642 TextDrawHideForPlayer(playerid,txtTimeDisp);
3643 playercash = GetPlayerMoney(playerid);
3644 ResetPlayerMoney(playerid);
3645 GivePlayerMoneyText(playerid, -playercash);
3646 LastMoney[playerid]=playercash;
3647
3648 #if defined SCORESYSTEM
3649 #if SCORESYSTEM==0
3650 if(killerid != playerid && killerid != INVALID_PLAYER_ID)
3651 {
3652 GivePlayerMoneyText(killerid,playercash);
3653 }
3654 #elseif SCORESYSTEM==1
3655
3656 if(killerid != playerid && killerid != INVALID_PLAYER_ID)
3657 {
3658 if(GetPlayerScore(killerid) >= 100)
3659 GivePlayerMoneyText(killerid,playercash+playercash/4);
3660 if(GetPlayerScore(killerid) >= 500)
3661 GivePlayerMoneyText(killerid,playercash+playercash/2);
3662 if(GetPlayerScore(killerid) >= 1000)
3663 GivePlayerMoneyText(killerid,playercash * 2);
3664 }
3665 #endif
3666 #else
3667 if(killerid != playerid && killerid != INVALID_PLAYER_ID)
3668 {
3669 GivePlayerMoneyText(killerid,playercash);
3670 }
3671 #endif
3672
3673
3674 PKills[playerid] += 1;
3675 if(BED_STATE_TEAM_ONE!=0 && FIRST_TEAM == gPlayerTeamSelection[playerid])
3676 {
3677 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Unable to respawn. The bed of team %s {FFFFFF}already has been destroyed.",FIRST_TEAM_COLOR_TAG);
3678 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Entering spectator mode..");
3679 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
3680 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
3681 gPlayerTeamSelection[playerid] =TEAM_SPECTATOR;
3682 SetPlayerColor(playerid,COLOR_WHITE);
3683 SpecRandomPlayer(playerid);
3684 }
3685 if(BED_STATE_TEAM_TWO!=0 && SECOND_TEAM == gPlayerTeamSelection[playerid])
3686 {
3687 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Unable to respawn. The bed of team %s {FFFFFF}already has been destroyed.",SECOND_TEAM_COLOR_TAG);
3688 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Entering spectator mode..");
3689 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
3690 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
3691 gPlayerTeamSelection[playerid] =TEAM_SPECTATOR;
3692 SetPlayerColor(playerid,COLOR_WHITE);
3693 SpecRandomPlayer(playerid);
3694 }
3695 #if defined TEAMSIZE
3696 #if TEAMSIZE >= 3
3697 if(BED_STATE_TEAM_THREE!=0 && THIRD_TEAM == gPlayerTeamSelection[playerid])
3698 {
3699 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Unable to respawn. The bed of team %s {FFFFFF}already has been destroyed.",THIRD_TEAM_COLOR_TAG);
3700 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Entering spectator mode..");
3701 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
3702 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
3703 gPlayerTeamSelection[playerid] =TEAM_SPECTATOR;
3704 SetPlayerColor(playerid,COLOR_WHITE);
3705 SpecRandomPlayer(playerid);
3706 }
3707 #endif
3708 #endif
3709 #if defined TEAMSIZE
3710 #if TEAMSIZE >= 4
3711 if(BED_STATE_TEAM_FOUR!=0 && FOURTH_TEAM == gPlayerTeamSelection[playerid])
3712 {
3713 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Unable to respawn. The bed of team %s {FFFFFF}already has been destroyed.",FOURTH_TEAM_COLOR_TAG);
3714 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Entering spectator mode..");
3715 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
3716 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
3717 gPlayerTeamSelection[playerid] =TEAM_SPECTATOR;
3718 SetPlayerColor(playerid,COLOR_WHITE);
3719 SpecRandomPlayer(playerid);
3720 }
3721 #endif
3722 #endif
3723 #if defined TEAMSIZE
3724 #if TEAMSIZE >= 5
3725 if(BED_STATE_TEAM_FIVE!=0 && FIFTH_TEAM == gPlayerTeamSelection[playerid])
3726 {
3727 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Unable to respawn. The bed of team %s {FFFFFF}already has been destroyed.",FIFTH_TEAM_COLOR_TAG);
3728 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Entering spectator mode..");
3729 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
3730 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
3731 gPlayerTeamSelection[playerid] =TEAM_SPECTATOR;
3732 SetPlayerColor(playerid,COLOR_WHITE);
3733 SpecRandomPlayer(playerid);
3734 }
3735 #endif
3736 #endif
3737 #if defined TEAMSIZE
3738 #if TEAMSIZE == 6
3739 if(BED_STATE_TEAM_SIX!=0 && SIXTH_TEAM == gPlayerTeamSelection[playerid])
3740 {
3741 SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Unable to respawn. The bed of team %s {FFFFFF}already has been destroyed.",SIXTH_TEAM_COLOR_TAG);
3742 SendClientMessage(playerid,COLOR_WHITE,"SERVER: Entering spectator mode..");
3743 SetPlayerCameraPos(playerid,243.2876,1802.5547,7.4141);
3744 SetPlayerCameraLookAt(playerid,243.1261,1805.2798,8.3794);
3745 gPlayerTeamSelection[playerid] =TEAM_SPECTATOR;
3746 SetPlayerColor(playerid,COLOR_WHITE);
3747 SpecRandomPlayer(playerid);
3748 }
3749 #endif
3750 #endif
3751 if(GetActiveTeamCount() >= 2)
3752 {
3753 TeamsAlive(false);
3754 }
3755 if(IsBeingSpeced[playerid] == 1)
3756 {
3757 for(new i;i<MAX_PLAYERS;i++)
3758 {
3759 if(spectatorid[i] == playerid)
3760 {
3761 SpecRandomPlayer(i);
3762 }
3763 }
3764 }
3765 return 1;
3766}
3767
3768ClassSel_SetupSelectedTeam(playerid)
3769{
3770 PlayerTextDrawDestroy(playerid, TeamText[playerid]);
3771 PlayerTextDrawDestroy(playerid, TeamCover[playerid]);
3772 PlayerTextDrawDestroy(playerid, LocText[playerid]);
3773 TeamText[playerid] = CreatePlayerTextDraw(playerid, 65.000000,349.000000,"Team:");
3774 ClassSel_InitTeamNameText(playerid,TeamText[playerid]);
3775 TeamCover[playerid] = CreatePlayerTextDraw(playerid, 10.000000,349.000000,"Team:");
3776 ClassSel_InitTeamNameText(playerid,TeamCover[playerid]);
3777 LocText[playerid] = CreatePlayerTextDraw(playerid, 10.000000,379.000000,"Location:");
3778 ClassSel_InitTeamNameText(playerid,LocText[playerid]);
3779 PlayerTextDrawShow(playerid,TeamCover[playerid]);
3780 PlayerPlaySound(playerid,1185,0,0,0);
3781 SetPlayerColor(playerid,COLOR_WHITE);
3782 gettime(hour, minute);
3783 SetPlayerTime(playerid,hour,minute);
3784 if(gPlayerTeamSelection[playerid] == -1) {
3785 gPlayerTeamSelection[playerid] = FIRST_TEAM;
3786 }
3787
3788 if(gPlayerTeamSelection[playerid] == FIRST_TEAM) {
3789 SetPlayerInterior(playerid,TEAM_ONE_SEL_INTERIOR);
3790 SetPlayerCameraPos(playerid,ClassSel_SetupTeamTEAM_POS[0][0],ClassSel_SetupTeamTEAM_POS[0][1],ClassSel_SetupTeamTEAM_POS[0][2]);
3791 SetPlayerCameraLookAt(playerid,ClassSel_SetupTeamTEAM_LOOK_AT[0][0],ClassSel_SetupTeamTEAM_LOOK_AT[0][1],ClassSel_SetupTeamTEAM_LOOK_AT[0][2]);
3792 new astring[64];
3793 PlayerTextDrawHide(playerid,TeamText[playerid]);
3794 PlayerTextDrawHide(playerid,LocText[playerid]);
3795 PlayerTextDrawSetString(playerid, TeamText[playerid],FIRST_TEAM_NAME_TAG);
3796 PlayerTextDrawColor(playerid,TeamText[playerid],COLOR_TEAM_ONE_TD);
3797 PlayerTextDrawShow(playerid,TeamText[playerid]);
3798 format(astring,sizeof(astring),"Location:"#FIRST_TEAM_LOCATION);
3799 PlayerTextDrawSetString(playerid, LocText[playerid], astring);
3800 PlayerTextDrawShow(playerid,LocText[playerid]);
3801
3802 SetPlayerWeather(playerid,15);
3803 PlayerPlaySound(playerid,2403,0,0,0);
3804
3805 }
3806 #if defined TEAMSIZE
3807 #if TEAMSIZE >= 2
3808 else if(gPlayerTeamSelection[playerid] == SECOND_TEAM) {
3809 SetPlayerInterior(playerid,TEAM_TWO_SEL_INTERIOR);
3810 SetPlayerWeather(playerid,15);
3811 SetPlayerCameraPos(playerid,ClassSel_SetupTeamTEAM_POS[1][0],ClassSel_SetupTeamTEAM_POS[1][1],ClassSel_SetupTeamTEAM_POS[1][2]);
3812 SetPlayerCameraLookAt(playerid,ClassSel_SetupTeamTEAM_LOOK_AT[1][0],ClassSel_SetupTeamTEAM_LOOK_AT[1][1],ClassSel_SetupTeamTEAM_LOOK_AT[1][2]);
3813 new astring[64];
3814 PlayerTextDrawHide(playerid,TeamText[playerid]);
3815 PlayerTextDrawHide(playerid,LocText[playerid]);
3816 PlayerTextDrawSetString(playerid, TeamText[playerid],SECOND_TEAM_NAME_TAG);
3817 PlayerTextDrawColor(playerid,TeamText[playerid],COLOR_TEAM_TWO_TD);
3818 PlayerTextDrawShow(playerid,TeamText[playerid]);
3819 format(astring,sizeof(astring),"Location:"#SECOND_TEAM_LOCATION);
3820 PlayerTextDrawSetString(playerid, LocText[playerid], astring);
3821 PlayerTextDrawShow(playerid,LocText[playerid]);
3822 PlayerPlaySound(playerid,2402,0,0,0);
3823
3824 }
3825 #endif
3826 #endif
3827 #if defined TEAMSIZE
3828 #if TEAMSIZE >= 3
3829 else if(gPlayerTeamSelection[playerid] == THIRD_TEAM) {
3830 SetPlayerInterior(playerid,TEAM_THREE_SEL_INTERIOR);
3831 SetPlayerCameraPos(playerid,ClassSel_SetupTeamTEAM_POS[2][0],ClassSel_SetupTeamTEAM_POS[2][1],ClassSel_SetupTeamTEAM_POS[2][2]);
3832 SetPlayerCameraLookAt(playerid,ClassSel_SetupTeamTEAM_LOOK_AT[2][0],ClassSel_SetupTeamTEAM_LOOK_AT[2][1],ClassSel_SetupTeamTEAM_LOOK_AT[2][2]);
3833 new astring[64];
3834 PlayerTextDrawHide(playerid,TeamText[playerid]);
3835 PlayerTextDrawHide(playerid,LocText[playerid]);
3836 PlayerTextDrawSetString(playerid, TeamText[playerid],THIRD_TEAM_NAME_TAG);
3837 PlayerTextDrawColor(playerid,TeamText[playerid],COLOR_TEAM_THREE_TD);
3838 PlayerTextDrawShow(playerid,TeamText[playerid]);
3839 format(astring,sizeof(astring),"Location:"#THIRD_TEAM_LOCATION);
3840 PlayerTextDrawSetString(playerid, LocText[playerid], astring);
3841 PlayerTextDrawShow(playerid,LocText[playerid]);
3842 PlayerPlaySound(playerid,2404,0,0,0);
3843
3844 }
3845 #endif
3846 #endif
3847 #if defined TEAMSIZE
3848 #if TEAMSIZE >= 4
3849 else if(gPlayerTeamSelection[playerid] == FOURTH_TEAM) {
3850 SetPlayerInterior(playerid,TEAM_FOUR_SEL_INTERIOR);
3851 SetPlayerCameraPos(playerid,ClassSel_SetupTeamTEAM_POS[3][0],ClassSel_SetupTeamTEAM_POS[3][1],ClassSel_SetupTeamTEAM_POS[3][2]);
3852 SetPlayerCameraLookAt(playerid,ClassSel_SetupTeamTEAM_LOOK_AT[3][0],ClassSel_SetupTeamTEAM_LOOK_AT[3][1],ClassSel_SetupTeamTEAM_LOOK_AT[3][2]);
3853 new astring[64];
3854 PlayerTextDrawHide(playerid,TeamText[playerid]);
3855 PlayerTextDrawHide(playerid,LocText[playerid]);
3856 PlayerTextDrawSetString(playerid, TeamText[playerid],FOURTH_TEAM_NAME_TAG);
3857 PlayerTextDrawColor(playerid,TeamText[playerid],COLOR_TEAM_FOUR_TD);
3858 PlayerTextDrawShow(playerid,TeamText[playerid]);
3859 format(astring,sizeof(astring),"Location:"#FOURTH_TEAM_LOCATION);
3860 PlayerTextDrawSetString(playerid, LocText[playerid], astring);
3861 PlayerTextDrawShow(playerid,LocText[playerid]);
3862 SetPlayerWeather(playerid,0);
3863 PlayerPlaySound(playerid,2404,0,0,0);
3864
3865 }
3866 #endif
3867 #endif
3868 #if defined TEAMSIZE
3869 #if TEAMSIZE >= 5
3870 else if(gPlayerTeamSelection[playerid] == FIFTH_TEAM) {
3871 SetPlayerInterior(playerid,TEAM_FIVE_SEL_INTERIOR);
3872 SetPlayerCameraPos(playerid,ClassSel_SetupTeamTEAM_POS[4][0],ClassSel_SetupTeamTEAM_POS[4][1],ClassSel_SetupTeamTEAM_POS[4][2]);
3873 SetPlayerCameraLookAt(playerid,ClassSel_SetupTeamTEAM_LOOK_AT[4][0],ClassSel_SetupTeamTEAM_LOOK_AT[4][1],ClassSel_SetupTeamTEAM_LOOK_AT[4][2]);
3874 new astring[64];
3875 PlayerTextDrawHide(playerid,TeamText[playerid]);
3876 PlayerTextDrawHide(playerid,LocText[playerid]);
3877 PlayerTextDrawSetString(playerid, TeamText[playerid],FIFTH_TEAM_NAME_TAG);
3878 PlayerTextDrawColor(playerid,TeamText[playerid],COLOR_TEAM_FIVE_TD);
3879 PlayerTextDrawShow(playerid,TeamText[playerid]);
3880 format(astring,sizeof(astring),"Location:"#FIFTH_TEAM_LOCATION);
3881 PlayerTextDrawSetString(playerid, LocText[playerid], astring);
3882 PlayerTextDrawShow(playerid,LocText[playerid]);
3883
3884 SetPlayerWeather(playerid,0);
3885 PlayerPlaySound(playerid,2404,0,0,0);
3886
3887 }
3888 #endif
3889 #endif
3890 #if defined TEAMSIZE
3891 #if TEAMSIZE == 6
3892 else if(gPlayerTeamSelection[playerid] == SIXTH_TEAM) {
3893 SetPlayerInterior(playerid,TEAM_SIX_SEL_INTERIOR);
3894 SetPlayerCameraPos(playerid,ClassSel_SetupTeamTEAM_POS[5][0],ClassSel_SetupTeamTEAM_POS[5][1],ClassSel_SetupTeamTEAM_POS[5][2]);
3895 SetPlayerCameraLookAt(playerid,ClassSel_SetupTeamTEAM_LOOK_AT[5][0],ClassSel_SetupTeamTEAM_LOOK_AT[5][1],ClassSel_SetupTeamTEAM_LOOK_AT[5][2]);
3896 new astring[64];
3897 PlayerTextDrawHide(playerid,TeamText[playerid]);
3898 PlayerTextDrawHide(playerid,LocText[playerid]);
3899 PlayerTextDrawSetString(playerid, TeamText[playerid],SIXTH_TEAM_NAME_TAG);
3900 PlayerTextDrawColor(playerid,TeamText[playerid],COLOR_TEAM_SIX_TD);
3901 PlayerTextDrawShow(playerid,TeamText[playerid]);
3902 format(astring,sizeof(astring),"Location:"#SIXTH_TEAM_LOCATION);
3903 PlayerTextDrawSetString(playerid, LocText[playerid], astring);
3904 PlayerTextDrawShow(playerid,LocText[playerid]);
3905 PlayerPlaySound(playerid,2404,0,0,0);
3906
3907 }
3908 #endif
3909 #endif
3910}
3911
3912//----------------------------------------------------------
3913public BlowUpThisBed()
3914{
3915 CreateExplosion(x1, y1, z1, 7, 10.0);//'heavy' explosion close to bed
3916 CreateExplosion(x1, y1, z1, 9, 10.0);
3917 running=0;
3918 printf("Blow Up This Bed called");
3919 if(BED_STATE_TEAM_ONE == -1)
3920 {
3921 BED_STATE_TEAM_ONE = -2;
3922 SendTeamMessage(FIRST_TEAM,COLOR_WHITE,"SERVER: Sudden death! Keep running, your bed has been blown up! There is no respawn after death!");
3923 new adstring[64];
3924 format(adstring,sizeof(adstring),"SERVER: The bed of team %s {FFFFFF}blew up!",FIRST_TEAM_COLOR_TAG);
3925 SendClientMessageToAll(-1,adstring);
3926 GangZoneHideForAll(TEAM_ZONE_ONE);
3927 printf("Violet");
3928
3929 }
3930 if(BED_STATE_TEAM_TWO == -1)
3931 {
3932 BED_STATE_TEAM_TWO = -2;
3933 SendTeamMessage(SECOND_TEAM,COLOR_WHITE,"SERVER: Sudden death! Keep running, your bed has been blown up! There is no respawn after death!");
3934 new adstring[64];
3935 format(adstring,sizeof(adstring),"SERVER: The bed of team %s {FFFFFF}blew up!",SECOND_TEAM_COLOR_TAG);
3936 SendClientMessageToAll(-1,adstring);
3937 GangZoneHideForAll(TEAM_ZONE_TWO);
3938 }
3939 #if defined TEAMSIZE
3940 #if TEAMSIZE >= 3
3941 if(BED_STATE_TEAM_THREE == -1)
3942 {
3943 BED_STATE_TEAM_THREE = -2;
3944 SendTeamMessage(THIRD_TEAM,COLOR_WHITE,"SERVER: Sudden death! Keep running, your bed has been blown up! There is no respawn after death!");
3945 new adstring[64];
3946 format(adstring,sizeof(adstring),"SERVER: The bed of team %s {FFFFFF}blew up!",THIRD_TEAM_COLOR_TAG);
3947 SendClientMessageToAll(-1,adstring);
3948 GangZoneHideForAll(TEAM_ZONE_THREE);
3949 }
3950 #endif
3951 #endif
3952 #if defined TEAMSIZE
3953 #if TEAMSIZE >= 4
3954 if(BED_STATE_TEAM_FOUR == -1)
3955 {
3956 BED_STATE_TEAM_FOUR = -2;
3957 SendTeamMessage(FOURTH_TEAM,COLOR_WHITE,"SERVER: Sudden death! Keep running, your bed has been blown up! There is no respawn after death!");
3958 new adstring[64];
3959 format(adstring,sizeof(adstring),"SERVER: The bed of team %s {FFFFFF}blew up!",FOURTH_TEAM_COLOR_TAG);
3960 SendClientMessageToAll(-1,adstring);
3961 GangZoneHideForAll(TEAM_ZONE_FOUR);
3962
3963 }
3964 #endif
3965 #endif
3966 #if defined TEAMSIZE
3967 #if TEAMSIZE >= 5
3968 if(BED_STATE_TEAM_FIVE == -1)
3969 {
3970 BED_STATE_TEAM_FIVE = -2;
3971 SendTeamMessage(FIFTH_TEAM,COLOR_WHITE,"SERVER: Sudden death! Keep running, your bed has been blown up! There is no respawn after death!");
3972 new adstring[64];
3973 format(adstring,sizeof(adstring),"SERVER: The bed of team %s {FFFFFF}blew up!",FIFTH_TEAM_COLOR_TAG);
3974 SendClientMessageToAll(-1,adstring);
3975 GangZoneHideForAll(TEAM_ZONE_FIVE);
3976 }
3977 #endif
3978 #endif
3979 #if defined TEAMSIZE
3980 #if TEAMSIZE == 6
3981 if(BED_STATE_TEAM_SIX == -1)
3982 {
3983 BED_STATE_TEAM_SIX = -2;
3984 SendTeamMessage(SIXTH_TEAM,COLOR_WHITE,"SERVER: Sudden death! Keep running, your bed has been blown up! There is no respawn after death!");
3985 new adstring[64];
3986 format(adstring,sizeof(adstring),"SERVER: The bed of team %s {FFFFFF}blew up!",SIXTH_TEAM_COLOR_TAG);
3987 SendClientMessageToAll(-1,adstring);
3988 GangZoneHideForAll(TEAM_ZONE_SIX);
3989 }
3990 #endif
3991 #endif
3992}
3993stock GetVehicleDriver(vid)
3994{
3995 for(new i; i < GetMaxPlayers(); i++)
3996 {
3997 if(!IsPlayerConnected(i)) continue;
3998 if(GetPlayerVehicleID(i) == vid && GetPlayerSeat(playerid) == 0) return i;
3999 }
4000 return INVALID_PLAYER_ID;
4001}
4002stock RespawnAllVehicles()
4003{
4004 for(new i = GetVehiclePoolSize(); i > 0; i--)
4005 {
4006 if(GetVehicleDriver(i) != INVALID_PLAYER_ID) continue;
4007 SetVehicleToRespawn(i);
4008 }
4009}
4010stock GetPlayerCount()
4011{
4012 new counter=0;
4013 for(new k;k<MAX_PLAYERS;k++)
4014 {
4015 if(!IsPlayerConnected(k) || IsPlayerNPC(k)) continue;
4016
4017 counter++;
4018 }
4019 return counter;
4020}
4021
4022public OnPlayerStateChange(playerid, newstate, oldstate)
4023{
4024 if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
4025 {
4026 if(IsBeingSpeced[playerid] == 1)
4027 {
4028 for(new i;i<MAX_PLAYERS;i++)
4029 {
4030 if(spectatorid[i] == playerid)
4031 {
4032 PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
4033 }
4034 }
4035 }
4036 }
4037 if(newstate == PLAYER_STATE_ONFOOT)
4038 {
4039 if(IsBeingSpeced[playerid] == 1)
4040 {
4041 for(new i;i<MAX_PLAYERS;i++)
4042 {
4043 if(spectatorid[i] == playerid)
4044 {
4045 PlayerSpectatePlayer(i, playerid);
4046 }
4047 }
4048 }
4049 }
4050 return 1;
4051}
4052public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
4053{
4054 if(IsBeingSpeced[playerid] == 1)
4055 {
4056 for(new i;i<MAX_PLAYERS;i++)
4057 {
4058 if(spectatorid[i] == playerid)
4059 {
4060 SetPlayerInterior(i,GetPlayerInterior(playerid));
4061 SetPlayerVirtualWorld(i,GetPlayerVirtualWorld(playerid));
4062 }
4063 }
4064 }
4065 return 1;
4066}
4067
4068public OnPlayerSpawn(playerid)
4069{
4070 if(IsSpecing[playerid] == 1)
4071 {
4072 SetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
4073 SetPlayerInterior(playerid,Inter[playerid]);
4074 SetPlayerVirtualWorld(playerid,vWorld[playerid]);
4075 IsSpecing[playerid] = 0;
4076 IsBeingSpeced[spectatorid[playerid]] = 0;
4077 }
4078 if(IsPlayerNPC(playerid)) return 1;
4079 if(IsSpecing[playerid] == 1) return 1;
4080 if(gPlayerTeamSelection[playerid] == TEAM_SPECTATOR) return 1;
4081
4082 TextDrawShowForPlayer(playerid,txtTimeDisp);
4083 PlayerPlaySound(playerid,1188,0,0,0);
4084 SetPlayerWorldBounds(playerid,MAP_WORLDBOUNDS[0][0], MAP_WORLDBOUNDS[0][1], MAP_WORLDBOUNDS[0][2], MAP_WORLDBOUNDS[0][3]);
4085
4086 new randSpawn = 0;
4087
4088
4089 SetPlayerVirtualWorld(playerid,0);
4090 TogglePlayerClock(playerid,0);
4091 ResetPlayerMoney(playerid);
4092
4093 switch(gPlayerTeamSelection[playerid])
4094 {
4095 case FIRST_TEAM:
4096 {
4097 randSpawn = random(sizeof(gSpawnsTeam_TEAM_ONE));
4098 SetPlayerPos(playerid,gSpawnsTeam_TEAM_ONE[randSpawn][0],gSpawnsTeam_TEAM_ONE[randSpawn][1],gSpawnsTeam_TEAM_ONE[randSpawn][2]);
4099 SetPlayerFacingAngle(playerid,gSpawnsTeam_TEAM_ONE[randSpawn][3]);
4100 }
4101 #if defined TEAMSIZE
4102 #if TEAMSIZE >= 2
4103 case SECOND_TEAM:
4104 {
4105 randSpawn = random(sizeof(gSpawnsTeam_TEAM_TWO));
4106 SetPlayerPos(playerid,
4107 gSpawnsTeam_TEAM_TWO[randSpawn][0],
4108 gSpawnsTeam_TEAM_TWO[randSpawn][1],
4109 gSpawnsTeam_TEAM_TWO[randSpawn][2]);
4110 SetPlayerFacingAngle(playerid,gSpawnsTeam_TEAM_TWO[randSpawn][3]);
4111 }
4112 #endif
4113 #endif
4114 #if defined TEAMSIZE
4115 #if TEAMSIZE >= 3
4116 case THIRD_TEAM:
4117 {
4118 randSpawn = random(sizeof(gSpawnsTeam_TEAM_THREE));
4119 SetPlayerPos(playerid,
4120 gSpawnsTeam_TEAM_THREE[randSpawn][0],
4121 gSpawnsTeam_TEAM_THREE[randSpawn][1],
4122 gSpawnsTeam_TEAM_THREE[randSpawn][2]);
4123 SetPlayerFacingAngle(playerid,gSpawnsTeam_TEAM_THREE[randSpawn][3]);
4124 }
4125 #endif
4126 #endif
4127 #if defined TEAMSIZE
4128 #if TEAMSIZE >= 4
4129 case FOURTH_TEAM:
4130 {
4131 randSpawn = random(sizeof(gSpawnsTeam_TEAM_FOUR));
4132 SetPlayerPos(playerid,
4133 gSpawnsTeam_TEAM_FOUR[randSpawn][0],
4134 gSpawnsTeam_TEAM_FOUR[randSpawn][1],
4135 gSpawnsTeam_TEAM_FOUR[randSpawn][2]);
4136 SetPlayerFacingAngle(playerid,gSpawnsTeam_TEAM_FOUR[randSpawn][3]);
4137 }
4138 #endif
4139 #endif
4140 #if defined TEAMSIZE
4141 #if TEAMSIZE >= 5
4142 case FIFTH_TEAM:
4143 {
4144 randSpawn = random(sizeof(gSpawnsTeam_TEAM_FIVE));
4145 SetPlayerPos(playerid,
4146 gSpawnsTeam_TEAM_FIVE[randSpawn][0],
4147 gSpawnsTeam_TEAM_FIVE[randSpawn][1],
4148 gSpawnsTeam_TEAM_FIVE[randSpawn][2]);
4149 SetPlayerFacingAngle(playerid,gSpawnsTeam_TEAM_FIVE[randSpawn][3]);
4150 }
4151 #endif
4152 #endif
4153 #if defined TEAMSIZE
4154 #if TEAMSIZE == 6
4155 case SIXTH_TEAM:
4156 {
4157 randSpawn = random(sizeof(gSpawnsTeam_TEAM_SIX));
4158 SetPlayerPos(playerid,
4159 gSpawnsTeam_TEAM_SIX[randSpawn][0],
4160 gSpawnsTeam_TEAM_SIX[randSpawn][1],
4161 gSpawnsTeam_TEAM_SIX[randSpawn][2]);
4162 SetPlayerFacingAngle(playerid,gSpawnsTeam_TEAM_SIX[randSpawn][3]);
4163 }
4164 #endif
4165 #endif
4166 }
4167
4168
4169 GangZoneShowForPlayer(playerid, TEAM_ZONE_ONE, COLOR_TEAM_ONE);
4170 GangZoneShowForPlayer(playerid, TEAM_ZONE_TWO, COLOR_TEAM_TWO);
4171 #if defined TEAMSIZE
4172 #if TEAMSIZE >= 3
4173 GangZoneShowForPlayer(playerid, TEAM_ZONE_THREE, COLOR_TEAM_THREE);
4174 #endif
4175 #endif
4176 #if defined TEAMSIZE
4177 #if TEAMSIZE >= 4
4178 GangZoneShowForPlayer(playerid, TEAM_ZONE_FOUR, COLOR_TEAM_FOUR);
4179 #endif
4180 #endif
4181 #if defined TEAMSIZE
4182 #if TEAMSIZE >= 5
4183 GangZoneShowForPlayer(playerid, TEAM_ZONE_FIVE, COLOR_TEAM_FIVE);
4184 #endif
4185 #endif
4186 #if defined TEAMSIZE
4187 #if TEAMSIZE == 6
4188 GangZoneShowForPlayer(playerid, TEAM_ZONE_SIX, COLOR_TEAM_SIX);
4189 #endif
4190 #endif
4191
4192
4193 SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,100);
4194 SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL_SILENCED,100);
4195 SetPlayerSkillLevel(playerid,WEAPONSKILL_DESERT_EAGLE,100);
4196 SetPlayerSkillLevel(playerid,WEAPONSKILL_SHOTGUN,100);
4197 SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,100);
4198 SetPlayerSkillLevel(playerid,WEAPONSKILL_SPAS12_SHOTGUN,100);
4199 SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,100);
4200 SetPlayerSkillLevel(playerid,WEAPONSKILL_MP5,100);
4201 SetPlayerSkillLevel(playerid,WEAPONSKILL_AK47,100);
4202 SetPlayerSkillLevel(playerid,WEAPONSKILL_M4,100);
4203 SetPlayerSkillLevel(playerid,WEAPONSKILL_SNIPERRIFLE,100);
4204
4205 GivePlayerWeapon(playerid,WEAPON_COLT45,100);
4206 GivePlayerWeapon(playerid,25,5);
4207
4208 switch(gPlayerTeamSelection[playerid])
4209 {
4210 case FIRST_TEAM:
4211 {
4212 SetPlayerInterior(playerid,TEAM_ONE_INTERIOR);
4213 }
4214 case SECOND_TEAM:
4215 {
4216 SetPlayerInterior(playerid,TEAM_TWO_INTERIOR);
4217 }
4218 #if defined TEAMSIZE
4219 #if TEAMSIZE >= 3
4220 case THIRD_TEAM:
4221 {
4222 SetPlayerInterior(playerid,TEAM_THREE_INTERIOR);
4223 }
4224 #endif
4225 #endif
4226 #if defined TEAMSIZE
4227 #if TEAMSIZE >= 4
4228 case FOURTH_TEAM:
4229 {
4230 SetPlayerInterior(playerid,TEAM_FOUR_INTERIOR);
4231 }
4232 #endif
4233 #endif
4234 #if defined TEAMSIZE
4235 #if TEAMSIZE >= 5
4236 case FIFTH_TEAM:
4237 {
4238 SetPlayerInterior(playerid,TEAM_FIVE_INTERIOR);
4239 }
4240 #endif
4241 #endif
4242 #if defined TEAMSIZE
4243 #if TEAMSIZE >= 6
4244 case SIXTH_TEAM:
4245 {
4246 SetPlayerInterior(playerid,TEAM_SIX_INTERIOR);
4247 }
4248 #endif
4249 #endif
4250 default:
4251 {
4252 printf("Something went wrong..");
4253 TextDrawHideForPlayer(playerid,txtSpectatorHelper);
4254 }
4255 }
4256
4257
4258 return 1;
4259}
4260
4261public TEAM_MONEY()//MONEY FOR EACH TEAM
4262{
4263 for (new m=0;m<sizeof(MoneySpawns)-1;m++)
4264 {
4265 GenerateRandomPickup(1212,19,MoneySpawns[m][0],MoneySpawns[m][1],MoneySpawns[m][2],MoneySpawns[m][3],MoneySpawns[m][4],MoneySpawns[m][5],0);
4266 }
4267
4268}
4269
4270//----------------------------------------------------------
4271
4272
4273public MONEY_MAIN()//MAIN
4274{
4275
4276 GenerateRandomPickup(1212,19,MoneySpawns[sizeof(MoneySpawns)-1][0],MoneySpawns[sizeof(MoneySpawns)-1][1],MoneySpawns[sizeof(MoneySpawns)-1][2],MoneySpawns[sizeof(MoneySpawns)-1][3],MoneySpawns[sizeof(MoneySpawns)-1][4],MoneySpawns[sizeof(MoneySpawns)-1][5],0);
4277}
4278
4279
4280stock ResetPlayerData(playerid)
4281{
4282 IsSpecing[playerid]=0;
4283 IsBeingSpeced[playerid]=0;
4284 PStealth[playerid]=0;
4285 Warppowder[playerid]=0;
4286 Helmet[playerid]=0;
4287 PBombID[playerid]=0;
4288 PBomb[playerid]=0;
4289 PSkill[playerid]=0;
4290 WarpVar[playerid]=4;
4291 if(IsValidObject(BombObject[playerid]))
4292 DestroyObject(BombObject[playerid]);
4293 pZ[playerid]=0;
4294 pY[playerid]=0;
4295 pZ[playerid]=0;
4296 if(IsValidObject(Beam[playerid]))
4297 DestroyObject(Beam[playerid]);
4298 SetPlayerFightingStyle(playerid,FIGHT_STYLE_NORMAL);
4299}
4300
4301stock CreateGlobalActor(actorid,modelid,Float:ax,Float:ay,Float:az,Float:angle,Float:distance,pickupid)
4302{
4303 actorid = CreateActor(modelid,ax,ay,az,angle);
4304 new Float:x, Float:y, Float:z;
4305
4306 GetActorPos(actorid, x, y, z);
4307 GetXYInFrontOfActor(actorid, x, y, distance);
4308 ActorPickups[pickupid] = CreatePickup(1210,2,x,y,z,-1);
4309 SetActorInvulnerable(actorid, true);
4310 printf("Actor created, pickupid %d",pickupid);
4311 printf("Array pickupid %d",ActorPickups[Shop_Counter++]);
4312 return pickupid;
4313}
4314
4315stock GetXYInFrontOfActor(actorid, &Float:x, &Float:y, Float:distance)
4316{
4317 new Float:a;
4318 GetActorPos(actorid, x, y, a);
4319 GetActorFacingAngle(actorid, a);
4320 x += (distance * floatsin(-a, degrees));
4321 y += (distance * floatcos(-a, degrees));
4322}
4323
4324stock GivePlayerMoneyText(playerid,value)
4325{
4326 new moneyplayerid[32];
4327 if(value < 0)
4328 format(moneyplayerid,sizeof(moneyplayerid), "~r~ %d~y~$",value);
4329 if(value >= 0)
4330 format(moneyplayerid,sizeof(moneyplayerid), "~g~ %d~y~$",value);
4331 GameTextForPlayer(playerid,moneyplayerid,1000,1);
4332 GivePlayerMoney(playerid,value);
4333}
4334ClassSel_InitTextDraws()
4335{
4336
4337 // Init our observer helper text display
4338 txtClassSelHelper = TextDrawCreate(10.0, 415.0,
4339 " Press ~b~~k~~GO_LEFT~ ~w~or ~b~~k~~GO_RIGHT~ ~w~to switch teams.~n~ Press ~y~~k~~PED_FIREWEAPON~ ~y~to select.");
4340 TextDrawUseBox(txtClassSelHelper, 1);
4341 TextDrawBoxColor(txtClassSelHelper,0x22222266);
4342 TextDrawLetterSize(txtClassSelHelper,0.3,1.0);
4343 TextDrawTextSize(txtClassSelHelper,400.0,40.0);
4344 TextDrawFont(txtClassSelHelper, 2);
4345 TextDrawSetShadow(txtClassSelHelper,0);
4346 TextDrawSetOutline(txtClassSelHelper,1);
4347 TextDrawBackgroundColor(txtClassSelHelper,0x000000FF);
4348 TextDrawColor(txtClassSelHelper,0xFFFFFFFF);
4349
4350
4351}