/* /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$ | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$ | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$ | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/ | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/ | $$\ $$$| $$ \ $$ | $$ \ $$| $$ | $$ \ $$| $$$$$$/ | $$ | $$| $$ |__/ \__/ \______/ |__/ |__/|__/ Poker System Next Generation Gaming, LLC (created by Next Generation Gaming Development Team) * Copyright (c) 2016, Next Generation Gaming, LLC * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are not permitted in any case. * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include hook OnPlayerDisconnect(playerid, reason) { if(GetPVarType(playerid, "pkrTableID")) { new tableid = GetPVarInt(playerid, "pkrTableID")-1; // Convert prkChips to cgChips //SetPVarInt(playerid, "cgChips", GetPVarInt(playerid, "cgChips")+GetPVarInt(playerid, "pkrChips")); GivePlayerCashEx(playerid, TYPE_ONHAND, GetPVarInt(playerid, "pkrChips")); format(szMiscArray, sizeof(szMiscArray), "%s(%d) (IP:%s) has left the table with $%s (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(GetPVarInt(playerid, "pkrChips")), tableid); Log("logs/poker.log", szMiscArray); PokerTable[tableid][pkrPot] -= GetPVarInt(playerid, "pkrChips"); // Poker Table Money Exploit fix. // De-occuply Slot PokerTable[tableid][pkrPlayers] -= 1; if(GetPVarInt(playerid, "pkrStatus")) PokerTable[tableid][pkrActivePlayers] -= 1; PokerTable[tableid][pkrSlot][GetPVarInt(playerid, "pkrSlot")] = -1; // Check & Stop the Game Loop if No Players at the Table if(PokerTable[tableid][pkrPlayers] == 0) { for(new i = 0, pid; i < 6; i++) { pid = PokerTable[tableid][pkrSlot][i]; if(pid != INVALID_PLAYER_ID) { SetPVarInt(pid, "pkrChips", GetPVarInt(pid, "pkrChips")+PokerTable[tableid][pkrPot]); // Last one gets all. LeavePokerTable(pid); } } KillTimer(PokerTable[tableid][pkrPulseTimer]); new tmpString[64]; format(tmpString, sizeof(tmpString), "Poker Table %d", tableid); Update3DTextLabelText(PokerTable[tableid][pkrText3DID], COLOR_YELLOW, tmpString); ResetPokerTable(tableid); } if(PokerTable[tableid][pkrRound] == 0 && PokerTable[tableid][pkrDelay] < 5) { ResetPokerRound(tableid); } SetPlayerInterior(playerid, PokerTable[tableid][pkrInt]); SetPlayerVirtualWorld(playerid, PokerTable[tableid][pkrVW]); SetPlayerPos(playerid, GetPVarFloat(playerid, "pkrTableJoinX"), GetPVarFloat(playerid, "pkrTableJoinY"), GetPVarFloat(playerid, "pkrTableJoinZ")+0.1); SetCameraBehindPlayer(playerid); TogglePlayerControllable(playerid, 1); ApplyAnimation(playerid, "CARRY", "crry_prtial", 2.0, 0, 0, 0, 0, 0); if(GetPVarInt(playerid, "pkrActiveHand")) { PokerTable[tableid][pkrActiveHands]--; } // Destroy Poker Memory DeletePVar(playerid, "pkrWinner"); DeletePVar(playerid, "pkrCurrentBet"); DeletePVar(playerid, "pkrChips"); DeletePVar(playerid, "pkrTableJoinX"); DeletePVar(playerid, "pkrTableJoinY"); DeletePVar(playerid, "pkrTableJoinZ"); DeletePVar(playerid, "pkrTableID"); DeletePVar(playerid, "pkrSlot"); DeletePVar(playerid, "pkrStatus"); DeletePVar(playerid, "pkrRoomLeader"); DeletePVar(playerid, "pkrRoomBigBlind"); DeletePVar(playerid, "pkrRoomSmallBlind"); DeletePVar(playerid, "pkrRoomDealer"); DeletePVar(playerid, "pkrCard1"); DeletePVar(playerid, "pkrCard2"); DeletePVar(playerid, "pkrActivePlayer"); DeletePVar(playerid, "pkrActiveHand"); DeletePVar(playerid, "pkrHide"); // Destroy GUI DestroyPokerGUI(playerid); } } PokerOptions(playerid, option) { switch(option) { case 0: { DeletePVar(playerid, "pkrActionOptions"); PlayerTextDrawHide(playerid, PlayerPokerUI[playerid][38]); PlayerTextDrawHide(playerid, PlayerPokerUI[playerid][39]); PlayerTextDrawHide(playerid, PlayerPokerUI[playerid][40]); } case 1: // if(CurrentBet >= ActiveBet) { SetPVarInt(playerid, "pkrActionOptions", 1); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][38], "RAISE"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][39], "CHECK"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][40], "FOLD"); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][38]); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][39]); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][40]); } case 2: // if(CurrentBet < ActiveBet) { SetPVarInt(playerid, "pkrActionOptions", 2); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][38], "CALL"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][39], "RAISE"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][40], "FOLD"); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][38]); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][39]); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][40]); } case 3: // if(pkrChips < 1) { SetPVarInt(playerid, "pkrActionOptions", 3); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][38], "CHECK"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][39], "FOLD"); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][38]); PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][39]); } } } PokerCallHand(playerid) { ShowCasinoGamesMenu(playerid, DIALOG_CGAMESCALLPOKER); } PokerRaiseHand(playerid) { ShowCasinoGamesMenu(playerid, DIALOG_CGAMESRAISEPOKER); } PokerCheckHand(playerid) { if(GetPVarInt(playerid, "pkrActiveHand")) { SetPVarString(playerid, "pkrStatusString", "Check"); } // Animation ApplyAnimation(playerid, "CASINO", "cards_raise", 4.1, 0, 1, 1, 1, 1, 1); } PokerFoldHand(playerid) { if(GetPVarInt(playerid, "pkrActiveHand")) { DeletePVar(playerid, "pkrCard1"); DeletePVar(playerid, "pkrCard2"); DeletePVar(playerid, "pkrActiveHand"); DeletePVar(playerid, "pkrStatus"); PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrActiveHands]--; SetPVarString(playerid, "pkrStatusString", "Fold"); // SFX GlobalPlaySound(5602, PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrX], PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrY], PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrZ]); // Animation ApplyAnimation(playerid, "CASINO", "cards_out", 4.1, 0, 1, 1, 1, 1, 1); } } PokerDealHands(tableid) { new tmp = 0; // Loop through active players. for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { if(GetPVarInt(playerid, "pkrStatus") && GetPVarInt(playerid, "pkrChips") > 0) { SetPVarInt(playerid, "pkrCard1", PokerTable[tableid][pkrDeck][tmp]); SetPVarInt(playerid, "pkrCard2", PokerTable[tableid][pkrDeck][tmp+1]); SetPVarInt(playerid, "pkrActiveHand", 1); PokerTable[tableid][pkrActiveHands]++; // SFX PlayerPlaySound(playerid, 5602, 0.0, 0.0, 0.0); // Animation ApplyAnimation(playerid, "CASINO", "cards_in", 4.1, 0, 1, 1, 1, 1, 1); tmp += 2; } } } // Loop through community cards. for(new i = 0; i < 5; i++) { PokerTable[tableid][pkrCCards][i] = PokerTable[tableid][pkrDeck][tmp]; tmp++; } } PokerShuffleDeck(tableid) { // SFX GlobalPlaySound(5600, PokerTable[tableid][pkrX], PokerTable[tableid][pkrY], PokerTable[tableid][pkrZ]); // Order the deck for(new i = 0; i < 52; i++) { PokerTable[tableid][pkrDeck][i] = i; } // Randomize the array (AKA Shuffle Algorithm) new rand, tmp, i; for(i = 52; i > 1; i--) { rand = random(52) % i; tmp = PokerTable[tableid][pkrDeck][rand]; PokerTable[tableid][pkrDeck][rand] = PokerTable[tableid][pkrDeck][i-1]; PokerTable[tableid][pkrDeck][i-1] = tmp; } } PokerFindPlayerOrder(tableid, index) { new tmpIndex = -1; for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { tmpIndex++; if(tmpIndex == index) { if(GetPVarInt(playerid, "pkrStatus") == 1) return playerid; } } } return -1; } PokerAssignBlinds(tableid) { if(PokerTable[tableid][pkrPos] == 6) { PokerTable[tableid][pkrPos] = 0; } // Find where to start & distubute blinds. new bool:roomDealer = false, bool:roomBigBlind = false, bool:roomSmallBlind = false; // Find the Dealer. new tmpPos = PokerTable[tableid][pkrPos]; if(roomDealer == false) { if(tmpPos == 6) { tmpPos = 0; } new playerid = PokerFindPlayerOrder(tableid, tmpPos); if(playerid != -1) { SetPVarInt(playerid, "pkrRoomDealer", 1); SetPVarString(playerid, "pkrStatusString", "Dealer"); roomDealer = true; } else { tmpPos++; } } // Find the player after the Dealer. tmpPos = PokerTable[tableid][pkrPos]; if(roomBigBlind == false) { if(tmpPos == 6) { tmpPos = 0; } new playerid = PokerFindPlayerOrder(tableid, tmpPos); if(playerid != -1) { if(GetPVarInt(playerid, "pkrRoomDealer") != 1 && GetPVarInt(playerid, "pkrRoomBigBlind") != 1 && GetPVarInt(playerid, "pkrRoomSmallBlind") != 1) { SetPVarInt(playerid, "pkrRoomBigBlind", 1); new tmpString[128]; format(tmpString, sizeof(tmpString), "~r~BB -$%d", PokerTable[tableid][pkrBlind]); SetPVarString(playerid, "pkrStatusString", tmpString); roomBigBlind = true; if(GetPVarInt(playerid, "pkrChips") < PokerTable[tableid][pkrBlind]) { PokerTable[tableid][pkrPot] += GetPVarInt(playerid, "pkrChips"); SetPVarInt(playerid, "pkrChips", 0); } else { PokerTable[tableid][pkrPot] += PokerTable[tableid][pkrBlind]; SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")-PokerTable[tableid][pkrBlind]); } SetPVarInt(playerid, "pkrCurrentBet", PokerTable[tableid][pkrBlind]); PokerTable[tableid][pkrActiveBet] = PokerTable[tableid][pkrBlind]; } else { tmpPos++; } } else { tmpPos++; } } // Small Blinds are active only if there are more than 2 players. if(PokerTable[tableid][pkrActivePlayers] > 2) { // Find the player after the Big Blind. tmpPos = PokerTable[tableid][pkrPos]; if(roomSmallBlind == false) { if(tmpPos == 6) { tmpPos = 0; } new playerid = PokerFindPlayerOrder(tableid, tmpPos); if(playerid != -1) { if(GetPVarInt(playerid, "pkrRoomDealer") != 1 && GetPVarInt(playerid, "pkrRoomBigBlind") != 1 && GetPVarInt(playerid, "pkrRoomSmallBlind") != 1) { SetPVarInt(playerid, "pkrRoomSmallBlind", 1); new tmpString[128]; format(tmpString, sizeof(tmpString), "~r~SB -$%d", PokerTable[tableid][pkrBlind]/2); SetPVarString(playerid, "pkrStatusString", tmpString); roomSmallBlind = true; if(GetPVarInt(playerid, "pkrChips") < (PokerTable[tableid][pkrBlind]/2)) { PokerTable[tableid][pkrPot] += GetPVarInt(playerid, "pkrChips"); SetPVarInt(playerid, "pkrChips", 0); } else { PokerTable[tableid][pkrPot] += (PokerTable[tableid][pkrBlind]/2); SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")-(PokerTable[tableid][pkrBlind]/2)); } SetPVarInt(playerid, "pkrCurrentBet", PokerTable[tableid][pkrBlind]/2); PokerTable[tableid][pkrActiveBet] = PokerTable[tableid][pkrBlind]/2; } else { tmpPos++; } } else { tmpPos++; } } } PokerTable[tableid][pkrPos]++; } PokerRotateActivePlayer(tableid) { new nextactiveid = -1, lastapid = -1, lastapslot = -1; if(PokerTable[tableid][pkrActivePlayerID] != -1) { lastapid = PokerTable[tableid][pkrActivePlayerID]; for(new i = 0; i < 6; i++) { if(PokerTable[tableid][pkrSlot][i] == lastapid) { lastapslot = i; } } DeletePVar(lastapid, "pkrActivePlayer"); DeletePVar(lastapid, "pkrTime"); PokerOptions(lastapid, 0); } // New Round Init Block if(PokerTable[tableid][pkrRotations] == 0 && lastapid == -1 && lastapslot == -1) { // Find & Assign ActivePlayer to Dealer for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(GetPVarInt(playerid, "pkrRoomDealer") == 1) { nextactiveid = playerid; PokerTable[tableid][pkrActivePlayerID] = playerid; PokerTable[tableid][pkrActivePlayerSlot] = i; PokerTable[tableid][pkrRotations]++; PokerTable[tableid][pkrSlotRotations] = i; } } } else if(PokerTable[tableid][pkrRotations] >= 6) { PokerTable[tableid][pkrRotations] = 0; PokerTable[tableid][pkrStage]++; if(PokerTable[tableid][pkrStage] > 3) { PokerTable[tableid][pkrActive] = 4; PokerTable[tableid][pkrDelay] = 20+1; return 1; } PokerTable[tableid][pkrSlotRotations]++; if(PokerTable[tableid][pkrSlotRotations] >= 6) { PokerTable[tableid][pkrSlotRotations] -= 6; } new playerid = PokerFindPlayerOrder(tableid, PokerTable[tableid][pkrSlotRotations]); if(playerid != -1) { nextactiveid = playerid; PokerTable[tableid][pkrActivePlayerID] = playerid; PokerTable[tableid][pkrActivePlayerSlot] = PokerTable[tableid][pkrSlotRotations]; PokerTable[tableid][pkrRotations]++; } else { PokerTable[tableid][pkrRotations]++; PokerRotateActivePlayer(tableid); } } else { PokerTable[tableid][pkrSlotRotations]++; if(PokerTable[tableid][pkrSlotRotations] >= 6) { PokerTable[tableid][pkrSlotRotations] -= 6; } new playerid = PokerFindPlayerOrder(tableid, PokerTable[tableid][pkrSlotRotations]); if(playerid != -1) { nextactiveid = playerid; PokerTable[tableid][pkrActivePlayerID] = playerid; PokerTable[tableid][pkrActivePlayerSlot] = PokerTable[tableid][pkrSlotRotations]; PokerTable[tableid][pkrRotations]++; } else { PokerTable[tableid][pkrRotations]++; PokerRotateActivePlayer(tableid); } } if(nextactiveid != -1) { if(GetPVarInt(nextactiveid, "pkrActiveHand")) { new currentBet = GetPVarInt(nextactiveid, "pkrCurrentBet"); new activeBet = PokerTable[tableid][pkrActiveBet]; new apSoundID[] = {5809, 5810}; new randomApSoundID = random(sizeof(apSoundID)); PlayerPlaySound(nextactiveid, apSoundID[randomApSoundID], 0.0, 0.0, 0.0); if(GetPVarInt(nextactiveid, "pkrChips") < 1) { PokerOptions(nextactiveid, 3); } else if(currentBet >= activeBet) { PokerOptions(nextactiveid, 1); } else if (currentBet < activeBet) { PokerOptions(nextactiveid, 2); } else { PokerOptions(nextactiveid, 0); } SetPVarInt(nextactiveid, "pkrTime", 60); SetPVarInt(nextactiveid, "pkrActivePlayer", 1); } } return 1; } InitPokerTables() { for(new i = 0; i < MAX_POKERTABLES; i++) { PokerTable[i][pkrActive] = 0; PokerTable[i][pkrPlaced] = 0; PokerTable[i][pkrObjectID] = 0; for(new c = 0; c < MAX_POKERTABLEMISCOBJS; c++) { PokerTable[i][pkrMiscObjectID][c] = 0; } for(new s = 0; s < 6; s++) { PokerTable[i][pkrSlot][s] = -1; } PokerTable[i][pkrX] = 0.0; PokerTable[i][pkrY] = 0.0; PokerTable[i][pkrZ] = 0.0; PokerTable[i][pkrRX] = 0.0; PokerTable[i][pkrRY] = 0.0; PokerTable[i][pkrRZ] = 0.0; PokerTable[i][pkrVW] = 0; PokerTable[i][pkrInt] = 0; PokerTable[i][pkrPlayers] = 0; PokerTable[i][pkrLimit] = 6; PokerTable[i][pkrBuyInMax] = 1000; PokerTable[i][pkrBuyInMin] = 500; PokerTable[i][pkrBlind] = 100; PokerTable[i][pkrPos] = 0; PokerTable[i][pkrRound] = 0; PokerTable[i][pkrStage] = 0; PokerTable[i][pkrActiveBet] = 0; PokerTable[i][pkrSetDelay] = 15; PokerTable[i][pkrActivePlayerID] = -1; PokerTable[i][pkrActivePlayerSlot] = -1; PokerTable[i][pkrRotations] = 0; PokerTable[i][pkrSlotRotations] = 0; PokerTable[i][pkrWinnerID] = -1; PokerTable[i][pkrWinners] = 0; } } ResetPokerRound(tableid) { PokerTable[tableid][pkrRound] = 0; PokerTable[tableid][pkrStage] = 0; PokerTable[tableid][pkrActiveBet] = 0; PokerTable[tableid][pkrActive] = 2; PokerTable[tableid][pkrDelay] = PokerTable[tableid][pkrSetDelay]; PokerTable[tableid][pkrPot] = 0; PokerTable[tableid][pkrRotations] = 0; PokerTable[tableid][pkrSlotRotations] = 0; PokerTable[tableid][pkrWinnerID] = -1; PokerTable[tableid][pkrWinners] = 0; // Reset Player Variables for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { DeletePVar(playerid, "pkrWinner"); DeletePVar(playerid, "pkrRoomBigBlind"); DeletePVar(playerid, "pkrRoomSmallBlind"); DeletePVar(playerid, "pkrRoomDealer"); DeletePVar(playerid, "pkrCard1"); DeletePVar(playerid, "pkrCard2"); DeletePVar(playerid, "pkrActivePlayer"); DeletePVar(playerid, "pkrTime"); if(GetPVarInt(playerid, "pkrActiveHand")) { PokerTable[tableid][pkrActiveHands]--; // Animation ApplyAnimation(playerid, "CASINO", "cards_out", 4.1, 0, 1, 1, 1, 1, 1); } DeletePVar(playerid, "pkrActiveHand"); DeletePVar(playerid, "pkrCurrentBet"); DeletePVar(playerid, "pkrResultString"); DeletePVar(playerid, "pkrHide"); } } return 1; } ResetPokerTable(tableid) { new szString[32]; format(szString, sizeof(szString), ""); strmid(PokerTable[tableid][pkrPass], szString, 0, strlen(szString), 64); PokerTable[tableid][pkrActive] = 0; PokerTable[tableid][pkrLimit] = 6; PokerTable[tableid][pkrBuyInMax] = 1000; PokerTable[tableid][pkrBuyInMin] = 500; PokerTable[tableid][pkrBlind] = 100; PokerTable[tableid][pkrPos] = 0; PokerTable[tableid][pkrRound] = 0; PokerTable[tableid][pkrStage] = 0; PokerTable[tableid][pkrActiveBet] = 0; PokerTable[tableid][pkrDelay] = 0; PokerTable[tableid][pkrPot] = 0; PokerTable[tableid][pkrSetDelay] = 15; PokerTable[tableid][pkrRotations] = 0; PokerTable[tableid][pkrSlotRotations] = 0; PokerTable[tableid][pkrWinnerID] = -1; PokerTable[tableid][pkrWinners] = 0; } ShowPokerGUI(playerid, guitype) { switch(guitype) { case GUI_POKER_TABLE: { SetPVarInt(playerid, "pkrTableGUI", 1); for(new i = 0; i < MAX_PLAYERPOKERUI; i++) { PlayerTextDrawShow(playerid, PlayerPokerUI[playerid][i]); } } } } DestroyPokerGUI(playerid) { for(new i = 0; i < MAX_PLAYERPOKERUI; i++) { PlayerTextDrawDestroy(playerid, PlayerPokerUI[playerid][i]); } } PlacePokerTable(tableid, skipmisc, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, virtualworld, interior) { PokerTable[tableid][pkrPlaced] = 1; PokerTable[tableid][pkrX] = x; PokerTable[tableid][pkrY] = y; PokerTable[tableid][pkrZ] = z; PokerTable[tableid][pkrRX] = rx; PokerTable[tableid][pkrRY] = ry; PokerTable[tableid][pkrRZ] = rz; PokerTable[tableid][pkrVW] = virtualworld; PokerTable[tableid][pkrInt] = interior; // Create Table PokerTable[tableid][pkrObjectID] = CreateDynamicObject(OBJ_POKER_TABLE, x, y, z, rx, ry, rz, virtualworld, interior, -1, DRAWDISTANCE_POKER_TABLE); if(skipmisc != 0) { } // Create 3D Text Label new szString[64]; format(szString, sizeof(szString), "Poker Table %d", tableid); PokerTable[tableid][pkrText3DID] = Create3DTextLabel(szString, COLOR_YELLOW, x, y, z+1.3, DRAWDISTANCE_POKER_MISC, virtualworld, 0); return tableid; } DestroyPokerTable(tableid) { if(PokerTable[tableid][pkrPlaced] == 1) { foreach(new i : Player) { if(GetPVarInt(i, "pkrTableID")-1 == tableid) { LeavePokerTable(i); SendClientMessageEx(i, COLOR_YELLOW, "The poker table owner has destroyed the table."); } } // Delete Table if(IsValidDynamicObject(PokerTable[tableid][pkrObjectID])) DestroyDynamicObject(PokerTable[tableid][pkrObjectID]); // Delete 3D Text Label Delete3DTextLabel(PokerTable[tableid][pkrText3DID]); // Delete Misc Obj for(new c = 0; c < MAX_POKERTABLEMISCOBJS; c++) { if(IsValidObject(PokerTable[tableid][pkrMiscObjectID][c])) DestroyObject(PokerTable[tableid][pkrMiscObjectID][c]); } } PokerTable[tableid][pkrX] = 0.0; PokerTable[tableid][pkrY] = 0.0; PokerTable[tableid][pkrZ] = 0.0; PokerTable[tableid][pkrRX] = 0.0; PokerTable[tableid][pkrRY] = 0.0; PokerTable[tableid][pkrRZ] = 0.0; PokerTable[tableid][pkrVW] = 0; PokerTable[tableid][pkrInt] = 0; PokerTable[tableid][pkrPlayers] = 0; PokerTable[tableid][pkrLimit] = 6; PokerTable[tableid][pkrPlaced] = 0; return tableid; } // Note: 0, 1 should be the hand, the rest are community cards. AnaylzePokerHand(playerid, Hand[]) { new pokerArray[7]; for(new i = 0; i < sizeof(pokerArray); i++) { pokerArray[i] = Hand[i]; } new suitArray[4][13]; new tmp = 0; new pairs = 0; new bool:isRoyalFlush = false; new bool:isFlush = false; new bool:isStraight = false; new bool:isFour = false; new bool:isThree = false; new bool:isTwoPair = false; new bool:isPair = false; // Convert Hand[] (AKA pokerArray) to suitArray[] for(new i = 0; i < sizeof(pokerArray); i++) { if(pokerArray[i] < 13) { // Clubs (0 - 12) suitArray[0][pokerArray[i]] = 1; } if(12 < pokerArray[i] < 26) { // Diamonds (13 - 25) suitArray[1][pokerArray[i]-13] = 1; } if(25 < pokerArray[i] < 39) { // Hearts (26 - 38) suitArray[2][pokerArray[i]-26] = 1; } if(38 < pokerArray[i] < 52) { // Spades (39 - 51) suitArray[3][pokerArray[i]-39] = 1; } } // Royal Check for(new i = 0; i < 4; i++) { if(suitArray[i][8] == 1) { // Must be 8 (?) -> 10, Jack, Queen, King, Ace. if(suitArray[i][9] == 1) { if(suitArray[i][10] == 1) { if(suitArray[i][11] == 1) { if(suitArray[i][12] == 1) { isRoyalFlush = true; break; } } } } } } tmp = 0; // Flush Check for(new i = 0; i < 4; i++) { for(new j = 0; j < 13; j++) { if(suitArray[i][j] == 1) { tmp++; } } if(tmp > 4) { isFlush = true; break; } else { tmp = 0; } } tmp = 0; // Four of a Kind Check // Three of a Kind Check for(new i = 0; i < 4; i++) { for(new j = 0; j < 13; j++) { if(suitArray[i][j] == 1) { for(new c = 0; c < 4; c++) { if(suitArray[c][j] == 1) { tmp++; } } if(tmp == 4) { isFour = true; } else if(tmp == 3) { // if tmp >= 3, then tmp = 4 is also ruled as a Three of a Kind. isThree = true; } else { tmp = 0; } } } } tmp = 0; // Two Pair & Pair Check for(new j = 0; j < 13; j++) { tmp = 0; for(new i = 0; i < 4; i++) { if(suitArray[i][j] == 1) { tmp++; if(tmp >= 2) { isPair = true; pairs++; if(pairs >= 2) { isTwoPair = true; } } } } } tmp = 0; // Straight Check for(new j = 0; j < 13; j++) { for(new i = 0; i < 4; i++) { if(suitArray[i][j] == 1) { for(new s = 0; s < 5; s++) { for(new c = 0; c < 4; c++) { if(j+s == 13) { if(suitArray[c][0] == 1) { tmp++; break; } } else if (j+s >= 14) { break; } else { if(suitArray[c][j+s] == 1) { tmp++; break; } } } } } if(tmp >= 5) { isStraight = true; } tmp = 0; } } tmp = 0; // Convert Hand to Singles // Card 1 if(pokerArray[0] > 12 && pokerArray[0] < 26) pokerArray[0] -= 13; if(pokerArray[0] > 25 && pokerArray[0] < 39) pokerArray[0] -= 26; if(pokerArray[0] > 38 && pokerArray[0] < 52) pokerArray[0] -= 39; if(pokerArray[0] == 0) pokerArray[0] = 13; // Convert Aces to worth 13. // Card 2 if(pokerArray[1] > 12 && pokerArray[1] < 26) pokerArray[1] -= 13; if(pokerArray[1] > 25 && pokerArray[1] < 39) pokerArray[1] -= 26; if(pokerArray[1] > 38 && pokerArray[1] < 52) pokerArray[1] -= 39; if(pokerArray[1] == 0) pokerArray[1] = 13; // Convert Aces to worth 13. // 10) POKER_RESULT_ROYAL_FLUSH - A, K, Q, J, 10 (SAME SUIT) * ROYAL + FLUSH * if(isRoyalFlush) { SetPVarString(playerid, "pkrResultString", "Royal Flush"); return 1000 + pokerArray[0] + pokerArray[1]; } // 9) POKER_RESULT_STRAIGHT_FLUSH - Any five card squence. (SAME SUIT) * STRAIGHT + FLUSH * if(isStraight && isFlush) { SetPVarString(playerid, "pkrResultString", "Straight Flush"); return 900 + pokerArray[0] + pokerArray[1]; } // 8) POKER_RESULT_FOUR_KIND - All four cards of the same rank. * FOUR KIND * if(isFour) { SetPVarString(playerid, "pkrResultString", "Four of a Kind"); return 800 + pokerArray[0] + pokerArray[1]; } // 7) POKER_RESULT_FULL_HOUSE - Three of a kind combined with a pair. * THREE KIND + PAIR * if(isThree && isTwoPair) { SetPVarString(playerid, "pkrResultString", "Full House"); return 700 + pokerArray[0] + pokerArray[1]; } // 6) POKER_RESULT_FLUSH - Any five cards of the same suit, no sequence. * FLUSH * if(isFlush) { SetPVarString(playerid, "pkrResultString", "Flush"); return 600 + pokerArray[0] + pokerArray[1]; } // 5) POKER_RESULT_STRAIGHT - Five cards in sequence, but not in the same suit. * STRAIGHT * if(isStraight) { SetPVarString(playerid, "pkrResultString", "Straight"); return 500 + pokerArray[0] + pokerArray[1]; } // 4) POKER_RESULT_THREE_KIND - Three cards of the same rank. * THREE KIND * if(isThree) { SetPVarString(playerid, "pkrResultString", "Three of a Kind"); return 400 + pokerArray[0] + pokerArray[1]; } // 3) POKER_RESULT_TWO_PAIR - Two seperate pair. * TWO PAIR * if(isTwoPair) { SetPVarString(playerid, "pkrResultString", "Two Pair"); return 300 + pokerArray[0] + pokerArray[1]; } // 2) POKER_RESULT_PAIR - Two cards of the same rank. * PAIR * if(isPair) { SetPVarString(playerid, "pkrResultString", "Pair"); return 200 + pokerArray[0] + pokerArray[1]; } // 1) POKER_RESULT_HIGH_CARD - Highest card. SetPVarString(playerid, "pkrResultString", "High Card"); return pokerArray[0] + pokerArray[1]; } forward PokerExit(playerid); public PokerExit(playerid) { SetCameraBehindPlayer(playerid); TogglePlayerControllable(playerid, 1); ClearAnimationsEx(playerid); CancelSelectTextDraw(playerid); } forward PokerPulse(tableid); public PokerPulse(tableid) { // Idle Animation Loop & Re-seater for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { // Disable Weapons SetPlayerArmedWeapon(playerid,0); new idleRandom = random(100); if(idleRandom >= 90) { SetPlayerPosObjectOffset(PokerTable[tableid][pkrObjectID], playerid, PokerTableMiscObjOffsets[i][0], PokerTableMiscObjOffsets[i][1], PokerTableMiscObjOffsets[i][2]); SetPlayerFacingAngle(playerid, PokerTableMiscObjOffsets[i][5]+90.0); SetPlayerInterior(playerid, PokerTable[tableid][pkrInt]); SetPlayerVirtualWorld(playerid, PokerTable[tableid][pkrVW]); // Animation if(GetPVarInt(playerid, "pkrActiveHand")) { ApplyAnimation(playerid, "CASINO", "cards_loop", 4.1, 0, 1, 1, 1, 1, 1); } } } } // 3D Text Label Update3DTextLabelText(PokerTable[tableid][pkrText3DID], COLOR_YELLOW, " "); if(PokerTable[tableid][pkrActivePlayers] >= 2 && PokerTable[tableid][pkrActive] == 2) { // Count the number of active players with more than $0, activate the round if more than 1 gets counted. new tmpCount = 0; for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { if(GetPVarInt(playerid, "pkrChips") > 0) { tmpCount++; } } } if(tmpCount > 1) { PokerTable[tableid][pkrActive] = 3; PokerTable[tableid][pkrDelay] = PokerTable[tableid][pkrSetDelay]; } } if(PokerTable[tableid][pkrPlayers] < 2 && PokerTable[tableid][pkrActive] == 3) { // Pseudo Code (Move Pot towards last player's chip count) for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")+PokerTable[tableid][pkrPot]); LeavePokerTable(playerid); ResetPokerTable(tableid); JoinPokerTable(playerid, tableid); } } } // Winner Loop if(PokerTable[tableid][pkrActive] == 4) { if(PokerTable[tableid][pkrDelay] == 20) { new endBetsSoundID[] = {5826, 5827}; new randomEndBetsSoundID = random(sizeof(endBetsSoundID)); GlobalPlaySound(endBetsSoundID[randomEndBetsSoundID], PokerTable[tableid][pkrX], PokerTable[tableid][pkrY], PokerTable[tableid][pkrZ]); for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { PokerOptions(playerid, 0); } } } if(PokerTable[tableid][pkrDelay] > 0) { PokerTable[tableid][pkrDelay]--; if(PokerTable[tableid][pkrDelay] <= 5 && PokerTable[tableid][pkrDelay] > 0) { for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0); } } } if(PokerTable[tableid][pkrDelay] == 0) { return ResetPokerRound(tableid); } if(PokerTable[tableid][pkrDelay] == 19) { // Anaylze Cards new resultArray[6]; for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; new cards[7]; if(playerid != -1) { if(GetPVarInt(playerid, "pkrActiveHand")) { cards[0] = GetPVarInt(playerid, "pkrCard1"); cards[1] = GetPVarInt(playerid, "pkrCard2"); new tmp = 0; for(new c = 2; c < 7; c++) { cards[c] = PokerTable[tableid][pkrCCards][tmp]; tmp++; } SetPVarInt(playerid, "pkrResult", AnaylzePokerHand(playerid, cards)); } } } // Sorting Results (Highest to Lowest) for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { if(GetPVarInt(playerid, "pkrActiveHand")) { resultArray[i] = GetPVarInt(playerid, "pkrResult"); } } } BubbleSort(resultArray, sizeof(resultArray)); // Determine Winner(s) for(new i = 0; i < 6; i++) { if(resultArray[5] == resultArray[i]) PokerTable[tableid][pkrWinners]++; } // Notify Table of Winner & Give Rewards for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { if(PokerTable[tableid][pkrWinners] > 1) { // Split if(resultArray[5] == GetPVarInt(playerid, "pkrResult")) { new splitpot = PokerTable[tableid][pkrPot]/PokerTable[tableid][pkrWinners]; SetPVarInt(playerid, "pkrWinner", 1); SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")+splitpot); PlayerPlaySound(playerid, 5821, 0.0, 0.0, 0.0); } else { PlayerPlaySound(playerid, 31202, 0.0, 0.0, 0.0); } } else { // Single Winner if(resultArray[5] == GetPVarInt(playerid, "pkrResult")) { SetPVarInt(playerid, "pkrWinner", 1); SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")+PokerTable[tableid][pkrPot]); PokerTable[tableid][pkrWinnerID] = playerid; new winnerSoundID[] = {5847, 5848, 5849, 5854, 5855, 5856}; new randomWinnerSoundID = random(sizeof(winnerSoundID)); PlayerPlaySound(playerid, winnerSoundID[randomWinnerSoundID], 0.0, 0.0, 0.0); } else { PlayerPlaySound(playerid, 31202, 0.0, 0.0, 0.0); } } } } } } // Game Loop if(PokerTable[tableid][pkrActive] == 3) { if(PokerTable[tableid][pkrActiveHands] == 1 && PokerTable[tableid][pkrRound] == 1) { PokerTable[tableid][pkrStage] = 0; PokerTable[tableid][pkrActive] = 4; PokerTable[tableid][pkrDelay] = 20+1; for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { if(GetPVarInt(playerid, "pkrActiveHand")) { SetPVarInt(playerid, "pkrHide", 1); } } } } // Delay Time Controller if(PokerTable[tableid][pkrDelay] > 0) { PokerTable[tableid][pkrDelay]--; if(PokerTable[tableid][pkrDelay] <= 5 && PokerTable[tableid][pkrDelay] > 0) { for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0); } } } // Assign Blinds & Active Player if(PokerTable[tableid][pkrRound] == 0 && PokerTable[tableid][pkrDelay] == 5) { for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { SetPVarInt(playerid, "pkrStatus", 1); } } PokerAssignBlinds(tableid); } // If no round active, start it. if(PokerTable[tableid][pkrRound] == 0 && PokerTable[tableid][pkrDelay] == 0) { PokerTable[tableid][pkrRound] = 1; for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { SetPVarString(playerid, "pkrStatusString", " "); } } // Shuffle Deck & Deal Cards & Allocate Community Cards PokerShuffleDeck(tableid); PokerDealHands(tableid); PokerRotateActivePlayer(tableid); } // Round Logic // Time Controller for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; if(playerid != -1) { if(GetPVarInt(playerid, "pkrActivePlayer")) { SetPVarInt(playerid, "pkrTime", GetPVarInt(playerid, "pkrTime")-1); if(GetPVarInt(playerid, "pkrTime") == 0) { new name[24]; GetPlayerName(playerid, name, sizeof(name)); if(GetPVarInt(playerid, "pkrActionChoice")) { DeletePVar(playerid, "pkrActionChoice"); ShowPlayerDialogEx(playerid, -1, DIALOG_STYLE_LIST, "Close", "Close", "Close", "Close"); } PokerFoldHand(playerid); PokerRotateActivePlayer(tableid); } } } } } // Update GUI for(new i = 0; i < 6; i++) { new playerid = PokerTable[tableid][pkrSlot][i]; new tmp, tmpString[128]; // Set Textdraw Offset switch(i) { case 0: { tmp = 0; } case 1: { tmp = 5; } case 2: { tmp = 10; } case 3: { tmp = 15; } case 4: { tmp = 20; } case 5: { tmp = 25; } } if(playerid != -1) { // Debug /* new string[512]; format(string, sizeof(string), "Debug:~n~pkrActive: %d~n~pkrPlayers: %d~n~pkrActivePlayers: %d~n~pkrActiveHands: %d~n~pkrPos: %d~n~pkrDelay: %d~n~pkrRound: %d~n~pkrStage: %d~n~pkrActiveBet: %d~n~pkrRotations: %d", PokerTable[tableid][pkrActive], PokerTable[tableid][pkrPlayers], PokerTable[tableid][pkrActivePlayers], PokerTable[tableid][pkrActiveHands], PokerTable[tableid][pkrPos], PokerTable[tableid][pkrDelay], PokerTable[tableid][pkrRound], PokerTable[tableid][pkrStage], PokerTable[tableid][pkrActiveBet], PokerTable[tableid][pkrRotations] ); format(string, sizeof(string), "%s~n~----------~n~", string); new sstring[128]; GetPVarString(playerid, "pkrStatusString", sstring, 128); format(string, sizeof(string), "%spkrTableID: %d~n~pkrCurrentBet: %d~n~pkrStatus: %d~n~pkrRoomLeader: %d~n~pkrRoomBigBlind: %d~n~pkrRoomSmallBlind: %d~n~pkrRoomDealer: %d~n~pkrActivePlayer: %d~n~pkrActiveHand: %d~n~pkrStatusString: %s", string, GetPVarInt(playerid, "pkrTableID")-1, GetPVarInt(playerid, "pkrCurrentBet"), GetPVarInt(playerid, "pkrStatus"), GetPVarInt(playerid, "pkrRoomLeader"), GetPVarInt(playerid, "pkrRoomBigBlind"), GetPVarInt(playerid, "pkrRoomSmallBlind"), GetPVarInt(playerid, "pkrRoomDealer"), GetPVarInt(playerid, "pkrActivePlayer"), GetPVarInt(playerid, "pkrActiveHand"), sstring ); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][45], string); */ // Name new name[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, name, sizeof(name)); for(new td = 0; td < 6; td++) { new pid = PokerTable[tableid][pkrSlot][td]; if(pid != -1) PlayerTextDrawSetString(pid, PlayerPokerUI[pid][0+tmp], name); } // Chips if(GetPVarInt(playerid, "pkrChips") > 0) { format(tmpString, sizeof(tmpString), "$%d", GetPVarInt(playerid, "pkrChips")); } else { format(tmpString, sizeof(tmpString), "~r~$%d", GetPVarInt(playerid, "pkrChips")); } for(new td = 0; td < 6; td++) { new pid = PokerTable[tableid][pkrSlot][td]; if(pid != -1) PlayerTextDrawSetString(pid, PlayerPokerUI[pid][1+tmp], tmpString); } // Cards for(new td = 0; td < 6; td++) { new pid = PokerTable[tableid][pkrSlot][td]; if(pid != -1) { if(GetPVarInt(playerid, "pkrActiveHand")) { if(playerid != pid) { if(PokerTable[tableid][pkrActive] == 4 && PokerTable[tableid][pkrDelay] <= 19 && GetPVarInt(playerid, "pkrHide") != 1) { format(tmpString, sizeof(tmpString), "%s", DeckTextdrw[GetPVarInt(playerid, "pkrCard1")+1]); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][2+tmp], tmpString); format(tmpString, sizeof(tmpString), "%s", DeckTextdrw[GetPVarInt(playerid, "pkrCard2")+1]); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][3+tmp], tmpString); } else { PlayerTextDrawSetString(pid, PlayerPokerUI[pid][2+tmp], DeckTextdrw[0]); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][3+tmp], DeckTextdrw[0]); } } else { format(tmpString, sizeof(tmpString), "%s", DeckTextdrw[GetPVarInt(playerid, "pkrCard1")+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][2+tmp], tmpString); format(tmpString, sizeof(tmpString), "%s", DeckTextdrw[GetPVarInt(playerid, "pkrCard2")+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][3+tmp], tmpString); } } else { PlayerTextDrawSetString(pid, PlayerPokerUI[pid][2+tmp], " "); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][3+tmp], " "); } } } // Status if(PokerTable[tableid][pkrActive] < 3) { format(tmpString, sizeof(tmpString), " "); } else if(GetPVarInt(playerid, "pkrActivePlayer") && PokerTable[tableid][pkrActive] == 3) { format(tmpString, sizeof(tmpString), "0:%d", GetPVarInt(playerid, "pkrTime")); } else { if(PokerTable[tableid][pkrActive] == 3 && PokerTable[tableid][pkrDelay] > 5) { SetPVarString(playerid, "pkrStatusString", " "); } if(PokerTable[tableid][pkrActive] == 4 && PokerTable[tableid][pkrDelay] == 19) { if(PokerTable[tableid][pkrWinners] == 1) { if(GetPVarInt(playerid, "pkrWinner")) { format(tmpString, sizeof(tmpString), "+$%d", PokerTable[tableid][pkrPot]); SetPVarString(playerid, "pkrStatusString", tmpString); } else { format(tmpString, sizeof(tmpString), "-$%d", GetPVarInt(playerid, "pkrCurrentBet")); SetPVarString(playerid, "pkrStatusString", tmpString); } } else { if(GetPVarInt(playerid, "pkrWinner")) { new splitpot = PokerTable[tableid][pkrPot]/PokerTable[tableid][pkrWinners]; format(tmpString, sizeof(tmpString), "+$%d", splitpot); SetPVarString(playerid, "pkrStatusString", tmpString); } else { format(tmpString, sizeof(tmpString), "-$%d", GetPVarInt(playerid, "pkrCurrentBet")); SetPVarString(playerid, "pkrStatusString", tmpString); } } } if(PokerTable[tableid][pkrActive] == 4 && PokerTable[tableid][pkrDelay] == 19) { if(GetPVarInt(playerid, "pkrActiveHand") && GetPVarInt(playerid, "pkrHide") != 1) { new resultString[64]; GetPVarString(playerid, "pkrResultString", resultString, 64); format(tmpString, sizeof(tmpString), "%s", resultString); SetPVarString(playerid, "pkrStatusString", resultString); } } if(PokerTable[tableid][pkrActive] == 4 && PokerTable[tableid][pkrDelay] == 10) { if(PokerTable[tableid][pkrWinners] == 1) { if(GetPVarInt(playerid, "pkrWinner")) { format(tmpString, sizeof(tmpString), "+$%d", PokerTable[tableid][pkrPot]); SetPVarString(playerid, "pkrStatusString", tmpString); } else { format(tmpString, sizeof(tmpString), "-$%d", GetPVarInt(playerid, "pkrCurrentBet")); SetPVarString(playerid, "pkrStatusString", tmpString); } } else { if(GetPVarInt(playerid, "pkrWinner")) { new splitpot = PokerTable[tableid][pkrPot]/PokerTable[tableid][pkrWinners]; format(tmpString, sizeof(tmpString), "+$%d", splitpot); SetPVarString(playerid, "pkrStatusString", tmpString); } else { format(tmpString, sizeof(tmpString), "-$%d", GetPVarInt(playerid, "pkrCurrentBet")); SetPVarString(playerid, "pkrStatusString", tmpString); } } } GetPVarString(playerid, "pkrStatusString", tmpString, 128); } for(new td = 0; td < 6; td++) { new pid = PokerTable[tableid][pkrSlot][td]; if(pid != -1) PlayerTextDrawSetString(pid, PlayerPokerUI[pid][4+tmp], tmpString); } // Pot if(PokerTable[tableid][pkrDelay] > 0 && PokerTable[tableid][pkrActive] == 3) { if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][37], "Texas Holdem Poker"); } else if(PokerTable[tableid][pkrActive] == 2) { if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][37], "Texas Holdem Poker"); } else if(PokerTable[tableid][pkrActive] == 3) { format(tmpString, sizeof(tmpString), "Pot: $%d", PokerTable[tableid][pkrPot]); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][37], tmpString); } else if(PokerTable[tableid][pkrActive] == 4 && PokerTable[tableid][pkrDelay] < 19) { if(PokerTable[tableid][pkrWinnerID] != -1) { new winnerName[24]; GetPlayerName(PokerTable[tableid][pkrWinnerID], winnerName, sizeof(winnerName)); format(tmpString, sizeof(tmpString), "%s Won $%d", winnerName, PokerTable[tableid][pkrPot]); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][37], tmpString); } else if(PokerTable[tableid][pkrWinners] > 1) { new splitpot = PokerTable[tableid][pkrPot]/PokerTable[tableid][pkrWinners]; format(tmpString, sizeof(tmpString), "%d Winners Won $%d", PokerTable[tableid][pkrWinners], splitpot); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][37], tmpString); } } else { if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][37], "Texas Holdem Poker"); } // Bet if(PokerTable[tableid][pkrDelay] > 0 && PokerTable[tableid][pkrActive] == 3) { format(tmpString, sizeof(tmpString), "Round Begins in ~r~%d~w~...", PokerTable[tableid][pkrDelay]); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][46], tmpString); } else if(PokerTable[tableid][pkrActive] == 2) { format(tmpString, sizeof(tmpString), "Waiting for players...", PokerTable[tableid][pkrPot]); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][46], tmpString); } else if(PokerTable[tableid][pkrActive] == 3) { format(tmpString, sizeof(tmpString), "Bet: $%d", PokerTable[tableid][pkrActiveBet]); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][46], tmpString); } else if(PokerTable[tableid][pkrActive] == 4) { format(tmpString, sizeof(tmpString), "Round Ends in ~r~%d~w~...", PokerTable[tableid][pkrDelay]); if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][46], tmpString); } else { if(playerid != -1) PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][46], "Texas Holdem Poker"); } // Community Cards switch(PokerTable[tableid][pkrStage]) { case 0: // Opening { PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][31], "LD_CARD:cdback"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][32], "LD_CARD:cdback"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][33], "LD_CARD:cdback"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][34], "LD_CARD:cdback"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][35], "LD_CARD:cdback"); } case 1: // Flop { PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][31], DeckTextdrw[PokerTable[tableid][pkrCCards][0]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][32], DeckTextdrw[PokerTable[tableid][pkrCCards][1]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][33], DeckTextdrw[PokerTable[tableid][pkrCCards][2]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][34], "LD_CARD:cdback"); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][35], "LD_CARD:cdback"); } case 2: // Turn { PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][31], DeckTextdrw[PokerTable[tableid][pkrCCards][0]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][32], DeckTextdrw[PokerTable[tableid][pkrCCards][1]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][33], DeckTextdrw[PokerTable[tableid][pkrCCards][2]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][34], DeckTextdrw[PokerTable[tableid][pkrCCards][3]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][35], "LD_CARD:cdback"); } case 3: // River { PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][31], DeckTextdrw[PokerTable[tableid][pkrCCards][0]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][32], DeckTextdrw[PokerTable[tableid][pkrCCards][1]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][33], DeckTextdrw[PokerTable[tableid][pkrCCards][2]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][34], DeckTextdrw[PokerTable[tableid][pkrCCards][3]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][35], DeckTextdrw[PokerTable[tableid][pkrCCards][4]+1]); } case 4: // Win { PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][31], DeckTextdrw[PokerTable[tableid][pkrCCards][0]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][32], DeckTextdrw[PokerTable[tableid][pkrCCards][1]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][33], DeckTextdrw[PokerTable[tableid][pkrCCards][2]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][34], DeckTextdrw[PokerTable[tableid][pkrCCards][3]+1]); PlayerTextDrawSetString(playerid, PlayerPokerUI[playerid][35], DeckTextdrw[PokerTable[tableid][pkrCCards][4]+1]); } } } else { for(new td = 0; td < 6; td++) { new pid = PokerTable[tableid][pkrSlot][td]; if(pid != -1) { PlayerTextDrawSetString(pid, PlayerPokerUI[pid][0+tmp], " "); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][1+tmp], " "); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][2+tmp], " "); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][3+tmp], " "); PlayerTextDrawSetString(pid, PlayerPokerUI[pid][4+tmp], " "); } } } } return 1; } ShowCasinoGamesMenu(playerid, dialogid) { switch(dialogid) { case DIALOG_CGAMESCALLPOKER: { if(GetPVarInt(playerid, "pkrChips") > 0) { SetPVarInt(playerid, "pkrActionChoice", 1); new tableid = GetPVarInt(playerid, "pkrTableID")-1; new actualBet = PokerTable[tableid][pkrActiveBet]-GetPVarInt(playerid, "pkrCurrentBet"); if(actualBet > GetPVarInt(playerid, "pkrChips")) { format(szMiscArray, sizeof(szMiscArray), "{FFFFFF}Are you sure you want to call $%s (All-In)?:", number_format(actualBet)); return ShowPlayerDialogEx(playerid, DIALOG_CGAMESCALLPOKER, DIALOG_STYLE_MSGBOX, "{FFFFFF}Texas Holdem Poker - (Call)", szMiscArray, "All-In", "Cancel"); } format(szMiscArray, sizeof(szMiscArray), "{FFFFFF}Are you sure you want to call $%s?:", number_format(actualBet)); return ShowPlayerDialogEx(playerid, DIALOG_CGAMESCALLPOKER, DIALOG_STYLE_MSGBOX, "{FFFFFF}Texas Holdem Poker - (Call)", szMiscArray, "Call", "Cancel"); } else { SendClientMessage(playerid, COLOR_WHITE, "DEALER: You do not have enough funds to call."); new noFundsSoundID[] = {5823, 5824, 5825}; new randomNoFundsSoundID = random(sizeof(noFundsSoundID)); PlayerPlaySound(playerid, noFundsSoundID[randomNoFundsSoundID], 0.0, 0.0, 0.0); } } case DIALOG_CGAMESRAISEPOKER: { new tableid = GetPVarInt(playerid, "pkrTableID")-1; SetPVarInt(playerid, "pkrActionChoice", 1); if(GetPVarInt(playerid, "pkrCurrentBet")+GetPVarInt(playerid, "pkrChips") > PokerTable[tableid][pkrActiveBet]+PokerTable[tableid][pkrBlind]/2) { SetPVarInt(playerid, "pkrActionChoice", 1); format(szMiscArray, sizeof(szMiscArray), "{FFFFFF}How much do you want to Raise? ($%d-$%d):", PokerTable[tableid][pkrActiveBet]+PokerTable[tableid][pkrBlind]/2, GetPVarInt(playerid, "pkrCurrentBet")+GetPVarInt(playerid, "pkrChips")); return ShowPlayerDialogEx(playerid, DIALOG_CGAMESRAISEPOKER, DIALOG_STYLE_INPUT, "{FFFFFF}Texas Holdem Poker - (Raise)", szMiscArray, "Raise", "Cancel"); } else if(GetPVarInt(playerid, "pkrCurrentBet")+GetPVarInt(playerid, "pkrChips") == PokerTable[tableid][pkrActiveBet]+PokerTable[tableid][pkrBlind]/2) { SetPVarInt(playerid, "pkrActionChoice", 1); format(szMiscArray, sizeof(szMiscArray), "{FFFFFF}How much do you want to Raise? (All-In):", PokerTable[tableid][pkrActiveBet]+PokerTable[tableid][pkrBlind]/2, GetPVarInt(playerid, "pkrCurrentBet")+GetPVarInt(playerid, "pkrChips")); return ShowPlayerDialogEx(playerid, DIALOG_CGAMESRAISEPOKER, DIALOG_STYLE_INPUT, "{FFFFFF}Texas Holdem Poker - (Raise)", szMiscArray, "All-In", "Cancel"); } else { SendClientMessage(playerid, COLOR_WHITE, "DEALER: You do not have enough funds to raise."); new noFundsSoundID[] = {5823, 5824, 5825}; new randomNoFundsSoundID = random(sizeof(noFundsSoundID)); PlayerPlaySound(playerid, noFundsSoundID[randomNoFundsSoundID], 0.0, 0.0, 0.0); } } case DIALOG_CGAMESBUYINPOKER: { format(szMiscArray, sizeof(szMiscArray), "{FFFFFF}Please input a buy-in amount for the table:\n\nCurrent Casino Chips: {00FF00}$%d{FFFFFF}\nCurrent Poker Chips: {00FF00}$%d{FFFFFF}\nBuy-In Maximum/Minimum: {00FF00}$%d{FFFFFF}/{00FF00}$%d{FFFFFF}", GetPlayerCash(playerid), GetPVarInt(playerid, "pkrChips"), PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMax], PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMin]); return ShowPlayerDialogEx(playerid, DIALOG_CGAMESBUYINPOKER, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (BuyIn Menu)", szMiscArray, "Buy In", "Leave"); } case DIALOG_CGAMESADMINMENU: { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESADMINMENU, DIALOG_STYLE_LIST, "{FFFFFF}Casino Games - (Admin Menu)", "{FFFFFF}Setup Poker Minigame...\nLine2\nCredits", "Select", "Close"); } case DIALOG_CGAMESSELECTPOKER: { szMiscArray[0] = 0; new szPlaced[64]; for(new i = 0; i < MAX_POKERTABLES; i++) { if(PokerTable[i][pkrPlaced] == 1) { format(szPlaced, sizeof(szPlaced), "{00FF00}Active{FFFFFF}"); } if(PokerTable[i][pkrPlaced] == 0) { format(szPlaced, sizeof(szPlaced), "{FF0000}Deactived{FFFFFF}"); } format(szMiscArray, sizeof(szMiscArray), "%sPoker Table %d (%s)\n", szMiscArray, i, szPlaced, PokerTable[i][pkrPlayers]); } return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSELECTPOKER, DIALOG_STYLE_LIST, "Casino Games - (Select Poker Table)", szMiscArray, "Select", "Back"); } case DIALOG_CGAMESSETUPPOKER: { new tableid = GetPVarInt(playerid, "tmpEditPokerTableID")-1; if(PokerTable[tableid][pkrPlaced] == 0) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPOKER, DIALOG_STYLE_LIST, "{FFFFFF}Casino Games - (Setup Poker Minigame)", "{FFFFFF}Place Table...", "Select", "Back"); } else { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPOKER, DIALOG_STYLE_LIST, "{FFFFFF}Casino Games - (Setup Poker Minigame)", "{FFFFFF}Edit Table...\nDelete Table...", "Select", "Back"); } } case DIALOG_CGAMESCREDITS: { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESCREDITS, DIALOG_STYLE_MSGBOX, "{FFFFFF}Casino Games - (Credits)", "{FFFFFF}Developed By: Dan 'GhoulSlayeR' Reed", "Back", ""); } case DIALOG_CGAMESSETUPPGAME: { new tableid = GetPVarInt(playerid, "pkrTableID")-1; if(GetPVarType(playerid, "pkrTableID")) { new szString[512]; if(PokerTable[tableid][pkrPass][0] == EOS) { format(szString, sizeof(szString), "{FFFFFF}Buy-In Max\t({00FF00}$%d{FFFFFF})\nBuy-In Min\t({00FF00}$%d{FFFFFF})\nBlind\t\t({00FF00}$%d{FFFFFF} / {00FF00}$%d{FFFFFF})\nLimit\t\t(%d)\nPassword\t(%s)\nRound Delay\t(%d)\nStart Game", PokerTable[tableid][pkrBuyInMax], PokerTable[tableid][pkrBuyInMin], PokerTable[tableid][pkrBlind], PokerTable[tableid][pkrBlind]/2, PokerTable[tableid][pkrLimit], "None", PokerTable[tableid][pkrSetDelay] ); } else { format(szString, sizeof(szString), "{FFFFFF}Buy-In Max\t({00FF00}$%d{FFFFFF})\nBuy-In Min\t({00FF00}$%d{FFFFFF})\nBlind\t\t({00FF00}$%d{FFFFFF} / {00FF00}$%d{FFFFFF})\nLimit\t\t(%d)\nPassword\t(%s)\nRound Delay\t(%d)\nStart Game", PokerTable[tableid][pkrBuyInMax], PokerTable[tableid][pkrBuyInMin], PokerTable[tableid][pkrBlind], PokerTable[tableid][pkrBlind]/2, PokerTable[tableid][pkrLimit], PokerTable[tableid][pkrPass], PokerTable[tableid][pkrSetDelay] ); } return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME, DIALOG_STYLE_LIST, "{FFFFFF}Casino Games - (Setup Poker Room)", szString, "Select", "Quit"); } } case DIALOG_CGAMESSETUPPGAME2: { if(GetPVarType(playerid, "pkrTableID")) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME2, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (Buy-In Max)", "{FFFFFF}Please input a Buy-In Max:", "Change", "Back"); } } case DIALOG_CGAMESSETUPPGAME3: { if(GetPVarType(playerid, "pkrTableID")) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME3, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (Buy-In Min)", "{FFFFFF}Please input a Buy-In Min:", "Change", "Back"); } } case DIALOG_CGAMESSETUPPGAME4: { if(GetPVarType(playerid, "pkrTableID")) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME4, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (Blinds)", "{FFFFFF}Please input Blinds:\n\nNote: Small blinds are automatically half of a big blind.", "Change", "Back"); } } case DIALOG_CGAMESSETUPPGAME5: { if(GetPVarType(playerid, "pkrTableID")) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME5, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (Limit)", "{FFFFFF}Please input a Player Limit (2-6):", "Change", "Back"); } } case DIALOG_CGAMESSETUPPGAME6: { if(GetPVarType(playerid, "pkrTableID")) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME6, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (Password)", "{FFFFFF}Please input a Password:\n\nNote: Leave blank to have a public room", "Change", "Back"); } } case DIALOG_CGAMESSETUPPGAME7: { if(GetPVarType(playerid, "pkrTableID")) { return ShowPlayerDialogEx(playerid, DIALOG_CGAMESSETUPPGAME7, DIALOG_STYLE_INPUT, "{FFFFFF}Casino Games - (Round Delay)", "{FFFFFF}Please input a Round Delay (15-120sec):", "Change", "Back"); } } } return 1; } JoinPokerTable(playerid, tableid) { // Check if there is room for the player if(PokerTable[tableid][pkrPlayers] < PokerTable[tableid][pkrLimit]) { // Check if table is not joinable. if(PokerTable[tableid][pkrActive] == 1) { SendClientMessage(playerid, COLOR_WHITE, "Someone is setting up this table, try again later."); return 1; } // Find an open seat for(new s; s < 6; s++) { if(PokerTable[tableid][pkrSlot][s] == -1) { SetPVarInt(playerid, "pkrTableID", tableid+1); SetPVarInt(playerid, "pkrSlot", s); // Occuply Slot PokerTable[tableid][pkrPlayers] += 1; PokerTable[tableid][pkrSlot][s] = playerid; // Check & Start Game Loop if Not Active if(PokerTable[tableid][pkrPlayers] == 1) { // Player is Room Creator SetPVarInt(playerid, "pkrRoomLeader", 1); ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME); PokerTable[tableid][pkrActive] = 1; // Warmup Phase PokerTable[tableid][pkrPulseTimer] = SetTimerEx("PokerPulse", 1000, true, "i", tableid); //PokerPulse(tableid); } else { // Execute code for Non-Room Creators ShowCasinoGamesMenu(playerid, DIALOG_CGAMESBUYINPOKER); SelectTextDraw(playerid, COLOR_YELLOW); } CameraRadiusSetPos(playerid, PokerTable[tableid][pkrX], PokerTable[tableid][pkrY], PokerTable[tableid][pkrZ], 90.0, 4.7, 0.1); new Float:tmpPos[3]; GetPlayerPos(playerid, tmpPos[0], tmpPos[1], tmpPos[2]); SetPlayerInterior(playerid, PokerTable[tableid][pkrInt]); SetPlayerVirtualWorld(playerid, PokerTable[tableid][pkrVW]); SetPVarFloat(playerid, "pkrTableJoinX", tmpPos[0]); SetPVarFloat(playerid, "pkrTableJoinY", tmpPos[1]); SetPVarFloat(playerid, "pkrTableJoinZ", tmpPos[2]); new string[128]; format(string, sizeof(string), "%s(%d) (IP:%s) has joined poker table (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), tableid); Log("logs/poker.log", string); ApplyAnimation(playerid, "CASINO", "cards_out", 4.1, 0, 1, 1, 1, 1, 1); TogglePlayerControllable(playerid, 0); SetPlayerPosObjectOffset(PokerTable[tableid][pkrObjectID], playerid, PokerTableMiscObjOffsets[s][0], PokerTableMiscObjOffsets[s][1], PokerTableMiscObjOffsets[s][2]); SetPlayerFacingAngle(playerid, PokerTableMiscObjOffsets[s][5]+90.0); ApplyAnimation(playerid, "CASINO", "cards_out", 4.1, 0, 1, 1, 1, 1, 1); // Create GUI CreatePokerGUI(playerid); ShowPokerGUI(playerid, GUI_POKER_TABLE); // Hide Action Bar PokerOptions(playerid, 0); return 1; } } } return 1; } LeavePokerTable(playerid) { new tableid = GetPVarInt(playerid, "pkrTableID")-1; // SFX new leaveSoundID[2] = {5852, 5853}; new randomLeaveSoundID = random(sizeof(leaveSoundID)); PlayerPlaySound(playerid, leaveSoundID[randomLeaveSoundID], 0.0, 0.0, 0.0); // Convert prkChips to cgChips //SetPVarInt(playerid, "cgChips", GetPVarInt(playerid, "cgChips")+GetPVarInt(playerid, "pkrChips")); GivePlayerCashEx(playerid, TYPE_ONHAND, GetPVarInt(playerid, "pkrChips")); PokerTable[tableid][pkrPot] -= GetPVarInt(playerid, "pkrChips"); new string[128]; format(string, sizeof(string), "%s(%d) (IP:%s) has left the table with $%s (%d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(GetPVarInt(playerid, "pkrChips")), tableid); Log("logs/poker.log", string); // De-occuply Slot PokerTable[tableid][pkrPlayers] -= 1; if(GetPVarInt(playerid, "pkrStatus")) PokerTable[tableid][pkrActivePlayers] -= 1; PokerTable[tableid][pkrSlot][GetPVarInt(playerid, "pkrSlot")] = -1; // Check & Stop the Game Loop if No Players at the Table if(PokerTable[tableid][pkrPlayers] == 0) { KillTimer(PokerTable[tableid][pkrPulseTimer]); new tmpString[64]; format(tmpString, sizeof(tmpString), "Poker Table %d", tableid); Update3DTextLabelText(PokerTable[tableid][pkrText3DID], COLOR_YELLOW, tmpString); ResetPokerTable(tableid); } if(PokerTable[tableid][pkrRound] == 0 && PokerTable[tableid][pkrDelay] < 5) { ResetPokerRound(tableid); } SetPlayerInterior(playerid, PokerTable[tableid][pkrInt]); SetPlayerVirtualWorld(playerid, PokerTable[tableid][pkrVW]); SetPlayerPos(playerid, GetPVarFloat(playerid, "pkrTableJoinX"), GetPVarFloat(playerid, "pkrTableJoinY"), GetPVarFloat(playerid, "pkrTableJoinZ")+0.1); SetCameraBehindPlayer(playerid); TogglePlayerControllable(playerid, 1); ApplyAnimation(playerid, "CARRY", "crry_prtial", 2.0, 0, 0, 0, 0, 0); CancelSelectTextDraw(playerid); ShowPlayerDialogEx(playerid, -1, DIALOG_STYLE_LIST, "Close", "Close", "Close", "Close"); if(GetPVarInt(playerid, "pkrActiveHand")) { PokerTable[tableid][pkrActiveHands]--; } // Destroy Poker Memory DeletePVar(playerid, "pkrWinner"); DeletePVar(playerid, "pkrCurrentBet"); DeletePVar(playerid, "pkrChips"); DeletePVar(playerid, "pkrTableJoinX"); DeletePVar(playerid, "pkrTableJoinY"); DeletePVar(playerid, "pkrTableJoinZ"); DeletePVar(playerid, "pkrTableID"); DeletePVar(playerid, "pkrSlot"); DeletePVar(playerid, "pkrStatus"); DeletePVar(playerid, "pkrRoomLeader"); DeletePVar(playerid, "pkrRoomBigBlind"); DeletePVar(playerid, "pkrRoomSmallBlind"); DeletePVar(playerid, "pkrRoomDealer"); DeletePVar(playerid, "pkrCard1"); DeletePVar(playerid, "pkrCard2"); DeletePVar(playerid, "pkrActivePlayer"); DeletePVar(playerid, "pkrActiveHand"); DeletePVar(playerid, "pkrHide"); // Destroy GUI DestroyPokerGUI(playerid); // Delay Exit Call SetTimerEx("PokerExit", 250, false, "d", playerid); return 1; } CMD:jointable(playerid, params[]) { if(PlayerInfo[playerid][pConnectHours] < 5) { SendClientMessageEx(playerid, COLOR_GREY, "You need 5 playing hours to join a poker table."); return 1; } if(GetPVarType(playerid, "pkrTableID") == 0) { for(new t = 0; t < MAX_POKERTABLES; t++) { if(IsPlayerInRangeOfPoint(playerid, 5.0, PokerTable[t][pkrX], PokerTable[t][pkrY], PokerTable[t][pkrZ])) { if(PokerTable[t][pkrPass][0] != EOS) { if(!strcmp(params, PokerTable[t][pkrPass], false, 32)) { JoinPokerTable(playerid, t); } else { return SendClientMessage(playerid, COLOR_WHITE, "Usage: /jointable (password)"); } } else { JoinPokerTable(playerid, t); } return 1; } } } else { SendClientMessage(playerid, COLOR_WHITE, "You are already at a Poker Table! You must /leavetable before you join another one!"); } return 1; } CMD:leavetable(playerid, params[]) { if(GetPVarType(playerid, "pkrTableID")) { LeavePokerTable(playerid); } return 1; } CMD:placetable(playerid, params[]) { if(PlayerInfo[playerid][pTable] == 1 || PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1) { if(GetPVarType(playerid, "IsInArena")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't do this while being in an arena!"); if(GetPVarInt(playerid, "WatchingTV")) return SendClientMessageEx(playerid, COLOR_GREY, "You can not do this while watching TV!"); if(GetPVarInt(playerid, "Injured") == 1 || PlayerInfo[playerid][pHospital] > 0 || IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You can't do this right now."); if(PlayerInfo[playerid][pVW] == 0 || PlayerInfo[playerid][pInt] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can only place poker tables inside interiors."); if(GetPVarType(playerid, "pTable")) return SendClientMessageEx(playerid, COLOR_GREY, "You already have a poker table out, use /destroytable."); foreach(new i: Player) { if(GetPVarType(i, "pTable")) { if(IsPlayerInRangeOfPoint(playerid, 7.0, PokerTable[GetPVarInt(i, "pTable")][pkrX], PokerTable[GetPVarInt(i, "pTable")][pkrY], PokerTable[GetPVarInt(i, "pTable")][pkrZ])) { SendClientMessage(playerid, COLOR_GREY, "You are in range of another poker table, you can't place one here!"); return 1; } } } format(szMiscArray, sizeof(szMiscArray), "%s has placed a poker table!", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, szMiscArray, COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW); new Float:fPos[4]; GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]); GetPlayerFacingAngle(playerid, fPos[3]); ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1); fPos[0] += (2 * floatsin(-fPos[3], degrees)); fPos[1] += (2 * floatcos(-fPos[3], degrees)); fPos[2] -= 0.5; for(new i = 0; i < MAX_POKERTABLES; i++) { if(PokerTable[i][pkrPlaced] == 0) { PlacePokerTable(i, 1, fPos[0], fPos[1], fPos[2], 0, 0, 0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)); SetPVarInt(playerid, "pTable", i); break; } } } else { SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot place a poker table."); } return 1; } CMD:destroytable(playerid, params[]) { if(GetPVarType(playerid, "pTable")) { if(PokerTable[GetPVarType(playerid, "pTable")][pkrPlayers] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't destroy your table while a game is in progress."); DestroyPokerTable(GetPVarInt(playerid, "pTable")); DeletePVar(playerid, "pTable"); SendClientMessage(playerid, COLOR_GREY, "You've destroyed your poker table!"); } return 1; } CMD:shoptable(playerid, params[]) { if (PlayerInfo[playerid][pShopTech] < 1) { SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command."); return 1; } new giveplayerid, invoice; if(sscanf(params, "ui", giveplayerid, invoice)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /shoptable [player] [invoice #]"); new string[128]; if(PlayerInfo[giveplayerid][pTable] == 1) { PlayerInfo[giveplayerid][pTable] = 0; format(string, sizeof(string), "Your poker table has been taken by Shop Tech %s. ", GetPlayerNameEx(playerid)); SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "[SHOPPOKERTABLE] %s has taken %s(%d) poker table - Invoice %d", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), invoice); SendClientMessageEx(playerid, COLOR_GRAD1, string); Log("logs/shoplog.log", string); } else { PlayerInfo[giveplayerid][pTable] = 1; format(string, sizeof(string), "You have been given a poker table from Shop Tech %s. ", GetPlayerNameEx(playerid)); SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "[SHOPPOKERTABLE] %s has given %s(%d) a poker table - Invoice %d", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), invoice); SendClientMessageEx(playerid, COLOR_GRAD1, string); Log("logs/shoplog.log", string); } return 1; }