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:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

Does your mapserver tells you it loaded x entries from import/skill_nocast_db?

-	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(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$,"deathduel";
	// 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";
	bindatcmd "fixduel","Duel_Death::OnFix",60;

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

}

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

 

  • Love 1
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:  

You could test this. Be aware, it's a prototype and there're some additional checks you might want to make (like charid in isloggedin).


-	script	Duel_Death	-1,{
	end;

OnCommand:

	set .@player$,strcharinfo(0);
	set .@oid,getcharid(3);
	set .@enemy$,implode(.@atcmd_parameters$," ");
	set .@id,getcharid(3,.@enemy$);
	if(!.@id) {
		dispbottom "Character offline.";
		end;
	} else {
		attachrid .@id;
		set @wait_duel,.@oid;
		dispbottom .@player$+" wants to duel. Use @accept to duel.";
	}
	end,

OnAccept:

	if(@wait_duel) {
		set .@oid,getcharid(3);
		if(isloggedin(@wait_duel)) {
			set @duel,@wait_duel;
			set @wait_duel,0;
			dispbottom "You accepted the duel.";
			attachrid @duel;
			dispbottom "You're now in a duel with "+rid2name(.@oid)+.".";
			set @duel,.@oid;
		} else {
			dispbottom "Other guy is offline";
			set @wait_duel,0;
		}
	}
	end;

OnPCDieEvent:
	if(@duel && killerrid == @duel) {
		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";
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "accept","Duel_Death::OnAccept";
	end;
    
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  145
  • Topics Per Day:  0.07
  • Content Count:  354
  • Reputation:   8
  • Joined:  04/16/18
  • Last Seen:  

4 hours ago, LucianoCP said:

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.

 

From what I understand, the char is deleted by losing the duel? ?

interesting, is it functional?

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 hours ago, n0tttt said:

You could test this. Be aware, it's a prototype and there're some additional checks you might want to make (like charid in isloggedin).



-	script	Duel_Death	-1,{
	end;

OnCommand:

	set .@player$,strcharinfo(0);
	set .@oid,getcharid(3);
	set .@enemy$,implode(.@atcmd_parameters$," ");
	set .@id,getcharid(3,.@enemy$);
	if(!.@id) {
		dispbottom "Character offline.";
		end;
	} else {
		attachrid .@id;
		set @wait_duel,.@oid;
		dispbottom .@player$+" wants to duel. Use @accept to duel.";
	}
	end,

OnAccept:

	if(@wait_duel) {
		set .@oid,getcharid(3);
		if(isloggedin(@wait_duel)) {
			set @duel,@wait_duel;
			set @wait_duel,0;
			dispbottom "You accepted the duel.";
			attachrid @duel;
			dispbottom "You're now in a duel with "+rid2name(.@oid)+.".";
			set @duel,.@oid;
		} else {
			dispbottom "Other guy is offline";
			set @wait_duel,0;
		}
	}
	end;

OnPCDieEvent:
	if(@duel && killerrid == @duel) {
		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";
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "accept","Duel_Death::OnAccept";
	end;
    
}

 

Hi, mate. Thanks for the script. I'll be able to test it in a few hours.

7 hours ago, IsabelaFernandez said:

 

From what I understand, the char is deleted by losing the duel? ?

interesting, is it functional?

The original script is more about "if you die, you'll lose your character". I want it to be part of an especific duel command. Players will be able to duel normally, and who wins is the best, but they also will be able to bet their characters, turning the duel something a bit more serious hahahaha

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  145
  • Topics Per Day:  0.07
  • Content Count:  354
  • Reputation:   8
  • Joined:  04/16/18
  • Last Seen:  

6 hours ago, LucianoCP said:

Hi, mate. Thanks for the script. I'll be able to test it in a few hours.

The original script is more about "if you die, you'll lose your character". I want it to be part of an especific duel command. Players will be able to duel normally, and who wins is the best, but they also will be able to bet their characters, turning the duel something a bit more serious hahahaha

 

very interesting (and risky ?) is there any problem if I test it too?

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:  

On 11/27/2018 at 1:24 AM, IsabelaFernandez said:

 

very interesting (and risky ?) is there any problem if I test it too?

Of course not ?

 

On 11/26/2018 at 9:02 AM, n0tttt said:

You could test this. Be aware, it's a prototype and there're some additional checks you might want to make (like charid in isloggedin).



-	script	Duel_Death	-1,{
	end;

OnCommand:

	set .@player$,strcharinfo(0);
	set .@oid,getcharid(3);
	set .@enemy$,implode(.@atcmd_parameters$," ");
	set .@id,getcharid(3,.@enemy$);
	if(!.@id) {
		dispbottom "Character offline.";
		end;
	} else {
		attachrid .@id;
		set @wait_duel,.@oid;
		dispbottom .@player$+" wants to duel. Use @accept to duel.";
	}
	end,

OnAccept:

	if(@wait_duel) {
		set .@oid,getcharid(3);
		if(isloggedin(@wait_duel)) {
			set @duel,@wait_duel;
			set @wait_duel,0;
			dispbottom "You accepted the duel.";
			attachrid @duel;
			dispbottom "You're now in a duel with "+rid2name(.@oid)+.".";
			set @duel,.@oid;
		} else {
			dispbottom "Other guy is offline";
			set @wait_duel,0;
		}
	}
	end;

OnPCDieEvent:
	if(@duel && killerrid == @duel) {
		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";
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "accept","Duel_Death::OnAccept";
	end;
    
}

 

Hi, mate. I finally tested it. I've found some minor bugs (missing ; for example), but i was able to correct it. However, your code is missing some functional things. I tried to add them by myself since last light, but my knowledge at coding (and english too hahaha) are really bad ?

So, if you could do these adjustments bellow, i would be very pleased.

- Need to test if the target @duel_death is already on a duel_death.
- Need to create a @reject option and let the player who started the @duel_death knows it.
- Need to create a delay to @duel_death about 2~5 minutes. (let's don't make a massive deletion, right? hahaha)
- Need to disable @accept/@reject option when players are in a duel, and make a dispbottom like "You need to relogg to cancel the duel_death"
- Need to create a dispbottom to @accept/reject when they have no invites to @duel_death. Something like "You don't have any duel_death invite right now."
- Need to create a "mes" (like NPC dialogue) checking if the players are REALLY SURE with betting their characters. (important for users to know that this isn't @duel command)
- Need to create a "pvpon" between the players, similar to @duel command in case they are in a pvpoff map.
- Need to create an announcement of who are dueling, and later, who won and who lost his character.
- Need to set off the @duel on the winner player, turning him able to @duel_death again.

You see, some of the items are just to make the @duel_death exactly like @duel command, except for the loser character deletion. Reinforcing, this needs to be as functional as @duel command, plus the deletion of loser character, some "are you really sure of it?" questions and announcements. I guess everybody would like to know if a duel of this kind is happening on the server, and of course, who is the loser hahaha

So, in case i forgot something, just try make @duel_death a copy of @duel command.

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:  

I did some of the things you listed. As I said, I can't test because I don't have a test server. I added some configs for a map with different locations, and a spectate command, to make it more epic. Change the mapflags to your desired map.

I could do it as an atcommand in source, but that would require even more testing.

-	script	Duel_Death	-1,{
	end;

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 {
		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 {
			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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @duel;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					close2;
					sleep2 20000;
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					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]);
					donpcevent "Duel_Death::OnStuck";
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set @wait_duelaid,0;
				set @wait_duelcid,0;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strhcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

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

OnSpectate:

	if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			atcommand "@hide";
			atcommand "@addperm disable_pvp";
			pcblocskill 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,0;
		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;
		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);
		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;
		awake "Death_Duel";
		addrid 5,.duel_map$;
		if(!@duel)
			atcommand "@hide";
		set @duel,0;
		atcommand "@rmvperm disable_pvp";
		pcblocskill getcharid(3),0;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .duel,0;
		attachrid @duel;
		set @duel,0;
	}
	end;

OnStuck:

	sleep .time*1000;
	if(.duel)
		set .duel,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"map";
	// 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";

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

}

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

 

Edited by n0tttt
Proofreading xy var
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:

I did some of the things you listed. As I said, I can't test because I don't have a test server. I added some configs for a map with different locations, and a spectate command, to make it more epic. Change the mapflags to your desired map.

I could do it as an atcommand in source, but that would require even more testing.


-	script	Duel_Death	-1,{
	end;

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 {
		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 {
			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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @duel;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					close2;
					sleep2 20000;
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					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]);
					donpcevent "Duel_Death::OnStuck";
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set @wait_duelaid,0;
				set @wait_duelcid,0;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strhcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

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

OnSpectate:

	if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			atcommand "@hide";
			atcommand "@addperm disable_pvp";
			pcblocskill 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,0;
		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;
		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);
		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;
		awake "Death_Duel";
		addrid 5,.duel_map$;
		if(!@duel)
			atcommand "@hide";
		set @duel,0;
		atcommand "@rmvperm disable_pvp";
		pcblocskill getcharid(3),0;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .duel,0;
		attachrid @duel;
		set @duel,0;
	}
	end;

OnStuck:

	sleep .time*1000;
	if(.duel)
		set .duel,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"map";
	// 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";

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

}

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

 

Wow, i was thinking something about a @duel, where players duel anywhere, but this idea of teleporting the rivals to a map and send spectators there is AMAZING! Really, this shit will be crazy! Just one thing i didn't notice, i guess... What do you think about giving 30~60 seconds of waiting to spectators enter it, and the players who will duel prepare themselves? A countdown on the map, advertising "30 seconds left to duel begins, get ready", then "5... 4... 3... 2... 1... GO!". I'm going to test the code as it is right now, but i had to make this question as sooner as possible hahaha

 

@EDIT

Dude, tested it and there was some typing erros, missing ";" letters changed, etc... Here is the code 100% functional, only missing those changes i've asked ?

-	script	Duel_Death	-1,{
	end;

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 {
		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 {
			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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @duel;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					close2;
					sleep2 20000;
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					set @duel,.@oid;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					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]);
					donpcevent "Duel_Death::OnStuck";
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set @wait_duelaid,0;
				set @wait_duelcid,0;
			}
		} 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.";
	}
	end;

OnReject:

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

OnSpectate:

	if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			atcommand "@hide";
			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,0;
		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;
		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);
		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;
		awake "Death_Duel";
		addrid 5,.duel_map$;
		if(!@duel)
			atcommand "@hide";
		set @duel,0;
		atcommand "@rmvperm disable_pvp";
		pcblockskill getcharid(3),0;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .duel,0;
		attachrid @duel;
		set @duel,0;
	}
	end;

OnStuck:

	sleep .time*1000;
	if(.duel)
		set .duel,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

 

Edited by LucianoCP
corrected some typing errors on your script
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 {
			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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @duel;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					close2;
					set .@i,60;
					set .@first_id,getcharid(3);
					detachrid;
					while(.@i > 0) {
						if(!(.@i % 5) || .@i < 5)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					attachrid .@first_id;
					set @duel,.@oid;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					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]);
					donpcevent "Duel_Death::OnStuck";
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@aid,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@aid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strhcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

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

OnSpectate:

	if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			atcommand "@hide";
			atcommand "@addperm disable_pvp";
			pcblocskill 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,0;
		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;
		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);
		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;
		awake "Death_Duel";
		addrid 5,.duel_map$;
		if(!@duel)
			atcommand "@hide";
		set @duel,0;
		atcommand "@rmvperm disable_pvp";
		pcblocskill getcharid(3),0;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .duel,0;
		attachrid @duel;
		set @duel,0;
	}
	end;

OnStuck:

	sleep .time*1000;
	if(.duel)
		set .duel,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"map";
	// 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";

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

}

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

Tell me what you think.

  • Upvote 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:  

1 hour 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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @duel;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					close2;
					set .@i,60;
					set .@first_id,getcharid(3);
					detachrid;
					while(.@i > 0) {
						if(!(.@i % 5) || .@i < 5)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					explode .@xy$,.duel_xy$,",";
					set .@r,rand(2);
					attachrid .@first_id;
					set @duel,.@oid;
					warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
					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]);
					donpcevent "Duel_Death::OnStuck";
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@aid,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@aid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strhcharinfo(0),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

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

OnSpectate:

	if(.duel) {
		if(strcharinfo(3) == .duel_map$) {
			message strcharinfo(0),"You're already in the map.";
		} else {
			atcommand "@hide";
			atcommand "@addperm disable_pvp";
			pcblocskill 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,0;
		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;
		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);
		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;
		awake "Death_Duel";
		addrid 5,.duel_map$;
		if(!@duel)
			atcommand "@hide";
		set @duel,0;
		atcommand "@rmvperm disable_pvp";
		pcblocskill getcharid(3),0;
	}
	end;

OnPCLogoutEvent:

	if(@duel) {
		set .duel,0;
		attachrid @duel;
		set @duel,0;
	}
	end;

OnStuck:

	sleep .time*1000;
	if(.duel)
		set .duel,0;
	end;
    
OnInit:

	// Map
	set .duel_map$,"map";
	// 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";

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

}

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

Tell me what you think.

here are some issues i have found:

when a player refuses your invite, you can't make another one unless you relogg.

when selected "no", on the confirmation if player really wants to bet his character, the dialogue bugs. there is no "close" buttom. Altough, the duel is cancelled.

When you select "yes" on the confirmation, another ask is made to you, on the same window. i guess it should be to the player who typed the @deathduel <player> at first, right?

You can use @rejectdd while countdown is goingon. The countdown keeps rolling.

You can use @spectatedd while you should duel. After i relloged this char, he kept with @hide on.

Well, with this bug above, i've relogged and i think the @deathduel didn't turn off. So, i guess if a player quit in the middle of the duel, the delay won't be activated and nobody will be able to deathduel after it ?

player who starts the @deathduel doesn't get warped.

the countdown starts and only when it ends the players get there. I think they should get there at the begining, like spectators do. The pvp between them could be activated when the countdown ends.

i THINK the the max duration for a duel isn't working. Don't know if i configured it right (set .time,10*120; = 120 seconds?) If it is right, it isn't working.

Only the invited player got sended to the map. He didn't get warped back to his savepoint +10 minutes after the duel "began".

The countdown announcement repeats the X* player name like "There'll be a Death Duel between X* and X*", where X* = the player who accepted the duel.

i recalled the player who didn't get warpped to the duel map, and when i killed him, the winner wasn't warpped to his save point and "user 'player' doesn't possess the 'disable_pvp' permission. Is that because i choose pvp_n_1-5 map? I think it already has pvpon, don't know. Didn't tested, but i think spectators doesn't get warpped to their savepoints too when duel ends.

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:  

Damn, this is what happens when you don't have a test server.

-	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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @wait_duelaid;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					//close2;
					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]);
					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]);
					detachrid;
					set .@i,60;
					while(.@i > 0) {
						if(!(.@i % 5) || .@i < 5)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                    } else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    }
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		awake "Death_Duel";
	} 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 {
			atcommand "@hide";
			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;
		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);
		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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;

OnStuck:

	sleep .time*1000;
	if(.duel) {
		set .duel,0;
		addrid 5,.duel_map$;
		warp "prontera",156,161;
		if(!@duel) {
			atcommand "@hide";
			atcommand "@rmvperm disable_pvp";
		}
		set @duel,0;
		pcblockskill getcharid(3),0;
	}
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

I think I adressed most of the things you said. I had a typo with using @duel instead of @wait_duelaid, I now also removed the pvp mapflag until it all starts. The message of the permission was because it was also trying to remove the permission from the participans. It'll now only remove it from spectators. The countdown has been changed to what you say. I added the close button. I fixed the warpings and added a mapwarp to send all the people to Prontera. Sorry for this mess... I made you test a lot.

The @hide after relog should need more test, as far as I remember, using @hide lasts for the session. Might need an extra check like:

Quote

OnPCLoginEvent:

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

 

Edited by n0tttt
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 hours ago, n0tttt said:

Damn, this is what happens when you don't have a test server.


-	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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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.";
				attachrid @wait_duelaid;
				mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("No.","Yes") == 2) {
					message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
					announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
					announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
					set .duel,1;
					//close2;
					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]);
					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]);
					detachrid;
					set .@i,60;
					while(.@i > 0) {
						if(!(.@i % 5) || .@i < 5)
							announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@oid)+"!",bc_all|bc_blue;
						sleep 1000;
						set .@i,.@i - 1;
					}
					if(.@i) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
                    } else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    }
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		awake "Death_Duel";
	} 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 {
			atcommand "@hide";
			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;
		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);
		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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;

OnStuck:

	sleep .time*1000;
	if(.duel) {
		set .duel,0;
		addrid 5,.duel_map$;
		warp "prontera",156,161;
		if(!@duel) {
			atcommand "@hide";
			atcommand "@rmvperm disable_pvp";
		}
		set @duel,0;
		pcblockskill getcharid(3),0;
	}
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

I think I adressed most of the things you said. I had a typo with using @duel instead of @wait_duelaid, I now also removed the pvp mapflag until it all starts. The message of the permission was because it was also trying to remove the permission from the participans. It'll now only remove it from spectators. The countdown has been changed to what you say. I added the close button. I fixed the warpings and added a mapwarp to send all the people to Prontera. Sorry for this mess... I made you test a lot.

The @hide after relog should need more test, as far as I remember, using @hide lasts for the session. Might need an extra check like:

 

Please, don't be sorry for making me test it. I'm really enjoying it! As in fact, i'm the one who needs to be sorry hahaha Thanks for helping me with it.

I was making some tests here before i noticed your reply and found this:

got a deletion problem here:

setarray has ".@char_delete$[0]"

query_sql has ".char_detele$[.@i]"

should i delete the @ on setarray or add it to querysql?

Another thing, depending on who wins the duel, the loser doesn't get his char deleted. But i can't tell you for sure if it is who accept or who creates the duel because it's past 3:00 am here =x

About the @hide "bug", is it possible that group_id of all accounts i'm using are 99 are messing this up?

Now i'm going to test those codes you sent and then going to sleep (;

@edit

When the countdown ends, mapserv.bat get's me this:

image.png.595ff7b58396f5a9b38aff2664bc8b4b.png

when the death duel is over, players (winner and the spectators) still on the map... i think would be nice if they had another countdown, for 5 seconds, telling they will be sent to their savepoints.

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:  

Nice catch that @. Fixed it.

I added a debug announce to check if the OnStuck label gets initiated or not, because that's what handles the warping everyone out of the duel. rAthena has some problems with multiprocessing so sometimes donpcevent doesn't work if I remember correctly.

-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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;
				doevent "Death_Duel::OnSecondAsk";
			} else {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnSecondAsk:

	mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
	if(select("No.","Yes.") == 2) {
		set .@second_id,@wait_duelaid;
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has accepted the duel.";
		announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
		announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
		set .duel,1;
		close2;
		setmapflag .duel_map$,mf_pvp,false;
		set .@first_id,getcharid(3);
		explode .@xy$,.duel_xy$,",";
		set .@r,rand(2);
		set @duel,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
		setoption 0x40,0;
		attachrid .@second_id;
		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,60;
		while(.@i > 0 && !.cancel) {
			if(!(.@i % 5) || .@i < 5)
				announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
			sleep 1000;
			set .@i,.@i - 1;
		}
		if(.@i) {
			announce "The Death Duel has been cancelled!",bc_all|bc_blue;
			set .cancel,0;
		} else {
			setmapflag .duel_map$,mf_pvp,true;
			donpcevent "Duel_Death::OnStuck";
		}
	} else {
		message strcharinfo(0),"The duel has been cancelled.";
		message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		close;
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
		awake "Death_Duel";
	} 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;
		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);
		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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;

OnStuck:

	announce "donpcevent OnStuck succesful label.",bc_all;
	sleep .time*1000;
	if(.duel) {
		set .duel,0;
		addrid 5,.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 "SavePoint",0,0;
		pcblockskill getcharid(3),0;
	}
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

If it doesn't work, here's the one without donpcevent:

-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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;
				doevent "Death_Duel::OnSecondAsk";
			} else {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnSecondAsk:

	mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
	if(select("No.","Yes.") == 2) {
		set .@second_id,@wait_duelaid;
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has accepted the duel.";
		announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
		announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
		set .duel,1;
		close2;
		setmapflag .duel_map$,mf_pvp,false;
		set .@first_id,getcharid(3);
		explode .@xy$,.duel_xy$,",";
		set .@r,rand(2);
		set @duel,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
		setoption 0x40,0;
		attachrid .@second_id;
		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,60;
		while(.@i > 0 && !.cancel) {
			if(!(.@i % 5) || .@i < 5)
				announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
			sleep 1000;
			set .@i,.@i - 1;
		}
		if(.@i) {
			announce "The Death Duel has been cancelled!",bc_all|bc_blue;
			set .cancel,0;
		} else {
			setmapflag .duel_map$,mf_pvp,true;
			sleep .time*1000;
			if(.duel) {
				set .duel,0;
				addrid 5,.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 "SavePoint",0,0;
				pcblockskill getcharid(3),0;
			}
		}
	} else {
		message strcharinfo(0),"The duel has been cancelled.";
		message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		close;
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
		awake "Death_Duel";
	} 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;
		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);
		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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	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:  

36 minutes ago, n0tttt said:

Nice catch that @. Fixed it.

I added a debug announce to check if the OnStuck label gets initiated or not, because that's what handles the warping everyone out of the duel. rAthena has some problems with multiprocessing so sometimes donpcevent doesn't work if I remember correctly.


-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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;
				doevent "Death_Duel::OnSecondAsk";
			} else {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnSecondAsk:

	mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
	if(select("No.","Yes.") == 2) {
		set .@second_id,@wait_duelaid;
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has accepted the duel.";
		announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
		announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
		set .duel,1;
		close2;
		setmapflag .duel_map$,mf_pvp,false;
		set .@first_id,getcharid(3);
		explode .@xy$,.duel_xy$,",";
		set .@r,rand(2);
		set @duel,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
		setoption 0x40,0;
		attachrid .@second_id;
		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,60;
		while(.@i > 0 && !.cancel) {
			if(!(.@i % 5) || .@i < 5)
				announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
			sleep 1000;
			set .@i,.@i - 1;
		}
		if(.@i) {
			announce "The Death Duel has been cancelled!",bc_all|bc_blue;
			set .cancel,0;
		} else {
			setmapflag .duel_map$,mf_pvp,true;
			donpcevent "Duel_Death::OnStuck";
		}
	} else {
		message strcharinfo(0),"The duel has been cancelled.";
		message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		close;
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
		awake "Death_Duel";
	} 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;
		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);
		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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;

OnStuck:

	announce "donpcevent OnStuck succesful label.",bc_all;
	sleep .time*1000;
	if(.duel) {
		set .duel,0;
		addrid 5,.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 "SavePoint",0,0;
		pcblockskill getcharid(3),0;
	}
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

If it doesn't work, here's the one without donpcevent:


-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			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;
				doevent "Death_Duel::OnSecondAsk";
			} else {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnSecondAsk:

	mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
	if(select("No.","Yes.") == 2) {
		set .@second_id,@wait_duelaid;
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has accepted the duel.";
		announce "There'll be a Death Duel between "+strcharinfo(0)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
		announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
		set .duel,1;
		close2;
		setmapflag .duel_map$,mf_pvp,false;
		set .@first_id,getcharid(3);
		explode .@xy$,.duel_xy$,",";
		set .@r,rand(2);
		set @duel,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
		setoption 0x40,0;
		attachrid .@second_id;
		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,60;
		while(.@i > 0 && !.cancel) {
			if(!(.@i % 5) || .@i < 5)
				announce .@i+" seconds for the duel between "+rid2name(.@first_id)+" and "+rid2name(.@second_id)+"!",bc_all|bc_blue;
			sleep 1000;
			set .@i,.@i - 1;
		}
		if(.@i) {
			announce "The Death Duel has been cancelled!",bc_all|bc_blue;
			set .cancel,0;
		} else {
			setmapflag .duel_map$,mf_pvp,true;
			sleep .time*1000;
			if(.duel) {
				set .duel,0;
				addrid 5,.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 "SavePoint",0,0;
				pcblockskill getcharid(3),0;
			}
		}
	} else {
		message strcharinfo(0),"The duel has been cancelled.";
		message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		close;
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
		awake "Death_Duel";
	} 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;
		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);
		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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;
    
OnInit:

	// Map
	set .duel_map$,"map"; //put the map name where you want to Death Duel happens.
	// 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";

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

}

//change the "map"s below to the same mape you've put on OnInit.

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	malflag	nomemo
map	mapflag	notrade
map	mapflag	nodrop
map	mapflag	nobranch
map	mapflag	nochat
map	mapflag	novending

 

Mate, the second question was a mistake of mine. Here is the code i'm using:

-	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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
					mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
				if(select("Não","Sim") == 2) {
					set .@second_id,@wait_duelaid;
					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,1;
					//close2;
					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) {
						announce "The Death Duel has been cancelled!",bc_all|bc_blue;
						set .cancel,0;
                    } else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    }
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;	
		awake "Death_Duel";
	} 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;
		awake "Death_Duel";
	}
	end;

OnPCLogoutEvent:

	if(@duel)
		awake "Death_Duel";
	end;

OnPCLoginEvent:

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

OnStuck:

	announce "donpcevent OnStuck succesful label.",bc_all;
	sleep .time*1000;
	if(.duel) {
		set .duel,0;
		addrid 5,.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 "SavePoint",0,0;
		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

By now, the only error i found is about the players keeping in the map after the duel ends. Also, i get a "donpcevent OnStuck succesful label" announcement. Is that 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:  

Yes, the announcement is right. I removed it now since if it's appears then the label is being executed.

So it's starting to work. Nice.

-	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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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,1;
					//close2;
					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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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;
						set .cancel,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
	} 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)
		.duel = 0;
	end;

OnPCLoginEvent:

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

OnStuck:

	while(.@i < .time && .duel) {
		sleep2 5000;
		.@i+= 5;
	}
	addrid 5,.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 "SavePoint",0,0;
	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

 

Edited by n0tttt
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:

Yes, the announcement is right. I removed it now since if it's appears then the label is being executed.

So it's starting to work. Nice.


-	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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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,1;
					//close2;
					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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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;
						set .cancel,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"You haven't been challenged to a duel.";
	}
	end;

OnReject:

	if(@duel) {
		message strcharinfo(0),"You're already in a duel.";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You rejected the duel.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
	} 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)
		.duel = 0;
	end;

OnPCLoginEvent:

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

OnStuck:

	while(.@i < .time && .duel) {
		sleep2 5000;
		.@i+= 5;
	}
	addrid 5,.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 "SavePoint",0,0;
	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

 

I'm testing this last code. When i choose "No" on confirmation, dialogue bugs:

image.png.d96d3d087965eeb5225a96f68bd85404.png

and i can't make a new death duel unless i relogg.

After all, when i started the duel i got this:

image.png.00192e6d0da4378acdd8cc86ca9b0b34.png

players got warpped to the map, but the countdown doesn't starts, so the duel doesn't 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:  

Okay, so I added a message for when one of them log outs. It should cancel the duel and say it. That message should only appear if one uses @reject or one of the characters logs out. Also I think I fixed the menu.

-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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,1;
					//close2;
					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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"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.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
	} 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 .duel,0;
	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,0;
	if(.duel)
		set .duel,0;
	addrid 5,.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 "SavePoint",0,0;
	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

 

Edited by n0tttt
Proofreading sleep2 -> sleep
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 minutes ago, n0tttt said:

Okay, so I added a message for when one of them log outs. It should cancel the duel and say it. That message should only appear if one uses @reject or one of the characters logs out. Also I think I fixed the menu.


-	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$);
			dispbottom .@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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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,1;
					//close2;
					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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				}
			}
			if(!@duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				attachrid .@id;
				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),"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.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		attachrid .@id;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		set .cancel,1;
	} 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 .duel,0;
	end;

OnPCLoginEvent:

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

OnStuck:

	while(.@i < .time && .duel && !.cancel) {
		sleep2 5000;
		set .@i,.@i + 5;
	}
	if(.cancel)
		set .cancel,0;
	if(.duel)
		set .duel,0;
	addrid 5,.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 "SavePoint",0,0;
	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

 

menu still bugged when invited player refuses the deathduel ?

mapserv.bat sends me this (several times) when players are warpped to deathduel:

image.png.146be62c2be25412ac610720227e18a4.png

and this for last:

image.png.aca3ceca224145a50d6f463b406ce0b5.png

and players still in the map when deathduel ends. Countdown doesn't starts 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:  

I fixed the first thing after editing the post. I added a close2 to the menu now. Tell me how it goes. And addrid lacked a parameter. 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 {
			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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				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.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		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 .duel,false;
	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

 

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:

I fixed the first thing after editing the post. I added a close2 to the menu now. Tell me how it goes. And addrid lacked a parameter. 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 {
			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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				}
			}
			if(!.duel) {
				message strcharinfo(0),"The duel has been cancelled.";
				message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
				set .@id,@wait_duelaid;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				close2;
				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.";
		message strcharinfo(0,@wait_duelcid),strcharinfo(0)+" has rejected the duel.";
		set .@id,@wait_duelaid;
		set @wait_duelaid,0;
		set @wait_duelcid,0;
		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 .duel,false;
	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

 

what do you think of setting a message like "the challenger changed his mind. The Death Duel is cancelled." to the one who accepts the duel, after the creator of the duel sends "no" to the confirmation?

mapserv.bat send me this:

image.png.c54dd2a3e9c6b67977035999b42d1a4f.png

but i can't tell you when this happened. Everything else appears to be working 100%. I'll run more tests later, ok? Need to leave right now. Be back in a few hours. Thank you very much!!!

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:  

Just added that. Also added a few checks to try to avoid that message.

-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,@wait_duelcid),"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 .duel,false;
	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

 

Edited by n0tttt
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:  

52 minutes ago, n0tttt said:

Just added that. Also added a few checks to try to avoid that message.


-	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);
		if(isloggedin(@wait_duelaid,@wait_duelcid)) {
			mes "Are you really sure about this duel? ^ff0000Your character will be deleted^000000";
			if(select("No.","Yes.") == 2) {
				close2;
				message strcharinfo(0),"You accepted the duel. Prepare yourself.";
				attachrid @wait_duelaid;
				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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} else {
						setmapflag .duel_map$,mf_pvp,true;
						donpcevent "Duel_Death::OnStuck";
                    			}
					end;
				} else {
					message strcharinfo(0,@wait_duelcid),"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 .duel,false;
	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

 

it looks to be working 100% fine, except for this:

the "buildin_strcharinfo" error, on mapserv.bat happens when i refuse the DD with the player who creates it. And the message that i asked to appears to the player who got invited, doesn't appears.

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:  

What about now?

-	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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} 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 .duel,false;
	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

 

  • 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:  

6 hours ago, n0tttt said:

What about now?


-	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 && isloggedin(.@oid) && isloggedin(.@first_id)) {
						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,0;
                   			} 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 .duel,false;
	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

 

Hi, dude. You've fixed the dialogue issues, including the mapserv.bat error. But now, the death duel isn't starting. The players get recalled to the map, but the countdown doesn't start. ?

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

  • MVP 1
Link to comment
Share on other sites

Join the conversation

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

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