Jump to content
  • 0
Sign in to follow this  
Takumirai

[Question] how to make a script to bet an item

Question

Example

 

Player 1 will talk to NPC bet his item or the npc have already a menu on betting an item

example you bet 10 apple.

 

Player 2 will talk to NPC

- you bet 10 apple

 

when an event start and 1 of them win they get all the apple.

example: they play tick tak toe and player 1 win he get the 20 apple

 

thanks

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Was gonna post but I dont remember scripting ffffuuuu

Edited by mleo1

Share this post


Link to post
Share on other sites
  • 0

mapname,x,y,z	script	npc_name	sprite_id,{mes "What would you like to do?";menu "Place a bet",L_Place,"Claim Winnings",L_Claim;L_Place:next;mes "Bets are placed in the form of RedPotions.";mes "How much would you like to bet?";switch( "1 Potion(s):5 Potion(s):10 Potion(s)" ) {	case 1:		if( !countitem(501) ){ .@i = 1; break; }		.potionbets += 1;		delitem 501, 1;		break;	case 2:		if( countitem(501) < 5 ){ .@i = 1; break; }		.potionbets += 5;		delitem 501,5;		break;	case 3:		if( countitem(501) < 10 ){ .@i = 1; break; }		.potionbets += 10;		delitem 501,10;		break;}if( .@i ){ next; mes "You don't have enough potions"; close; }next;mes "Bet placed successfully.";close;L_Claim:next;if( .winnerid != getcharid(3) ) { mes "You aren't the winner"; close; }getitem 501,.potionbets;.potionbets = 0;mes "Congratulations, here is your reward";close;}

 

I won't go into detail on how to make this work, other than, .winnerid needs to be set to the account id of the winner of said game/event. This is also an overly simplified version using somewhat very basic scripting techniques to make it easier to understand.

Share this post


Link to post
Share on other sites
  • 0

I don't know if i am getting this topic correct. Do you want a one-on-one bet npc or what?

 

@GmOcean : I think you should register all those people who bet their items. In your script, anyone who won the event regardless if he bet an item or not can win. If that is the case and if i am in the perspective of the player i wouldn't bet my item for i can also win even i do not place one.

 

Let me try my version. I made it more dynamic : 

prontera,150,150,0	script	Bet NPC	100,{	if ( .player1 && .player2 && getcharid( 3 ) != .player1 && getcharid( 3 ) != .player2 ) {		/*			 - Player 1 and Player 2 are set			 - This should not be triggered to those people who bet their items			   otherwise they cannot claim their items if ever they win		*/		mes .npc$;		mes "Bet NPC is full";		close;	}	mes .npc$;	mes "Hello " + strcharinfo( 0 ) + ". What can i do for you?";	next;	switch( select( ( .player1 && .player2 ? "" : "Bet an item" ) + ":" + ( .player1 && .player2 ? "Claim Reward" : "" ) + ":Exit" ) ) {		case 1:				 if ( .player1 ) {					/* Check if the first person who bet is other person or not. If not, then we terminate the script */					if ( .player1 == getcharid( 3 ) ) {						mes .npc$;						mes "Doing this is not good";						break;					}					mes .npc$;					mes "^FF0000" + rid2name( .player1 ) + "^000000 placed " + .bet_amount + "x " + getitemname( .bet_item );					next;					mes .npc$;					mes "So? do you want to bet the tantamount item " + rid2name( .player1 ) + " placed?";					next;					if ( select( "Yes:No" ) - 1 ) break;					if ( countitem( .bet_item ) < .bet_amount ) {						mes .npc$;						mes "You don't have enough items to bet";						break;					}					delitem .bet_item, .bet_amount;					.player2 = getcharid( 3 );					announce rid2name( .player1 ) + " and " + rid2name( .player2 ) + " are fighting for " + .bet_amount + "x " + getitemname( .bet_item ),0;				} else {					 mes .npc$;					mes "What item do you want to bet?";					next;					getinventorylist;					for ( .@i = 0; .@i < @inventorylist_count; .@i++ ) {						.@menu$ += getitemname( @inventorylist_id[ .@i ] );						.@menu$ += ":";					}					.@s = select( .@menu$ ) - 1;					mes .npc$;					mes "How many ^FF0000" + getitemname( @inventorylist_id[ .@s ] ) + "^000000 will you bet?";					next;					 input .@amount;					if ( !.@amount ) {						mes .npc$;						mes "Invalid amount";						break;					}					if ( countitem( @inventorylist_id[ .@s ] ) < .@amount ) {						mes .npc$;						mes "You don't have " + .@amount + "x ^FF0000" + getitemname( @inventorylist_id[ .@s ] ) + "^000000";						break;					}					mes .npc$;					mes "Are you sure you want to bet " + .@amount + "x ^FF0000" + getitemname( @inventorylist_id[ .@s ] ) + "^000000?";					next;					if ( select( "Yes:No" ) - 1 ) break;					.bet_item = @inventorylist_id[ .@s ];					.bet_amount = .@amount;					delitem .bet_item, .bet_amount;					.player1 = getcharid( 3 );					announce rid2name( .player1 ) + " placed " + .bet_amount + "x " + getitemname( .bet_item ) + " on bet NPC", 0;				}				break;		case 2: if ( getcharid( 3 ) != $wid ) {					mes .npc$;					mes "You are not the winner of the bet";				} else {					/* Check if the winner id that is set is one of the people who bet. If not, reset the winner id */					if ( $wid == .player1 || $wid == .player2 ) {						getitem .bet_item, .bet_amount * 2;						announce rid2name( getcharid( 3 ) ) + " won the bet",0;						.bet_item = 0;						.bet_amount = 0;						.player1 = 0;						.player2 = 0;						$wid = 0;					} else {						mes .npc$;						mes "You are not registered on our npc";						$wid = 0;						announce rid2name( getcharid( 3 ) ) + " is not registered on our bet npc therefore the npc will reset the winner id",0;					}				}				break;		case 3:		default:			 break;	}	close;	OnInit:		.npc$ = "[ ^FF0000" + strnpcinfo( 1 ) + "^000000 ]";		end;}// prontera,153,153,0	script	Test	100,{ $wid = 0; $wid = getcharid( 3 ); end; } 

 

Didn't fully test though because it is already 1:36 in the morning here in Philippines. I'm sleepy :D. Also, this is good for one-on-one betting game.

Share this post


Link to post
Share on other sites
  • 0

Well, I didn't add it because I wasn't sure how the event took place or not. Whether it registered people or something, so I left it very bland and basic so it could be added to an existing script if thats what it was inteded to do :/ but you are right, I should have added them all logged so only a better could receive the prize.

Share this post


Link to post
Share on other sites
  • 0

I don't know if i am getting this topic correct. Do you want a one-on-one bet npc or what?

almost correct

actually I wanna write this but me has more things to write haha

 

1. your script lack OnPCLogoutEvent

what happen if the player bet an item, then suddenly got dc

script will hang I think

 

2. your script lacks building an sql table

what happen if the player bet an item, then server shut down ? hahaha

should store everything in a SQL table, in case player say got scam ?

storing in a SQL served 2 purposes, 1st for logging, 2nd for give back the item when server restart

OnInit: ... give back all the item from sql

Share this post


Link to post
Share on other sites
  • 0

I am aware that when server shuts down. The bet npc is at mess. LOL but too lazy to make an SQL dependent script HAHA. K i leave here :D 

Share this post


Link to post
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
Answer this question...

×   Pasted as rich text.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.