Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Poker filterscript by.: Zsolesszka
- 2012.01.15 - 2012.01.27
- - Update Poker [FS] 2012.03.20 Beta version
- samp 0.3e RC4 use new function
- native TextDrawSetSelectable(Text:text, set); // the default is 0 (non-selectable)
- native SelectTextDraw(playerid, hovercolor); // enables the mouse so the player can select a textdraw
- native CancelSelectTextDraw(playerid); // cancel textdraw selection with the mouse
- forward OnPlayerClickTextDraw(playerid, Text:clickedid);
- Thank you SA-MP team.
- - 2012.03.22
- - Add exit textdraw, change background textdraw, bet textdraw, modified hold textdraw
- - 31 global textdraw OnFilterscriptInit, per player textdraw 7 2048 max textdraw (2048 - 31)/7 = ~288 max player slot
- - etc..
- */
- #include <a_samp>
- enum
- {
- TWO = 2,
- THREE,
- FOUR,
- FIVE,
- SIX,
- SEVEN,
- EIGHT,
- NINE,
- TEN,
- JACK,
- QUEEN,
- KING,
- ACE
- };
- enum
- {
- HIGH_CARD = 0,
- ONE_PAIR,
- TWO_PAIR,
- THREE_OF_A_KIND,
- STRAIGHT,
- FLUSH,
- FULL_HOUSE,
- FOUR_OF_A_KIND,
- STRAIGHT_FLUSH,
- ROYAL_FLUSH
- };
- stock
- rang_sor[][] =
- {
- {"High card"},
- {"One Pair"},
- {"Two Pair"},
- {"Three of a Kind"},
- {"Straight"},
- {"Flush"},
- {"Full house"},
- {"Four of Kind"},
- {"Straight Flush"},
- {"Royal Flush"}
- };
- new
- LD_POKE[][] =
- {
- { "LD_POKE:cd2c" },
- { "LD_POKE:cd3c" },
- { "LD_POKE:cd4c" },
- { "LD_POKE:cd5c" },
- { "LD_POKE:cd6c" },
- { "LD_POKE:cd7c" },
- { "LD_POKE:cd8c" },
- { "LD_POKE:cd9c" },
- { "LD_POKE:cd10c" },
- { "LD_POKE:cd11c" },
- { "LD_POKE:cd12c" },
- { "LD_POKE:cd13c" },
- { "LD_POKE:cd1c" },
- { "LD_POKE:cd2d" },
- { "LD_POKE:cd3d" },
- { "LD_POKE:cd4d" },
- { "LD_POKE:cd5d" },
- { "LD_POKE:cd6d" },
- { "LD_POKE:cd7d" },
- { "LD_POKE:cd8d" },
- { "LD_POKE:cd9d" },
- { "LD_POKE:cd10d" },
- { "LD_POKE:cd11d" },
- { "LD_POKE:cd12d" },
- { "LD_POKE:cd13d" },
- { "LD_POKE:cd1d" },
- { "LD_POKE:cd2h" },
- { "LD_POKE:cd3h" },
- { "LD_POKE:cd4h" },
- { "LD_POKE:cd5h" },
- { "LD_POKE:cd6h" },
- { "LD_POKE:cd7h" },
- { "LD_POKE:cd8h" },
- { "LD_POKE:cd9h" },
- { "LD_POKE:cd10h" },
- { "LD_POKE:cd11h" },
- { "LD_POKE:cd12h" },
- { "LD_POKE:cd13h" },
- { "LD_POKE:cd1h" },
- { "LD_POKE:cd2s" },
- { "LD_POKE:cd3s" },
- { "LD_POKE:cd4s" },
- { "LD_POKE:cd5s" },
- { "LD_POKE:cd6s" },
- { "LD_POKE:cd7s" },
- { "LD_POKE:cd8s" },
- { "LD_POKE:cd9s" },
- { "LD_POKE:cd10s" },
- { "LD_POKE:cd11s" },
- { "LD_POKE:cd12s" },
- { "LD_POKE:cd13s" },
- { "LD_POKE:cd1s" }
- };
- stock
- HoldCardName[][] =
- {
- { "{e00909}holdon" },
- { "{9c8c8c}holdoff" }
- };
- stock
- Card_Name[][] =
- {
- "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "Tc", "Jc", "Qc", "Kc", "Ac",
- "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "Td", "Jd", "Qd", "Kd", "Ad",
- "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "Th", "Jh", "Qh", "Kh", "Ah",
- "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "Ts", "Js", "Qs", "Ks", "As"
- };
- new
- Card_Value[] =
- {
- TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE,
- TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE,
- TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE,
- TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
- };
- new
- Bynary_Mask[] =
- {
- 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
- 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
- 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
- 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000
- // 2 3 4 5 6 7 8 9 T J Q K A
- };
- #define TREFF 0b1 //1 // "clubs"
- #define KARO 0b10 //2 // “diamonds”
- #define KOR 0b100 //4 // “hearts”
- #define PIKK 0b1000 //8 // “spades” or “shields”
- new
- Color_Mask[] =
- {
- TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, TREFF, // 1 = 0b10
- KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, KARO, // 2 = 0b100
- KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, KOR, // 4 = 0b1000
- PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK, PIKK // 8 = 0b10000
- };
- new
- pot[] = { 0, 0, 2, 3, 4, 5, 7, 20, 50, 250 };
- new
- Text:BackGroundText[15],
- Text:Win_Text,
- Text:CardsText[MAX_PLAYERS][5],
- Text:WinText[MAX_PLAYERS],
- Text:BetCreditText[MAX_PLAYERS],
- Text:DealsText,
- Text:AddCoinsText,
- Text:Text_HoldOn[5],
- Text:Text_Holdmid[5],
- Text:ExitPoker,
- Text:BetText,
- Text:ChangeBackGround;
- #define MIN_BET 5 // $5
- #define MAX_BET 100 // $100
- #define FIRST_DIVID (false) // enable hold card
- #define SECOND_DIVID (true) // disable hold card
- #define HOLDON (false)
- #define HOLDOFF (true) // Not modified
- forward TextDrawDizajn(playerid, index);
- forward TextDrawDizajn2(playerid, win, One_pair, Two_pair);
- enum
- Poker_PlayerInfoEnum
- {
- bool:PokerAktive,
- fivecards_hand[10],
- bool:holdstate[5],
- bool:hold,
- Bet,
- Credit,
- LastBackGround,
- };
- new
- PP_Info[MAX_PLAYERS][Poker_PlayerInfoEnum];
- public
- OnFilterScriptInit()
- {
- print("\nPoker filterscript loaded.\n\t * * * Created by Zsolesszka * * *\n");
- // ..........................................
- new
- BackGroundData[][] =
- {
- { "LOADSUK:loadscuk" }, { "LOADSUK:loadsc9" }, { "LOADSUK:loadsc8" },
- { "LOADSUK:loadsc7" }, { "LOADSUK:loadsc6" }, { "LOADSUK:loadsc5" },
- { "LOADSUK:loadsc4" }, { "LOADSUK:loadsc3" }, { "LOADSUK:loadsc2" },
- { "LOADSUK:loadsc14" }, { "LOADSUK:loadsc13" }, { "LOADSUK:loadsc12" },
- { "LOADSUK:loadsc11" }, { "LOADSUK:loadsc10" }, { "LOADSUK:loadsc1" }
- };
- for(new i; i < sizeof BackGroundData; i++)
- {
- BackGroundText[i] = TextDrawCreate(-0.000, -0.000, BackGroundData[i]);
- TextDrawFont(BackGroundText[i], 4);
- TextDrawTextSize(BackGroundText[i], 640.000, 450.000);
- TextDrawColor(BackGroundText[i], -1);
- }
- // ..........................................
- new
- Float:t_x = 167.500000;
- for(new i; i < 5; i++)
- {
- Text_HoldOn[i] = TextDrawCreate(t_x, 270.500, "LD_POKE:holdon");
- TextDrawFont(Text_HoldOn[i], 4);
- TextDrawTextSize(Text_HoldOn[i], 59.500, 14.500);
- TextDrawColor(Text_HoldOn[i], -1);
- Text_Holdmid[i] = TextDrawCreate(t_x, 270.500, "LD_POKE:holdmid");
- TextDrawFont(Text_Holdmid[i], 4);
- TextDrawTextSize(Text_Holdmid[i], 59.500, 14.500);
- TextDrawColor(Text_Holdmid[i], -1);
- t_x += 61.500000;
- }
- // ..........................................
- Win_Text = TextDrawCreate(167.500000, 154.000000, "Royal Flush~n~Straight Flush~n~4 of a Kind~n~Full House~n~Flush~n~Straight~n~3 of a Kind~n~Two Pair");
- TextDrawFont(Win_Text, 1);
- TextDrawLetterSize(Win_Text, 0.320000, 1.400000);
- TextDrawSetOutline(Win_Text, 1);
- TextDrawSetProportional(Win_Text, 1);
- // ..........................................
- AddCoinsText = TextDrawCreate(167.500, 400.500, "LD_POKE:addcoin");
- TextDrawFont(AddCoinsText, 4);
- TextDrawTextSize(AddCoinsText, 59.500, 14.500);
- TextDrawColor(AddCoinsText, -1);
- TextDrawSetSelectable(AddCoinsText, 1);
- // ..........................................
- DealsText = TextDrawCreate(229.000, 400.500, "LD_POKE:deal");
- TextDrawFont(DealsText, 4);
- TextDrawTextSize(DealsText, 59.500, 14.500);
- TextDrawColor(DealsText, -1);
- TextDrawSetSelectable(DealsText, 1);
- // ..........................................
- ExitPoker = TextDrawCreate(457.000, 253.000, "LD_BEAT:cross");
- TextDrawFont(ExitPoker, 4);
- TextDrawTextSize(ExitPoker, 16.000, 16.000);
- TextDrawColor(ExitPoker, -1);
- TextDrawSetSelectable(ExitPoker, 1);
- // ..........................................
- BetText = TextDrawCreate(167.500, 377.000, "LD_BEAT:circle");
- TextDrawFont(BetText, 4);
- TextDrawTextSize(BetText, 16.000, 16.000);
- TextDrawColor(BetText, -1);
- TextDrawSetSelectable(BetText, 1);
- // ..........................................
- ChangeBackGround = TextDrawCreate(437.000, 253.000, "LD_NONE:warp");
- TextDrawFont(ChangeBackGround, 4);
- TextDrawTextSize(ChangeBackGround, 16.000, 16.000);
- TextDrawColor(ChangeBackGround, -1);
- TextDrawSetSelectable(ChangeBackGround, 1);
- // ..........................................
- return 1;
- }
- public
- OnFilterScriptExit()
- {
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(WinText[i] != Text:INVALID_TEXT_DRAW)
- {
- Delete_PokerTextDraw(i);
- }
- }
- return 1;
- }
- public
- OnPlayerConnect(playerid)
- {
- PP_Info[playerid][LastBackGround] = 3;
- WinText[playerid] = Text:INVALID_TEXT_DRAW;
- BetCreditText[playerid] = Text:INVALID_TEXT_DRAW;
- for(new i; i < 5; i++)
- {
- CardsText[playerid][i] = Text:INVALID_TEXT_DRAW;
- }
- return 1;
- }
- public
- OnPlayerDisconnect(playerid, reason)
- {
- if(WinText[playerid] != Text:INVALID_TEXT_DRAW)
- {
- Delete_PokerTextDraw(playerid);
- }
- return 1;
- }
- public
- OnPlayerCommandText(playerid, cmdtext[])
- {
- new
- idx,
- cmd[20];
- cmd = strtok(cmdtext, idx);
- if(strcmp("/poker", cmd, true) == 0)
- {
- if(WinText[playerid] != Text:INVALID_TEXT_DRAW) return SendClientMessage(playerid, -1, "Usage: /exitpoker");
- cmd = strtok(cmdtext, idx);
- new
- credit = strval(cmd);
- if(strlen(cmd) == 0) SendClientMessage(playerid, -1, "{008888}Usage: {ffffff}/poker [5-100000]");
- else if(GetPlayerMoney(playerid) < credit) return SendClientMessage(playerid, -1, "Not have enough money.");
- else if(credit < 5 || credit > 100000) return SendClientMessage(playerid, -1, "{008888}Usage: {ffffff}/poker [5-100000]");
- else
- {
- Create_PokerTextDraw(playerid);
- PP_Info[playerid][Credit] = credit;
- GivePlayerMoney(playerid, -credit);
- TogglePlayerControllable(playerid, false);
- PP_Info[playerid][Bet] = MIN_BET;
- PP_Info[playerid][hold] = FIRST_DIVID;
- TextDrawShowForPlayer(playerid, BackGroundText[PP_Info[playerid][LastBackGround]]);
- TextDrawShowForPlayer(playerid, WinText[playerid]);
- TextDrawShowForPlayer(playerid, BetCreditText[playerid]);
- TextDrawShowForPlayer(playerid, Win_Text);
- TextDrawShowForPlayer(playerid, ExitPoker);
- TextDrawShowForPlayer(playerid, BetText);
- TextDrawShowForPlayer(playerid, ChangeBackGround);
- BetCredit(playerid);
- WinnText(playerid, 0);
- for(new i; i < 5; i++)
- {
- PP_Info[playerid][fivecards_hand][i] = 0;
- PP_Info[playerid][fivecards_hand][i + 5] = 0;
- PP_Info[playerid][holdstate][i] = HOLDOFF;
- TextDrawSetString(CardsText[playerid][i], "LD_TATT:8poker"); //"LD_POKE:backred");
- TextDrawShowForPlayer(playerid, CardsText[playerid][i]);
- TextDrawShowForPlayer(playerid, Text_HoldOn[i]);
- }
- TextDrawShowForPlayer(playerid, DealsText);
- TextDrawShowForPlayer(playerid, AddCoinsText);
- SelectTextDraw(playerid, 0x9999BBBB);
- }
- return 1;
- }
- return 0;
- }
- stock
- getwin(const cards[], &One_Pair_Type, &Two_Pair_Type)
- {
- new
- i = 0,
- getcolor,
- straight;
- getcolor = Color_Mask[cards[0]] | Color_Mask[cards[1]] | Color_Mask[cards[2]] | Color_Mask[cards[3]] | Color_Mask[cards[4]];
- getcolor = getcolor & (getcolor - 1);
- straight = (Bynary_Mask[cards[0]] | Bynary_Mask[cards[1]] | Bynary_Mask[cards[2]] | Bynary_Mask[cards[3]] | Bynary_Mask[cards[4]]);
- if(getcolor == 0)
- {
- if(straight == 31) return ROYAL_FLUSH;
- if(HasStraight(straight)) return STRAIGHT_FLUSH;
- return FLUSH;
- } else {
- new
- two_pair,
- three_of_a_kind,
- match[13];
- for(i = 0; i < 5; i++)
- {
- match[cards[i] % 13]++;
- }
- for(i = 0; i < 13; i++)
- {
- switch(match[i])
- {
- case 2:
- {
- two_pair++;
- if(two_pair == 1)
- One_Pair_Type = i;
- else if(two_pair == 2)
- Two_Pair_Type = i;
- }
- case 3: three_of_a_kind++, One_Pair_Type = i;
- case 4: return One_Pair_Type = i, FOUR_OF_A_KIND;
- }
- }
- if(two_pair == 1 && three_of_a_kind == 1) return FULL_HOUSE;
- if(two_pair == 2) return TWO_PAIR;
- if(two_pair == 1) return ONE_PAIR;
- if(three_of_a_kind == 1) return THREE_OF_A_KIND;
- if(HasStraight(straight)) return STRAIGHT;
- }
- return HIGH_CARD;
- }
- stock
- HasStraight(straight)
- {
- switch(straight)
- {
- case 31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 4111: return true;
- }
- return false;
- }
- public
- TextDrawDizajn(playerid, index)
- {
- if(index == 5)
- {
- new
- win,
- One_pair,
- Two_pair;
- win = getwin(PP_Info[playerid][fivecards_hand], One_pair, Two_pair);
- SetTimerEx("TextDrawDizajn2", 200, false, "iiii", playerid, win, One_pair, Two_pair);
- return 1;
- } else {
- PlaySound(playerid, 20800);
- TextDrawSetString(CardsText[playerid][index], "LD_POKE:cdback");
- TextDrawHideForPlayer(playerid, Text_Holdmid[index]);
- TextDrawHideForPlayer(playerid, Text_HoldOn[index]);
- SetTimerEx("TextDrawDizajn", 100, false, "ii", playerid, ++index);
- }
- return 1;
- }
- public
- TextDrawDizajn2(playerid, win, One_pair, Two_pair)
- {
- //--+
- for(new i; i < 5; i++)
- {
- TextDrawSetString(CardsText[playerid][i], LD_POKE[PP_Info[playerid][fivecards_hand][i]]);
- }
- //--+
- switch(win)
- {
- case STRAIGHT, FLUSH, STRAIGHT_FLUSH, FULL_HOUSE, ROYAL_FLUSH:
- {
- for(new i = 0; i < 5; i++)
- {
- TextDrawShowForPlayer(playerid, Text_HoldOn[i]);
- PP_Info[playerid][holdstate][i] = HOLDON;
- }
- }
- case TWO_PAIR:
- {
- for(new i = 0; i < 5; i++)
- {
- if( Card_Value[One_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]] ||
- Card_Value[Two_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
- {
- TextDrawShowForPlayer(playerid, Text_HoldOn[i]);
- PP_Info[playerid][holdstate][i] = HOLDON;
- }
- }
- }
- case ONE_PAIR, FOUR_OF_A_KIND, THREE_OF_A_KIND:
- {
- for(new i = 0; i < 5; i++)
- {
- if(Card_Value[One_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
- {
- TextDrawShowForPlayer(playerid, Text_HoldOn[i]);
- PP_Info[playerid][holdstate][i] = HOLDON;
- }
- }
- }
- }
- //--+
- WinnText(playerid, win);
- //--+
- return 1;
- }
- stock
- WinnText(playerid, win)
- {
- new
- str[100];
- str = "~w~";
- for(new i = 9; i > 1; i--)
- {
- if(i == win)
- format(str, sizeof str, "%s~r~$%d(win)~n~~w~", str, PP_Info[playerid][Bet] * pot[i]);
- else
- format(str, sizeof str, "%s$%d~n~", str, PP_Info[playerid][Bet] * pot[i]);
- }
- TextDrawSetString(WinText[playerid], str);
- }
- stock
- BetCredit(playerid)
- {
- new
- str[128];
- format(str, sizeof str, " ~g~Bet: ~w~$%d ~g~Credit: ~w~$%d",
- PP_Info[playerid][Bet],
- PP_Info[playerid][Credit]);
- TextDrawSetString(BetCreditText[playerid], str);
- return 1;
- }
- stock
- Create_PokerTextDraw(playerid)
- {
- // ..........................................
- BetCreditText[playerid] = TextDrawCreate(320.000000, 379.000000, "_");
- TextDrawAlignment(BetCreditText[playerid], 2);
- TextDrawBackgroundColor(BetCreditText[playerid], 255);
- TextDrawFont(BetCreditText[playerid], 3);
- TextDrawLetterSize(BetCreditText[playerid], 0.300000, 1.600000);
- TextDrawColor(BetCreditText[playerid], -1);
- TextDrawSetOutline(BetCreditText[playerid], 0);
- TextDrawSetProportional(BetCreditText[playerid], 1);
- TextDrawSetShadow(BetCreditText[playerid], 1);
- TextDrawUseBox(BetCreditText[playerid], 1);
- TextDrawBoxColor(BetCreditText[playerid], 335595560);
- TextDrawTextSize(BetCreditText[playerid], 6.000000, 302.000000);
- // ..........................................
- WinText[playerid] = TextDrawCreate(247.500000, 154.000000, "_");
- TextDrawFont(WinText[playerid], 1);
- TextDrawLetterSize(WinText[playerid], 0.320000, 1.400000);
- TextDrawSetOutline(WinText[playerid], 1);
- TextDrawSetProportional(WinText[playerid], 1);
- // ..........................................
- CardsText[playerid][0] = TextDrawCreate(167.500, 286.500, "LD_POKE:backcyan");
- TextDrawFont(CardsText[playerid][0], 4);
- TextDrawTextSize(CardsText[playerid][0], 59.500, 88.000);
- TextDrawColor(CardsText[playerid][0], -1);
- TextDrawSetSelectable(CardsText[playerid][0], 1);
- CardsText[playerid][1] = TextDrawCreate(229.000, 286.500, "LD_POKE:backcyan");
- TextDrawFont(CardsText[playerid][1], 4);
- TextDrawTextSize(CardsText[playerid][1], 59.500, 88.000);
- TextDrawColor(CardsText[playerid][1], -1);
- TextDrawSetSelectable(CardsText[playerid][1], 1);
- CardsText[playerid][2] = TextDrawCreate(290.500, 286.500, "LD_POKE:backcyan");
- TextDrawFont(CardsText[playerid][2], 4);
- TextDrawTextSize(CardsText[playerid][2], 59.500, 88.000);
- TextDrawColor(CardsText[playerid][2], -1);
- TextDrawSetSelectable(CardsText[playerid][2], 1);
- CardsText[playerid][3] = TextDrawCreate(352.000, 286.500, "LD_POKE:backcyan");
- TextDrawFont(CardsText[playerid][3], 4);
- TextDrawTextSize(CardsText[playerid][3], 59.500, 88.000);
- TextDrawColor(CardsText[playerid][3], -1);
- TextDrawSetSelectable(CardsText[playerid][3], 1);
- CardsText[playerid][4] = TextDrawCreate(413.500, 286.500, "LD_POKE:backcyan");
- TextDrawFont(CardsText[playerid][4], 4);
- TextDrawTextSize(CardsText[playerid][4], 59.500, 88.000);
- TextDrawColor(CardsText[playerid][4], -1);
- TextDrawSetSelectable(CardsText[playerid][4], 1);
- // ..........................................
- }
- stock
- Delete_PokerTextDraw(playerid)
- {
- TextDrawHideForPlayer(playerid, BackGroundText[PP_Info[playerid][LastBackGround]]);
- TextDrawHideForPlayer(playerid, WinText[playerid]);
- TextDrawHideForPlayer(playerid, BetCreditText[playerid]);
- TextDrawHideForPlayer(playerid, DealsText);
- TextDrawHideForPlayer(playerid, AddCoinsText);
- TextDrawHideForPlayer(playerid, Win_Text);
- TextDrawHideForPlayer(playerid, ExitPoker);
- TextDrawHideForPlayer(playerid, BetText);
- TextDrawHideForPlayer(playerid, ChangeBackGround);
- TextDrawDestroy(WinText[playerid]);
- TextDrawDestroy(BetCreditText[playerid]);
- WinText[playerid] = Text:INVALID_TEXT_DRAW;
- BetCreditText[playerid] = Text:INVALID_TEXT_DRAW;
- for(new i = 0; i < 5; i++)
- {
- TextDrawHideForPlayer(playerid, CardsText[playerid][i]);
- TextDrawHideForPlayer(playerid, Text_Holdmid[i]);
- TextDrawHideForPlayer(playerid, Text_HoldOn[i]);
- TextDrawDestroy(CardsText[playerid][i]);
- CardsText[playerid][i] = Text:INVALID_TEXT_DRAW;
- }
- return 1;
- }
- stock
- PlaySound(playerid, sound)
- {
- new
- Float:X,
- Float:Y,
- Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- PlayerPlaySound(playerid, sound, X, Y, Z);
- return sound;
- }
- stock
- HasDuplicateValues(const array[], size = sizeof array)
- {
- for(new f = 0; f < size - 1; ++f)
- {
- for(new c = f + 1; c < size; ++c)
- {
- if(array[f] == array[c])
- {
- return true;
- }
- }
- }
- return false;
- }
- stock
- RandomNumber(value, array[], size = sizeof array)
- {
- for(new p = 0; p < size; p++) array[p] = random(value);
- }
- stock
- Swap (&a, &b)
- {
- new s;
- s = a;
- a = b;
- b = s;
- }
- stock
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- public
- OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- if(clickedid == Text:INVALID_TEXT_DRAW) return 1;
- if(WinText[playerid] != Text:INVALID_TEXT_DRAW)
- {
- if(DealsText == clickedid) // Deal
- {
- if(PP_Info[playerid][hold] == FIRST_DIVID)
- {
- if(PP_Info[playerid][Credit] < PP_Info[playerid][Bet]) return SendClientMessage(playerid, -1, "No credit");
- //--+
- PP_Info[playerid][Credit] -= PP_Info[playerid][Bet];
- PP_Info[playerid][hold] = SECOND_DIVID;
- PlaySound(playerid, 43000);
- //--+
- do
- {
- RandomNumber(52, PP_Info[playerid][fivecards_hand], 10); // Pawn sizeof() does not work enum array
- }
- while(HasDuplicateValues(PP_Info[playerid][fivecards_hand], 10)) // Pawn sizeof() does not work enum array
- //--+
- WinnText(playerid, 0);
- BetCredit(playerid);
- TextDrawDizajn(playerid, 0);
- //--+
- } else {
- //--+
- PP_Info[playerid][hold] = FIRST_DIVID;
- //--+
- for(new i; i < 5; i++)
- {
- if(PP_Info[playerid][holdstate][i] == HOLDON)
- {
- TextDrawHideForPlayer(playerid, Text_HoldOn[i]);
- PP_Info[playerid][holdstate][i] = HOLDOFF;
- } else {
- Swap(PP_Info[playerid][fivecards_hand][i], PP_Info[playerid][fivecards_hand][i + 5]);
- TextDrawSetString(CardsText[playerid][i], LD_POKE[PP_Info[playerid][fivecards_hand][i]]);
- }
- }
- new
- One_pair,
- Two_pair,
- win;
- //--+
- win = getwin(PP_Info[playerid][fivecards_hand], One_pair, Two_pair);
- //--+
- if(win > ONE_PAIR)
- {
- //--+
- PP_Info[playerid][Credit] += (pot[win] * PP_Info[playerid][Bet]);
- //--+
- /* new
- str[128];
- format(str, sizeof str, "Win:{00a6ff}%s | $%d", rang_sor[win], pot[win] * PP_Info[playerid][Bet]);
- SendClientMessage(playerid, -1, str);*/
- //--+
- switch(win)
- {
- case STRAIGHT, FLUSH, STRAIGHT_FLUSH, FULL_HOUSE, ROYAL_FLUSH:
- {
- for(new i = 0; i < 5; i++)
- {
- TextDrawShowForPlayer(playerid, Text_Holdmid[i]);
- }
- }
- case TWO_PAIR:
- {
- for(new i = 0; i < 5; i++)
- {
- if( Card_Value[One_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]] ||
- Card_Value[Two_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
- {
- TextDrawShowForPlayer(playerid, Text_Holdmid[i]);
- }
- }
- }
- case ONE_PAIR, FOUR_OF_A_KIND, THREE_OF_A_KIND:
- {
- for(new i = 0; i < 5; i++)
- {
- if(Card_Value[One_pair] == Card_Value[PP_Info[playerid][fivecards_hand][i]])
- {
- TextDrawShowForPlayer(playerid, Text_Holdmid[i]);
- }
- }
- }
- }
- PlaySound(playerid, 5448); //43001); //30800);
- WinnText(playerid, win);
- BetCredit(playerid);
- //--+
- } else {
- //--+
- for(new i = 0; i < 5; i++)
- {
- TextDrawHideForPlayer(playerid, Text_HoldOn[i]);
- }
- //--+
- }
- }
- } else {
- if(PP_Info[playerid][hold] == SECOND_DIVID)
- {
- for(new i = 0; i < 5; i++)
- {
- if(CardsText[playerid][i] == clickedid)
- {
- PP_Info[playerid][holdstate][i] = HOLDOFF - PP_Info[playerid][holdstate][i];
- if(PP_Info[playerid][holdstate][i])
- TextDrawHideForPlayer(playerid, Text_HoldOn[i]);
- else
- TextDrawShowForPlayer(playerid, Text_HoldOn[i]);
- PlaySound(playerid, 21000); //43000);
- return 1;
- }
- }
- }
- else if(AddCoinsText == clickedid)
- {
- if(GetPlayerMoney(playerid) < 100)
- {
- SendClientMessage(playerid, -1, "{cc1212}You have no money.");
- } else {
- GivePlayerMoney(playerid, -100);
- PP_Info[playerid][Credit] += 100;
- BetCredit(playerid);
- PlaySound(playerid, 4203);
- }
- return 1;
- }
- else if(BetText == clickedid)
- {
- if(PP_Info[playerid][Bet] < 100)
- PP_Info[playerid][Bet] += 5;
- else
- PP_Info[playerid][Bet] = 5;
- BetCredit(playerid);
- WinnText(playerid, 0)
- PlaySound(playerid, 4202);
- return 1;
- }
- }
- if(ChangeBackGround == clickedid)
- {
- PP_Info[playerid][LastBackGround]++;
- if(PP_Info[playerid][LastBackGround] == sizeof BackGroundText)
- {
- PP_Info[playerid][LastBackGround] = 0;
- TextDrawHideForPlayer(playerid, BackGroundText[ sizeof (BackGroundText) - 1]);
- } else {
- TextDrawHideForPlayer(playerid, BackGroundText[PP_Info[playerid][LastBackGround] - 1]);
- }
- TextDrawShowForPlayer(playerid, BackGroundText[PP_Info[playerid][LastBackGround]]);
- return 1;
- }
- if(ExitPoker == clickedid)
- {
- SetPVarInt(playerid, "videopoker", 0);
- Delete_PokerTextDraw(playerid);
- TogglePlayerControllable(playerid, true);
- GivePlayerMoney(playerid, PP_Info[playerid][Credit]);
- new
- str[128];
- format(str, sizeof str, "Thank you using the {ffffff}¤ [Fs]Poker script by.: Zsolesszka ¤{22a4b5} Add money : {ffffff}$%d", PP_Info[playerid][Credit]);
- PP_Info[playerid][Credit] = 0;
- SendClientMessage(playerid, 0x22a4b5AA, str);
- CancelSelectTextDraw(playerid);
- return 1;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement