Advertisement
Darky

Mafia Minigame

Feb 15th, 2012
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.01 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #if defined Credits
  3. ________________________________________________________________________________
  4. Hey hey ! I'm DarKy and this is my script (my minigame) , "Mafia Minigame".This
  5. script si something like Counter Strike.Is a minigame with Mafia vs. Police !
  6. Thanks for using Mafia Minigame !
  7. _______________________________________________________________________________
  8. #endif
  9. /* ========================================================================== */
  10. #include              <a_samp>
  11. #include            <streamer>
  12. #include              <sscanf>
  13. /* ========================================================================== */
  14. #define TEAM_MAFIA 1
  15. #define TEAM_POLICE 2
  16. /* ========================================================================== */
  17. #define COLOR_GREY                         0xAFAFAFAA
  18. #define COLOR_GREEN                        0x33AA33AA
  19. #define COLOR_RED                          0xAA3333AA
  20. #define COLOR_YELLOW                       0xFFFF00AA
  21. #define COLOR_WHITE                        0xFFFFFFAA
  22. #define COLOR_ULTRARED                     0xE60000FF
  23. #define COLOR_BLUE                         0x0000BBAA
  24. #define COLOR_LIGHTGREEN                   0x9ACD32AA
  25. #define COLOR_LIGHTBLUE                    0x33CCFFAA
  26. #define COLOR_ORANGE                       0xFF9900AA
  27. #define COLOR_RED                          0xAA3333AA
  28. #define COLOR_LIME                         0x10F441AA
  29. #define COLOR_MAGENTA                      0xFF00FFFF
  30. #define COLOR_PURPLE                       0x9900FFAA
  31. #define COLOR_ALIEN                        0x90FF87FF
  32. #define COLOR_NAVY                         0x000080AA
  33. #define COLOR_AQUA                         0xF0F8FFAA
  34. #define COLOR_CRIMSON                      0xDC143CAA
  35. #define COLOR_FLBLUE                       0x6495EDAA
  36. #define COLOR_BISQUE                       0xFFE4C4AA
  37. #define COLOR_BLACK                        0x000000AA
  38. #define COLOR_CHARTREUSE                   0x7FFF00AA
  39. #define COLOR_BROWN                        0XA52A2AAA
  40. #define COLOR_CORAL                        0xFF7F50AA
  41. #define COLOR_GOLD                         0xB8860BAA
  42. #define COLOR_GREENYELLOW                  0xADFF2FAA
  43. #define COLOR_INDIGO                       0x4B00B0AA
  44. #define COLOR_IVORY                        0xFFFF82AA
  45. #define COLOR_LAWNGREEN                    0x7CFC00AA
  46. #define COLOR_SEAGREEN                     0x20B2AAAA
  47. #define COLOR_LIMEGREEN                    0x32CD32AA
  48. #define COLOR_MIDNIGHTBLUE                 0x191970AA
  49. #define COLOR_MAROON                       0x800000AA
  50. #define COLOR_OLIVE                        0x808000AA
  51. #define COLOR_ORANGERED                    0xFF4500AA
  52. #define COLOR_PINK                         0xFFC0CBAA
  53. #define COLOR_SPRINGGREEN                  0x00FF7FAA
  54. #define COLOR_TOMATO                       0xFF6347AA
  55. #define COLOR_YELLOWGREEN                  0x9ACD32AA
  56. #define COLOR_MEDIUMAQUA                   0x83BFBFAA
  57. #define COLOR_MEDIUMMAGENTA                0x8B008BAA
  58. /* ========================================================================== */
  59. new gTeam[MAX_PLAYERS];
  60. new IsPlanted[MAX_PLAYERS];
  61. new BombTimer;
  62. new DefuseTimer;
  63. new BombC;
  64. /* ========================================================================== */
  65. public OnFilterScriptInit()
  66. {
  67.    print("               ,        ,");
  68.    print("              /(        )`");
  69.    print("              | |___   / ||");
  70.    print("              /- _  `-/  '");
  71.    print("             (/|/ | |   /|");
  72.    print("             / /   | `    |");
  73.    print("             O O   ) /    |");
  74.    print("             `-^--'`<     '");
  75.    print("            (_.)  _  )   /");
  76.    print("             `.___/`    /");
  77.    print("               `-----' /");
  78.    print("  <----.     __ / __   |");
  79.    print("  <----|====O)))==) |) /====");
  80.    print("  <----'    `--' `.__,' |");
  81.    print("               |        |");
  82.    print("                |       /");
  83.    print("           ______( (_  / |______");
  84.    print("         ,'  ,-----'   |        |");
  85.    print("         `--{__________)       //");
  86.     print("+----------------------------+");
  87.     print("|        Mafia Minigame      |");
  88.     print("|    Copyright @ 2012 DarKy  |");
  89.     print("+----------------------------+");
  90.     print("|      SCRIPT WAS LOADED !   |");
  91.     print("+----------------------------+");
  92. /* ========================================================================== */
  93.     CreateDynamicObject(4843, 3788.556640625, -1007, 22.800483703613, 2.4224853515625, 14.26025390625, 359.37927246094);
  94.     CreateDynamicObject(18450, 3788.0417480469, -1074.3570556641, 28.603553771973, 271.82019042969, 105.94512939453, 105.95275878906);
  95.     CreateDynamicObject(18450, 3752.2565917969, -1034.466796875, 30.965980529785, 271.81823730469, 105.94110107422, 9.951904296875);
  96.     CreateDynamicObject(18450, 3795.3010253906, -994.7861328125, 30.988925933838, 87.696228027344, 130.62664794922, 229.35363769531);
  97.     CreateDynamicObject(18450, 3829.0361328125, -1033.736328125, 28.466419219971, 87.698364257813, 40.512084960938, 223.51135253906);
  98.     CreateDynamicObject(5836, 3762.46875, -1060.9654541016, 33.749580383301, 0, 0, 0);
  99.     CreateDynamicObject(3244, 3817.2033691406, -1006.7029418945, 23.351663589478, 0, 0, 0);
  100.     CreateDynamicObject(11426, 3763.2980957031, -1048.7274169922, 22.138051986694, 0, 0, 0);
  101.     CreateDynamicObject(11440, 3763.1037597656, -1040.1733398438, 22.192417144775, 0, 0, 0);
  102.     CreateDynamicObject(11444, 3761.8654785156, -1023.9291381836, 23.29563331604, 0, 0, 87);
  103.     CreateDynamicObject(11447, 3763.8076171875, -1014.5645751953, 23.725009918213, 0.25, 0, 83.5);
  104.     CreateDynamicObject(11459, 3809.7502441406, -1006.7024536133, 22.369380950928, 0, 0, 0);
  105.     CreateDynamicObject(11425, 3788.8916015625, -1063.1005859375, 23.222801208496, 0, 0, 0);
  106.     CreateDynamicObject(2892, 3763.8696289063, -1039.8968505859, 25.301792144775, 0, 0, 0);
  107.     CreateDynamicObject(3277, 3814.0671386719, -1065.7998046875, 20.544910430908, 0, 0, 0);
  108.     CreateDynamicObject(3279, 3762.6506347656, -1003.1516723633, 24.117984771729, 0, 0, 0);
  109.     CreateDynamicObject(16093, 3787.5080566406, -1004.9901733398, 24.341495513916, 0, 0, 0);
  110.     CreateDynamicObject(3884, 3813.9548339844, -1065.9423828125, 20.519918441772, 0, 0, 0);
  111.     CreateDynamicObject(2977, 3788.9877929688, -1066.1768798828, 21.319984436035, 0, 0, 0);
  112.     CreateDynamicObject(4882, 3796.8549804688, -1037.2819824219, 26.579437255859, 0, 0, 0);
  113.     CreateDynamicObject(1637, 3770.4956054688, -1067.5883789063, 22.887557983398, 0, 0, 0);
  114.     CreateDynamicObject(13637, 3816.90234375, -1040.4141845703, 21.758207321167, 0, 0, 0);
  115.     CreateDynamicObject(1454, 3800.2314453125, -1005.2055053711, 24.239179611206, 0, 0, 0);
  116.     CreateDynamicObject(1457, 3778.3935546875, -1004.3561401367, 25.944948196411, 0, 0, 0);
  117.     CreateDynamicObject(1458, 3771.2314453125, -1033.5455322266, 23.3118724823, 0, 0, 0);
  118.     CreateDynamicObject(1483, 3788.2023925781, -1066.6140136719, 23.287937164307, 0, 0, 0);
  119.     CreateDynamicObject(3252, 3797.9787597656, -1058.7006835938, 21.185646057129, 0, 0, 0);
  120.     CreateDynamicObject(14875, 3780.8703613281, -1051.8704833984, 22.676380157471, 0, 0, 0);
  121.     CreateDynamicObject(16405, 3782.0483398438, -1067.8461914063, 23.358337402344, 0, 0, 0);
  122.     CreateDynamicObject(16406, 3826.7817382813, -1021.5054931641, 26.651744842529, 0, 0, 0);
  123.     CreateDynamicObject(1452, 3791.9660644531, -1000.9810791016, 25.533332824707, 0, 0, 0);
  124.     CreateDynamicObject(1463, 3770.9719238281, -1052.3360595703, 22.586893081665, 0, 0, 0);
  125.     CreateDynamicObject(615, 3776.9450683594, -1056.181640625, 21.17707824707, 0, 0, 0);
  126.     CreateDynamicObject(654, 3788.8693847656, -1031.6385498047, 22.414892196655, 0, 0, 0);
  127.     CreateDynamicObject(654, 3798.4265136719, -1001.9503173828, 23.328159332275, 0, 0, 0);
  128.     CreateDynamicObject(660, 3820.4982910156, -1064.2631835938, 20.781923294067, 0, 0, 0);
  129.     CreateDynamicObject(671, 3774.3537597656, -1013.5877075195, 23.751955032349, 0, 0, 0);
  130.     CreateDynamicObject(672, 3770.8112792969, -997.68231201172, 24.484878540039, 0, 0, 0);
  131.     CreateDynamicObject(700, 3769.8898925781, -1025.9455566406, 23.43603515625, 0, 0, 0);
  132.     CreateDynamicObject(703, 3779.4379882813, -1019.9229736328, 23.190059661865, 0, 0, 0);
  133.     CreateDynamicObject(706, 3805.1826171875, -1018.3567504883, 22.39249420166, 0, 0, 0);
  134.     CreateDynamicObject(726, 3813.5812988281, -1057.4226074219, 20.876085281372, 0, 0, 0);
  135.     CreateDynamicObject(729, 3758.0971679688, -1049.3806152344, 22.193546295166, 0, 0, 0);
  136.     CreateDynamicObject(763, 3782.6611328125, -1027.328125, 23.002702713013, 0, 0, 0);
  137.     CreateDynamicObject(744, 3783.7329101563, -1038.345703125, 22.306625366211, 0, 0, 0);
  138.     CreateDynamicObject(749, 3803.3459472656, -1055.2156982422, 20.71215057373, 0, 0, 0);
  139.     CreateDynamicObject(748, 3782.2346191406, -1040.9794921875, 23.45666885376, 0, 0, 0);
  140.     CreateDynamicObject(750, 3808.3913574219, -1032.6060791016, 21.548503875732, 0, 0, 0);
  141.     CreateDynamicObject(744, 3802.9118652344, -1048.4647216797, 21.382221221924, 0, 0, 0);
  142.     return 1;
  143. }
  144. /* ========================================================================== */
  145. public OnPlayerRequestClass(playerid, classid)
  146. {
  147.     SetPlayerTeamFromClass(playerid);
  148.     return 1;
  149. }
  150. /* ========================================================================== */
  151. SetPlayerTeamFromClass(playerid)
  152. {
  153.     gTeam[playerid] = TEAM_MAFIA;
  154.     gTeam[playerid] = TEAM_POLICE;
  155. }
  156. /* ========================================================================== */
  157. public OnPlayerSpawn(playerid)
  158. {
  159.     SetPlayerTeam(playerid, 0);
  160.     TogglePlayerControllable(playerid,1);
  161.     SetPlayerArmour(playerid, 0);
  162.     SetPlayerHealth(playerid, 100);
  163.     return 1;
  164. }
  165. /* ========================================================================== */
  166. public OnPlayerCommandText(playerid, cmdtext[])
  167. {
  168.     new id;
  169.     if (strcmp(cmdtext, "/Mafia", true) == 0)
  170.     {
  171.         new name[MAX_PLAYER_NAME], string[44];
  172.         GetPlayerName(playerid, name, sizeof(name));
  173.         format(string, sizeof(string), "%s has joined to Mafia.",name);
  174.         SendClientMessageToAll(0xFFFF00AA, string);
  175.         SetPlayerPos(playerid, 3811.0046,-1040.1082,22.4528);
  176.         SetPlayerTeam(playerid, TEAM_MAFIA);
  177.         SetPlayerColor(playerid, COLOR_RED);
  178.         SetPlayerHealth(playerid, 100);
  179.         SetPlayerArmour(playerid, 100);
  180.         SetPlayerSkin(playerid, 179);
  181.         GivePlayerWeapon(playerid, 24, 10000);
  182.         GivePlayerWeapon(playerid, 25, 10000);
  183.         GivePlayerWeapon(playerid, 32, 10000);
  184.         GivePlayerWeapon(playerid, 33, 10000);
  185.         GivePlayerWeapon(playerid, 30, 10000);
  186.         GivePlayerMoney(playerid, -100);
  187.         return 1;
  188.     }
  189.     if (strcmp(cmdtext, "/Police", true) == 0)
  190.     {
  191.         new name[MAX_PLAYER_NAME], string[44];
  192.         GetPlayerName(playerid, name, sizeof(name));
  193.         format(string, sizeof(string), "%s has joined Police.",name);
  194.         SendClientMessageToAll(0xFFFF00AA, string);
  195.         SetPlayerPos(playerid, 3756.1958,-1022.8865,24.7479);
  196.         SetPlayerTeam(playerid, TEAM_POLICE);
  197.         SetPlayerColor(playerid, COLOR_BLUE);
  198.         SetPlayerHealth(playerid, 100);
  199.         SetPlayerArmour(playerid, 100);
  200.         SetPlayerSkin(playerid, 285);
  201.         GivePlayerWeapon(playerid, 22, 10000);
  202.         GivePlayerWeapon(playerid, 27, 10000);
  203.         GivePlayerWeapon(playerid, 29, 10000);
  204.         GivePlayerWeapon(playerid, 31, 10000);
  205.         GivePlayerWeapon(playerid, 34, 10000);
  206.         GivePlayerMoney(playerid, -100);
  207.         return 1;
  208.     }
  209.     if (strcmp(cmdtext, "/bomb", true) == 0)
  210.     {
  211.         if(IsPlanted[id] == 0)
  212.         {
  213.             if(GetPlayerTeam(playerid) == TEAM_MAFIA)
  214.             {
  215.                 if(IsPlayerInRangeOfPoint(playerid, 7.0, 3787.4651,-1002.8569,25.4665))
  216.                 {
  217.                     IsPlanted[id] = 1;
  218.                     BombTimer = SetTimer("Bomb",30000,false);
  219.                     SendClientMessageToAll(COLOR_BLUE, "The Bomb has been planted !");
  220.                     BombC = CreateDynamicCP(3787.4651,-1002.8569,25.4665, 1.5, -1, -1, -1, 100.0);
  221.                     return 1;
  222.                 }
  223.                 else return SendClientMessage(playerid, COLOR_RED, "(ERROR) You must be in POLICE Generator Room");
  224.             }
  225.             else return SendClientMessage(playerid, COLOR_RED, "(ERROR) Only MAFIA can use this command");
  226.         }
  227.         else return SendClientMessage(playerid, COLOR_RED, "(ERROR) Bomb has been planted !");
  228.     }
  229.  
  230.     return 0;
  231. }
  232. /* ========================================================================== */
  233. forward Bomb();
  234. public Bomb()
  235. {
  236.     new playerid, id;
  237.         new Float:x, Float:y, Float:z;
  238.         GetPlayerPos(playerid,x,y,z);
  239. for(new i = 0; i < MAX_PLAYERS; i++)
  240. {
  241.     PlayAudioStreamForPlayer(i, "http://darkydownload.netau.net/explosion.mp3");
  242. }
  243.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  244.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  245.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  246.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  247.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  248.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  249.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  250.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  251.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  252.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  253.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  254.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  255.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  256.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  257.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  258.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  259.     CreateExplosion(3787.4651,-1002.8569,25.4665, 6, 150.0);
  260.     IsPlanted[id] = 0;
  261.     GameTextForPlayer(playerid,"~r~Mafia Win",3000,6);
  262.     TogglePlayerControllable(playerid,0);
  263.     KillTimer(DefuseTimer);
  264.     SetTimer("Spawn",3000,false);
  265.     if(GetPlayerTeam(playerid) == TEAM_MAFIA)
  266.     {
  267.         GivePlayerMoney(playerid, 5000);
  268.     }
  269.     if(GetPlayerTeam(playerid) == TEAM_POLICE)
  270.     {
  271.         GivePlayerMoney(playerid, 2500);
  272.     }
  273.     DestroyDynamicCP(BombC);
  274. }
  275. /* ========================================================================== */
  276. forward Spawn();
  277. public Spawn()
  278. {
  279.     new playerid;
  280.     for(new i = 0; i < MAX_PLAYERS; i++) {
  281.         if(GetPlayerTeam(playerid) == TEAM_MAFIA)
  282.         {
  283.             SpawnPlayer(i);
  284.         }
  285.         if(GetPlayerTeam(playerid) == TEAM_POLICE)
  286.         {
  287.             SpawnPlayer(i);
  288.         }
  289.     }
  290. }
  291. /* ========================================================================== */
  292. forward Defuse();
  293. public Defuse()
  294. {
  295.     new playerid;
  296.     new id;
  297.     GameTextForPlayer(playerid,"~b~Police Win",3000,6);
  298.     TogglePlayerControllable(playerid,0);
  299.     KillTimer(BombTimer);
  300.     SetTimer("Spawn",3000,false);
  301.     IsPlanted[id] = 0;
  302.     if(GetPlayerTeam(playerid) == TEAM_MAFIA)
  303.     {
  304.         GivePlayerMoney(playerid, 2500);
  305.     }
  306.     if(GetPlayerTeam(playerid) == TEAM_POLICE)
  307.     {
  308.         GivePlayerMoney(playerid, 5000);
  309.     }
  310.     DestroyDynamicCP(BombC);
  311. }
  312. /* ========================================================================== */
  313. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  314. {
  315.     if(checkpointid == BombC)
  316.     {
  317.         if(GetPlayerTeam(playerid) == TEAM_POLICE)
  318.         {
  319.             if(IsPlayerInRangeOfPoint(playerid, 7.0, 3787.4651,-1002.8569,25.4665))
  320.             {
  321.                 if(IsPlanted[playerid] == 1)
  322.                 {
  323.                     SendClientMessage(playerid, COLOR_RED, "Bomb being defused !");
  324.                     DefuseTimer = SetTimer("Defuse",10000,false);
  325.                     if(IsPlanted[playerid] == 0)
  326.                     {
  327.                         SendClientMessageToAll(COLOR_RED, "Defused failed !");
  328.                     }
  329.                     return 1;
  330.                 }
  331.                 else return SendClientMessage(playerid, COLOR_RED, "(ERROR) Bomb has not been planted !");
  332.             }
  333.             else return SendClientMessage(playerid, COLOR_RED, "(ERROR) You must be in Generator !");
  334.         }
  335.         else return SendClientMessage(playerid, COLOR_RED, "(ERROR) Only POLICE can defused the bomb !");
  336.     }
  337.     return 1;
  338. }
  339. /* ========================================================================== */
  340. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  341. {
  342.     if(GetPlayerTeam(playerid) == TEAM_POLICE)
  343.     {
  344.         KillTimer(DefuseTimer);
  345.         SendClientMessage(playerid, COLOR_RED, "(ERROR) Defuse failed, you must be in checkpoint to defuse bomb !");
  346.     }
  347. }
  348. /* ========================================================================== */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement