Jump to content
  • 0
IndieRO

Tictac with required zeny

Question

i have script npc event tic tac toe

-	script	3er_2	-1,{

	if ( ( .X2 && .O2 ) && ( .X2 == getcharid ( 3 ) || .O2 == getcharid ( 3 ) ) &&  ( ! isloggedin ( .X2, .X ) || ! isloggedin ( .O2, .O ) ) ) donpcevent "Tic Tac Toe#3z::OnResetGame";
	set .@a, atoi ( strnpcinfo ( 2 ) );
	if ( ( ! $@ttt_a[.@a] ) && ( $@ttt_turn ) ) {
		if ( getcharid ( 0 ) == getvariableofnpc ( .X, "Tic Tac Toe#3z" ) ) {
			if ( ( $@ttt_turn % 2 ) ) {
				set $@ttt_a[.@a], 1;
				setnpcdisplay "Poring#"+ .@a, $@ttt_ids[0] ;
				set .@c, 1;
			}
			else dispbottom "Is not your turn!";
		}
		if ( getcharid ( 0 ) == getvariableofnpc ( .O, "Tic Tac Toe#3z" ) ) {
			if ( ! ( $@ttt_turn % 2 ) ) {
				set $@ttt_a[.@a], 2;
				setnpcdisplay "Poring#"+ .@a, $@ttt_ids[1] ;
				set .@c, 2;
			}
			else dispbottom "Is not your turn!";
		}
		if ( .@c ) {
			set $@ttt_turn, $@ttt_turn + 1;
			specialeffect 44 ;
			set .@b, callsub ( CheckTic, .@c );
			if ( .@b ) callsub Winner, .@b;
			else if ( $@ttt_turn >= 10 ) {
				if ( $@ttt_ann >= 0 ) announce "Draw game.", ( ( $@ttt_ann <= 3 ) ? $@ttt_ann : 3 ), "0x"+$@ttt_ann$ ;
				donpcevent "Tic Tac Toe#3z::OnResetGame";
			}
		}
	}
	end ;

OnInit:
	/*
			Item1 Amount1, Item2, Amount2, {Item...}, {Amount...}
			( Max items: 64 )
	*/
	setarray $@ttt_prizes[0],607,5;

			// Sprites.
			// ID X  ID O
	setarray $@ttt_ids[0],1582,1568;

	/*
		Announce:
		-1 = No announce
		0 = All.
		1 = Map.
		2 = Area.
		3 = Self.
	*/
	set $@ttt_ann,1;

	// Color of the announce (winner).
	// Default = "30bdb5"
	set $@ttt_ann$,"30bdb5";

	end;

CheckTic:


	setarray .@a[0], 1, 2, 3, 1, 5, 9, 3, 5, 7, 4, 5, 6, 7, 8, 9, 1, 6, 7, 2, 5, 8, 3, 4, 9;
	for ( set .@b, 0; .@b < getarraysize ( .@a ) ; set .@b, .@b + 3 )
		if (
			$@ttt_a[.@a[.@b]] == getarg ( 0 ) &&
			$@ttt_a[.@a[.@b + 1]] == getarg ( 0 ) &&
			$@ttt_a[.@a[.@b + 2]] == getarg ( 0 )
		) return getarg ( 0 ) ;
	return 0;

Winner:

	for ( set .@i, 0; .@i < getarraysize ( $@ttt_prizes ) ; set .@i, .@i + 2 )
		getitem $@ttt_prizes[.@i], $@ttt_prizes[.@i + 1];
	if ( $@ttt_ann >= 0 ) announce "The player "+ getarg ( 0 ) +" ("+ strcharinfo ( 0 ) +") has won!", ( ( $@ttt_ann <= 3 ) ? $@ttt_ann : 3 ), "0x"+$@ttt_ann$ ;
	donpcevent "Tic Tac Toe#3z::OnResetGame";
	return ;
	
}

prontera,152,136,4	duplicate(3er_2)	Poring#1	909
prontera,155,136,4	duplicate(3er_2)	Poring#2	909
prontera,158,136,4	duplicate(3er_2)	Poring#3	909
prontera,158,133,4	duplicate(3er_2)	Poring#4	909
prontera,155,133,4	duplicate(3er_2)	Poring#5	909
prontera,152,133,4	duplicate(3er_2)	Poring#6	909
prontera,152,130,4	duplicate(3er_2)	Poring#7	909
prontera,155,130,4	duplicate(3er_2)	Poring#8	909
prontera,158,130,4	duplicate(3er_2)	Poring#9	909

prontera,164,136,4	script	Tic Tac Toe#3z	909,{

	// NPC Name.
	set .@a$, "^2b86b5Tic Tac Toe^000000";

	mes .@a$;
	setarray .@a[0], .X2, .X, .O2, .O;
	for ( set .@b, getarraysize ( .@a ) ; .@c < .@b ; set .@c, .@c + 2 ) {
		if ( isloggedin ( .@a[.@c], .@a[.@c + 1] ) ) mes "Player "+ ( .@c / 2 + 1 ) +": "+ rid2name ( ( ( .@c == 0 ) ? .X2 : .O2 ) ) +".";
		else {
			mes "Player "+ ( .@c / 2 + 1 ) +": There isn't.";
			setd ( ( .@c == 0 ) ? ".X2" : ".O2" ), 0;
			setd ( ( .@c == 0 ) ? ".X" : ".O" ), 0;
		}
	}
	switch ( select ( "Register", "^911b1bExit^000000" ) ) {

		case 1:

			if (  .X && .O ) {
				mes "I'm sorry, but somebody else has already register before than you.";
				break ;
			}
			if ( .X2 == getcharid ( 3 ) || .O2 == getcharid ( 3 ) ) {
				mes "You're registered already.";
				break ;
			}
			if ( ! .X && ! .O ) {
				set .@a, rand ( 1, 2 );
				setd ( ( .@a == 1 ) ? ".X" : ".O" ), getcharid ( 0 );
				setd ( ( .@a == 1 ) ? ".X2" : ".O2" ), getcharid ( 3 );
			}
			else {
				setd ( ( .X == 0 ) ? ".X" : ".O" ), getcharid ( 0 );
				setd ( ( .X2 == 0  ) ? ".X2" : ".O2" ), getcharid ( 3 );
			}
			if (  .X && .O )  {
				set $@ttt_turn, rand ( 1, 2 );
				npctalk "The game can start, "+ strcharinfo ( 0 ) +" has been register!";
			}
			mes "You're registered now, you're the "+ ( ( .X2 == getcharid ( 3 ) ) ? "Deviling" : "Angeling" );
			break ;

		case 2:

			mes "Have a nice day.";
			break ;
	}
	close ;

OnResetGame:

	while ( set ( .@i, .@i + 1 ) < 10 ) {
		set $@ttt_a[.@i], 0;
		setnpcdisplay "Poring#"+ .@i, 909 ;
	}
	set .X2, 0;
	set .X, 0;
	set .O2, 0;
	set .O, 0;
	end ;
}

how to make cost zeny when register

somebody can help me?

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
On 20/06/2018 at 1:54 PM, melv0 said:

i have script npc event tic tac toe


-	script	3er_2	-1,{

	if ( ( .X2 && .O2 ) && ( .X2 == getcharid ( 3 ) || .O2 == getcharid ( 3 ) ) &&  ( ! isloggedin ( .X2, .X ) || ! isloggedin ( .O2, .O ) ) ) donpcevent "Tic Tac Toe#3z::OnResetGame";
	set .@a, atoi ( strnpcinfo ( 2 ) );
	if ( ( ! $@ttt_a[.@a] ) && ( $@ttt_turn ) ) {
		if ( getcharid ( 0 ) == getvariableofnpc ( .X, "Tic Tac Toe#3z" ) ) {
			if ( ( $@ttt_turn % 2 ) ) {
				set $@ttt_a[.@a], 1;
				setnpcdisplay "Poring#"+ .@a, $@ttt_ids[0] ;
				set .@c, 1;
			}
			else dispbottom "Is not your turn!";
		}
		if ( getcharid ( 0 ) == getvariableofnpc ( .O, "Tic Tac Toe#3z" ) ) {
			if ( ! ( $@ttt_turn % 2 ) ) {
				set $@ttt_a[.@a], 2;
				setnpcdisplay "Poring#"+ .@a, $@ttt_ids[1] ;
				set .@c, 2;
			}
			else dispbottom "Is not your turn!";
		}
		if ( .@c ) {
			set $@ttt_turn, $@ttt_turn + 1;
			specialeffect 44 ;
			set .@b, callsub ( CheckTic, .@c );
			if ( .@b ) callsub Winner, .@b;
			else if ( $@ttt_turn >= 10 ) {
				if ( $@ttt_ann >= 0 ) announce "Draw game.", ( ( $@ttt_ann <= 3 ) ? $@ttt_ann : 3 ), "0x"+$@ttt_ann$ ;
				donpcevent "Tic Tac Toe#3z::OnResetGame";
			}
		}
	}
	end ;

OnInit:
	/*
			Item1 Amount1, Item2, Amount2, {Item...}, {Amount...}
			( Max items: 64 )
	*/
	setarray $@ttt_prizes[0],607,5;

			// Sprites.
			// ID X  ID O
	setarray $@ttt_ids[0],1582,1568;

	/*
		Announce:
		-1 = No announce
		0 = All.
		1 = Map.
		2 = Area.
		3 = Self.
	*/
	set $@ttt_ann,1;

	// Color of the announce (winner).
	// Default = "30bdb5"
	set $@ttt_ann$,"30bdb5";

	end;

CheckTic:


	setarray .@a[0], 1, 2, 3, 1, 5, 9, 3, 5, 7, 4, 5, 6, 7, 8, 9, 1, 6, 7, 2, 5, 8, 3, 4, 9;
	for ( set .@b, 0; .@b < getarraysize ( .@a ) ; set .@b, .@b + 3 )
		if (
			$@ttt_a[.@a[.@b]] == getarg ( 0 ) &&
			$@ttt_a[.@a[.@b + 1]] == getarg ( 0 ) &&
			$@ttt_a[.@a[.@b + 2]] == getarg ( 0 )
		) return getarg ( 0 ) ;
	return 0;

Winner:

	for ( set .@i, 0; .@i < getarraysize ( $@ttt_prizes ) ; set .@i, .@i + 2 )
		getitem $@ttt_prizes[.@i], $@ttt_prizes[.@i + 1];
	if ( $@ttt_ann >= 0 ) announce "The player "+ getarg ( 0 ) +" ("+ strcharinfo ( 0 ) +") has won!", ( ( $@ttt_ann <= 3 ) ? $@ttt_ann : 3 ), "0x"+$@ttt_ann$ ;
	donpcevent "Tic Tac Toe#3z::OnResetGame";
	return ;
	
}

prontera,152,136,4	duplicate(3er_2)	Poring#1	909
prontera,155,136,4	duplicate(3er_2)	Poring#2	909
prontera,158,136,4	duplicate(3er_2)	Poring#3	909
prontera,158,133,4	duplicate(3er_2)	Poring#4	909
prontera,155,133,4	duplicate(3er_2)	Poring#5	909
prontera,152,133,4	duplicate(3er_2)	Poring#6	909
prontera,152,130,4	duplicate(3er_2)	Poring#7	909
prontera,155,130,4	duplicate(3er_2)	Poring#8	909
prontera,158,130,4	duplicate(3er_2)	Poring#9	909

prontera,164,136,4	script	Tic Tac Toe#3z	909,{

	// NPC Name.
	set .@a$, "^2b86b5Tic Tac Toe^000000";

	mes .@a$;
	setarray .@a[0], .X2, .X, .O2, .O;
	for ( set .@b, getarraysize ( .@a ) ; .@c < .@b ; set .@c, .@c + 2 ) {
		if ( isloggedin ( .@a[.@c], .@a[.@c + 1] ) ) mes "Player "+ ( .@c / 2 + 1 ) +": "+ rid2name ( ( ( .@c == 0 ) ? .X2 : .O2 ) ) +".";
		else {
			mes "Player "+ ( .@c / 2 + 1 ) +": There isn't.";
			setd ( ( .@c == 0 ) ? ".X2" : ".O2" ), 0;
			setd ( ( .@c == 0 ) ? ".X" : ".O" ), 0;
		}
	}
	switch ( select ( "Register", "^911b1bExit^000000" ) ) {

		case 1:

			if (  .X && .O ) {
				mes "I'm sorry, but somebody else has already register before than you.";
				break ;
			}
			if ( .X2 == getcharid ( 3 ) || .O2 == getcharid ( 3 ) ) {
				mes "You're registered already.";
				break ;
			}
			if ( ! .X && ! .O ) {
				set .@a, rand ( 1, 2 );
				setd ( ( .@a == 1 ) ? ".X" : ".O" ), getcharid ( 0 );
				setd ( ( .@a == 1 ) ? ".X2" : ".O2" ), getcharid ( 3 );
			}
			else {
				setd ( ( .X == 0 ) ? ".X" : ".O" ), getcharid ( 0 );
				setd ( ( .X2 == 0  ) ? ".X2" : ".O2" ), getcharid ( 3 );
			}
			if (  .X && .O )  {
				set $@ttt_turn, rand ( 1, 2 );
				npctalk "The game can start, "+ strcharinfo ( 0 ) +" has been register!";
			}
			mes "You're registered now, you're the "+ ( ( .X2 == getcharid ( 3 ) ) ? "Deviling" : "Angeling" );
			break ;

		case 2:

			mes "Have a nice day.";
			break ;
	}
	close ;

OnResetGame:

	while ( set ( .@i, .@i + 1 ) < 10 ) {
		set $@ttt_a[.@i], 0;
		setnpcdisplay "Poring#"+ .@i, 909 ;
	}
	set .X2, 0;
	set .X, 0;
	set .O2, 0;
	set .O, 0;
	end ;
}

how to make cost zeny when register

somebody can help me?

 

Try this:

Spoiler

prontera,164,136,4    script    Tic Tac Toe#3z    909,{

    // NPC Name.
    set .@a$, "^2b86b5Tic Tac Toe^000000";
    
    // Zeny cost
    set .@zeny, 100000;

    mes .@a$;
    setarray .@a[0], .X2, .X, .O2, .O;
    for ( set .@b, getarraysize ( .@a ) ; .@c < .@b ; set .@c, .@c + 2 ) {
        if ( isloggedin ( .@a[.@c], .@a[.@c + 1] ) ) mes "Player "+ ( .@c / 2 + 1 ) +": "+ rid2name ( ( ( .@c == 0 ) ? .X2 : .O2 ) ) +".";
        else {
            mes "Player "+ ( .@c / 2 + 1 ) +": There isn't.";
            setd ( ( .@c == 0 ) ? ".X2" : ".O2" ), 0;
            setd ( ( .@c == 0 ) ? ".X" : ".O" ), 0;
        }
    }
    switch ( select ( "Register", "^911b1bExit^000000" ) ) {

        case 1:
            if (  .X && .O ) {
                mes "I'm sorry, but somebody else has already register before than you.";
                break ;
            }
            if ( .X2 == getcharid ( 3 ) || .O2 == getcharid ( 3 ) ) {
                mes "You're registered already.";
                break ;
            }
            
            mes "You need to pay "+.@zeny+" to register in this game.";
            switch ( select ( "Pay the fee", "^911b1bExit^000000" ) ) {
                
                case 1:
                    if(Zeny >= .@zeny){
                        Zeny = Zeny - .@zeny;
                    } 
                    else {
                        next;
                        mes "You don't have the required money."
                        close;
                    }
                    break;
                    
                case 2:
                    next;
                    mes "Have a nice day.";
                    close;
                    break;
            }
            
            if ( ! .X && ! .O ) {
                set .@a, rand ( 1, 2 );
                setd ( ( .@a == 1 ) ? ".X" : ".O" ), getcharid ( 0 );
                setd ( ( .@a == 1 ) ? ".X2" : ".O2" ), getcharid ( 3 );
            }
            else {
                setd ( ( .X == 0 ) ? ".X" : ".O" ), getcharid ( 0 );
                setd ( ( .X2 == 0  ) ? ".X2" : ".O2" ), getcharid ( 3 );
            }
            
            if (  .X && .O )  {
                set $@ttt_turn, rand ( 1, 2 );
                npctalk "The game can start, "+ strcharinfo ( 0 ) +" has been register!";
            }
            
            mes "You're registered now, you're the "+ ( ( .X2 == getcharid ( 3 ) ) ? "Deviling" : "Angeling" );
            break ;

        case 2:
            mes "Have a nice day.";
            break ;
    }
    close ;

OnResetGame:

    while ( set ( .@i, .@i + 1 ) < 10 ) {
        set $@ttt_a[.@i], 0;
        setnpcdisplay "Poring#"+ .@i, 909 ;
    }
    set .X2, 0;
    set .X, 0;
    set .O2, 0;
    set .O, 0;
    end ;
}

If you got any problem just tell me here.

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...

×
×
  • Create New...

Important Information

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