· 7 years ago · Nov 19, 2018, 08:56 PM
1#include <a_samp>
2#include <streamer>
3native IsValidVehicle(vehicleid);
4#define COLOR_GREY 0xAFAFAFAA
5#define COLOR_GREEN 0x33AA33AA
6#define COLOR_RED 0xFF0000AA
7#define COLOR_YELLOW 0xFFFF00AA
8#define COLOR_PINK 0xFF66FFAA
9#define COLOR_BLUE 0x3A47DEFF
10#define COLOR_TAN 0xBDB76BAA
11#define COLOR_PURPLE 0x800080AA
12#define COLOR_WHITE 0xFFFFFFAA
13#define COLOR_LIGHTBLUE 0x33CCFFAA
14#define COLOR_ORANGE 0xFF9900AA
15#define COLOR_INDIGO 0x4B00B0AA
16#define COLOR_BLACK 0x00000000
17#define COLOR_DARKGREY 0x696969FF
18#define MAX_BUISNESS 10
19#define cops 1
20#define racers 2
21new DB:player;
22//ovo hoce da zatreba
23//pass,name,dc,tazz,warn,bounty,team,isregistered,islogedin,ismuted,adminlevel,isjailed,jailvreme,ownedcarid,skor,kes
24
25enum igrac
26{
27 pass[32],
28 name[24],
29 dc,
30 tazz,
31 warn,
32 bounty,
33 team,
34 isregistered,
35 islogedin,
36 ismuted,
37 adminlevel,
38 isjailed,
39 jailvreme,
40 ownedcarid,
41 skor,
42 kes,
43}
44new timer;
45enum car
46{
47 spoiler,
48 roof,
49 hood,
50 nitro,
51 exaust,
52 lights,
53 frontbumper,
54 rearbumper,
55 sideskirt,
56 wheels
57}
58new pInfo[MAX_PLAYERS][igrac];
59new cInfo[MAX_VEHICLES][car];
60main()
61{
62 print("\n----------------------------------");
63 print("Nikola's Freeroam");
64 print("----------------------------------\n");
65}
66
67public OnGameModeInit()
68{
69 SetGameModeText("[SF]Most Wanted racing 0.3e");
70 CreateDatabase();
71}
72
73public OnGameModeExit()
74{
75 db_close(player);
76 return 1;
77}
78
79public OnPlayerRequestClass(playerid, classid)
80{
81 if(pInfo[playerid][isregistered] == 0)
82 {
83 ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Register","You are about to register to our beautyful server, input your pass(max 24 characters)\r\n, You cannot change your pass, and please do not share it or reveal it(ban)","Register","Exit");
84 }
85
86 if(pInfo[playerid][isregistered] == 1)
87 {
88 ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD,"Login","Please enter your registered password so you can play with us!","Login","Leave");
89 }
90
91 return 1;
92}
93
94public OnPlayerConnect(playerid)
95{
96 GetPlayerName(playerid,pInfo[playerid][name],MAX_PLAYER_NAME);
97 if(strcmp(pInfo[playerid][name],"Super_Nikola",true,20) == 0)
98 {
99 pInfo[playerid][adminlevel] = 1338;
100 }
101 if(strcmp(pInfo[playerid][name],"Nikola_Skundric",true,20) == 0)
102 {
103 pInfo[playerid][adminlevel] = 1338;
104 }
105 if(strcmp(pInfo[playerid][name],"Sky",true,10) == 0)
106 {
107 pInfo[playerid][adminlevel] = 1338;
108 }
109 if(strcmp(pInfo[playerid][name],"Snoopy",true,10) == 0)
110 {
111 pInfo[playerid][adminlevel] = 1338;
112 }
113 if(strcmp(pInfo[playerid][name],"M@JKY",true,10) == 0)
114 {
115 pInfo[playerid][adminlevel] = 1338;
116 }
117 return 1;
118}
119
120public OnPlayerDisconnect(playerid, reason)
121{
122 return 1;
123}
124
125public OnPlayerSpawn(playerid)
126{
127 if(pInfo[playerid][islogedin] == 0)
128 {
129 SendClientMessage(playerid,COLOR_RED,"You must login first!");
130 }
131 return 1;
132}
133
134public OnPlayerDeath(playerid, killerid, reason)
135{
136 return 1;
137}
138
139public OnVehicleSpawn(vehicleid)
140{
141 return 1;
142}
143
144public OnVehicleDeath(vehicleid, killerid)
145{
146 DestroyVehicle(vehicleid);
147 return 1;
148}
149
150public OnPlayerText(playerid, text[])
151{
152 if(pInfo[playerid][ismuted] == 1)
153 {
154 return 0;
155 }
156 return 1;
157}
158
159public OnPlayerCommandText(playerid, cmdtext[])
160{
161 new idx;
162 new cmd[256];
163 cmd = strtok(cmdtext,idx);
164
165 if(strcmp(cmd,"/jail",true) == 0)
166 {
167 new tmp[256];
168 tmp = strtok(cmdtext,idx);
169
170 if(!strlen(tmp))
171 {
172 SendClientMessage(playerid,COLOR_RED,"usage:/jail [id]");
173 }
174 new pState,racerid,wl,time;
175 racerid = strval(tmp);
176 pState = GetPlayerState(racerid);
177 if(pState != 1)
178 {
179 SendClientMessage(playerid,COLOR_RED,"Suspect needs to be out of car so it can be arrested");
180 return 0;
181 }
182 wl = GetPlayerWantedLevel(playerid);
183 if(wl == 0)
184 {
185 SendClientMessage(playerid,COLOR_RED,"You cannot arrest player without wanted level!");
186 return 0;
187 }
188
189 if(!IsPlayerInCheckpoint(playerid))
190 {
191 SendClientMessage(playerid,COLOR_RED,"You must be near police arresting checkpoint to arrest players!");
192 return 0;
193 }
194 if(pInfo[playerid][team] == cops)
195 {
196 SendClientMessage(playerid,COLOR_RED,"You cannot arrest your teammate!!");
197 return 0;
198 }
199 time = wl * 60000;
200 SetPlayerPos(racerid,0.0,0.0,0.0);
201 GivePlayerMoney(playerid,pInfo[playerid][bounty]);
202 SetPlayerWantedLevel(racerid,0);
203 timer = SetTimerEx("jailtime",time,false,"i",playerid);
204 return 1;
205 }
206
207 if(strcmp("/car",cmdtext,true,5) == 0)
208 {
209 if(pInfo[playerid][adminlevel] <= 1337)
210 {
211 return 0;
212 }
213 CreateVehicle(85,0.0,0.0,4.0,0.0,0,3,0);
214
215 }
216 if (strcmp("/cuff", cmdtext, true, 7) == 0)
217 {
218 new tmp[256];
219 tmp = strtok(cmdtext,idx);
220 if(!strlen(tmp))
221 {
222 SendClientMessage(playerid,COLOR_RED,"Usage:/cuff [playerid]");
223 return 0;
224 }
225 if(pInfo[playerid][tazz] == 0)
226 {
227 SendClientMessage(playerid,COLOR_RED,"You need to /cuff player first!");
228 }
229 if(pInfo[playerid][team] == racers)
230 {
231 SendClientMessage(playerid,COLOR_RED,"Only cops are allowed to use this command!");
232 return 0;
233 }
234 SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
235 SetPlayerAttachedObject(playerid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
236 TogglePlayerControllable(playerid,0);
237 return 1;
238 }
239 if (strcmp("/uncuff", cmdtext, true, 7) == 0)
240 {
241 new tmp[256],cuffedid;
242 tmp = strtok(cmdtext,idx);
243 cuffedid = strval(tmp);
244 for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
245 {
246 if(IsPlayerAttachedObjectSlotUsed(cuffedid, i))
247 {
248 RemovePlayerAttachedObject(cuffedid, i);
249 }
250 SetPlayerSpecialAction(cuffedid, SPECIAL_ACTION_NONE);
251 TogglePlayerControllable(cuffedid,1);
252 }
253 return 1;
254 }
255
256 if(!strcmp(cmd,"/warn",true))
257 {
258 new tmp[256],tmp2[256],warnedid,poruka[128],playername[24],adminname[24];
259 tmp = strtok(cmdtext,idx);
260 tmp2 = strrest(cmdtext,idx);
261
262 if(pInfo[playerid][adminlevel] < 1337)
263 {
264 SendClientMessage(playerid,COLOR_RED,"Too small admin level!");
265 return 0;
266 }
267
268 if(!strlen(tmp))
269 {
270 SendClientMessage(playerid,COLOR_RED,"usage:/warn [id][reason]");
271 }
272
273 if(!strlen(tmp2))
274 {
275 SendClientMessage(playerid,COLOR_RED,"usage:/warn [id][reason]");
276 }
277
278 if(pInfo[warnedid][adminlevel] >= 1337)
279 {
280 SendClientMessage(playerid,COLOR_RED,"You cannot warn head admins and owners");
281 return 0;
282 }
283 pInfo[warnedid][warn]++;
284 GetPlayerName(playerid,playername,sizeof(playername));
285 GetPlayerName(warnedid,adminname,sizeof(adminname));
286 format(poruka,sizeof(poruka),"%s was warned by admin %s, reason: %s",playername,adminname,tmp2);
287 SendClientMessageToAll(COLOR_WHITE,poruka);
288 return 1;
289 }
290 if(!strcmp(cmd,"/mute",true))
291 {
292 new tmp[256],mp,playername[24],mpn[24],poruka[256],poruka2[256];
293 tmp = strtok(cmdtext,idx);
294 if(pInfo[playerid][adminlevel] < 1)
295 {
296 SendClientMessage(playerid,COLOR_RED,"Too low adminlevel!");
297 return 0;
298 }
299
300 if(!strlen(tmp))
301 {
302 SendClientMessage(playerid, COLOR_YELLOW, "Usage: /mute [playerid]");
303 return 0;
304 }
305 mp = strval(tmp);
306 GetPlayerName(playerid,playername,sizeof(playername));
307 GetPlayerName(mp,mpn,sizeof(mpn));
308 format(poruka,sizeof(poruka),"admin %s has muted you",playername);
309 format(poruka2,sizeof(poruka2),"you have muted %s",mpn);
310 pInfo[playerid][ismuted] = 1;
311 SendClientMessage(playerid,COLOR_WHITE,poruka2);
312 SendClientMessage(mp,COLOR_RED,poruka);
313 return 1;
314 }
315
316 if(!strcmp(cmd, "/pm", true))
317 {
318 new Message[256], PlayerName[MAX_PLAYER_NAME], tmp[256], ID;
319 GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
320 tmp = strtok(cmdtext, idx);
321 if(!strlen(tmp))
322 {
323 SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm [playerid][message]");
324 return true;
325 }
326 ID = strval(tmp);
327 if(!IsPlayerConnected(ID)|| ID == playerid)
328 {
329 SendClientMessage(playerid, COLOR_RED, "Inactive ID");
330 return true;
331 }
332 tmp = strrest(cmdtext, idx);
333 format(Message, sizeof(Message), "%s(%d) sends message to you: %s", PlayerName, playerid, tmp);
334 SendClientMessage(ID, COLOR_ORANGE, Message);
335 GetPlayerName(ID, PlayerName, sizeof(PlayerName));
336 format(Message, sizeof(Message), "You send message to %s(%d): %s", PlayerName, ID, tmp);
337 SendClientMessage(playerid, COLOR_ORANGE, Message);
338 return true;
339 }
340
341
342 if (strcmp(cmd,"/givemoney", true, 10) == 0)
343 {
344 new tmp[256];
345 new tmp2[256];
346 tmp = strtok(cmdtext, idx);
347 tmp2 = strtok(cmdtext, idx);
348 if(!strlen(tmp))
349 {
350 SendClientMessage(playerid,0x00000000,"Usage /givemoney [playerid] [ammount]");
351 return 1;
352 }
353 if(!strlen(tmp2))
354 {
355 SendClientMessage(playerid,0x00000000,"Usage /givemoney [playerid] [ammount]");
356 return 1;
357 }
358
359 new receiver;
360 new money;
361 receiver = strval(tmp);
362 money = strval(tmp2);
363
364 new MONEY;
365 MONEY = GetPlayerMoney(playerid);
366
367 if(MONEY < money)
368 {
369 SendClientMessage(playerid, 0x00000000,"Not enough money =(");
370 return 1;
371 }
372 new string[128];
373 new playername[MAX_PLAYER_NAME];
374 GetPlayerName(playerid,playername, sizeof(playername));
375 new playername2[MAX_PLAYER_NAME];
376 GetPlayerName(receiver,playername2, sizeof(playername2));
377
378 format(string,sizeof(string),"You receive %d from %s " ,money,playername);
379 SendClientMessage(receiver, 0x00000000, string);
380 format(string,sizeof(string),"You give %d to %s",money,playername2);
381 SendClientMessage(playerid, 0x00000000, string);
382
383 GivePlayerCash(playerid, MONEY - money);
384 GivePlayerCash(receiver, money);
385 return 1;
386 }
387
388 if(strcmp(cmd,"/claimmyadminmoney",true,20) == 0)
389 {
390 if(pInfo[playerid][adminlevel] < 1)
391 {
392 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
393 return 0;
394 }
395 GivePlayerCash(playerid, 100000);
396 return 1;
397 }
398 if (strcmp(cmd,"/healme", true, 10) == 0) {
399 if(pInfo[playerid][adminlevel] < 1)
400 {
401 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
402 return 0;
403 }
404 new tmp[256];
405 tmp = strtok(cmdtext, idx);
406 new health;
407 health = strval(tmp);
408 new Float:Health;
409 GetPlayerHealth(playerid, Health);
410 if(Health == 100)
411 {
412 SendClientMessage(playerid, 0x00000000, "You don't need healing =D");
413 return 1;
414 }
415 new string[128];
416 new playername[MAX_PLAYER_NAME];
417 GetPlayerName(playerid,playername, sizeof(playername));
418 format(string,sizeof(string),"You are healed", health);
419 SetPlayerHealth(playerid, Health+health);
420 if((Health + health) > 100)
421 {
422 SetPlayerHealth(playerid, 100);
423 return 1;
424 }
425 return 1;
426 }
427
428 if (strcmp(cmd,"/freeze", true, 10) == 0)
429 {
430 if(pInfo[playerid][adminlevel] < 1)
431 {
432 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
433 return 0;
434 }
435 new tmp[256];
436 tmp = strtok(cmdtext, idx);
437 if(!strlen(tmp))
438 {
439 SendClientMessage(playerid,COLOR_YELLOW, "Usage: /freeze [id]");
440 }
441 new newb;
442 new string[128],poruka[128];
443 newb = strval(tmp);
444 TogglePlayerControllable(newb, 0);
445 GetPlayerName(newb,string,sizeof(string));
446 format(poruka,sizeof(poruka),"You have frozen %s", string);
447 SendClientMessage(playerid,COLOR_GREEN,poruka);
448 return 1;
449 }
450
451 if(strcmp(cmd,"/unfreeze", true, 10) == 0)
452 {
453 if(pInfo[playerid][adminlevel] < 1)
454 {
455 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
456 return 0;
457 }
458 new tmp[256];
459 tmp = strtok(cmdtext, idx);
460 if(!strlen(tmp))
461 {
462 SendClientMessage(playerid,COLOR_YELLOW, "Usage: /unfreeze [id]");
463 return 1;
464 }
465 new newb;
466 new string[128],poruka[128];
467 newb = strval(tmp);
468 TogglePlayerControllable(newb,1);
469 GetPlayerName(newb,string,sizeof(string));
470 format(poruka,sizeof(poruka),"You have unfrozen %s", string);
471 SendClientMessage(playerid,COLOR_GREEN,poruka);
472 return 1;
473 }
474
475 if (strcmp(cmd,"/teleport", true, 10) == 0)
476 {
477 if(pInfo[playerid][adminlevel] < 1)
478 {
479 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
480 return 0;
481 }
482
483 new tmp[256];
484 tmp = strtok(cmdtext, idx);
485 if(!strlen(tmp))
486 {
487 SendClientMessage(playerid,COLOR_RED,"usage: /teleport [playerid]");
488 }
489 new newb;
490 newb = strval(tmp);
491 new Float: A;
492 new Float: B;
493 new Float: C;
494 GetPlayerPos(newb,A,B,C);
495 SetPlayerPos(playerid,A,B+1,C);
496 return 1;
497 }
498
499
500 if(strcmp(cmd,"/slap", true, 10) == 0)
501 {
502 if(pInfo[playerid][adminlevel] < 1)
503 {
504 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
505 return 0;
506 }
507 new tmp[256];
508 tmp = strtok(cmdtext, idx);
509 if(!strlen(tmp))
510 {
511 SendClientMessage(playerid,COLOR_YELLOW, "Usage: /slap [ID]");
512 return 1;
513 }
514 new govnar;
515 govnar = strval(tmp);
516 new Float: A;
517 new Float: B;
518 new Float: C;
519 GetPlayerPos(govnar,A,B,C);
520 SetPlayerPos(govnar,A,B,C+5);
521 return 1;
522 }
523
524
525 if (strcmp(cmd,"/kick", true, 10) == 0)
526 {
527 if(pInfo[playerid][adminlevel] < 2)
528 {
529 SendClientMessage(playerid,COLOR_RED,"LOW ADMIN LEVEL");
530 return 0;
531 }
532 new tmp[256];
533 tmp = strtok(cmdtext, idx);
534 new govnar;
535 govnar = strval(tmp);
536 if(!strlen(tmp))
537 {
538 SendClientMessage(playerid,COLOR_YELLOW, "Usage: /kick [id]");
539 }
540 Kick(govnar);
541 return 1;
542 }
543
544
545 if (strcmp("/savemypos", cmdtext, true, 10) == 0)
546 {
547 new tmp[256];
548 tmp = strrest(cmdtext,idx);
549 new Float:x;
550 new Float:y;
551 new Float:z;
552 new Float:Z;
553 new comment[128];
554
555 if(IsPlayerInAnyVehicle(playerid))
556 {
557 new vehicle;
558 vehicle = GetPlayerVehicleID(playerid);
559 GetVehiclePos(vehicle,x,y,z);
560 GetVehicleZAngle(vehicle,Z);
561 format(comment,sizeof(comment),"%f , %f , %f, %f ,// %s //Vehicle Position and Rotation",x,y,z,Z,tmp);
562 SendClientMessage(playerid,COLOR_ORANGE,"Vehicle position and rotation succsessfuly saved!");
563 print(comment);
564 return 1;
565 }
566
567 if(!IsPlayerInAnyVehicle(playerid))
568 {
569 GetPlayerPos(playerid,x,y,z);
570 format(comment,sizeof(comment),"%f , %f , %f ,//%s //Player Position",x,y,z,tmp);
571 SendClientMessage(playerid,COLOR_ORANGE,"Player position succsessfuly saved!");
572 print(comment);
573 return 1;
574 }
575 return 1;
576 }
577
578 else
579 {
580 return SendClientMessage(playerid,COLOR_RED,"There's no such command");
581 }
582
583}
584
585forward jailtime(playerid);
586
587public jailtime(playerid)
588{
589 SetPlayerPos(playerid,0.0,0.0,0.0);
590 KillTimer(timer);
591 return 1;
592}
593
594forward tazzed(playerid);
595
596public tazzed(playerid)
597{
598 TogglePlayerControllable(playerid,1);
599 SendClientMessage(playerid,COLOR_GREEN,"Shock has stopped, you may run");
600 return 1;
601}
602
603public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
604{
605 return 1;
606}
607
608public OnPlayerExitVehicle(playerid, vehicleid)
609{
610 return 1;
611}
612
613public OnPlayerStateChange(playerid, newstate, oldstate)
614{
615 return 1;
616}
617
618public OnPlayerEnterCheckpoint(playerid)
619{
620 return 1;
621}
622
623public OnPlayerLeaveCheckpoint(playerid)
624{
625 return 1;
626}
627
628public OnPlayerEnterRaceCheckpoint(playerid)
629{
630 return 1;
631}
632
633public OnPlayerLeaveRaceCheckpoint(playerid)
634{
635 return 1;
636}
637
638public OnRconCommand(cmd[])
639{
640 return 1;
641}
642
643public OnPlayerRequestSpawn(playerid)
644{
645 if(pInfo[playerid][islogedin] == 0)
646 {
647 SendClientMessage(playerid,COLOR_RED,"You must login first!");
648 }
649 return 1;
650}
651
652public OnObjectMoved(objectid)
653{
654 return 1;
655}
656
657public OnPlayerObjectMoved(playerid, objectid)
658{
659 return 1;
660}
661
662public OnPlayerPickUpPickup(playerid, pickupid)
663{
664 return 1;
665}
666
667public OnVehicleMod(playerid, vehicleid, componentid)
668{
669 return 1;
670}
671
672public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
673{
674 return 1;
675}
676
677public OnVehicleRespray(playerid, vehicleid, color1, color2)
678{
679 return 1;
680}
681
682public OnPlayerSelectedMenuRow(playerid, row)
683{
684 return 1;
685}
686
687public OnPlayerExitedMenu(playerid)
688{
689 return 1;
690}
691
692public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
693{
694 return 1;
695}
696
697public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
698{
699 return 1;
700}
701
702public OnRconLoginAttempt(ip[], password[], success)
703{
704 return 1;
705}
706
707public OnPlayerUpdate(playerid)
708{
709 return 1;
710}
711
712public OnPlayerStreamIn(playerid, forplayerid)
713{
714 return 1;
715}
716
717public OnPlayerStreamOut(playerid, forplayerid)
718{
719 return 1;
720}
721
722public OnVehicleStreamIn(vehicleid, forplayerid)
723{
724 return 1;
725}
726
727public OnVehicleStreamOut(vehicleid, forplayerid)
728{
729 return 1;
730}
731
732public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
733{
734 if(dialogid == 2)
735 {
736 if(!response)
737 {
738 Kick(playerid);
739 return 0;
740 }
741 if(strcmp(inputtext,pInfo[playerid][pass]) == 0)
742 {
743 pInfo[playerid][islogedin] = 1;
744 SetPlayerScore(playerid,pInfo[playerid][skor]);
745 GivePlayerMoney(playerid,pInfo[playerid][kes]);
746 SendClientMessage(playerid,COLOR_GREEN,"Sucessful login!");
747
748 if(pInfo[playerid][dc] == 0)
749 {
750 ShowPlayerDialog(playerid,0,DIALOG_STYLE_LIST,"Select Class","Cops\nRacers","Select","Exit");
751 return 1;
752 }
753 return 1;
754 }
755 SendClientMessage(playerid,COLOR_RED,"Wrong password!");
756 ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD,"Login","Please enter your registered password so you can play with us!","Login","Leave");
757 return 1;
758 }
759
760 if(dialogid == 0)
761 {
762 if(!response)
763 {
764 Kick(playerid);
765 return 0;
766 }
767
768 if(listitem == 0)
769 {
770 pInfo[playerid][team] = 0;
771 pInfo[playerid][dc] = 1;
772 SetSpawnInfo(playerid,0,281,0.0,0.0,0.0,0.0,0,0,0,0,0,0);
773 }
774 if(listitem == 1)
775 {
776 pInfo[playerid][team] = 1;
777 pInfo[playerid][dc] = 1;
778 SetSpawnInfo(playerid,0,29,0.0,0.0,0.0,0.0,0,0,0,0,0,0);
779 }
780 }
781
782 if(dialogid == 1)
783 {
784 if(!response)
785 {
786 Kick(playerid);
787 }
788
789
790 if(SavePlayer(playerid,inputtext))
791 {
792 pInfo[playerid][isregistered] = 1;
793 SendClientMessage(playerid,COLOR_GREEN,"Sucessfuly registered! Now please log in");
794 if(pInfo[playerid][islogedin] == 0)
795 {
796 ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD,"Login","Please enter your registered password so you can play with us!","Login","Leave");
797 }
798 }
799 }
800 return 1;
801}
802public OnPlayerClickPlayer(playerid, clickedplayerid, source)
803{
804 return 1;
805}
806
807stock strtok(const string[], &index)
808{
809 new length = strlen(string);
810 while ((index < length) && (string[index] <= ' '))
811 {
812 index++;
813 }
814 new offset = index;
815 new result[20];
816 while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
817 {
818 result[index - offset] = string[index];
819 index++;
820 }
821 result[index - offset] = EOS;
822 return result;
823}
824stock DestroyEmptyCars()
825{
826 new CanDestroy;
827 for(new i=0;i<MAX_VEHICLES;i++)
828 {
829 if(!IsValidVehicle(i)) continue;
830 CanDestroy = 1;
831 for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
832 {
833 if(IsPlayerConnected(playerid) && IsPlayerInVehicle(playerid, i))
834 {
835 CanDestroy = 0;
836 }
837 }
838 if(CanDestroy) DestroyVehicle(i);
839 }
840 return true;
841}
842stock strrest(const string[], &index)
843{
844 new length = strlen(string);
845 while ((index < length) && (string[index] <= ' '))
846 {
847 index++;
848 }
849 new offset = index;
850 new result[128];
851 while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
852 {
853 result[index - offset] = string[index];
854 index++;
855 }
856 result[index - offset] = EOS;
857 return result;
858}
859stock GivePlayerCash(playerid, amount)
860{
861 pInfo[playerid][kes] = pInfo[playerid][kes] + amount;
862 return GivePlayerMoney(playerid, pInfo[playerid][kes]);
863}
864
865
866stock SetScoreForPlayer(playerid, score)
867{
868 pInfo[playerid][score] = score;
869 return SetPlayerScore(playerid, pInfo[playerid][score]);
870}
871
872
873stock SavePlayerPos(playerid)
874{
875 new Float:X, Float:Y, Float:Z, Float:Rotation, String[256];
876 GetPlayerPos(playerid, X, Y, Z);
877 GetPlayerFacingAngle(playerid, Rotation);
878 format(String, sizeof(String), "%f,%f,%f,%f\n", X, Y, Z, Rotation);
879 new File:File = fopen("positions.txt", io_append);
880 fwrite(File, String);
881 fclose(File);
882 return true;
883}
884public OnPlayerTakeDamage(playerid,issuerid,Float:amount,weaponid)
885{
886 if(pInfo[issuerid][team] == cops && pInfo[playerid][team] == cops)
887 {
888 new ime[24],poruka[128];
889 SendClientMessage(playerid,COLOR_BLACK,"You are kicked from server for friendly fire!");
890 GetPlayerName(issuerid,ime,sizeof(ime));
891 Kick(issuerid);
892 format(poruka,sizeof(poruka),"%s was kicked for frendly fire!");
893 SendClientMessageToAll(COLOR_BLACK,poruka);
894 }
895 new warning;
896 if(pInfo[issuerid][team] == racers && pInfo[issuerid][team])
897 {
898 SendClientMessage(issuerid,COLOR_RED,"Do not fight with your teammates, you will get kicked from server!!!");
899 warning++;
900
901 if(warning <= 3)
902 {
903 Kick(issuerid);
904 }
905
906 }
907 if(pInfo[issuerid][team] == cops && pInfo[playerid][team] == racers && weaponid == 22 || weaponid == 3)
908 {
909 if(GetPlayerWantedLevel(playerid) <= 1)
910 {
911 new ime[24],poruka[128];
912 GivePlayerMoney(playerid,1000);
913 GivePlayerMoney(issuerid,-1000);
914 GetPlayerName(issuerid,ime,sizeof(ime));
915 format(poruka,sizeof(poruka),"%s has been punished for police brutality",ime);
916 }
917 TogglePlayerControllable(playerid,0);
918 SendClientMessage(playerid,COLOR_YELLOW,"You have been tazzed, you can run away after shock(10 seconds) if police officer does not cuff you!");
919 pInfo[playerid][tazz] = 1;
920 SetTimerEx("tazzed",10000,false,"i",playerid);
921 }
922 return 1;
923}
924stock SavePlayer(playerid, password[]){
925 new Query[1024];
926 new Query2[256];
927 format(Query, sizeof(Query), "INSERT INTO`player`(`pass`,`name`,`dc`,`tazz`,`warn`,`bounty`,`team`,`isregistered`,`islogedin`,`ismuted`) VALUES('%s', '%s', %d, %d, %d, %d, %d, %d, %d)",pInfo[playerid][pass],pInfo[playerid][name],pInfo[playerid][dc],pInfo[playerid][tazz],pInfo[playerid][warn],pInfo[playerid][bounty],pInfo[playerid][team],pInfo[playerid][isregistered],pInfo[playerid][islogedin],pInfo[playerid][ismuted]);
928 format(Query2, sizeof(Query2),"INSERT INTO `player`(`adminlevel`,`isjailed`,`jailvreme`,`ownedcarid`,`skor`,`kes`) VALUES(%d, %d, %d, %d, %d, %d, %d)",pInfo[playerid][adminlevel],pInfo[playerid][isjailed],pInfo[playerid][jailvreme],pInfo[playerid][ownedcarid],pInfo[playerid][skor],pInfo[playerid][kes]);
929 if(!db_free_result(db_query(player, Query)))
930 {
931 return 1;
932 }
933 return true;
934}
935stock CreateDatabase(){
936 new Query[256];
937 player = db_open("Player.db");
938 format(Query, sizeof(Query), "CREATE TABLE IF NOT EXISTS `Players` (`pID` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(24), `pass` VARCHAR(128), `adminlevel` INTEGER, `skor` INTEGER, `kes` INTEGER, `JoinDate` VARCHAR(32))");
939 if(!db_free_result(db_query(player, Query))) return 1;
940 return true;
941}