saw this script on a forum, but it only works until waiting for player, after the game start, it stuck.
can anyone fix this script?
thanks in advance!!
Quote
prontera,150,150,5 script TexasHold'em 817,{// Optionsset@currency,0;// 0 - points, 1 - zeny, 2 - itemset@max,250;// Maximum betset@min,1;// Minumum betset@ante,1;// Anteset@itemid,0;// Item ID if credits// No game in progressif($@tex_status ==0){
mes "[Texas Hold'em]";
mes "Hello, would you like to start a game?";
next;
menu "Start New Game",-,"Cancel",T_Exit;if($@tex_status ==0){set $@tex_status,1;set $@tex_players,1;set $@tex_player$[1],strcharinfo(0);set@tex_player,$@tex_players;
announce strcharinfo(0)+": I've started a game of Texas Hold'em",2;
mes "[Texas Hold'em]";
mes "Waiting for players...";
mes "Please speak with me again once at least 1 other player has joined and you are ready to begin.";
close;}if($@tex_status !=0){
mes "[Texas Hold'em]";
mes "Somebody has started the game before you. Try joining.";
close;}}// Waiting for playersif($@tex_status ==1){if(strcharinfo(0)== $@tex_player$[1]){if($@tex_players <2){
mes "[Texas Hold'em]";
mes "Cannot start a game with only 1 player.";
mes "Please wait for more players to join or cancel the game.";
menu "Cancel Game",-,"Wait",T_Exit;
T_CancelGame:
callfunc "tex_reset";
mes "Game has been reset.";
announce strcharinfo(0)+": I've cancelled the game",2;
close;}if($@tex_players >1){
mes "[Texas Hold'em]";
mes "There are currently "+ $@tex_players +" waiting.";
mes "Start the game?";
next;
menu "Start Game",-,"Wait Longer",T_Exit,"Cancel Game",T_CancelGame;
T_StartGame:set $@tex_status,2;set $@tex_maxbid,@ante;
callfunc "tex_deck_reset";
callfunc "tex_deal";if($@tex_hand$[1]==""){
callfunc "tex_const";}
mes "[Texas Hold'em]";
mes "Game is commencing...";Announce"Texas Hold'em: Game is commencing... Please speak to me to receive your hands.",2;
close;}}else{if($@tex_player$[@tex_player]!= strcharinfo(0)){
mes "[Texas Hold'em]";
mes "This game has been started by "+ $@tex_player$[1]+". Would you like to join?";
next;
menu "Join Game",-,"Cancel",T_Exit;set $@tex_players,$@tex_players+1;set $@tex_player$[$@tex_players],strcharinfo(0);set $@tex_ready[$@tex_players],1;set@tex_player,$@tex_players;
announce strcharinfo(0)+": I'm in. Game now has "+ $@tex_players +"/5 players.",2;if($@tex_players >=5)goto T_StartGame;
mes "[Texas Hold'em]";
mes "Welcome to the game. Please wait for "+ $@tex_player$[1]+" to begin the game.";
close;}else{
mes "[Texas Hold'em]";
mes "You are already part of this game.";
mes "Please wait for it to begin.";
close;}}}// Game has begunif($@tex_status >=2){if($@tex_player$[@tex_player]== strcharinfo(0)){set@playernum,callfunc("tex_playernum");// Take anteif($@tex_bet[@playernum]<@ante){set $@tex_bet[@playernum],@ante;}
T_Disp:// Check if all players are readyset@i,0;while(@i< $@tex_players){set@i,@i+1;if($@tex_ready[@i]==0)goto T_Disp_Cont;}// All players are ready
callfunc "tex_unready",0;// Found the winner// Everybody folded except invoking characterif($@tex_folded ==4&& $@tex_ready[@playernum]!=2){set $@tex_status,5;set $@tex_winner,@playernum;}if($@tex_status ==5){if($@tex_player$[$@tex_winner]== strcharinfo(0)){set@prize,$@tex_bet[1]+$@tex_bet[2]+$@tex_bet[3]+$@tex_bet[4]+$@tex_bet[5];
mes "[Texas Hold'em]";
mes "Congratulations, you have won "+@prize+".";
close;}else{if($@folded <4){
mes "[Texas Hold'em]";
mes "The winner is "+ $@tex_player$[$@tex_winner]+" with a "+ $@tex_hand$[$@tex_winning]+".";
announce "The winner is "+ $@tex_player$[$@tex_winner]+" with a "+ $@tex_hand$[$@tex_winning]+".",2;
close;}else{
mes "[Texas Hold'em]";
mes "The winner is "+ $@tex_player$[$@tex_winner];
announce "The winner is "+ $@tex_player$[$@tex_winner],2;
close;}}}// Deal the cardsif($@tex_status ==4){set $@tex_public[5],callfunc("tex_getcard");set $@tex_status,5;
announce "Texas Hold'em: I've just dealt the RIVER",2;}if($@tex_status ==3){set $@tex_public[4],callfunc("tex_getcard");set $@tex_status,4;
announce "Texas Hold'em: I've just dealt the TURN",2;}if($@tex_status ==2){set $@tex_public[1],callfunc("tex_getcard");set $@tex_public[2],callfunc("tex_getcard");set $@tex_public[3],callfunc("tex_getcard");set $@tex_status,3;
announce "Texas Hold'em: I've just dealt the FLOP",2;}
T_Disp_Cont://mes "[Texas Hold'em]";
mes "Status: "+ $@tex_status$[$@tex_ready[@playernum]];
mes "Your Cards:";
mes $@tex_card_name$[$@tex_card_1[@playernum]]+" & "+ $@tex_card_name$[$@tex_card_2[@playernum]];set@hand,callfunc("tex_hand");// Change player's hand to current winning handif($@tex_winning >@hand){set $@tex_winning,@hand;set $@tex_winner,@playernum;}
mes $@tex_hand$[@hand];
mes "Public Cards:";/// Nothingif($@tex_status ==2){
mes "None";}/// The FLOPif($@tex_status >=3){
mes $@tex_card_name$[$@tex_public[1]];
mes $@tex_card_name$[$@tex_public[2]];
mes $@tex_card_name$[$@tex_public[3]];}/// The TURNif($@tex_status >=4){
mes $@tex_card_name$[$@tex_public[4]];}/// The RIVERif($@tex_status >=5){
mes $@tex_card_name$[$@tex_public[5]];}
next;if($@tex_status[@playernum]!=2){
menu "Refresh",T_Disp,"Raise/Call",T_RaiseCall,"Check",T_Check,"Fold",T_Fold;}else{
menu "Refresh",T_Disp,"Exit",T_Exit;}// Raise or Call current bet
T_RaiseCall:
mes "[Texas Hold'em]";
mes "How much to put into the pot?";
mes "Amount needed to call: "+($@tex_maxbid -@tex_bet[@playernum]);
mes "^606060Enter exact amount to call or higher to raise.^000000";
next;
input @bet;// Not within allowed bet rangeif(@bet>@max||@bet<@min){
mes "[Texas Hold'em]";
mes "The maximum bet is "+@max+" and the minimum bet is "+@min+". Your bet was "+@bet+".";
mes "Please try again.";
next;goto T_Disp;}// Player tried to raise againif($@tex_maxbidder ==@playernum){
mes "[Texas Hold'em]";
mes "You were the last to raise. Please wait for other players to re-raise before raising again.";goto T_Disp;}// Player's raise is not enough to callif($@tex_bet[@playernum]+@bet< $@tex_maxbid){
mes "[Texas Hold'em]";
mes "You must enter at least "+($@tex_maxbid -@tex_bet[@playernum])+" to stay in the game.";goto T_Disp;}set $@tex_bet[@playernum],$@tex_bet[@playernum]+@bet;set@raise,$@tex_bet[@playernum]- $@tex_maxbid;
mes "[Texas Hold'em]";
mes "Your bet is now "+ $@tex_bet[@playernum]+".";set $@tex_ready[@playernum],1;// Player RAISEDif($@tex_bet[@playernum]> $@tex_maxbid){set $@tex_maxbid,$@tex_bet[@playernum];set $@tex_maxbidder,@playernum;
mes "You now have the highest bet.";
callfunc "tex_unready",@playernum;
announce strcharinfo(0)+": Raise "+@raise,2;}else{
announce strcharinfo(0)+": Call",2;}goto T_Disp;
T_Check:// Check successfulif($@tex_bet[@playernum]== $@tex_maxbid){set $@tex_ready[@playernum],1;
mes "[Texas Hold'em]";
mes "You checked.";goto T_Disp;}else{
mes "[Texas Hold'em]";
mes "Somebody raised. You are unable to check.";goto T_Disp;}
T_Fold:
mes "[Texas Hold'em]";
mes "Are you sure you want to fold?";
next;
menu "Yes",-,"No",T_Disp;
announce strcharinfo(0)+": I fold",2;
mes "[Texas Hold'em]";
mes "You are now out of the round.";set $@tex_ready[@playernum],2;set $@tex_folded,$@tex_folded+1;
close;}if($@tex_player$[@tex_player]!= strcharinfo(0)){
mes "[Texas Hold'em]";
mes "Sorry, you are not part of this game. Please wait for the game to end to participate in the next game.";
close;}}
close2;
end;// Responses
T_Exit:
mes "[Texas Hold'em]";
mes "As you wish.";
close;// Define constantsOnInit:
callfunc "tex_const";
end;}// Function: Set all players to not ready// Syntax: callfunc("tex_unready"{,player to not unready});
function script tex_unready {//cleararray $@tex_ready[1],0,5;set $@tex_ready[1],$@tex_fold[1];set $@tex_ready[2],$@tex_fold[2];set $@tex_ready[3],$@tex_fold[3];set $@tex_ready[4],$@tex_fold[4];set $@tex_ready[5],$@tex_fold[5];if(getarg(0)!=0)set $@tex_ready[getarg(0)],1;return();}// Function: Get a card from the deck
function script tex_getcard {set $@tex_dealt,0;while($@tex_dealt !=1){set $@randcard,rand(1,52);if($@tex_deck[$@randcard]==1){set $@tex_deck[$@randcard],0;set $@tex_dealt,1;}}return($@randcard);}// Function: Deal cards
function script tex_deal {// Everyone gets 1st cardset@i,0;while(@i< $@tex_players){set@i,@i+1;set $@tex_card_1[@i],(callfunc("tex_getcard"));}// Everyone gets 2nd cardset@i,0;while(@i< $@tex_players){set@i,@i+1;set $@tex_card_2[@i],(callfunc("tex_getcard"));}return();}// Function: Return player's number
function script tex_playernum {set@i,0;set@num,0;while(@i< $@tex_players){set@i,@i+1;if(strcharinfo(0)== $@tex_player$[@i]){set@num,@i;}}return(@num);}// Function: Reset the Deck (Make all cards available)
function script tex_deck_reset {
cleararray $@tex_deck[1],1,52;return();}// Function: Reset Game. Clear all variables
function script tex_reset {set $@tex_status,0;set $@tex_players,0;set $@tex_maxbidder,0;set $@tex_maxbid,0;set $@tex_folded,0;
cleararray $@tex_player$[1],"",5;
cleararray $@tex_card_1[1],0,5;
cleararray $@tex_card_2[1],0,5;
cleararray $@tex_bet[1],0,5;
cleararray $@tex_ready[1],0,5;
cleararray $@tex_fold[1],0,5;
cleararray $@tex_public[1],0,5;return();}// Function: Check if player is already part of game// Syntax: if (callfunc("tex_playercheck")) mes "Player is part of game";
function script tex_playercheck {set@i,0;while(@i< $@tex_players){if($@tex_player$[@i]== strcharinfo(0)){goto T_TRUE;}set@i,@i+1;}return(0);
T_TRUE:return(1);}// Function: Checks all cards for like numbers
function script tex_combo_like {// Linear Comparisonset@i,0;while(@i<13){set@i,@i+1;if($@tex_card_num[$@tex_public[1]]==@i&& $@tex_public[1]!=0)set@combo_like,@combo_like+1;if($@tex_card_num[$@tex_public[2]]==@i&& $@tex_public[2]!=0)set@combo_like,@combo_like+1;if($@tex_card_num[$@tex_public[3]]==@i&& $@tex_public[3]!=0)set@combo_like,@combo_like+1;if($@tex_card_num[$@tex_public[4]]==@i&& $@tex_public[4]!=0)set@combo_like,@combo_like+1;if($@tex_card_num[$@tex_public[5]]==@i&& $@tex_public[5]!=0)set@combo_like,@combo_like+1;if($@tex_card_num[$@tex_card_1[@playernum]]==@i)set@combo_like,@combo_like+1;if($@tex_card_num[$@tex_card_2[@playernum]]==@i)set@combo_like,@combo_like+1;if(@combo_like== getarg(0)){set@num,@num+1;}set@combo_like,0;}return(@num);}// Function: Checks for cards with the same suit
function script tex_combo_suit {// Linear Comparisonset@i,0;while(@i<4){set@i,@i+1;if($@tex_card_suit[$@tex_public[1]]==@i&& $@tex_public[1]!=0)set@combo_suit,@combo_suit+1;if($@tex_card_suit[$@tex_public[2]]==@i&& $@tex_public[2]!=0)set@combo_suit,@combo_suit+1;if($@tex_card_suit[$@tex_public[3]]==@i&& $@tex_public[3]!=0)set@combo_suit,@combo_suit+1;if($@tex_card_suit[$@tex_public[4]]==@i&& $@tex_public[4]!=0)set@combo_suit,@combo_suit+1;if($@tex_card_suit[$@tex_public[5]]==@i&& $@tex_public[5]!=0)set@combo_suit,@combo_suit+1;if($@tex_card_suit[$@tex_card_1[@playernum]]==@i)set@combo_like,@combo_like+1;if($@tex_card_suit[$@tex_card_2[@playernum]]==@i)set@combo_like,@combo_like+1;if(@combo_like>= getarg(0)){return(1);}set@combo_like,0;}return();}// Function: Selection sort: Highest to Lowest// Returns the highest card #
function script tex_sort {// First do a selection sortset@i,8;
setarray @card[1],$@tex_card_num[$@tex_public[1]],$@tex_card_num[$@tex_public[2]],$@tex_card_num[$@tex_public[3]],$@tex_card_num[$@tex_public[4]],$@tex_card_num[$@tex_public[5]],$@tex_card_num[$@tex_card_1[@playernum]],$@tex_card_num[$@tex_card_2[@playernum]];set@max_n,0;while(@i>0){set@c,0;while(@c<@i){set@c,@c+1;if(@card[@c]>@max_n)set@max_n,@c;}set@i,@i-1;set $@card_sorted[@i],@max_n;}// Return highest cardreturn(@card_sorted[7]);}// Function: Checks for consecutive cards
function script tex_combo_cons {
callfunc "tex_sort";// Now check for consecutive numbersset@i,0;while(@i<7){set@i,@i+1;if($@card_sorted[@i]==($@card_sorted[@i+1]+1)){set@combo_cons,@combo_cons+1;if(@combo_cons>= getarg(0)-1)return(1);}else{if($@card_sorted[@i]!=($@card_sorted[@i+1])){set@combo_cons,0;}}}return(0);}// Function: Displays the rank of the current player's hand
function script tex_hand {// Straight Flushif(callfunc("tex_combo_suit",5)==1&& callfunc("tex_combo_cons",5)==1){set@combo,2;goto TH_End;}// Four of a Kindif(callfunc("tex_combo_like",4)>=1){set@combo,3;goto TH_End;}// Full Houseif((callfunc("tex_combo_like",3)==1&& callfunc("tex_combo_like",2))|| callfunc("tex_combo_like",3)>=2){set@combo,4;goto TH_End;}// Flushif(callfunc("tex_combo_suit",5)==1){set@combo,5;goto TH_End;}// Straightif(callfunc("tex_combo_cons",5)==1){set@combo,6;goto TH_End;}// Three of a Kindif(callfunc("tex_combo_like",3)==1){set@combo,7;goto TH_End;}// Two Pairif(callfunc("tex_combo_like",2)==2){set@combo,8;goto TH_End;}// One Pairif(callfunc("tex_combo_like",2)==1){set@combo,9;goto TH_End;}// High Cardset@combo,10;set@highest,callfunc("tex_sort");
TH_End:return(@combo);}// Function: Define constants
function script tex_const {set $@tex_status$[0],"^FF0000Pending Action...^000000";set $@tex_status$[1],"^00FF00Ready^000000";set $@tex_status$[2],"^606060Folded^000000";set $@tex_hand$[1],"Royal Straight Flush";set $@tex_hand$[2],"Straight Flush";set $@tex_hand$[3],"Four of a Kind";set $@tex_hand$[4],"Full House";set $@tex_hand$[5],"Flush";set $@tex_hand$[6],"Straight";set $@tex_hand$[7],"Three of a Kind";set $@tex_hand$[8],"Two Pair";set $@tex_hand$[9],"One Pair";set $@tex_hand$[10],"High Card";set $@tex_card_num[1],1;set $@tex_card_num[2],2;set $@tex_card_num[3],3;set $@tex_card_num[4],4;set $@tex_card_num[5],5;set $@tex_card_num[6],6;set $@tex_card_num[7],7;set $@tex_card_num[8],8;set $@tex_card_num[9],9;set $@tex_card_num[10],10;set $@tex_card_num[11],11;set $@tex_card_num[12],12;set $@tex_card_num[13],13;set $@tex_card_num[14],1;set $@tex_card_num[15],2;set $@tex_card_num[16],3;set $@tex_card_num[17],4;set $@tex_card_num[18],5;set $@tex_card_num[19],6;set $@tex_card_num[20],7;set $@tex_card_num[21],8;set $@tex_card_num[22],9;set $@tex_card_num[23],10;set $@tex_card_num[24],11;set $@tex_card_num[25],12;set $@tex_card_num[26],13;set $@tex_card_num[27],1;set $@tex_card_num[28],2;set $@tex_card_num[29],3;set $@tex_card_num[30],4;set $@tex_card_num[31],5;set $@tex_card_num[32],6;set $@tex_card_num[33],7;set $@tex_card_num[34],8;set $@tex_card_num[35],9;set $@tex_card_num[36],10;set $@tex_card_num[37],11;set $@tex_card_num[38],12;set $@tex_card_num[39],13;set $@tex_card_num[40],1;set $@tex_card_num[41],2;set $@tex_card_num[42],3;set $@tex_card_num[43],4;set $@tex_card_num[44],5;set $@tex_card_num[45],6;set $@tex_card_num[46],7;set $@tex_card_num[47],8;set $@tex_card_num[48],9;set $@tex_card_num[49],10;set $@tex_card_num[50],11;set $@tex_card_num[51],12;set $@tex_card_num[52],13;set $@tex_card_suit[1],1;set $@tex_card_suit[2],1;set $@tex_card_suit[3],1;set $@tex_card_suit[4],1;set $@tex_card_suit[5],1;set $@tex_card_suit[6],1;set $@tex_card_suit[7],1;set $@tex_card_suit[8],1;set $@tex_card_suit[9],1;set $@tex_card_suit[10],1;set $@tex_card_suit[11],1;set $@tex_card_suit[12],1;set $@tex_card_suit[13],1;set $@tex_card_suit[14],2;set $@tex_card_suit[15],2;set $@tex_card_suit[16],2;set $@tex_card_suit[17],2;set $@tex_card_suit[18],2;set $@tex_card_suit[19],2;set $@tex_card_suit[20],2;set $@tex_card_suit[21],2;set $@tex_card_suit[22],2;set $@tex_card_suit[23],2;set $@tex_card_suit[24],2;set $@tex_card_suit[25],2;set $@tex_card_suit[26],2;set $@tex_card_suit[27],3;set $@tex_card_suit[28],3;set $@tex_card_suit[29],3;set $@tex_card_suit[30],3;set $@tex_card_suit[31],3;set $@tex_card_suit[32],3;set $@tex_card_suit[33],3;set $@tex_card_suit[34],3;set $@tex_card_suit[35],3;set $@tex_card_suit[36],3;set $@tex_card_suit[37],3;set $@tex_card_suit[38],3;set $@tex_card_suit[39],3;set $@tex_card_suit[40],4;set $@tex_card_suit[41],4;set $@tex_card_suit[42],4;set $@tex_card_suit[43],4;set $@tex_card_suit[44],4;set $@tex_card_suit[45],4;set $@tex_card_suit[46],4;set $@tex_card_suit[47],4;set $@tex_card_suit[48],4;set $@tex_card_suit[49],4;set $@tex_card_suit[50],4;set $@tex_card_suit[51],4;set $@tex_card_suit[52],4;set $@tex_card_name$[1],"A of SPADES";set $@tex_card_name$[2],"2 of SPADES";set $@tex_card_name$[3],"3 of SPADES";set $@tex_card_name$[4],"4 of SPADES";set $@tex_card_name$[5],"5 of SPADES";set $@tex_card_name$[6],"6 of SPADES";set $@tex_card_name$[7],"7 of SPADES";set $@tex_card_name$[8],"8 of SPADES";set $@tex_card_name$[9],"9 of SPADES";set $@tex_card_name$[10],"10 of SPADES";set $@tex_card_name$[11],"J of SPADES";set $@tex_card_name$[12],"Q of SPADES";set $@tex_card_name$[13],"K of SPADES";set $@tex_card_name$[14],"^FF0000A of HEARTS^000000";set $@tex_card_name$[15],"^FF00002 of HEARTS^000000";set $@tex_card_name$[16],"^FF00003 of HEARTS^000000";set $@tex_card_name$[17],"^FF00004 of HEARTS^000000";set $@tex_card_name$[18],"^FF00005 of HEARTS^000000";set $@tex_card_name$[19],"^FF00006 of HEARTS^000000";set $@tex_card_name$[20],"^FF00007 of HEARTS^000000";set $@tex_card_name$[21],"^FF00008 of HEARTS^000000";set $@tex_card_name$[22],"^FF00009 of HEARTS^000000";set $@tex_card_name$[23],"^FF000010 of HEARTS^000000";set $@tex_card_name$[24],"^FF0000J of HEARTS^000000";set $@tex_card_name$[25],"^FF0000Q of HEARTS^000000";set $@tex_card_name$[26],"^FF0000K of HEARTS^000000";set $@tex_card_name$[27],"A of CLUBS";set $@tex_card_name$[28],"2 of CLUBS";set $@tex_card_name$[29],"3 of CLUBS";set $@tex_card_name$[30],"4 of CLUBS";set $@tex_card_name$[31],"5 of CLUBS";set $@tex_card_name$[32],"6 of CLUBS";set $@tex_card_name$[33],"7 of CLUBS";set $@tex_card_name$[34],"8 of CLUBS";set $@tex_card_name$[35],"9 of CLUBS";set $@tex_card_name$[36],"10 of CLUBS";set $@tex_card_name$[37],"J of CLUBS";set $@tex_card_name$[38],"Q of CLUBS";set $@tex_card_name$[39],"K of CLUBS";set $@tex_card_name$[40],"^FF0000A of DIAMONDS^000000";set $@tex_card_name$[41],"^FF00002 of DIAMONDS^000000";set $@tex_card_name$[42],"^FF00003 of DIAMONDS^000000";set $@tex_card_name$[43],"^FF00004 of DIAMONDS^000000";set $@tex_card_name$[44],"^FF00005 of DIAMONDS^000000";set $@tex_card_name$[45],"^FF00006 of DIAMONDS^000000";set $@tex_card_name$[46],"^FF00007 of DIAMONDS^000000";set $@tex_card_name$[47],"^FF00008 of DIAMONDS^000000";set $@tex_card_name$[48],"^FF00009 of DIAMONDS^000000";set $@tex_card_name$[49],"^FF000010 of DIAMONDS^000000";set $@tex_card_name$[50],"^FF0000J of DIAMONDS^000000";set $@tex_card_name$[51],"^FF0000Q of DIAMONDS^000000";set $@tex_card_name$[52],"^FF0000K of DIAMONDS^000000";return();}
Question
tokenacc001
hello masters!
saw this script on a forum, but it only works until waiting for player, after the game start, it stuck.
can anyone fix this script?
thanks in advance!!
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.