Jump to content
  • 0
dfabsgwapings

Help with Party check

Question

can anyone help me on this party check.

a leader will talk to the NPC for the whole party get warp to a specific map. the npc requirement will be

> all party members should be in the map of prontera. if some member are not in this map the party leader will get a message that all party members must be in prontera.
> all party members should be online. if some member are not online the party leader will get a message some of your party member are currently offline.
> all party members should have this variable called TICKETMANIAC. if some party member does not have 1 TICKETMANIAC variable, the party leader will get a message some of your party member doesn't have enough TICKETMANIAC.

if all party members including the leader meet the requirements

> all party member will be warp to a specific map let say payon.
> all party member TICKETMANIAC will decrease by 1.

 

Thanks in advance ...

Edited by dfabsgwapings

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

That's quite resource-intensive, but sure:

prontera,39,30,0	script	npc_name	npc_id,{

	// ask the player if they want to proceed
	mesf("Do you want to warp your party to %s? It will cost %i tickets to every party member.", .destination_map$, .ticket_cost);

	if (select("yes", "no") != 1) close;

	// now go through a lenghty routine to validate everything

	.@party = getcharid(CHAR_ID_PARTY);

	if (.@party < 1) {
		mes("You must be in a party.");
		close;
	}

	.@leader = getpartyleader(.@party, 1);

	if (.@leader != getcharid(CHAR_ID_ACCOUNT)) {
		mes("You must be a party leader.");
		close;
	}

	if (strcharinfo(PC_MAP) != .start_map$) {
		mesf("You must be on %s.", .start_map$);
		close;
	}

	.@ticket_delta = .ticket_cost - TICKETMANIAC;

	if (.@ticket_delta > 0) {
		mesf("You are missing %i ticket%s.", .@ticket_delta, .@ticket_delta > 1 ? "s" : "");
		close;
	}

	getpartymember(.@party, 1);
	.@party_count = $@partymembercount;
	copyarray(.@party_cid[0], $@partymembercid[0], .@party_count);
	copyarray(.@party_name$[0], $@partymembername$[0], .@party_count);

	freeloop(true);
	for (.@i = 0; .@i < .@party_count; ++.@i) {
		.@name$ = .@party_name$[.@i];
		.@cid = .@party_cid[.@i];
		.@aid = charid2rid(.@cid);

		if (.@aid < 1 || isloggedin(.@aid, .@cid) == false) {
			mesf("All party members must be online, but %s is currently offline.", .@name$);
			freeloop(false);
			close;
		}

		.@map$ = strcharinfo(PC_MAP, "", .@aid);

		if (.@map$ != .start_map$) {
			mesf("All party members must be on %s, but %s is currently on %s.", .start_map$, .@name$, .@map$);
			freeloop(false);
			close;
		}

		.@ticket_delta = .ticket_cost - getvariableofpc(TICKETMANIAC, .@aid, 0);

		if (.@ticket_delta > 0) {
			mesf("Party member %s is missing %i ticket%s.", .@name$, .@ticket_delta, .@ticket_delta > 1 ? "s" : "");
			freeloop(false);
			close;
		}
	}

	// we got through the loop, so all conditions are met; now let's warp and decrease tickets

	for (.@i = 0; .@i < .@party_count; ++.@i) {
		.@cid = .@party_cid[.@i];
		.@aid = charid2rid(.@cid);

		set(getvariableofpc(TICKETMANIAC, .@aid), max(0, getvariableofpc(TICKETMANIAC, .@aid) - .ticket_cost));

		if (.@cid != getcharid(CHAR_ID_CHAR)) {
			warpchar(.destination_map$, rand(.destination_loc[0], .destination_loc[2]), rand(.destination_loc[1], .destination_loc[3]), .@cid);
		}
	}
	freeloop(false);
  
	mes("All party members have been warped. Now it's your turn!");
	close2();
	TICKETMANIAC = max(0, TICKETMANIAC - .ticket_cost);
	warp(.destination_map$, rand(.destination_loc[0], .destination_loc[2]), rand(.destination_loc[1], .destination_loc[3]));
	end;


OnInit:
	// change those settings to your liking
	.start_map$ = "prontera";
	.ticket_cost = 1;
	.destination_map$ = "payon";
	.destination_loc[0] = 20; // x1
	.destination_loc[1] = 20; // y1
	.destination_loc[2] = 90; // x2
	.destination_loc[3] = 90; // y2
}

 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

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