Jump to content

Quests, Games: Dicebet Gambling


Recommended Posts


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

Dicebet Gambling


Dicebet Gambling

This is a simple script that allows players to gamble with other player using dicebet command.
This idea came from  GTA SAMP which me and my brother played before. He asked me if I can implement it into his server so I did.
I decided to share it here so I can give some contribution here even with this simple script.
I hope you guys would like it and please report if you found any bugs in the script.

I'm actually thinking ways to optimize this script and add some features into it. So I guess suggestions will be welcome. 
/gawi
 

Configuration

OnInit:
	.MinBet = 1; // Minimum amount to bet
	.MaxBet = 500000000; // Maximum amount to bet NOTE: If you increase it by 500m, make sure that max zeny allowed per char is > 1b


New Atcommands
@dicebet <opponent name> <amount to bet> - sends a dicebet invitation to another player
@acceptdb - accepts the dicebet invitation
@declinedb - declines the dicebet invitation
@resetdb - resets the dicebet invitation


 

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

Prevent scammers when playing dice.. nice one! /gawi

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  62
  • Topics Per Day:  0.02
  • Content Count:  296
  • Reputation:   4
  • Joined:  02/19/17
  • Last Seen:  

Ihave this type of error...need assistance sir

dasda.png

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

@skymia You need to update your trunk files or apply this patch manually. LINK

Link to comment
Share on other sites

  • 3 months later...

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  80
  • Reputation:   2
  • Joined:  04/27/16
  • Last Seen:  

Hi,

Using the latest rathena, Getting an error below

image.png.54423a53b7bbd36d6d1f874eeb2432ca.png

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

14 hours ago, rmon said:

Hi,

Using the latest rathena, Getting an error below

image.png.54423a53b7bbd36d6d1f874eeb2432ca.png

Updated to 1.1. Please re-download the file. Thanks for reporting. /no1

Link to comment
Share on other sites

  • 3 months later...

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  42
  • Reputation:   2
  • Joined:  02/04/12
  • Last Seen:  

On 19/11/2560 at 6:16 PM, Technoken said:

Updated to 1.1. Please re-download the file. Thanks for reporting. /no1

What if I want to change it from zeny to item how can I do it sir ?

example : if I want to bet with my cash coin/card/etc. 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

8 hours ago, blazerza said:

What if I want to change it from zeny to item how can I do it sir ?

example : if I want to bet with my cash coin/card/etc. 

That would be a new feature. I'll try to update it with that feature when I get my free time. :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  42
  • Reputation:   2
  • Joined:  02/04/12
  • Last Seen:  

@Technoken Thank you sir I will try to make it too and I will share here if it works :D

Link to comment
Share on other sites

  • 2 years later...

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  80
  • Reputation:   2
  • Joined:  04/27/16
  • Last Seen:  

I tried to using this on 2018 Client, using latest rathena.

The char who initiate dicebet is not rolling a dice once the other char use @acceptdb showing /dice emoticon

Link to comment
Share on other sites

  • 3 months later...

  • Group:  Members
  • Topic Count:  123
  • Topics Per Day:  0.03
  • Content Count:  640
  • Reputation:   82
  • Joined:  04/07/14
  • Last Seen:  

On 7/22/2020 at 5:00 AM, rmon said:

I tried to using this on 2018 Client, using latest rathena.

The char who initiate dicebet is not rolling a dice once the other char use @acceptdb showing /dice emoticon

yep. Please update thanks!

Link to comment
Share on other sites

  • 9 months later...

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  11
  • Reputation:   1
  • Joined:  02/01/14
  • Last Seen:  

On 11/17/2020 at 8:46 PM, Gidz Cross said:

yep. Please update thanks!

yep. Please update thanks very much!

Link to comment
Share on other sites

  • 1 year later...

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

Fix both char right now show their dice
 

//===== rAthena Script =======================================
//= Dicebet Gambling
//===== By: ==================================================
//= Technoken
//= LearningRO
//===== Current Version: =====================================
//= 1.2
//===== Features: ============================================
//= Gamble with other players using dicebet.
//= This idea came from GTA Samp gamble system
//= New atcommands:
//= 	@dicebet <opponent name> <amount to bet>
//= 	  - sends a dicebet invitation to another player
//= 	@acceptdb - accepts the dicebet invitation
//= 	@declinedb - declines the dicebet invitation
//= 	@resetdb - resets the dicebet invitation
//===== Features: ============================================
//
//= THIS IS A FREE SCRIPT
//
//===== Change Logs: =========================================
//= 1.0 First version.
//= 1.1 Updated script to work on rAthena Hash ea88ea5
//= 1.2 Both Char right now show their own DICE!
//============================================================
-	script	DicebetGambling	-1,{
OnInit:
	.MinBet = 1; // Minimum amount to bet
	.MaxBet = 500000000; // Maximum amount to bet NOTE: If you increase it by 500m, make sure that max zeny allowed per char is > 1b
	bindatcmd("dicebet","DicebetGambling::OnAtcommandDicebet",0,99);
	bindatcmd("acceptdb","DicebetGambling::OnAtcommandAcceptDB",0,99);
	bindatcmd("declinedb","DicebetGambling::OnAtcommandDeclineDB",0,99);
	bindatcmd("resetdb","DicebetGambling::OnAtcommandResetDB",0,99);
	end;
	
OnAtcommandDicebet:
	if( .@atcmd_numparameters < 2 ) {
		message strcharinfo(0),"Silakan memasukan format yang benar (format: @dicebet <nama player> <jumlah taruhan>)";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	.@tmp$ = implode(.@atcmd_parameters$," ");
	.@eil = getstrlen(.@atcmd_parameters$[.@atcmd_numparameters-1]) + 1;
	.@charName$ = substr(.@tmp$, 0, (getstrlen(.@tmp$) - .@eil) - 1);
	@oppRID = getcharid(3,.@charName$);
	@oppCID = getcharid(0,.@charName$);
	setd "$var$",strcharinfo(0);
	if( !isloggedin(@oppRID,@oppCID)  ) {
		message strcharinfo(0),"Nama Karakter tidak ditemukan.";
		message strcharinfo(0),"Karakter sedang offline atau tidak ada.";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	if( @oppRID == getcharid(3) ) {
		message strcharinfo(0),"Kamu tidak dapat mengajak dirimu bertaruh.";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	if( @onbet || @diceDealerCID ) { // Prevents from offering another one
		message strcharinfo(0),"1x taruhan dalam sekali.";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	getmapxy(.@map$,.@x,.@y,BL_PC);
	getmapxy(.@map1$,.@x1,.@y1,BL_PC,rid2name(@oppRID));
	if( distance( .@x, .@y, .@x1, .@y1 ) > 3 ) { // 3 cells distance
		message strcharinfo(0),"You must be near to your opponent.";
		message strcharinfo(0),"@dicebet failed.";
		end;
	}
	.@oppInviter = getvar(@onbet,@oppCID); //  Opponent already invite someone
	.@oppInvited = getvar(@diceDealerCID,@oppCID); // Opponent is already invited by someone
	if( .@oppInviter || .@oppInvited ) { // Prevents from dealing inviters and someone whos already on a bet
		message strcharinfo(0),.@charName$+" sedang bertaruh dengan yang lain.";
		message strcharinfo(0),"@dicebet failed.";
		end;
	}
	.@bet = .@atcmd_parameters$[.@atcmd_numparameters-1];
	if( .@bet > .MaxBet || .@bet < .MinBet ) {
		message strcharinfo(0),"Minimum Taruhan: "+.MinBet+"z";
		message strcharinfo(0),"Maximum Taruhan: "+.MaxBet+"z";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	// Checks if the opponent has right amount of zeny to bet
	.@oppZeny = readparam(Zeny,@oppCID);
	if( .@oppZeny < .@bet ) {
		message strcharinfo(0),"Lawanmu tidak memiliki cukup zeny.";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	if( Zeny < .@bet ) {
		message strcharinfo(0),"Kamu tidak memiliki cukup zeny untuk bertaruh.";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	set(@dicebet,.@bet,@oppCID); // Sets the bet
	set(@diceDealerCID,getcharid(0),@oppCID); // Sets who's the dealer
	set(@diceDealerRID,getcharid(3),@oppCID);
	@onbet = 1; // Sets to 1 when the player already dicebet someone
	dispbottom "Kamu telah mengajak "+rid2name(@oppRID)+" taruhan sebesar "+.@bet+"z.",0x63D1F4;
	dispbottom strcharinfo(0)+" telah menawarkan taruhan sebesar "+.@bet+"z. Apakah kamu ingin menerima ? (Gunakan @acceptdb/@declinedb)",0x63D1F4,@oppCID;
	end;
	
OnAtcommandAcceptDB:
	if( @rolling ) {
		message strcharinfo(0),"Kamu sedang memutar dice";
		message strcharinfo(0),"@acceptdb gagal.";
		end;
	}
	if( !@diceDealerCID ) {
		message strcharinfo(0),"Tidak ada yang mengajak kamu bertaruh.";
		message strcharinfo(0),"@acceptdb gagal.";
		end;
	}
	if( .@atcmd_numparameters != 0 ) {
		message strcharinfo(0),"Silakan memasukan format yang benar (format: @acceptdb)";
		message strcharinfo(0),"@acceptdb gagal.";
		end;
	}
	if( !isloggedin(@diceDealerRID,@diceDealerCID) ) {
		message strcharinfo(0),"Lawanmu telah offline.";
		message strcharinfo(0),"@acceptdb gagal.";
		goto D_Reset;
		end;
	}
	if( Zeny < @dicebet ) {
		message strcharinfo(0),"Kamu tidak memiliki cukup zeny untuk menerima taruhan.";
		message strcharinfo(0),"@acceptdb gagal.";
		end;
	}
	.@oppZeny = readparam(Zeny,@diceDealerCID); // Checks if the opponent still has the zeny that he bet
	if( .@oppZeny < @dicebet ) {
		message strcharinfo(0),"Lawanmu tidak memiliki cukup zeny untuk bertaruh.";
		message strcharinfo(0),"@dicebet gagal.";
		end;
	}
	getmapxy(.@map$,.@x,.@y,BL_PC);
	getmapxy(.@map1$,.@x1,.@y1,BL_PC,rid2name(@diceDealerRID));
	if( distance( .@x, .@y, .@x1, .@y1 ) > 3 ) {
		message strcharinfo(0),"Kamu harus dekat dengan lawan.";
		message strcharinfo(0),"@acceptdb gagal.";
		end;
	}
	getmapxy(.@map$,.@x,.@y,BL_PC);
	.@bet = @dicebet;
	.@ownRID = getattachedrid();
	.@diceDealerRID = @diceDealerRID;
	@rolling = 1;
	dispbottom strcharinfo(0)+" menerima taruhan sebesar "+@dicebet+"z.",0x63D1F4,@diceDealerCID;
	setarray .@dice[1],ET_DICE1,ET_DICE2,ET_DICE3,ET_DICE4,ET_DICE5,ET_DICE6;
	.@rand = rand(1,6);
	emotion .@dice[.@rand],strcharinfo(0);

	detachrid; attachrid(.@diceDealerRID);
	.@rand1 = rand(1,6);
	emotion .@dice[.@rand1],.@diceDealerRID;

	detachrid; attachrid(.@ownRID);
	sleep2 1200;
	if( !isloggedin(@diceDealerRID) || !@diceDealerCID ) { // Checks if the inviter logged out
		dispbottom strcharinfo(0,@diceDealerCID)+" logout dan batalkan taruhan.",0x63D1F4;
		goto D_Reset;
		end;
	}
	
	//.@diceDealerRID = @diceDealerRID;
	while( .@i < 2 ) { // Checks Zeny again
		if( Zeny < .@bet ) {
			areaannounce .@map$,.@x-3,.@y-3,.@x+3,.@y+3,"Taruhan telah dibatalkan karena zeny "+strcharinfo(0)+" telah habis !",0,0x63D1F4;
			.@t++;
		}
		detachrid;
		if( .@i == 0 ) attachrid(.@diceDealerRID);
		else attachrid(.@ownRID);
		.@i++;
	}
	if( !.@t ) {
		areaannounce .@map$,.@x-3,.@y-3,.@x+3,.@y+3,"* * "+strcharinfo(0,@diceDealerCID)+" memutar dice dan mendapatkan angka "+.@rand1+" * *",0,0x63D1F4;
		areaannounce .@map$,.@x-3,.@y-3,.@x+3,.@y+3,"* * "+strcharinfo(0)+" memutar dice dan mendapatkan angka "+.@rand+" * *",0,0x63D1F4;
		if( .@rand == .@rand1 ) // Both dice lands on same number
			areaannounce .@map$,.@x-3,.@y-3,.@x+3,.@y+3,"Tidak ada yg memenangkan "+.@bet+"z karena draw.",0,0x63D1F4;
		else {
			if( .@rand > .@rand1 ) { // I WON
				Zeny += .@bet;
				.@winner$ = strcharinfo(0);
				detachrid; attachrid(.@diceDealerRID);
				Zeny -= .@bet;
			} else { // I LOSE
				Zeny -= .@bet;
				detachrid; attachrid(.@diceDealerRID);
				.@winner$ = strcharinfo(0);
				Zeny += .@bet;
			}
			detachrid; attachrid(.@ownRID);
			areaannounce .@map$,.@x-3,.@y-3,.@x+3,.@y+3,.@winner$+" telah memenangkan taruhan sebesar "+.@bet+"z.",0,0x63D1F4;
		}
	}
	set(@onbet,0,@diceDealerCID);
	goto D_Reset;
	end;
	
OnAtcommandDeclineDB:
	if( @rolling ) {
		message strcharinfo(0),"Kamu sedang memutar dice.";
		message strcharinfo(0),"@declinedb gagal.";
		end;
	}
	if( .@atcmd_numparameters != 0 ) {
		message strcharinfo(0),"Silakan memasukan format yang benar (format: @declinedb)";
		message strcharinfo(0),"@declinedb gagal.";
		end;
	}
	if( !@diceDealerCID ) {
		message strcharinfo(0),"Tidak ada yang mengajak kamu bertaruh.";
		message strcharinfo(0),"@declinedb gagal.";
		end;
	}
	dispbottom "Taruhan telah ditolak.",0x63D1F4;
	dispbottom strcharinfo(0)+" menolak untuk bertaruh.",0x63D1F4,@diceDealerCID;
	set(@onbet,0,@diceDealerCID);
	goto D_Reset;
	end;

OnAtcommandResetDB:
	if( @oppCID )
		.@rolling = getvar(@rolling,@oppCID);
	else
		.@rolling = 0;
	if( .@rolling ) {
		message strcharinfo(0),"Kamu sedang memutar dice.";
		message strcharinfo(0),"@resetdb gagal.";
		end;
	}
	if( !@onbet ) {
		message strcharinfo(0),"Kamu tidak memiliki undangan yang tertunda.";
		message strcharinfo(0),"@resetdb gagal.";
		end;
	}
	@onbet = 0;
	dispbottom "Undangan yang tertunda telah direset.";
	detachrid; attachrid(@oppRID);
	dispbottom "Pending dicebet invitation has been cancelled.";
	goto D_Reset;
	end;

OnPCLogoutEvent:
	if( @onbet ) {
		detachrid; attachrid(@oppRID);
		goto D_Reset;
	}
	if( @diceDealerCID ) { // When the one who use @acceptdb logged out
		dispbottom strcharinfo(0)+" logged out and cancels the dice bet.",0x63D1F4,@diceDealerCID;
		set(@onbet,0,@diceDealerCID);
	}
	end;

D_Reset:
	@dicebet = 0;
	@diceDealerCID = 0;
	@diceDealerRID = 0;
	@rolling = 0;
	end;
}

 

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...