Jump to content
  • 0
DR4LUC0N

How to transform this into checking party member Unique_id(gepard)

Question

So I have a script that checks for party members IP, but I'd like to also have it check their Unique_id(to prevent using a different PC without VPN and to prevent using same PC with VPN) I've been knocking my head on the table for an hour now trying to figure it out. I'm using SQL because I'm having the table get TRUNCATED at OnClock0000(couldn't find any other way to remove everyones variable).

 

//===== rAthena Script =======================================
//= MVP Ladder Game
//===== By: ==================================================
//= aftermath, AnnieRuru (rewrite)
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Gather a party and kill every MVP in ascending order.
//===== Additional Comments: =================================
//= 1.0 First version, edited. [Euphy]
//============================================================

veil,81,134,6	script	Quistis Trepe	10414,{
	.gui = get_unique_id ();
	[email protected] = query_sql("SELECT `bloodybranch` FROM `bloody_branch` WHERE `unique_id` = "+.gui+" LIMIT 1", [email protected]);
	
	mes "[Quistis Trepe]";
	mes "Say... do you want to play the MvP Ladder game? It cost 15 Vote Coins Per person, total of 30 Vote Coins now to get in.";
	next;
	switch(select("Yes, let's get it on!:Information.:Show me the best record.:No.")) {
		case 1:
			if ([email protected] <= 0) {
				break;
			} else if ([email protected] >= 1) {
				mes "You have already completed the Bloody Branch Quest for today. Come back tomorrow after 12:00am server time.";
				close;
			}
			
		
		case 2:
			mes "[Quistis Trepe]";
			mes "In this game, your party has to kill every single MvP monster in ascending order, from the weakest to strongest.";
			if ( .finish_item_amount )
				mes "If your party can finish the MVP ladder game, each member will earn "+ callfunc("F_InsertPlural", .finish_item_amount, getitemname( .finish_item_id )) +".";
			if ( .register_cost )
//				mes "But the entrance fee is "+ callfunc( "F_InsertComma", .register_cost ) +" zeny.";
				mes "But the entrance fee is 15 vote coins per person, which means 30 Vote Coin total.";
				mes "Everyone need to vote on the websites to get 300 Vote Point, you can exchange them for 30 Vote Coins with the VoteForPoints Npc";
			next;
			mes "[Quistis Trepe]";
			mes "You lose the game if you can't finish in "+ .timeout +" minutes, or if your entire party is killed.";
			mes "Good luck!";
			close;
		
		case 3:
			mes "[Quistis Trepe]";
			if ( !$mvpladdderparty_time ) {
				mes "Nobody has finished this game yet.";
				close;
			}
			mes "The best record is";
			mes "[ "+( $mvpladdderparty_time / 60 )+" min "+( $mvpladdderparty_time % 60 )+" sec ]";
			mes "By the party ^FF0000"+ $mvpladdderparty_name$ +"^000000.";
			[email protected] = getarraysize( $mvpladderparty_member$ );
			for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ )
				mes "^000000"+ ( [email protected] +1 ) +". ^0000FF"+ $mvpladderparty_member$[[email protected]];
			if ( getgmlevel() < .gmlvlreset ) close;
			next;
			if ( select( "Close.", "Reset the record." ) == 1 ) close;
			if ( select( "Never mind.", "I really want to reset it." ) == 1 ) close;
			$mvpladdderparty_time = 0;
			$mvpladdderparty_name$ = "";
			deletearray $mvpladderparty_member$[[email protected]];
			mes "[Quistis Trepe]";
			mes "Record reset successfully.";
			close;
			
		case 4:
			mes "[Quistis Trepe]";
			mes "When you are strong enough to complete the game, please come back.";
			close;
		}
		
	if ( !getcharid(1) ) {
		mes "[Quistis Trepe]";
		mes "You have to form a party to play.";
		close;
	}
	
	if ( is_party_leader() == false ) {
		mes "[Quistis Trepe]";
		mes "Only the party leader can register.";
		close;
	}
	
	[email protected] = getcharid(3);
	getpartymember getcharid(1),1;
	getpartymember getcharid(1),2;
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
		if (isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) == 0)
		continue;{
			[email protected] = readparam( Class, [email protected][[email protected]] );
			if (compare( [email protected]_list$, "|" + [email protected] + "|" ) == 1) {
				mes "Sorry, only one " + jobname([email protected]) + " is allowed.";
				close;
			}
		[email protected]_list$ += "|" + [email protected] + "|";
		[email protected]++;
		}	
	}
	
// START OF NEW CHECK - [Duplicate IP in one party?]
	attachrid [email protected];
	// for IP check
	set [email protected]_list$, "";
	set [email protected]_list$, "";
	set [email protected], 0;
	
	// Check Party Members
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
		if (isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) == 0)
		continue;{
			attachrid [email protected][[email protected]];
			query_sql ("SELECT `last_ip` FROM `login` WHERE `account_id`=" + [email protected][[email protected]] + "", [email protected]$);
			// If same IP is on party
			if(compare([email protected]_list$, "|" + [email protected]$ + "|" ) == 1) {
				set [email protected], 1;
			} else 
				// Add IP to party list for checking
				[email protected]_list$ += "|" + [email protected]$ + "|";
			
			// If acc has entered ladder
			if (compare( .en_acc_list$, "|" + getcharid(3,strcharinfo(0)) + "|" ) == 1) {
				if([email protected]_list$ == "")
					[email protected]_list$ += strcharinfo(0);
				else
					[email protected]_list$ += ", " + strcharinfo(0);
			}
		}	
	}
	
	// Get back to PTL to display message
	attachrid [email protected];
	
	if([email protected]) {
		mes "Sorry, party members with the same IP address can't enter.";
		close;
	}
	
	if([email protected]_list$ != "") {
		mes "Sorry, the following people has already entered the ladder today:";
		mes [email protected]_list$;
		close;
	}
	
// END OF NEW CHECK
	else if ( [email protected] != .register_min ) {
		mes "[Quistis Trepe]";
		mes "You have to form a party with exactly "+ .register_min +" different classes members to play.";
		close;
	}
	
	else if ( [email protected] != .register_min )  {
		mes "[Quistis Trepe]";
		mes "Your party must have "+ .register_min +" members online on map '"+ strnpcinfo(4) +"'.";
		close;
	}
	
	else if (countitem(34207) < 15) {
		mes "[Quistis Trepe]";
		mes "You don't have 15 vote coins. Please come back when you do.";
		close;
	}
	
// PTL has 5 miths, check for other pt members
	else if (countitem(34207) > 14) {
		for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
			attachrid [email protected][[email protected]];
			if (countitem(34207) < 15) {
				attachrid [email protected];
				mes "[Quistis Trepe]";
				mes "You don't have 15 Vote Points. Please come back when you do.";
				close;
			}
		}
		attachrid [email protected];
	}
	
	if ( .party_id ) {
		mes "[Quistis Trepe]";
		mes "I'm sorry, but a party is currently playing the game. Please standby until the party is finished.";
		mes "Thank you.";
		close;
	}
	
	announce "The party ["+ strcharinfo(1) +"] has started the MvP ladder game.", bc_all;
	// Delete mithril coins for each PT member
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
		attachrid [email protected][[email protected]];
		delitem 34207,15;
	}
	
	attachrid [email protected];
	set .party_id, getcharid(1);
	set [email protected]_enter, gettimetick(2);
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
		if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {
			attachrid [email protected][[email protected]];
			if ( strcharinfo(3) == strnpcinfo(4) ) {
				announce "You have "+ .timeout +" minutes to complete "+ .totalround +" rounds.", bc_self;
				[email protected]$[[email protected]] = strcharinfo(0);
				[email protected]++;
			}
		}
	}
	
	cleanmap .eventmap$;
	warpparty .eventmap$, 0,0, .party_id, strnpcinfo(4);
	attachrid [email protected];
	mes "hello";
	donpcevent strnpcinfo(0)+"::OnMvpDead";
	sleep .timeout * 60000;
	if ( .round == .totalround +1 ) {
		getpartymember .party_id, 1;
		getpartymember .party_id, 2;
		mapannounce .eventmap$, "Congratulations... You were able to defeat all the MVPs!", bc_map;
		for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
			if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {
				attachrid [email protected][[email protected]];
				query_sql ("SELECT `last_ip` FROM `login` WHERE `account_id`=" + [email protected][[email protected]] + "", [email protected]$);
				if ( strcharinfo(3) == .eventmap$ )
					getitem .finish_item_id, .finish_item_amount;
					query_sql( "INSERT INTO `bloody_branch` VALUES ("+.gui+", 1)");
				.entered_list$ += "|" + [email protected]$ + "|";
				.en_acc_list$ += "|" + getcharid(3,strcharinfo(0)) + "|";
			}
		}
		
		set [email protected] , getcharid(3,strcharinfo(0));
		addrid (2,0,getcharid(1)); //attach the rid of all players in the group
		set questdelay,gettimetick(2)+86400; //set the delay for all players in group
		detachrid;
		attachrid([email protected]); //so that the rest of the script will only run on the party leader		
		set [email protected], gettimetick(2) - [email protected]_enter;
		if ( .bonus_item_amount && [email protected] < .bonus_time * 60 ) {
			mapannounce .eventmap$, "You are rewarded a bonus item for completing the ladder within "+ .bonus_time +" minutes.", bc_map;
			for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
				if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {
					attachrid [email protected][[email protected]];
					if ( strcharinfo(3) == .eventmap$ )
						getitem .bonus_item_id, .bonus_item_amount;
				}
			}
		}

		if ( !$mvpladdderparty_time || [email protected] < $mvpladdderparty_time ) {
			mapannounce .eventmap$, "And you broke the record! [ "+( [email protected] / 60 )+" min "+( [email protected] % 60 )+" sec ]", bc_map;
			set $mvpladdderparty_time, [email protected];
			set $mvpladdderparty_name$, getpartyname( .party_id );
			copyarray $mvpladderparty_member$, [email protected]$, .register_min;
		}
		else
			mapannounce .eventmap$, "Time used [ "+( [email protected] / 60 )+" min "+( [email protected] % 60 )+" sec ]", bc_map;
		sleep 10000;
		announce "Player ["+ [email protected]$ +"] of the party ["+ getpartyname( .party_id ) +"] has finished the Bloody Branch Quest!", bc_all;
	}
	else
		announce "Player ["+ [email protected]$ +"] of the party ["+ getpartyname( .party_id ) +"] has failed to finish the MvP ladder game.", bc_all;
	mapwarp .eventmap$, .map$, .x, .y;
	killmonsterall .eventmap$;
	.party_id = .round = 0;
	end;

OnMvpDead:
	getpartymember .party_id, 1;
	getpartymember .party_id, 2;
	.round++;
	if ( .round >= 2 && .round != .totalround +1 && .round_item_amount ) {
		for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
			if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {
				attachrid [email protected][[email protected]];
				if ( strcharinfo(3) == .eventmap$ )
					getitem .round_item_id, .round_item_amount;
			}
		}
	}
	if ( .round == .totalround +1 ) {
		awake strnpcinfo(0);
		end;
	}
	else if ( .round == .totalround )
		mapannounce .eventmap$, "The final Round will begin in "+ .delay +" seconds...", bc_map;
	else
		mapannounce .eventmap$, "Starting round "+ .round +" in "+ .delay +" seconds...", bc_map;
	sleep .delay * 1000;
	if ( .mvpid[.round] == 1646 )  // pick random Bio3 MVP
		.mvpid[.round] = rand(1646,1651);
	monster .eventmap$,0,0, "--ja--", .mvpid[.round], 1, strnpcinfo(0)+"::OnMvpDead";
	mapannounce .eventmap$, getmonsterinfo( .mvpid[.round], MOB_NAME ) +" has spawned!", bc_map|bc_blue;
	end;

OnPCLogoutEvent:
	if ( hp > 0 )
		[email protected]_one = 1;
	else
		end;
		
OnPCDieEvent:
	if ( strcharinfo(3) != .eventmap$ || !getcharid(1) ) end;
	if ( getcharid(1) != .party_id ) end;
	getpartymember .party_id, 1;
	getpartymember .party_id, 2;
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
		if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {
			attachrid [email protected][[email protected]];
			if ( strcharinfo(3) == .eventmap$ && hp > 0 )
				[email protected]++;
		}
	}
	if ( [email protected]_one )
		[email protected];
	if ( [email protected] ) {
		mapannounce .eventmap$, "Party wiped!", bc_map;
		sleep 10000;
		awake strnpcinfo(0);
	}
	end;

OnClock0000:
	set .entered_list$, "";
	set .en_acc_list$, "";
	query_sql "truncate table bloody_branch";
	end;

OnInit:
	set .entered_list$, "";
	set .en_acc_list$, "";
//	Configurations -----------------------------------------------------

	// Time limit (in minutes)
	// When time runs out, all players inside the room will be kicked out.
	// Do NOT set this to zero!
	set .timeout, 30;

	// entrance fee (in Zeny)
	set .register_cost, 200000000;

	// exact amount of party members needed to start the game
	set .register_min, 2;

	// id of each mvp. you can add more
	setarray .mvpid[1],
		1086,//	Golden Thief Bug	64
//		1651,// H.Wizz				99
		1115,//	Eddga				65
		1150,//	Moonlight Flower	67
		1159,//	Phreeoni			69
		1112,//	Drake				70
		1583,//	Tao Gunka			70
		1492,//	Incantation Samurai	71
		1046,//	Doppelgangger		72
//		1649,// H.Priest			99
		1252,//	Garm				73
		1418,//	Evil Snake Lord		73
		1059,//	Mistress			74
		1190,//	Orc Lord			74
//		1646,// Lord Knight			99
		1087,//	Orc Hero			77
		1251,//	Knight of Windstorm	77
		1038,//	Osiris				78
//		1658,//	Ygnizem				79
//		1647,// Assassin X			99
		1272,//	Dark Lord			80
		1871,//	Fallen Bishop		80
		1039,//	Baphomet			81
		1147,//	Maya				81
//		1650,// Sniper Cecil		99
		1785,//	Atroce				82
		1389,//	Dracula				85
		1630,//	Bacsojin			85
		1885,//	Gorynych			85
		1623,//	RSX 0806			86
		1511,//	Amon Ra				88
//		1648,// Whitesmith			99
		1688,//	Lady Tanee			89
		1768,//	Gloom Under Night	89
		1719,//	Datale				90
		1734,//	Kiel D-01			90
		1157,//	Pharaoh				93
		1373,//	Lord of Death		94
		1312,//	Turtle General		97
		1779,//	Ktullanux			98
		1874,//	Beelzebub			98
//		1646,// Bio3 placeholder    99
		1708,//	Thanatos			99
		1751,//	Valkyrie Randgris	99
		1832;//	Ifrit				99


	// number of rounds (default: 39)
	//set .totalround, getarraysize(.mvpid) -1;
	set .totalround, 30; //if you want 35 rounds

	// item reward for completing each round
//	set .round_item_id, 607;
//	set .round_item_amount, 1;

	// item reward for completing the entire ladder
	set .finish_item_id, 12103;
	set .finish_item_amount, 20;

	// bonus reward if ladder completed within a certain time (in minutes)
	set .bonus_time, 15; // if completed within 15 minutes, this reward is given
	set .bonus_item_id, 12103;
	set .bonus_item_amount, 5;

	// time delay between rounds, in seconds (default: 3)
	set .delay, 3;

	// minimum GM level to reset the best record
	set .gmlvlreset, 99;

	// event map
	set .eventmap$, "cguild_vs22";

	// mapflag configuration
	setarray [email protected],
		mf_nowarp,
		mf_nowarpto,
		mf_nosave,
		mf_nomemo,
		mf_noteleport,
//		mf_nopenalty, // disable exp loss
		mf_noreturn,
//		mf_nobranch,
//		mf_nomobloot, // disable monster drop loots,
//		mf_nomvploot, // 2 of these
//		mf_nodrop,
		mf_partylock;

//	Config Ends --------------------------------------------------------------

	mapannounce .eventmap$, "An administrator has refreshed the server. Please re-register. We apologize for the inconvenience.", bc_map;
	getmapxy .map$, .x, .y, BL_NPC;
	mapwarp .eventmap$, .map$, .x, .y;
	killmonsterall .eventmap$;
	[email protected] = getarraysize( [email protected] );
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ )
		setmapflag .eventmap$, [email protected][[email protected]];

//waitingroom"Bloody Branch Quest",0;

end;
}





-	script	no_reins2	-1,{
OnPCLoadMapEvent:
if (strcharinfo(3) == "cguild_vs22" && ismounting() ) { setmounting(); }
}
cguild_vs22	mapflag	loadevent

Now I'm not quite sure if I need to add another row into my table(maybe to record account_id?)

CREATE TABLE IF NOT EXISTS `bloody_branch` (
	`unique_id` int(11) unsigned NOT NULL default '0',
	`bloodybranch` varchar(30) NOT NULL default '',
	PRIMARY KEY	(`unique_id`)
) ENGINE=MyISAM;

I greatly appreciate any and all help.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

since you already have an IP check and you were already pulling their IP, you might as well pull their unique_id

find the lines:

			query_sql ("SELECT `last_ip` FROM `login` WHERE `account_id`=" + [email protected][[email protected]] + "", [email protected]$);
			// If same IP is on party
			if(compare([email protected]_list$, "|" + [email protected]$ + "|" ) == 1) {
				set [email protected], 1;

and adjust to something like

			query_sql ("SELECT `last_ip`,`last_unique_id` FROM `login` WHERE `account_id`=" + [email protected][[email protected]] + "", [email protected]$, [email protected]_id$);
			// If same IP is on party
			if ( compare([email protected]_list$, "|" + [email protected]$ + "|") || compare([email protected]_list$, "|" + [email protected]_id$ + "|") ) {
				set [email protected], 1;

 

Haven't tested the code

Link to comment
Share on other sites

  • 0
6 hours ago, Magnetix said:

since you already have an IP check and you were already pulling their IP, you might as well pull their unique_id

find the lines:

			query_sql ("SELECT `last_ip` FROM `login` WHERE `account_id`=" + [email protected][[email protected]] + "", [email protected]$);
			// If same IP is on party
			if(compare([email protected]y_list$, "|" + [email protected]$ + "|" ) == 1) {
				set [email protected], 1;

and adjust to something like

			query_sql ("SELECT `last_ip`,`last_unique_id` FROM `login` WHERE `account_id`=" + [email protected][[email protected]] + "", [email protected]$, [email protected]_id$);
			// If same IP is on party
			if ( compare([email protected]_list$, "|" + [email protected]$ + "|") || compare([email protected]_list$, "|" + [email protected]_id$ + "|") ) {
				set [email protected], 1;

 

Haven't tested the code

Oops, should have been more specific, basically it would be to check the party member if they entered before against the sql(bloody_branch) table for the NPC. Because I can do a check at the beginning for the person attached to the NPC, but not the party member. So the party member can use same PC with different IP and get in.

Link to comment
Share on other sites

  • 0
Posted (edited)
5 hours ago, DR4LUC0N said:

Oops, should have been more specific, basically it would be to check the party member if they entered before against the sql(bloody_branch) table for the NPC. Because I can do a check at the beginning for the person attached to the NPC, but not the party member. So the party member can use same PC with different IP and get in.

You can just re-use the check since you're already attaching the party members

	.gui = get_unique_id();
	[email protected] = query_sql("SELECT `bloodybranch` FROM `bloody_branch` WHERE `unique_id` = "+.gui+" LIMIT 1", [email protected]);
	if ([email protected]) [email protected] = 1;

 

There's a simpler way, instead of the checking the IPs and unique ID, you can also save their account ids.

Edited by Magnetix
Link to comment
Share on other sites

  • 0
3 hours ago, Magnetix said:

You can just re-use the check since you're already attaching the party members

	.gui = get_unique_id();
	[email protected] = query_sql("SELECT `bloodybranch` FROM `bloody_branch` WHERE `unique_id` = "+.gui+" LIMIT 1", [email protected]);
	if ([email protected]) [email protected] = 1;

 

There's a simpler way, instead of the checking the IPs and unique ID, you can also save their account ids.

Yeah but how would that be a stronger security vs unique_id and IP? I must not be following what you're saying.

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

Important Information

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