Jump to content
  • 0

Help me with MVP reward script


Question

Posted

This is the code 

-	script	mvprewarders	-1,{
OnNPCKillEvent:
	if ( getmonsterinfo( killedrid, MOB_MVPEXP ) && rand(100) < 100 ) {
		if ( getcharid(1) ) {
			getpartymember getcharid(1), 1;
			getpartymember getcharid(1), 2;
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { // what happens if someone in the party member is offline =/
					.@partymemberaid[.@c] = $@partymemberaid[.@i];
					.@c++;
				}
			}
			getitem 30022, 1, .@partymemberaid[ rand( .@c ) ];
			announce "Party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and a Random Party Member Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}
		else {
			getitem 30022, 1;
			announce "Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}
	}
	end;
}

The problem is how can i make all party member to get the reward instead of random party member? Also only party member in the area will be valid to get the reward.

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

Not tested. But something like that. I were think about getpartyitem, but i guess someone already maybe made such src command for giving entire party via simple script command rewards for all (but this command can be very abused by cheaters, for example by very big party). 

 

-	script	mvprewarders	-1,{
OnNPCKillEvent:
	if ( getmonsterinfo( killedrid, MOB_MVPEXP ) && rand(100) < 100 ) {
		if ( getcharid(1) ) {
			
			getpartymember getcharid(1), 0; // for party member names.
			getpartymember getcharid(1), 1;
			getpartymember getcharid(1), 2;

			// let's get coordinates of the guy which triggered the event.
			// Then, we will check distance from this master guy to party_members.
			getmapxy(.master_map$, .master_x, .master_y, UNITTYPE_PC, strcharinfo(0));


			for ( .@i = 0; .@i < $@partymembercount; .@i++ )
			{
				// what happens if someone in the party member is offline =/
				if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) )
				{

					// let's get party member coordinates. Which we will check with master.
					// If distance < then AREA_SIZE (around 14 cells), then we will reward party member with the item
					// Either, we will do nothing.
					getmapxy(.party_member_map$, .party_member_x, .party_member_y, UNITTYPE_PC, $@partymembername$[.@i]);
					if( distance(.master_x,.master_y,.party_member_x,.party_member_y) < getbattleflag("area_size") )
						getitem 30022, 1, .@partymemberaid[.@i];

					.@partymemberaid[.@c] = $@partymemberaid[.@i];
					.@c++;
					
				}
			}
			getitem 30022, 1, .@partymemberaid[ rand( .@c ) ];
			announce "Party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and a Random Party Member Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}
		else {
			getitem 30022, 1;
			announce "Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}
	}
	end;
}

P.S. Not tested. Because of cloudflare rules, some variables replaced via CF, so, here is pastebin: http://pastebin.com/Rbq1xEMm

Edited by Anacondaqq
  • 0
Posted

Hello Anacondaqq

thank you very much but the area codes are not working. Players can get the item even though they are too far or in another map. Also may i ask what do you mean by "  but this command can be very abused by cheaters, for example by very big party "

  • 0
Posted
		if ( getcharid(1) ) {
			getpartymember getcharid(1), 1;
			getpartymember getcharid(1), 2;
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { // what happens if someone in the party member is offline =/
					.@partymemberaid[.@c] = $@partymemberaid[.@i];
					.@c++;
				}
			}
			getitem 30022, 1, .@partymemberaid[ rand( .@c ) ];
			announce "Party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and a Random Party Member Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}
		else {
			getitem 30022, 1;
			announce "Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}

change to

		.@party_id = getcharid(1);
		if ( .@party_id ) {
			getpartymember .@party_id, 2;
			.@current_map$ = strcharinfo(3);
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( attachrid( $@partymemberaid[.@i] ) ) {
					if ( getcharid(1) == .@party_id && strcharinfo(3) == .@current_map$ )
						getitem 30022, 1;
				}
				detachrid;
			}
			announce "Party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and a Random Party Member Got 1 MVP TOKEN at "+ strcharinfo(3),0,0x00FF00;
		}

 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...