Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- #include <a_samp>
- #define MAX_PLAYERS 5
- #include <dc_cmd>
- #include <sscanf2>
- main() return 1;
- new PlayerText:BoxGame[MAX_PLAYERS][83];
- new bool:BoxUnity[MAX_PLAYERS][81];
- new WinCheck[9][8][3] =
- {
- {{0,1,2}, {9,10,11}, {18,19,20}, {0,9,18}, {1,10,19}, {2,11,20}, {0,10,20}, {2,10,18}},
- {{3,4,5}, {12,13,14}, {21,22,23}, {3,12,21}, {4,13,22}, {5,14,23}, {3,13,23}, {5,13,21}},
- {{6,7,8}, {15,16,17}, {24,25,26}, {6,15,24}, {7,16,25}, {8,17,26}, {6,16,26}, {8,16,24}},
- {{27,28,29}, {36,37,38}, {45,46,47}, {27,36,45}, {28,37,46}, {29,38,47}, {27,37,47}, {29,37,45}},
- {{30,31,32}, {39,40,41}, {48,49,50}, {30,39,48}, {31,40,49}, {32,41,50}, {30,40,50}, {32,40,48}},
- {{33,34,35}, {42,43,44}, {51,52,53}, {33,42,51}, {34,43,52}, {35,44,53}, {33,43,53}, {35,43,51}},
- {{54,55,56}, {63,64,65}, {72,73,74}, {54,63,72}, {55,64,73}, {56,65,74}, {54,64,74}, {56,64,72}},
- {{57,58,59}, {66,67,68}, {75,76,77}, {57,66,75}, {58,67,76}, {59,68,77}, {57,67,77}, {59,67,75}},
- {{60,61,62}, {69,70,71}, {78,79,80}, {60,69,78}, {61,70,79}, {62,71,80}, {60,70,80}, {62,70,78}}
- };
- stock CheckWin(playerid, bool:number, slot)
- {
- for(new f = 0; f < 8; f ++)
- {
- new count = 0;
- for(new j = 0; j < 3; j ++) if(BoxUnity[playerid][WinCheck[slot][f][j]] == number) count++;
- if(count >= 3) return 1;
- }
- return 0;
- }
- public OnGameModeInit()
- {
- AddPlayerClass(120,1152.66, -1769.65, 16.59,0,0,0,0,0,0,0);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new count = 0x0, Color;
- for(new r = 1; r < 10; r++)
- {
- for(new f = 1; f < 10; f++)
- {
- BoxGame[playerid][count] = CreatePlayerTextDraw(playerid, 173.3 + f * 34.3, 64.0 + r * 27.3, "_");
- PlayerTextDrawLetterSize(playerid,BoxGame[playerid][count], 0.5, 2.5);
- PlayerTextDrawTextSize(playerid,BoxGame[playerid][count], 15.0, 30.0);
- PlayerTextDrawAlignment(playerid,BoxGame[playerid][count], 2);
- PlayerTextDrawColor(playerid,BoxGame[playerid][count], -1);
- PlayerTextDrawUseBox(playerid,BoxGame[playerid][count], true);
- switch(count)
- {
- case 0..2,9..11,18..20: Color = 0xFF0000FF;
- case 3..5,12..14,21..23: Color = 0xFF2C00FF;
- case 6..8,15..17,24..26: Color = 0xFF5000FF;
- case 27..29,36..38,45..47: Color = 0xFF8700FF;
- case 30..32,39..41,48..50: Color = 0xFFA700FF;
- case 33..35,42..44,51..53: Color = 0xFFDC00FF;
- case 54..56,63..65,72..74: Color = 0xFFFB00FF;
- case 57..59,66..68,75..77: Color = 0xC4FF00FF;
- case 60..62,69..71,78..80: Color = 0x7BFF00FF;
- default: Color = 0xFFFFFFFF;
- }
- PlayerTextDrawBoxColor(playerid,BoxGame[playerid][count], Color);
- PlayerTextDrawSetOutline(playerid,BoxGame[playerid][count], 1);
- PlayerTextDrawBackgroundColor(playerid,BoxGame[playerid][count], 224);
- PlayerTextDrawFont(playerid,BoxGame[playerid][count], 2);
- PlayerTextDrawSetSelectable(playerid,BoxGame[playerid][count], true);
- count++;
- }
- }
- BoxGame[playerid][count] = CreatePlayerTextDraw(playerid,499.997985, 91.100036, "usebox");
- PlayerTextDrawLetterSize(playerid,BoxGame[playerid][count], 0.000000, 26.836849);
- PlayerTextDrawTextSize(playerid,BoxGame[playerid][count], 189.666503, 0.000000);
- PlayerTextDrawAlignment(playerid,BoxGame[playerid][count], 1);
- PlayerTextDrawColor(playerid,BoxGame[playerid][count], 0);
- PlayerTextDrawUseBox(playerid,BoxGame[playerid][count], true);
- PlayerTextDrawBoxColor(playerid,BoxGame[playerid][count], 170);
- PlayerTextDrawSetShadow(playerid,BoxGame[playerid][count], 300);
- PlayerTextDrawSetOutline(playerid,BoxGame[playerid][count], 0);
- PlayerTextDrawBackgroundColor(playerid,BoxGame[playerid][count], -1061109505);
- PlayerTextDrawFont(playerid,BoxGame[playerid][count], 0);
- count++;
- BoxGame[playerid][count] = CreatePlayerTextDraw(playerid,283.333251, 71.348098, "Noughts and Crosses");
- PlayerTextDrawLetterSize(playerid,BoxGame[playerid][count], 0.351333, 1.861333);
- PlayerTextDrawAlignment(playerid,BoxGame[playerid][count], 1);
- PlayerTextDrawColor(playerid,BoxGame[playerid][count], -1);
- PlayerTextDrawSetShadow(playerid,BoxGame[playerid][count], 0);
- PlayerTextDrawSetOutline(playerid,BoxGame[playerid][count], 0);
- PlayerTextDrawBackgroundColor(playerid,BoxGame[playerid][count], 51);
- PlayerTextDrawFont(playerid,BoxGame[playerid][count], 1);
- PlayerTextDrawSetProportional(playerid,BoxGame[playerid][count], 1);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i = 0; i < 83; i ++) PlayerTextDrawDestroy(playerid, BoxGame[playerid][i]);
- return 1;
- }
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- if(GetPVarInt(playerid, "show"))
- {
- if(!GetPVarInt(playerid, "StartHod")) return SendClientMessage(playerid, 0xFF0000FF, "Ñåé÷àñ íå Âàø õîä!");
- new slot = -1, id = -1, gid = GetPVarInt(playerid, "GamerPlayer");
- for(new i = 0; i < 81; i ++)
- {
- if(playertextid == BoxGame[playerid][i])
- {
- slot = i;
- break;
- }
- }
- if(slot == -1) return 1;
- switch(slot)
- {
- case 0..2,9..11,18..20: id = 1;
- case 3..5,12..14,21..23: id = 2;
- case 6..8,15..17,24..26: id = 3;
- case 27..29,36..38,45..47: id = 4;
- case 30..32,39..41,48..50: id = 5;
- case 33..35,42..44,51..53: id = 6;
- case 54..56,63..65,72..74: id = 7;
- case 57..59,66..68,75..77: id = 8;
- case 60..62,69..71,78..80: id = 9;
- }
- if(id == -1) return 1;
- DeletePVar(playerid, "StartHod");
- SetPVarInt(GetPVarInt(playerid, "GamerPlayer"), "StartHod", true);
- if(!BoxUnity[playerid][slot])
- {
- BoxUnity[playerid][slot] = true;
- PlayerTextDrawSetString(playerid,BoxGame[playerid][slot], (GetPVarInt(playerid, "TypeTic") == 1 ? ("X") : ("0")));
- if(gid != playerid) PlayerTextDrawSetString(gid,BoxGame[playerid][slot], (GetPVarInt(playerid, "TypeTic") == 1 ? ("X") : ("0")));
- if(CheckWin(playerid, true, id-1))
- {
- new string[24+30], Name[24];
- GetPlayerName(playerid, Name, 24);
- format(string,sizeof(string),"Ïîáåäèë: %s(%d)", Name,playerid);
- SendClientMessage(playerid, 0xFF0000FF, string);
- for(new i = 0; i < 81; i ++)
- {
- BoxUnity[playerid][i] = false;
- BoxUnity[gid][i] = false;
- PlayerTextDrawSetString(playerid,BoxGame[playerid][i], "_");
- PlayerTextDrawSetString(gid,BoxGame[gid][i], "_");
- PlayerTextDrawHide(playerid, BoxGame[playerid][i]);
- PlayerTextDrawHide(gid, BoxGame[gid][i]);
- }
- PlayerTextDrawHide(playerid, BoxGame[playerid][81]), PlayerTextDrawHide(playerid, BoxGame[playerid][82]);
- PlayerTextDrawHide(gid, BoxGame[gid][81]), PlayerTextDrawHide(gid, BoxGame[gid][82]);
- CancelSelectTextDraw(playerid);
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid) return SendClientMessage(playerid, -1, "Äîáðî ïîæàëîâàòü. /SHOW (ID) - íà÷àòü èãðó â Êðåñòèêè Íîëèêè!");
- CMD:show(playerid, params[])
- {
- if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, -1, "/show [id]");
- if(params[0] == playerid) return SendClientMessage(playerid, -1, "Çàïðåùåíî èãðàòü ñ ñîáîé!");
- for(new i = 0; i < 83; i++)
- {
- PlayerTextDrawShow(playerid,BoxGame[playerid][i]);
- PlayerTextDrawShow(params[0],BoxGame[playerid][i]);
- }
- SelectTextDraw(playerid,0xFF9900FF), SelectTextDraw(params[0],0xFF9900FF);
- SetPVarInt(params[0], "GamerPlayer", playerid);
- SetPVarInt(playerid, "show", true), SetPVarInt(params[0], "show", true);
- SetPVarInt(params[0], "StartHod", true);
- SetPVarInt(playerid, "TypeTic", 1), SetPVarInt(params[0], "TypeTic", 2);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement