Advertisement
Guest User

Untitled

a guest
Dec 8th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.60 KB | None | 0 0
  1. //
  2. #include <a_samp>
  3. #define MAX_PLAYERS 5
  4. #include <dc_cmd>
  5. #include <sscanf2>
  6. main() return 1;
  7. new PlayerText:BoxGame[MAX_PLAYERS][83];
  8. new bool:BoxUnity[MAX_PLAYERS][81];
  9. new WinCheck[9][8][3] =
  10. {
  11.     {{0,1,2}, {9,10,11}, {18,19,20}, {0,9,18}, {1,10,19}, {2,11,20}, {0,10,20}, {2,10,18}},
  12.     {{3,4,5}, {12,13,14}, {21,22,23}, {3,12,21}, {4,13,22}, {5,14,23}, {3,13,23}, {5,13,21}},
  13.     {{6,7,8}, {15,16,17}, {24,25,26}, {6,15,24}, {7,16,25}, {8,17,26}, {6,16,26}, {8,16,24}},
  14.     {{27,28,29}, {36,37,38}, {45,46,47}, {27,36,45}, {28,37,46}, {29,38,47}, {27,37,47}, {29,37,45}},
  15.     {{30,31,32}, {39,40,41}, {48,49,50}, {30,39,48}, {31,40,49}, {32,41,50}, {30,40,50}, {32,40,48}},
  16.     {{33,34,35}, {42,43,44}, {51,52,53}, {33,42,51}, {34,43,52}, {35,44,53}, {33,43,53}, {35,43,51}},
  17.     {{54,55,56}, {63,64,65}, {72,73,74}, {54,63,72}, {55,64,73}, {56,65,74}, {54,64,74}, {56,64,72}},
  18.     {{57,58,59}, {66,67,68}, {75,76,77}, {57,66,75}, {58,67,76}, {59,68,77}, {57,67,77}, {59,67,75}},
  19.     {{60,61,62}, {69,70,71}, {78,79,80}, {60,69,78}, {61,70,79}, {62,71,80}, {60,70,80}, {62,70,78}}
  20. };
  21. stock CheckWin(playerid, bool:number, slot)
  22. {
  23.     for(new f = 0; f < 8; f ++)
  24.     {
  25.         new count = 0;
  26.         for(new j = 0; j < 3; j ++) if(BoxUnity[playerid][WinCheck[slot][f][j]] == number) count++;
  27.         if(count >= 3) return 1;
  28.     }
  29.     return 0;
  30. }
  31. public OnGameModeInit()
  32. {
  33.     AddPlayerClass(120,1152.66, -1769.65, 16.59,0,0,0,0,0,0,0);
  34.     return 1;
  35. }
  36. public OnPlayerConnect(playerid)
  37. {
  38.     new count = 0x0, Color;
  39.     for(new r = 1; r < 10; r++)
  40.     {
  41.         for(new f = 1; f < 10; f++)
  42.         {
  43.             BoxGame[playerid][count] = CreatePlayerTextDraw(playerid, 173.3 + f * 34.3, 64.0 + r * 27.3, "_");
  44.             PlayerTextDrawLetterSize(playerid,BoxGame[playerid][count], 0.5, 2.5);
  45.             PlayerTextDrawTextSize(playerid,BoxGame[playerid][count], 15.0, 30.0);
  46.             PlayerTextDrawAlignment(playerid,BoxGame[playerid][count], 2);
  47.             PlayerTextDrawColor(playerid,BoxGame[playerid][count], -1);
  48.             PlayerTextDrawUseBox(playerid,BoxGame[playerid][count], true);
  49.             switch(count)
  50.             {
  51.                 case 0..2,9..11,18..20: Color = 0xFF0000FF;
  52.                 case 3..5,12..14,21..23: Color = 0xFF2C00FF;
  53.                 case 6..8,15..17,24..26: Color = 0xFF5000FF;
  54.                 case 27..29,36..38,45..47: Color = 0xFF8700FF;
  55.                 case 30..32,39..41,48..50: Color = 0xFFA700FF;
  56.                 case 33..35,42..44,51..53: Color = 0xFFDC00FF;
  57.                 case 54..56,63..65,72..74: Color = 0xFFFB00FF;
  58.                 case 57..59,66..68,75..77: Color = 0xC4FF00FF;
  59.                 case 60..62,69..71,78..80: Color = 0x7BFF00FF;
  60.                 default: Color = 0xFFFFFFFF;
  61.             }
  62.             PlayerTextDrawBoxColor(playerid,BoxGame[playerid][count], Color);
  63.             PlayerTextDrawSetOutline(playerid,BoxGame[playerid][count], 1);
  64.             PlayerTextDrawBackgroundColor(playerid,BoxGame[playerid][count], 224);
  65.             PlayerTextDrawFont(playerid,BoxGame[playerid][count], 2);
  66.             PlayerTextDrawSetSelectable(playerid,BoxGame[playerid][count], true);
  67.             count++;
  68.         }
  69.     }
  70.     BoxGame[playerid][count] = CreatePlayerTextDraw(playerid,499.997985, 91.100036, "usebox");
  71.     PlayerTextDrawLetterSize(playerid,BoxGame[playerid][count], 0.000000, 26.836849);
  72.     PlayerTextDrawTextSize(playerid,BoxGame[playerid][count], 189.666503, 0.000000);
  73.     PlayerTextDrawAlignment(playerid,BoxGame[playerid][count], 1);
  74.     PlayerTextDrawColor(playerid,BoxGame[playerid][count], 0);
  75.     PlayerTextDrawUseBox(playerid,BoxGame[playerid][count], true);
  76.     PlayerTextDrawBoxColor(playerid,BoxGame[playerid][count], 170);
  77.     PlayerTextDrawSetShadow(playerid,BoxGame[playerid][count], 300);
  78.     PlayerTextDrawSetOutline(playerid,BoxGame[playerid][count], 0);
  79.     PlayerTextDrawBackgroundColor(playerid,BoxGame[playerid][count], -1061109505);
  80.     PlayerTextDrawFont(playerid,BoxGame[playerid][count], 0);
  81.     count++;
  82.     BoxGame[playerid][count] = CreatePlayerTextDraw(playerid,283.333251, 71.348098, "Noughts and Crosses");
  83.     PlayerTextDrawLetterSize(playerid,BoxGame[playerid][count], 0.351333, 1.861333);
  84.     PlayerTextDrawAlignment(playerid,BoxGame[playerid][count], 1);
  85.     PlayerTextDrawColor(playerid,BoxGame[playerid][count], -1);
  86.     PlayerTextDrawSetShadow(playerid,BoxGame[playerid][count], 0);
  87.     PlayerTextDrawSetOutline(playerid,BoxGame[playerid][count], 0);
  88.     PlayerTextDrawBackgroundColor(playerid,BoxGame[playerid][count], 51);
  89.     PlayerTextDrawFont(playerid,BoxGame[playerid][count], 1);
  90.     PlayerTextDrawSetProportional(playerid,BoxGame[playerid][count], 1);
  91.     return 1;
  92. }
  93.  
  94. public OnPlayerDisconnect(playerid, reason)
  95. {
  96.     for(new i = 0; i < 83; i ++) PlayerTextDrawDestroy(playerid, BoxGame[playerid][i]);
  97.     return 1;
  98. }
  99. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  100. {
  101.     if(GetPVarInt(playerid, "show"))
  102.     {
  103.         if(!GetPVarInt(playerid, "StartHod")) return SendClientMessage(playerid, 0xFF0000FF, "Ñåé÷àñ íå Âàø õîä!");
  104.         new slot = -1, id = -1, gid = GetPVarInt(playerid, "GamerPlayer");
  105.         for(new i = 0; i < 81; i ++)
  106.         {
  107.             if(playertextid == BoxGame[playerid][i])
  108.             {
  109.                 slot = i;
  110.                 break;
  111.             }
  112.         }
  113.         if(slot == -1) return 1;
  114.         switch(slot)
  115.         {
  116.             case 0..2,9..11,18..20: id = 1;
  117.             case 3..5,12..14,21..23: id = 2;
  118.             case 6..8,15..17,24..26: id = 3;
  119.             case 27..29,36..38,45..47: id = 4;
  120.             case 30..32,39..41,48..50: id = 5;
  121.             case 33..35,42..44,51..53: id = 6;
  122.             case 54..56,63..65,72..74: id = 7;
  123.             case 57..59,66..68,75..77: id = 8;
  124.             case 60..62,69..71,78..80: id = 9;
  125.         }
  126.         if(id == -1) return 1;
  127.         DeletePVar(playerid, "StartHod");
  128.         SetPVarInt(GetPVarInt(playerid, "GamerPlayer"), "StartHod", true);
  129.         if(!BoxUnity[playerid][slot])
  130.         {
  131.             BoxUnity[playerid][slot] = true;
  132.             PlayerTextDrawSetString(playerid,BoxGame[playerid][slot], (GetPVarInt(playerid, "TypeTic") == 1 ? ("X") : ("0")));
  133.             if(gid != playerid) PlayerTextDrawSetString(gid,BoxGame[playerid][slot], (GetPVarInt(playerid, "TypeTic") == 1 ? ("X") : ("0")));
  134.             if(CheckWin(playerid, true, id-1))
  135.             {
  136.                 new string[24+30], Name[24];
  137.                 GetPlayerName(playerid, Name, 24);
  138.                 format(string,sizeof(string),"Ïîáåäèë: %s(%d)", Name,playerid);
  139.                 SendClientMessage(playerid, 0xFF0000FF, string);
  140.                 for(new i = 0; i < 81; i ++)
  141.                 {
  142.                     BoxUnity[playerid][i] = false;
  143.                     BoxUnity[gid][i] = false;
  144.                     PlayerTextDrawSetString(playerid,BoxGame[playerid][i], "_");
  145.                     PlayerTextDrawSetString(gid,BoxGame[gid][i], "_");
  146.                     PlayerTextDrawHide(playerid, BoxGame[playerid][i]);
  147.                     PlayerTextDrawHide(gid, BoxGame[gid][i]);
  148.                 }
  149.                 PlayerTextDrawHide(playerid, BoxGame[playerid][81]), PlayerTextDrawHide(playerid, BoxGame[playerid][82]);
  150.                 PlayerTextDrawHide(gid, BoxGame[gid][81]), PlayerTextDrawHide(gid, BoxGame[gid][82]);
  151.                 CancelSelectTextDraw(playerid);
  152.                 return 1;
  153.             }
  154.         }
  155.     }
  156.     return 1;
  157. }
  158. public OnPlayerRequestClass(playerid, classid) return SendClientMessage(playerid, -1, "Äîáðî ïîæàëîâàòü. /SHOW (ID) - íà÷àòü èãðó â Êðåñòèêè Íîëèêè!");
  159. CMD:show(playerid, params[])
  160. {
  161.     if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, -1, "/show [id]");
  162.     if(params[0] == playerid) return SendClientMessage(playerid, -1, "Çàïðåùåíî èãðàòü ñ ñîáîé!");
  163.     for(new i = 0; i < 83; i++)
  164.     {
  165.         PlayerTextDrawShow(playerid,BoxGame[playerid][i]);
  166.         PlayerTextDrawShow(params[0],BoxGame[playerid][i]);
  167.     }
  168.     SelectTextDraw(playerid,0xFF9900FF), SelectTextDraw(params[0],0xFF9900FF);
  169.     SetPVarInt(params[0], "GamerPlayer", playerid);
  170.     SetPVarInt(playerid, "show", true), SetPVarInt(params[0], "show", true);
  171.     SetPVarInt(params[0], "StartHod", true);
  172.     SetPVarInt(playerid, "TypeTic", 1), SetPVarInt(params[0], "TypeTic", 2);
  173.     return 1;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement