Jump to content
  • 0

@duel with character delection


LucianoCP

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

Hey, guys... I saw this script below, from @Nova, and wondered if was possible to turn it into a command, similar to @duel, where players will bet their characters.

//===== rAthena Script =======================================
//= Character Deletion on Death Script
//===== By: ==================================================
//= Nova http://www.novaragnarok.com
//============================================================


-    script    PERMANENTDEATH    -1,{
end;

OnPCDieEvent:
    set .@deadplayer,getcharid(0);
    message strcharinfo(0),"Game Over";
    atcommand "@kick "+strcharinfo(0);
    set .@j, getarraysize( .char_delete$ );
    for (.@i = 0; .@i < .@j; .@i++) {
        query_sql("DELETE FROM `"+ .char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
    }
    query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
    end;
    
OnInit:
setarray .char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
end;
    
}

Thanks.

@edit:

Here's the final code by @n0tttt:

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @duel_creator,1;
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You are the creater of the duel. Wait for the other player's answer.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(prompt("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(prompt("No","Yes") == 2) {
					if(isloggedin(.@oid,.@cid)) {
						if(!.duel) {
							message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
							announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
							announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
							set .duel,true;
							set .cancel,false;
							removemapflag .duel_map$,mf_pvp;
							removemapflag .duel_map$,mf_pvp_nocalcrank;
							setmapflag .duel_map$,mf_restricted,9;
							set .@first_id,getcharid(3);
							explode .@xy$,.duel_xy$,",";
							set .@r,rand(2);
							set @duel,.@oid;
							warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
							setoption 0x40,0;
							pcblockmove .@first_id,1;
							message strcharinfo(0),"You will not be able to move until the duel starts.";
							attachrid .@oid;
							set @duel,.@first_id;
							set .@r,!.@r;
							warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
							setoption 0x40,0;
							pcblockmove .@oid,1;
							message strcharinfo(0),"You will not be able to move until the duel starts.";
							detachrid;
							set .@i,30;
							while(.@i > 0 && !.cancel) {
								if(!(.@i % 10) || .@i < 6)
									announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
								sleep 1000;
								set .@i,.@i - 1;
							}
							pcblockmove .@first_id,0;
							pcblockmove .@oid,0;
							removemapflag .duel_map$,mf_restricted,9;
							if(.@i || .cancel) {
								announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   					} else {
								announce "The Death Duel has just started!",bc_all|bc_blue;
								setmapflag .duel_map$,mf_pvp;
								setmapflag .duel_map$,mf_pvp_nocalcrank;
								set .@i,0;
								while(.@i < .time && !.cancel && .duel) {
									sleep 5000;
									set .@i,.@i + 5;
								}
								if(.@i >= .time)
									announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    					}
							sleep 1000;
							if(.logout && .duel) {
								announce "One of the participants logged out.",bc_all|bc_blue;
								set .logout,false;
							}
							if(.cancel)
								set .cancel,false;
							set .duel,false;
							removemapflag .duel_map$,mf_pvp;
							removemapflag .duel_map$,mf_pvp_nocalcrank;
							addrid 5,0,.duel_map$;
							setoption 0x40,0;
							if(!@duel) {
								atcommand "@rmvperm disable_pvp";
							} else {
								set @duel,0;
								set @duel_creator,0;
								set @wait_duelaid,0;
								set @wait_duelcid,0;
							}
							set .@i,5;
							while(.@i) {
								message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
								sleep2 1000;
								set .@i,.@i - 1;
							}
							warp "prontera",156,161;
							pcblockskill getcharid(3),0;
							end;
						} else {
							message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
							message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
							end;
						}
					} else {
						message strcharinfo(0),"The other player disconnected.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			} else {
				message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			}
			set .duel,false;
			set .cancel,false;
			if(playerattached()) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
					set @duel,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				set @duel,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You have to wait for your opponent to choose.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnFixDuel:

	set .duel,false;
	set .cancel,false;
	set .logout,false;
	set .duel_delay,false;
	message strcharinfo(0),"Every variable has been cleared successfully.";
	addrid 0;
	set @duel,0;
	set @wait_duelaid,0;
	set @wait_duelcid,0;
	set @duel_creator,0;
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@wait_duelaid) {
		message strcharinfo(0,@wait_duelcid),"The other player disconnected.";
		set @wait_duelaid,0,@wait_duelcid;
		set @creator_duel,0,@wait_duelcid;
		set @wait_duelcid,0,@wait_duelcid;
	}
	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //insert the map name
	// Coordinates
	set .duel_xy$, "x,y,"+  // x,y first player
		       "x,y";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";
	bindatcmd "fixduel","Duel_Death::OnFix",60;

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

// change "map" to the same map you've insert above

map	mapflag	pvp
map	mapflag	pvp_nocalcrank
map	mapflag	noreturn
map	mapflag	nowarp
map	mapflag	nocommand	99
map	mapflag	nowarpto
map	mapflag	nosave	SavePoint
map	mapflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending
map	mapflag	restricted	9

To forbid the use of some skills during the countdown (i asked for movement ones), you should add this to your db/import/skill_nocast_db.txt:

//----------------------------------------------------------------------------
// Zone 9 - Death Duel
//----------------------------------------------------------------------------
150,8192	//TF_BACKSLIDING
426,8192	//TK_HIGHJUMP

if it doesn't work, maybe you need to do this:

 

Edited by LucianoCP
Script release made by @n0tttt
Link to comment
Share on other sites

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

8 minutes ago, n0tttt said:

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
						set .cancel,false;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		set .cancel,true;
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && .duel && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	if(.duel)
		set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

Let's see now.

Still doesn't work. The players get recalled and this happens:

image.png.c833083e5e5e9d7efce1a123928fbb83.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

This is one of the weirdest bugs because the variable .cancel shouldn't be defined and that var only happens if one logouts or rejects.

I changed it a little, but tell me how it goes

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
						set .cancel,false;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		set .cancel,true;
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

10 minutes ago, n0tttt said:

This is one of the weirdest bugs because the variable .cancel shouldn't be defined and that var only happens if one logouts or rejects.

I changed it a little, but tell me how it goes


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
						set .cancel,false;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		set .cancel,true;
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

The "this is one of the weirdest bugs" message made me think "what if i create new chars to test it?"

so... i created, and it worked. But, i think this tells us that the variable keeps it's value when char reloggs. Am i right?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

It shouldn't because the variable is a npc one, not a character one. But if you logout it means the variable was set to 0 again because the OnPCLogoutEvent got executed. But there's a 5 second refresh between the loops. Maybe if I refresh it so when a character logs out it's instantly canceled?

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
						set .cancel,false;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Death_Duel";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

7 minutes ago, n0tttt said:

It shouldn't because the variable is a npc one, not a character one. But if you logout it means the variable was set to 0 again because the OnPCLogoutEvent got executed. But there's a 5 second refresh between the loops. Maybe if I refresh it so when a character logs out it's instantly canceled?


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
						set .cancel,false;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Death_Duel";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

logged out with one of the participants to test it and realized something new: nothing happens except an announcement. The other player and the spectators keeps there and it's impossible to start a new death duel (i tried to relogg the player who was left there), because "there is a duel going on right now.", so... maybe you should take a look at this part of the code. 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Multiprocessing again. Now only one part of the code deals with the .cancel so it doesn't interfere with the other.

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Death_Duel";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

12 minutes ago, n0tttt said:

Multiprocessing again. Now only one part of the code deals with the .cancel so it doesn't interfere with the other.


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set .@id,@wait_duelaid;
				}
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				if(.@id) {
					attachrid .@id;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Death_Duel";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Same thing, bro. But, i think the mistake is on the NPC Name. Look:

image.png.24a0c81f0d2e48b0854480af8876c177.png

first line of your code: script Duel_Death

Sorry for bottering, i'm just trying to not change anything and mess up de code =x

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Ups. That's funny.

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

9 minutes ago, n0tttt said:

Ups. That's funny.


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;

OnStuck:

	while(.@i < .time && !.cancel) {
		sleep 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,false;
	set .duel,false;
	addrid 5,0,.duel_map$;
	setoption 0x40,0;
	if(!@duel)
		atcommand "@rmvperm disable_pvp";
	else
		set @duel,0;
	set .@i,5;
	while(.@i) {
		message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
		sleep2 1000;
		set .@i,.@i - 1;
	}
	warp "prontera",156,161;
	pcblockskill getcharid(3),0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

mapserv.bat error doesn't show up anymore, but after one of the players loggs out, an announcement "the death duel has been canceled" shows up. I remember that a previous code announced something about one of the players logging out. Also, the remaining player still keeps in the map.

Another thing, i had confused the clients and realized that is possible to create a @deathduel with your own character. Can you please fix it too?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

This should fix the duel with yourself, and also I got rid of the OnStuck label and now is just part of the OnAccept label.

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						while(.@i < .time && !.cancel) {
							sleep 5000;
							set .@i,.@i + 5;
						}
                    			}
					if(.cancel)
						set .cancel,false;
					set .duel,false;
					addrid 5,0,.duel_map$;
					setoption 0x40,0;
					if(!@duel)
						atcommand "@rmvperm disable_pvp";
					else
						set @duel,0;
					set .@i,5;
					while(.@i) {
						message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
						sleep2 1000;
						set .@i,.@i - 1;
					}
					warp "prontera",156,161;
					pcblockskill getcharid(3),0;
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

13 minutes ago, n0tttt said:

This should fix the duel with yourself, and also I got rid of the OnStuck label and now is just part of the OnAccept label.


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						while(.@i < .time && !.cancel) {
							sleep 5000;
							set .@i,.@i + 5;
						}
                    			}
					if(.cancel)
						set .cancel,false;
					set .duel,false;
					addrid 5,0,.duel_map$;
					setoption 0x40,0;
					if(!@duel)
						atcommand "@rmvperm disable_pvp";
					else
						set @duel,0;
					set .@i,5;
					while(.@i) {
						message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
						sleep2 1000;
						set .@i,.@i - 1;
					}
					warp "prontera",156,161;
					pcblockskill getcharid(3),0;
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Now it's working! But... I made a test with the time limit now and i have a question: After the time ends, the 5 sec warp back countdown starts. The issue is that pvp keeps on. Can you set the pvp to off when the warp back countdown starts?

Another thing, when the time ends, can you set an announcement like "Death Duel time is over. There was no winner."?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Done. Anything else, I'm here.

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						while(.@i < .time && !.cancel) {
							sleep 5000;
							set .@i,.@i + 5;
						}
                    			}
					if(.@i >= .time)
						announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
					if(.cancel)
						set .cancel,false;
					set .duel,false;
					setmapflag .duel_map$,mf_pvp,false;
					addrid 5,0,.duel_map$;
					setoption 0x40,0;
					if(!@duel)
						atcommand "@rmvperm disable_pvp";
					else
						set @duel,0;
					set .@i,5;
					while(.@i) {
						message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
						sleep2 1000;
						set .@i,.@i - 1;
					}
					warp "prontera",156,161;
					pcblockskill getcharid(3),0;
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

20 minutes ago, n0tttt said:

Done. Anything else, I'm here.


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,true;
					set .cancel,false;
					setmapflag .duel_map$,mf_pvp,false;
					set .@first_id,getcharid(3);
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					attachrid .@oid;
					set @duel,@wait_duelaid;
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					set .@r,!.@r;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					setoption 0x40,0;
					detachrid;
					set .@i,30;
					while(.@i > 0 && !.cancel) {
						if(!(.@i % 10) || .@i < 6)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i || .cancel) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						if(!isloggedin(.@oid) || !isloggedin(.@first_id))
							announce "One of the participans logged out.",bc_all|bc_blue;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						while(.@i < .time && !.cancel) {
							sleep 5000;
							set .@i,.@i + 5;
						}
                    			}
					if(.@i >= .time)
						announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
					if(.cancel)
						set .cancel,false;
					set .duel,false;
					setmapflag .duel_map$,mf_pvp,false;
					addrid 5,0,.duel_map$;
					setoption 0x40,0;
					if(!@duel)
						atcommand "@rmvperm disable_pvp";
					else
						set @duel,0;
					set .@i,5;
					while(.@i) {
						message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
						sleep2 1000;
						set .@i,.@i - 1;
					}
					warp "prontera",156,161;
					pcblockskill getcharid(3),0;
					end;
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Sorry for testing your patience, man ?

But the pvp still on when the warp back starts after the death duel time ends. Also, when a dueler logs out, the death duel is cancelled and the warp back countdown starts.

If i leave when the hasn't started yet, it says the duel got cancelled and says the time of death duel has ended.

If the duel has started, nothing is announced and the warp back countdown starts.

Edited by LucianoCP
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Had a stupid typo. Also changed the logout thing, it seems isloggedin needs some time to check the status? Anyways here it is. I also added security to avoid a situation where a player waited with the menu too long and a duel already started.

 

EDIT 2: changed another thing. Damn.

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
							if(.logout) {
								announce "One of the participants logged out.",bc_all|bc_blue;
								set .logout,0;
							}
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvpnocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel)
							atcommand "@rmvperm disable_pvp";
						else
							set @duel,0;
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}	
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,1;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Edited by n0tttt
Just read the edit and did an extra change
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

7 minutes ago, n0tttt said:

Had a stupid typo. Also changed the logout thing, it seems isloggedin needs some time to check the status? Anyways here it is. I also added security to avoid a situation where a player waited with the menu too long and a duel already started.


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
							if(.logout) {
								announce "One of the participants logged out.",bc_all|bc_blue;
								set .logout,0;
							}
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvpnocalcrank;
							while(.@i < .time && !.cancel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
                    				}
						if(.@i >= .time)
							announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel)
							atcommand "@rmvperm disable_pvp";
						else
							set @duel,0;
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}	
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
		attachrid .@oid;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,1;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,10*120;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

If i leave before the duel starts, the announcement is made but there is no warp back countdown, so there is no warp back.

If i leave after the duel starts, there is no announcement, no warp back countdown and no warp back. And after relogg both chars, can't use @death duel because "there is a duel going on right now..."

I think max duration of a duel isn't working anymore... it is set to 20 seconds, after that, nothing happened.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvpnocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel)
							atcommand "@rmvperm disable_pvp";
						else
							set @duel,0;
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}	
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

 

5 minutes ago, n0tttt said:

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvpnocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvpnocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel)
							atcommand "@rmvperm disable_pvp";
						else
							set @duel,0;
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}	
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

This happens when i leave before the duel starts: (in game, "the death duel has been cancelled" and "one of the participants logged out". No warp back countdown and no warp back)

image.png.21bf763832a225baa8e1fe1e97204c5d.png

This happens when the countdown for the duel begins (x seconds for the duel between a vs b) ends:

image.png.cfd62f5287fd4e969ce9cc69d97b4843.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Thank you for the screenshots. Literally just a lack of "_".

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel)
							atcommand "@rmvperm disable_pvp";
						else
							set @duel,0;
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}	
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

41 minutes ago, n0tttt said:

Thank you for the screenshots. Literally just a lack of "_".


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel)
							atcommand "@rmvperm disable_pvp";
						else
							set @duel,0;
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			if(!.duel || .cancel) {
				set .duel,false;
				set .cancel,false;
				if(playerattached()) {
					message strcharinfo(0),"The duel has been cancelled.";
					if(isloggedin(@wait_duelaid,@wait_duelcid)) {
						message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
						set .@id,@wait_duelaid;
					}
					set @wait_duelaid,0;
					set @wait_duelcid,0;
					close2;
					if(.@id) {
						attachrid .@id;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
					}
				}
				end;
			}	
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Found another issues:

- When i create a duel and type @acceptdd on the same char, it says "The character who challenged you is offline". Can you change it to "You are the creater of the duel. Wait for the other player's answer."

- After i accept the duel, in the dialogue menu, another dialogue is created to the one who invited, right? So, if i cancel in this one, the other player still can @acceptdd. Look: the player receives the "the character who challenged you has changed his mind. The duel is cancelled" and still can use @accept and it opens the dialogue menu. I think is should appears a "there is no death duel invite for you right now" message.

Everything else is working.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

With cancel do you mean choosing No or the "cancel" button in the menu? Anyways I added a detection for when the player chooses "cancel" (prompt instead of select). Also added the creator's thing. Tell me how it goes.

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @duel_creator,1;
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You are the creater of the duel. Wait for the other player's answer.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(prompt("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(prompt("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel) {
							atcommand "@rmvperm disable_pvp";
						} else {
							set @duel,0;
							set @duel_creator,0;
						}
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
						end;
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			set .duel,false;
			set .cancel,false;
			if(playerattached()) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  383
  • Reputation:   121
  • Joined:  03/31/12
  • Last Seen:  

Would love to add a queue system for this makes interesting. Thank you n0tt for your effort.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

19 minutes ago, n0tttt said:

With cancel do you mean choosing No or the "cancel" button in the menu? Anyways I added a detection for when the player chooses "cancel" (prompt instead of select). Also added the creator's thing. Tell me how it goes.


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @duel_creator,1;
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You are the creater of the duel. Wait for the other player's answer.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(prompt("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(prompt("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel) {
							atcommand "@rmvperm disable_pvp";
						} else {
							set @duel,0;
							set @duel_creator,0;
						}
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
						end;
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			set .duel,false;
			set .cancel,false;
			if(playerattached()) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

I meant selecting "no". Did you checked it?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Yeah, but now I added some debug announces:

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @duel_creator,1;
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You are the creater of the duel. Wait for the other player's answer.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(prompt("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(prompt("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel) {
							atcommand "@rmvperm disable_pvp";
						} else {
							set @duel,0;
							set @duel_creator,0;
						}
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
						end;
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			set .duel,false;
			set .cancel,false;
			announce "DEBUG 1: this part should be executed when one of the players choose no.",bc_all;
			if(playerattached()) {
				announce "DEBUG 2: this part should be executed when one of the players choose no and there's one attached.",bc_all;
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   3
  • Joined:  10/29/18
  • Last Seen:  

6 hours ago, n0tttt said:

Yeah, but now I added some debug announces:


-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @duel_creator,1;
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You are the creater of the duel. Wait for the other player's answer.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(prompt("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(prompt("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,@wait_duelaid;
						set @wait_duelaid,0;
						set @wait_duelcid,0;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel) {
							atcommand "@rmvperm disable_pvp";
						} else {
							set @duel,0;
							set @duel_creator,0;
						}
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
						end;
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			set .duel,false;
			set .cancel,false;
			announce "DEBUG 1: this part should be executed when one of the players choose no.",bc_all;
			if(playerattached()) {
				announce "DEBUG 2: this part should be executed when one of the players choose no and there's one attached.",bc_all;
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

 

First, i'll stablish a simple thing here:

Player A: who creates the duel

Player B: who accepts/rejects the duel

--------------------------------

- If player A creates the duel, he can type @reject. It's not a BUG, because player B can't accept after it, but player A receive a "You reject the duel". I think it's not the best message in this ocasion. I think he would be unnable to use it (like @accept) and wait for the dialogue menu appears to change his mind.

- When player B select "No" after @accept, this happens:

image.png.1a59c4868b98694a92d938fb8276647b.png

If player B reloggs after receiveng an invite, the duel isn't cancelled. Player A doesn't receive any message. Eventually he is forced to rellog to create a new @deathduel

Edited by LucianoCP
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @duel_creator,1;
			set @wait_duelaid,.@aid;
			set @wait_duelaid,.@cid;
			message strcharinfo(0),"Proposition sent. Wait for him/her to accept or reject.";
			attachrid .@aid;
			set @wait_duelaid,.@oid;
			set @wait_duelcid,getcharid(0,.@player$);
			message strcharinfo(0),.@player$+" wants to have a Death Duel with you. Use @acceptdd to accept it or @rejectdd to reject it.";
		}
	}
	end;

OnAccept:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You are the creater of the duel. Wait for the other player's answer.";
	} else if(@wait_duelaid) {
		set .@oid,getcharid(3);
		set .@cid,getcharid(0);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			// Player 2.
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(prompt("No.","Yes.") == 2) {
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				close2;
				attachrid @wait_duelaid;
				// Player 1.
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(prompt("Não","Sim") == 2) {
					if(!.duel) {
						message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
						announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
						announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
						set .duel,true;
						set .cancel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						set .@first_id,getcharid(3);
						explode .@xy$,.duel_xy$,",";
						set .@r,rand(2);
						set @duel,.@oid;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						attachrid .@oid;
						set @duel,.@first_id;
						set .@r,!.@r;
						warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
						setoption 0x40,0;
						detachrid;
						set .@i,30;
						while(.@i > 0 && !.cancel) {
							if(!(.@i % 10) || .@i < 6)
								announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" vs "+rid2name(.@oid)+"!",bc_all|bc_blue;
							sleep 1000;
							set .@i,.@i - 1;
						}
						if(.@i || .cancel) {
							announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                   				} else {
							setmapflag .duel_map$,mf_pvp;
							setmapflag .duel_map$,mf_pvp_nocalcrank;
							set .@i,0;
							while(.@i < .time && !.cancel && .duel) {
								sleep 5000;
								set .@i,.@i + 5;
							}
							if(.@i >= .time)
								announce "Death Duel time is over. There was no winner.",bc_all|bc_blue;
                    				}
						sleep 1000;
						if(.logout && .duel) {
							announce "One of the participants logged out.",bc_all|bc_blue;
							set .logout,false;
						}
						if(.cancel)
							set .cancel,false;
						set .duel,false;
						removemapflag .duel_map$,mf_pvp;
						removemapflag .duel_map$,mf_pvp_nocalcrank;
						addrid 5,0,.duel_map$;
						setoption 0x40,0;
						if(!@duel) {
							atcommand "@rmvperm disable_pvp";
						} else {
							set @duel,0;
							set @duel_creator,0;
							set @wait_duelaid,0;
							set @wait_duelcid,0;
						}
						set .@i,5;
						while(.@i) {
							message strcharinfo(0),.@i+" second"+((.@i > 1)? "s" : "")+" to warp you out.";
							sleep2 1000;
							set .@i,.@i - 1;
						}
						warp "prontera",156,161;
						pcblockskill getcharid(3),0;
						end;
					} else {
						message strcharinfo(0),"I'm sorry but a duel started a few moments ago.";
						message strcharinfo(0,.@cid),"I'm sorry but a duel started a few moments ago.";
						end;
					}
				} else {
					message strcharinfo(0,.@cid),"The challenger changed his mind. The Death Duel is cancelled.";
				}
			}
			set .duel,false;
			set .cancel,false;
			if(playerattached()) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
					set @duel,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				set @duel,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@duel_creator) {
		message strcharinfo(0),"You have to wait for your opponent to choose.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
			set .@id,@wait_duelaid;
		}
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		if(.@id) {
			attachrid .@id;
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
		set .cancel,true;
		awake "Duel_Death";
	} else {
		message strcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnSpectate:

	if(@duel) {
		message strcharinfo(0),"You're part of the duel.";
	} else if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			setoption 0x40,1;
			atcommand "@addperm disable_pvp";
			pcblockskill getcharid(3),1;
			warp .duel_map$,0,0;
		}
	} else {
		message strcharinfo(0),"There isn't a duel right now.";
	}
	end;

OnPCKillEvent:
	if(@duel && killedrid == @duel) {
		set .duel_delay,gettimetick(2) + 5*60;
		set .duel,false;
		set .@oid,getcharid(3);
		announce strcharinfo(0)+" has won a Death Duel against "+rid2name(@duel)+"!",bc_all|bc_blue;
		announce rid2name(@duel)+" was deleted.",bc_all|bc_blue;
		attachrid @duel;
		setarray .@char_delete$[0],"bonus_script","char","cart_inventory","elemental","friends","global_reg_value","guild","guild_member","homunculus","hotkey","inventory","memo","mercenary","mercenary_owner","pet","quest","sc_data","skill","skillcooldown";
		set .@deadplayer,getcharid(0);
		message strcharinfo(0),"Game Over";
		atcommand "@kick "+strcharinfo(0);
		set .@j, getarraysize( .@char_delete$ );
		for (.@i = 0; .@i < .@j; .@i++) {
			query_sql("DELETE FROM `"+ .@char_delete$[.@i] +"` WHERE `char_id` = '"+ .@deadplayer +"'");
		}
		query_sql "DELETE FROM `party` WHERE `leader_char` = '"+.@deadplayer+"'";
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .cancel,true;
		set .logout,true;
		awake "Duel_Death";
	}
	end;

OnPCLoginEvent:

	if(checkoption(0x40) && getgmlevel() < 60)
		setoption 0x40,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

	// Max duration of a duel (seconds).
	set .time,20;
	end;

}

pvp_n_8-5	mapflag	pvp
pvp_n_8-5	mapflag	pvp_nocalcrank
pvp_n_8-5	mapflag	noreturn
pvp_n_8-5	mapflag	nowarp
pvp_n_8-5	mapflag	nocommand	99
pvp_n_8-5	mapflag	nowarpto
pvp_n_8-5	mapflag	nosave	SavePoint
pvp_n_8-5	mapflag	nomemo
pvp_n_8-5	mapflag	notrade
pvp_n_8-5	mapflag	nodrop
pvp_n_8-5	mapflag	nobranch
pvp_n_8-5	mapflag	nochat
pvp_n_8-5	mapflag	novending

Done. The @reject thing I did intentionally if the one who made the duel changed his mind, but now that you point out, it really makes no sense, because there's already a confirmation when the other player accepts. So that part gets executed.

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

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