Jump to content
  • 0

@duel with character delection


LucianoCP

Question


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

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

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


-    script    PERMANENTDEATH    -1,{
end;

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

Thanks.

@edit:

Here's the final code by @n0tttt:

-	script	Duel_Death	-1,{

OnCommand:

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

OnAccept:

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

OnReject:

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

OnSpectate:

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

OnFixDuel:

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

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

OnPCLogoutEvent:

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

OnPCLoginEvent:

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

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

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

}

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

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

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

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

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

 

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

Recommended Posts

  • 0

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

8 minutes ago, n0tttt said:

-	script	Duel_Death	-1,{

OnCommand:

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

OnAccept:

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

OnReject:

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

OnSpectate:

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

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

OnPCLogoutEvent:

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

OnPCLoginEvent:

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

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

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

}

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

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

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

If player B select "Yes" on the dialogue menu and logs out after it, the dialogue menu appears to player A. I think that's not an issue, but the script keeps rolling as if player B hasn't logged out. I think should be a check before the announcements "there will be a death duel between A vs (null, because there is no player B)" to cancel it. Look:

image.png.e467ac8b0a7c3d1f98314febb0bfe7e5.png

If player B select "No" in the dialogue menu, both players receive a "the duel has been cancelled", but none explication for it. You see, when player A selects "No" on the dialogue menu, player B is warned that the player A has changed his mind.

Also, what do you think about this: after duelers get recalled, can they be unable to move until the countdown ends? This will avoid they to hide themselves, something like this, you know? Would be nice to block moving skills likes backsliding/high jump.

Link to comment
Share on other sites

  • 0

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

Done. I hope it turns out right.

-	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(@wait_duelaid,@wait_duelcid)) {
						if(!.duel) {
							message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
							announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
							announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
							set .duel,true;
							set .cancel,false;
							removemapflag .duel_map$,mf_pvp;
							removemapflag .duel_map$,mf_pvp_nocalcrank;
							set .@first_id,getcharid(3);
							explode .@xy$,.duel_xy$,",";
							set .@r,rand(2);
							set @duel,.@oid;
							warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
							setoption 0x40,0;
							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;
							}
							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;
								pcblockmove .@first_id,0;
								pcblockmove .@oid,0;
								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),"The challenger changed his mind. The Death Duel is cancelled.";
			}
			set .duel,false;
			set .cancel,false;
			if(playerattached()) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
					set @duel,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				set @duel,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

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

OnSpectate:

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

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

OnPCLogoutEvent:

	if(@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$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

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

}

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

 

Link to comment
Share on other sites

  • 0

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

34 minutes ago, n0tttt said:

Done. I hope it turns out right.


-	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(@wait_duelaid,@wait_duelcid)) {
						if(!.duel) {
							message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
							announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
							announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
							set .duel,true;
							set .cancel,false;
							removemapflag .duel_map$,mf_pvp;
							removemapflag .duel_map$,mf_pvp_nocalcrank;
							set .@first_id,getcharid(3);
							explode .@xy$,.duel_xy$,",";
							set .@r,rand(2);
							set @duel,.@oid;
							warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
							setoption 0x40,0;
							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;
							}
							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;
								pcblockmove .@first_id,0;
								pcblockmove .@oid,0;
								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),"The challenger changed his mind. The Death Duel is cancelled.";
			}
			set .duel,false;
			set .cancel,false;
			if(playerattached()) {
				message strcharinfo(0),"The duel has been cancelled.";
				if(isloggedin(@wait_duelaid,@wait_duelcid)) {
					message strcharinfo(0,@wait_duelcid),"The duel has been cancelled.";
					set @duel_creator,0,@wait_duelcid;
					set @wait_duelaid,0,@wait_duelcid;
					set @wait_duelcid,0,@wait_duelcid;
					set @duel,0,@wait_duelcid;
				}
				set @duel_creator,0;
				set @wait_duelaid,0;
				set @wait_duelcid,0;
				set @duel,0;
				close;
			}
		} else {
			message strcharinfo(0),"The character who challenged you is now offline.";
			set @wait_duelaid,0;
			set @wait_duelcid,0;
		}
	} else {
		message strcharinfo(0),"There is no death duel invite for you right now.";
	}
	close;

OnReject:

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

OnSpectate:

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

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

OnPCLogoutEvent:

	if(@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$,"pvp_n_8-5";
	// Coordinates
	set .duel_xy$, "95,100,"+  // x,y first player
		       "103,100";   // x,y second player
	bindatcmd "deathduel","Duel_Death::OnCommand";
	bindatcmd "acceptdd","Duel_Death::OnAccept";
	bindatcmd "rejectdd","Duel_Death::OnReject";
	bindatcmd "spectatedd","Duel_Death::OnSpectate";

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

}

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

 

When player B types @acceptdd and changes his mind after it, selecting "No" in dialogue menu, player A receives "challenger changed his mind", but player A is the challenger.

When i say "Yes" on both char's dialogue menu, the duel is cancelled.

Some part of the code is causing this: (don't know where exactly, sorry...)

image.png.8fcba967cf614a3515a879a26c0f82e6.png

Link to comment
Share on other sites

  • 0

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

Second error is really weird, since I don't think I changed much, just added the checking of offline characters. Maybe is connected to the other one? Anyways I changed the message. Anyways I added a new command: @fixduel, only usable by GMs. It should help testing and also when the duel gets stuck in a "ghost duel" (it shouldn't happen anyways, but this should help).

-	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(@wait_duelaid,@wait_duelcid)) {
						if(!.duel) {
							message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
							announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
							announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
							set .duel,true;
							set .cancel,false;
							removemapflag .duel_map$,mf_pvp;
							removemapflag .duel_map$,mf_pvp_nocalcrank;
							set .@first_id,getcharid(3);
							explode .@xy$,.duel_xy$,",";
							set .@r,rand(2);
							set @duel,.@oid;
							warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
							setoption 0x40,0;
							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;
							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$,"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";
	bindatcmd "fixduel","Duel_Death::OnFixDuel",60;

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

}

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

 

Link to comment
Share on other sites

  • 0

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

20 minutes ago, n0tttt said:

Second error is really weird, since I don't think I changed much, just added the checking of offline characters. Maybe is connected to the other one? Anyways I changed the message. Anyways I added a new command: @fixduel, only usable by GMs. It should help testing and also when the duel gets stuck in a "ghost duel" (it shouldn't happen anyways, but this should help).


-	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(@wait_duelaid,@wait_duelcid)) {
						if(!.duel) {
							message strcharinfo(0),rid2name(.@oid)+" has accepted the duel.";
							announce strcharinfo(0)+" e "+rid2name(.@oid)+" gonna make a Death Duel where the loser get's his character deleted!",bc_all|bc_blue;
							announce "If you want to spectate use @spectatedd",bc_all|bc_blue;
							set .duel,true;
							set .cancel,false;
							removemapflag .duel_map$,mf_pvp;
							removemapflag .duel_map$,mf_pvp_nocalcrank;
							set .@first_id,getcharid(3);
							explode .@xy$,.duel_xy$,",";
							set .@r,rand(2);
							set @duel,.@oid;
							warp .duel_map$,atoi(.@xy$[2*.@r]),atoi(.@xy$[2*.@r + 1]);
							setoption 0x40,0;
							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;
							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$,"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";
	bindatcmd "fixduel","Duel_Death::OnFixDuel",60;

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

}

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

 

look: when i choose yes on both characters, at dialogue menu, this happens:

image.png.b450b10d9f0c1d3dea1f9011c1cea15f.png

Link to comment
Share on other sites

  • 0

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

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

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

}

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

 

Link to comment
Share on other sites

  • 0

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

24 minutes ago, n0tttt said:

-	script	Duel_Death	-1,{

OnCommand:

	if(.duel) {
		message strcharinfo(0),"There is a duel going on right now. Wait for it to finish.";
	} else if(.duel_delay > gettimetick(2)) {
		message strcharinfo(0),"There's a global delay between duels. You have to wait "+Time2Str(.duel_delay)+".";
	} else if(@wait_duelaid) {
		message strcharinfo(0),"You're already waiting for a confirmation. Relog to cancel.";
	} else {
		set .@player$,strcharinfo(0);
		set .@oid,getcharid(3);
		set .@enemy$,implode(.@atcmd_parameters$," ");
		set .@aid,getcharid(3,.@enemy$);
		set .@cid,getcharid(0,.@enemy$);
		if(!.@aid) {
			message strcharinfo(0),"That character is not online.";
		} else if(getvar(@duel,.@cid)) {
			message strcharinfo(0),"That character is already in a duel.";
		} else if(.@oid == .@aid) {
			message strcharinfo(0),"You can't duel yourself.";
		} else {
			set @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;
							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;
							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$,"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";
	bindatcmd "fixduel","Duel_Death::OnFix",60;

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

}

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

 

can you forbid the use of certain skills like backsliding, high jump until the countdown ends? just like the movement permission.

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:  

db/import/skill_nocast_db.txt

Add:

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

 

And the script:

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

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

}

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

 

  • MVP 1
Link to comment
Share on other sites

  • 0

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

20 minutes ago, n0tttt said:

db/import/skill_nocast_db.txt

Add:


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

 

And the script:


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

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

}

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

 

image.png.1c2698154373646becb2820c17c891fd.png

the account group id is 99, does it allows me to use forbidden skills during the countdown or something is wrong?

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:  

Weird. By default GMs don't have that permission. What does @mapinfo show?

Link to comment
Share on other sites

  • 0

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

12 minutes ago, n0tttt said:

Weird. By default GMs don't have that permission. What does @mapinfo show?

image.png.85eef1d09335f1b92a118c63904bf7a8.png

i update the files, script and skill_nocast_db.txt and typed @reloadscript and @reloadskilldb ingame. Is this right?

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:  

Oh, I get it now. That map had its own mapflags beforehand, and it has the default pvp restricted one. You could duplicate it with this:
 

resnametable is in the data folder. map_index in db/import and maps_athena.conf in conf.

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:  

28 minutes ago, n0tttt said:

Oh, I get it now. That map had its own mapflags beforehand, and it has the default pvp restricted one. You could duplicate it with this:
 

resnametable is in the data folder. map_index in db/import and maps_athena.conf in conf.

image.png.58fb9d28dc1e0a31819072329111b72a.png

image.png.fabe707abe22cedaad53b69a7436bfdd.png

?

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:  

38 minutes ago, n0tttt said:

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

 

it does:

image.png.83ca2f39329bd46ba3515f6a73f63e4c.png

i'll test this last code and update this post soon.

@edit:

i'm still able to use backsliding

@edit2:

it's the group_id. tried to use with a normal account and it worked, i was unnable to use backsliding. So... Thank you!!!!

I'll fix your code at the first post. If any bug appears, i'll contact you (;

Edited by LucianoCP
  • Love 2
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:  

On 11/27/2018 at 7:47 PM, 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

 

http://prntscr.com/qqxcjz

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  830
  • Reputation:   316
  • Joined:  02/11/19
  • Last Seen:  

25 minutes ago, IsabelaFernandez said:
// Map
	set .duel_map$,"map";
	// Coordinates
	set .duel_xy$, "x,y,"+  // x,y first player
		       "x,y";   // x,y second player
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

You need to define this.

Edited by Mael
more info
  • Upvote 1
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:  

9 minutes ago, Mael said:

// Map
	set .duel_map$,"map";
	// Coordinates
	set .duel_xy$, "x,y,"+  // x,y first player
		       "x,y";   // x,y second player

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

You need to define this.

 

thanks, I managed to fix it. is it possible to make this script active only by GM? selecting the two players for the duel?

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  830
  • Reputation:   316
  • Joined:  02/11/19
  • Last Seen:  

6 minutes ago, IsabelaFernandez said:

 

thanks, I managed to fix it. is it possible to make this script active only by GM? selecting the two players for the duel?

I recommend using a bg pvp script, this script I think replaces @duel.

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:  

17 hours ago, Mael said:

I recommend using a bg pvp script, this script I think replaces @duel.

 

instead of being just a command for GM, would it be possible to create an NPC to perform this function? the player would enter the other player's nick for the duel

 

that would solve my problem /ic/thx

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