| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876 |
- /*
- /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
- | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
- | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
- | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
- | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
- | $$\ $$$| $$ \ $$ | $$ \ $$| $$
- | $$ \ $$| $$$$$$/ | $$ | $$| $$
- |__/ \__/ \______/ |__/ |__/|__/
- 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 <YSI\y_hooks>
- 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;
- }
|