Jump to content
  • 0

PVP ranks with announcement


asnizam

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   0
  • Joined:  09/19/18
  • Last Seen:  

//===== rAthena Script =======================================
//= PVP System
//===== By: ==================================================
//= hurtsky
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= PVP Controller System + Anti Abuse
//===== Additional Comments: =================================
//= 1.0	Initial script.
//=	1.1	reset abuseTime if #Abuse = 0
//=		make AntiAbuse configureable
//=		add announcer sound
//============================================================
//============================================================
//= PVP System
//============================================================
-	script	PVP_System	-1,{
	end;

//===== Abuse deduction progress / timer part=================
OnPCLoginEvent:
OnTimer60000:
	// collect current time!
	.@resetTime = gettimetick(2);
	
	if ( $enable_debug == 1 )
		debugmes "abuse reset timer started";

	// collect attach information!
	.@RID = getattachedrid();
	.@abuserName$ = rid2name ( .@RID );
	
	if ( $enable_debug == 1 ) {
		debugmes " RID " + .@RID;
		debugmes " Abuser Name = " + .@abuserName$;
		debugmes " player abuse point is = " + #Abuse;
	}
	
	// stop timer and reset abuseTIme when #Abuse already 0
	if ( #Abuse <= 0 ) {
		abuseTime = 0;
		#Abuse = 0;
		if ( getnpctimer(0) > 0 )
			stopnpctimer;
		end;
	}
	
	/* 
	 * differentiation from last abuse time and current loginTime time
	 * might bigger than reset time multiple by collect Abuse point
	 * in that case just reduce the Abuse point to 0
	 */
	if ( #Abuse > 0 ) {
	
		if ( $enable_debug == 1 )
			debugmes "entering #Abuse > 0";

		.@reduceTimeCal = #Abuse * .reduceTime;

		if ( $enable_debug == 1 )
			debugmes "#Abuse * .reduceTime = " + .@reduceTimeCal;

		.@curTime = .@resetTime - abuseTime;

		if ( $enable_debug == 1 )
			debugmes ".@resetTime - abuseTime = " + .@curTime;
	
		if ( .@curTime >= .@reduceTimeCal ) {

			if ( $enable_debug == 1 )
				debugmes .@curTime + " >= " + .@reduceTimeCal;

			#Abuse = 0;
			end;
		}
	}

	/*
	 * check every 1 minutes for Abuse point deduction
	 * deduct an abuse / a feed score every 1 minutes;
	 */
	if ( abuseTime > 0 ) {
		// only check when #Abuse > 0 
		if ( #Abuse > 0 ) {
		
			if ( $enable_debug == 1 )
				debugmes "entering abuse > 0 ";

			.@abuseCal = .@resetTime - abuseTime;

			if ( $enable_debug == 1 )
				debugmes ".@abuseCal = " + .@abuseCal;

			if ( .@abuseCal >= .reduceTime ) {
				#Abuse--;
				dispbottom "Your Abuse point been reduce to = " + #Abuse;

				if ( $enable_debug == 1 )
					debugmes "reduce #Abuse to = " + #Abuse;

				// reset abuse time to current reset time
				abuseTime = .@resetTime;
			}
			if ( #Abuse > 0 ) {
			
				if ( $enable_debug == 1 )
					debugmes "restart timer because still have abuse point";

				attachnpctimer .@abuserName$;
				initnpctimer;
			}
		}
		end;
	}

	if ( #Abuse >= 5 ) {

		if ( $enable_debug == 1 )
			debugmes "entering abuse >= 5 ";

		.@abuseCal = .@resetTime - lastAbuseTime;

		if ( $enable_debug == 1 )
			debugmes ".@abuseCal = " + .@abuseCal;

		if ( .@abuseCal >= .recordStop ) {
			lastAbuseTime = 0;
			#Abuse = 0;

			if ( $enable_debug == 1 )
				debugmes " reset abuse to " + #Abuse;

			//stop timer if got initimer
			if ( getnpctimer(0) > 0 )
				stopnpctimer;
		}
		if ( .@abuseCal < .recordStop ) {
			// restart timer if still enough 5mins

			if ( $enable_debug == 1 )
				debugmes "restart timer because not enought 5mins";

			attachnpctimer .@abuserName$;
			initnpctimer;
		}
		end;
	}
	
	// extra check if there are Abuse point timer should restart
	if ( #Abuse > 0 ) {

		if ( $enable_debug == 1 ) {
			debugmes "extra check!!";
			debugmes "restart timer because still have abuse point";
		}

		if ( getnpctimer(0) > 0 )
			stopnpctimer;
		attachnpctimer .@abuserName$;
		initnpctimer;
	}
	end;

//===== Abuse deduction progress / timer part=================
OnPCDieEvent:
	if ( $enable_debug == 1 )
		debugmes "killerid = " + killerrid;

	// mark the die sessions
	.@onDieSession = 1;
	.@account_id = getcharid(3);
	.@char_id = getcharid(0);
	.@charName$ = strcharinfo(0);
	.@charLoc$ = strcharinfo(3);
	callfunc ( "F_pvpReqChecks" , .@charLoc$ , .gmLvl , .gmBypass , .@onDieSession );
	currentDieTime = gettimetick(2);
	newKillerName$ = rid2name ( killerrid );

	if ( .antiAbuse ) {
		callfunc ( "F_pvpAbuseCheck" , 
		.recordStop , .@onDieSession , .@charName$ , 
		.recordDelay , .abuse , .penalty , .recordDelayEnable );
		
		oldKillerName$ = newKillerName$;
	}
	
	dispbottom newKillerName$ + " just kill you";
	Death++;
	lastDieTime = gettimetick(2);
	callfunc ( "F_pvpUpdateRec" , .@char_id , .@account_id , .@charName$ );
	.@onDieSession = 0;
	end;

OnPCKillEvent:
	// mark the kill sessions
	if ( $enable_debug == 1 )
		debugmes "killedrid = " + killedrid;

	.@onKillSession = 2;
	.@account_id = getcharid(3);
	.@char_id = getcharid(0);
	.@charName$ = strcharinfo(0);
	.@charLoc$ = strcharinfo(3);
	callfunc ( "F_pvpReqChecks" , @charLoc$ , .gmLvl , .gmBypass , .@onKillSession );
	currentKillTime = gettimetick(2);
	newVictimName$ = rid2name ( killedrid );

	if ( .antiAbuse ) {
		callfunc ( "F_pvpAbuseCheck" , 
		.recordStop , .@onKillSession , .@charName$ ,
		.recordDelay , .abuse , .penalty , .recordDelayEnable );
		
		oldVictimName$ = newVictimName$;
	}

	.@streakTime = currentKillTime - lastKillTime;
	if ( .@streakTime <= .streakTime )
		KillingStreak++;
	else
		KillingStreak = 0;

	.@killAnnounce$ = .@charName$ + " just kill " + newVictimName$ + " at " + .@charLoc$ + ".";

	switch ( KillingStreak ) {
		case 0:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " First Blood!!! ",bc_blue|bc_all;
			soundeffect "0_firstblood_KS1.wav", 0;
			break;
		case 1:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Double Kill!!! ",bc_blue|bc_all;
			soundeffect "0_doublekill_MK2.wav", 0;
			MultiKill++
			DoubleKill++;
			break;
		case 2:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Triple Kill!!! ",bc_blue|bc_all;
			soundeffect "0_killingspree_KS3.wav", 0;
			soundeffect "0_tripplekill_MK3.wav", 0;
			TripleKill++;
			KillingSpree++;
			break;
		case 3:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Dominating!!! ",bc_blue|bc_all;
			soundeffect "0_dominating_KS4.wav", 0;
			soundeffect "0_ultrakill_MK4.wav", 0;
			Dominating++;
			UltraKill++;
			break;
		case 4:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Rampage!!! ",bc_blue|bc_all;
			soundeffect "0_megakill_KS5.wav", 0;
			soundeffect "0_rampage_MK5.wav", 0;
			Rampage++;
			MegaKill++;
			break;
		case 5:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Owning!!! ",bc_blue|bc_all;
			soundeffect "0_unstopable_KS6.wav", 0;
			soundeffect "0_ownage_MK6.wav", 0;
			Ownage++;
			Unstoppable++;
			break;
		case 6:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Wicked Sick!!! ",bc_blue|bc_all;
			soundeffect "0_wickedsick_KS7.wav", 0;
			soundeffect "0_ownage_MK6.wav", 0;
			Ownage++;
			WickedSick++;
			break;
		case 7:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Monster Kill!!!! ",bc_blue|bc_all;
			soundeffect "0_monsterkill_KS8.wav", 0;
			soundeffect "0_ownage_MK6.wav", 0;
			Ownage++;
			MonsterKill++;
			break;
		case 8:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Godlike!!!! ",bc_blue|bc_all;
			soundeffect "0_godlike_KS9.wav", 0;
			soundeffect "0_ownage_MK6.wav", 0;
			Ownage++;
			GodLike++;
			break;
		case 9:
		case 10:
		case 11:
		case 12:
		case 13:
		case 14:
		case 15:
		case 16:
		case 17:
		case 18:
		case 19:
			announce .@killAnnounce$,bc_blue|bc_all;
			announce .@charName$ + " Beyond GodLike!!!! ",bc_blue|bc_all;
			soundeffect "0_beyondgodlike_KS10.wav", 0;
			soundeffect "0_ownage_MK6.wav", 0;
			Ownage++;
			BeyondGodLike++;
			break;
		default:
			break;
	}
	Kill++;
	lastKillTime = gettimetick(2);
	callfunc ( "F_pvpUpdateRec" , .@char_id , .@account_id , .@charName$ );
	.@onKillSession = 0;
	end;

OnInit:
	query_sql ( " CREATE TABLE IF NOT EXISTS `pvp_rank` "
		+ " ( "
		+ " `char_id` int(11) NOT NULL, "
		+ " `account_id` int(11) NOT NULL, " 
		+ " `char` varchar(30) NOT NULL, "
		+ " `kill` int(11) NOT NULL, "
		+ " `death` int(11) NOT NULL, "
		+ " `kdr` varchar(30) NOT NULL, "
		+ " `killingstreak` int(11) NOT NULL, "
		+ " `multikill` int(11) NOT NULL, "
		+ " `killingspree` int(11) NOT NULL, "
		+ " `dominating` int(11) NOT NULL, "
		+ " `megakill` int(11) NOT NULL, "
		+ " `unstoppable` int(11) NOT NULL, "
		+ " `wickedsick` int(11) NOT NULL, "
		+ " `monsterkill` int(11) NOT NULL, "
		+ " `godlike` int(11) NOT NULL, "
		+ " `beyondgodlike` int(11) NOT NULL, "
		+ " `doublekill` int(11) NOT NULL, "
		+ " `triplekill` int(11) NOT NULL, "
		+ " `ultrakill` int(11) NOT NULL, "
		+ " `rampage` int(11) NOT NULL, "
		+ " `ownage` int(11) NOT NULL, "
		+ " `nemesiskill` int(11) NOT NULL, "
		+ " `feedcount` int(11) NOT NULL, "
		+ " `abuse` int(11) NOT NULL, "
		+ " `mmr`int(11) NOT NULL, "
		+ " PRIMARY KEY (`char_id`) "
		+ " ) "
		+ " ENGINE=MyISAM DEFAULT CHARSET=latin1" );

//===== Anti abuse configuration

	// enable anti abuse = 1
	.antiAbuse = 1;
	
	// when the player abuse == 5 time kill same player, stop the pvp record for in seconds
	.recordStop = 300;		// 5minutes
	
	// reduce 1 abuse point in 1 minutes (default) if player not adding any abuse point 
	// = MUST HIGHER THAN 1 MINUTES!
	.reduceTime = 60; 		// 1minute
	
	// don't record if the killer kill in this delay time 
	// = default 5 seconds
	.recordDelayEnable = 1;
	.recordDelay = 5;
	
	// deduct kill points after player tag as Abuser
	.penalty = 6;
	
	// tag abuse if 5 time for same name
	.abuse = 5;
	
//===== End of Anti abuse configuration

	// streak time cooldown
	.streakTime = 60;

	// set lowest level of gm to not include in record
	// 0 = disable gmcheck! 1 = enable GM check!
	.gmBypass = 0; 
	.gmLvl = 6;
	
	// change to map name if you want specific map like , "prontera" , "geffen";
	setarray $pvpMap$[0],"pvp_y_8-2";
	end;
}
      
      
 ----------------------------------------------------------------
      
      //===== rAthena Script =======================================
//= PVP System Function
//===== By: ==================================================
//= hurtsky
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= PVP Function
//===== Additional Comments: =================================
//= 1.0	Initial script.
//=	1.1	add check for monsterID
//=	1.2	add PVP update record - save record to table
//=	1.3	re-arrange functions
//=		pull our killer/victim name check as F_pvpAbuseName
//=		only annouce abuser/feed after 4 times continuous
//=		abuser/feed.
//=		add sound for feeder
//=	1.4	fix F_pvpUpdateRec function argument
//=	1.5	combine all anti abuse function into one check
//============================================================
//============================================================
//= PVP System Function
//============================================================
function	script	F_pvpReqChecks	{

	// only records players
	if ( getarg(3) == 1 ) {
		if ( killerrid < 2000000 ) || ( killerrid > 3000000 )
			end;
	}
	
	if ( getarg(3) == 2 ) {
		if ( killedrid < 2000000 ) || ( killedrid > 3000000 )
			end;
	}

	// check gm enable or not
	if ( getarg(2) ) {
		if ( getgroupid() >= getarg(1) )
			end;
	}

	.@pvpMapSize = getarraysize ( $pvpMap$ );
	// don't detect die if not in pvp maps
	if ( $pvpMap$[0] != "ALL" ) {
		for ( .@i = 0; .@i < .@pvpMapSize; .@i++ ) {
			if ( getarg(0) != $pvpMap$[.@i] ) {
				end;
			}
		}
	}
	
	return;			// return if all check pass
}

function	script	F_pvpAbuseCheck	{
	
/*
	.recordStop			=	getarg(0)
	.@onDie/KillSession	=	getarg(1)
	.@charName$			=	getarg(2) 
	.recordDelay		=	getarg(3)
	.abuse				=	getarg(4)
	.penalty			=	getarg(5)
	.recordDelayEnable	=	getarg(6)
*/

	// check if already tagged as abuser
	// dont record them
	if ( lastAbuseTime > 0 ) {
		if ( getarg(1) == 1 ) {
			.@dieKillTime = currentDieTime;
		} else {
			.@dieKillTime = currentKillTime;
		}
		.@abuseCal = .@dieKillTime - lastAbuseTime;
		if ( getarg(0) >= 60 ) {
			.@recordStopMin = getarg(0) / 60;
			.@recordStopWord$ = "minutes";
		}
		if ( getarg(0) < 60 ) {
			.@recordStopMin = getarg(0);
			.@recordStopWord$ = "seconds";
		}
		if ( .@abuseCal < getarg(0) ) {
			dispbottom "You're tagged as PVP Abuser";
			dispbottom "No record will done in " + .@recordStopMin + " " + .@recordStopWord$;
			end;
		}
		if ( .@abuseCal > getarg(0) ) {
			lastAbuseTime = 0;
			#Abuse = 0;
		}
	}

	// record abuse time
	if ( getarg(1) == 1 ) {
		if ( newKillerName$ == oldKillerName$ ) {
			//delay the time record if same name kill the player
			if ( getarg(6) ) {
				.@delayRecord = currentDieTime - lastDieTime;					
				if ( .@delayRecord <= getarg(3) )
					end;
			}
			abuseTime = currentDieTime;
		}
	} else {
		if ( newVictimName$ == oldVictimName$ ) {
			//delay the time record if same name kill the player
			if ( getarg(6) ) {
				.@delayRecord = currentKillTime - lastKillTime;					
				if ( .@delayRecord <= getarg(3) ) {
					end;
				}
			}
			abuseTime = currentKillTime;
		}
	}
	#Abuse++;
	attachnpctimer getarg(2);
	initnpctimer;

	// tag abuse if more than abuse limit
	if ( #Abuse >= getarg(4) ) {
		dispbottom "You're already tagged as abuser!";
		dispbottom "Your kill and die wont be count until Abuse timer reseted";
		dispbottom "Your Kill Score been deduct by " + getarg(5);
		if ( Kill <= getarg(5) )
			Kill = 0;
		else 
			Kill = Kill - getarg(5);
		dispbottom "Your Kill Score now = " + Kill + " kills";
		lastAbuseTime = gettimetick(2);
		Abuser++;
		// delete abuseTime record! because we will just make the abuser wait 5minutes
		abuseTime = 0;
		//stop timer if got initimer
		if ( getnpctimer(0) > 0 )
			stopnpctimer;
		attachnpctimer getarg(2);
		initnpctimer;
		end;
	}

	if ( getarg(1) == 1 ) {
		if ( #Abuse >= getarg(4) ){
			announce strcharinfo(0) + " just feed " + newKillerName$ +" for " + #Abuse + " times.",bc_blue|bc_all;
			soundeffect "Feeder.wav", 0;
		}
	} else {
		if ( #Abuse >= getarg(4) )
			announce strcharinfo(0) + " abuse " + newVictimName$ +" for " + #Abuse + " times.",bc_blue|bc_all;
	}

	return;
}

function	script	F_pvpUpdateRec	{
	query_sql ( " REPLACE INTO `pvp_rank` "
		+ " ( `char_id`, `account_id`, `char` "
		+ " , `kill` , `death`, `kdr` "
		+ " , `killingstreak` , `multikill` , `nemesiskill` "
		+ " , `abuse` ,`killingspree` , `dominating` "
		+ " , `megakill` , `unstoppable` , `wickedsick` "
		+ " , `monsterkill` , `godlike` , `beyondgodlike` "
		+ " , `doublekill` , `triplekill` , `ultrakill` "
		+ " , `rampage` , `ownage` , `feedcount` "
		+ " , `mmr` ) "
		+ " VALUES "
		+ " ( " + getarg(0) + " , " + getarg(1) +" , '" + getarg(2) + "' "
		+ " , " + Kill + " , " + Death + " , '" + KDR + "' "
		+ " , " + KillingStreak + " , " + MultiKill + " , " + NemesisKill + " "
		+ " , " + Abuser + " , " + KillingSpree + " , " + Dominating + " "
		+ " , " + MegaKill + " , " + Unstoppable + " , " + WickedSick + " "
		+ " , " + MonsterKill + " , " + Godlike + " , " + BeyondGodlike + " "
		+ " , " + DoubleKill + " , " + TripleKill + " , " + UltraKill + " "
		+ " , " + Rampage + " , " + Ownage + " , " + Feedcount + " "
		+ " , " + MMR + " ) " );
	return;
}

Dear all,

Please help me to solve issue below:

1. The ranks seems like only work with "death" variables, i assume even "kill" point count as death since i dont have any data for other variables (KDR and KILL). When i opened the pvp_rank, only "death" data has been captured.

2. The "text" announcement not working with me.

 

Thanks.

 

Regards,

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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