Jump to content
  • 0

activate pvp when X players are in a map.


HristDead

Question


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Hi rathena,

 

can anyone help me with this script? I want to make it so that when there are > 9 players in a map (guild_vs2), pvp will automatically run.

 

Right now, it turns on even if there is < 9 players... :(

 

Here's what I got so far:

 

OnPCLoadMapEvent:
if(getmapusers("guild_vs2") > 9)
    sleep2 1000;
    pvpon "prt_are01";
    end;
}
Edited by HristDead
Link to comment
Share on other sites

15 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Everything works except this doesn't trigger. but there's no error either...

 

-	script	pvpon	-1,{
	OnPCLoadMapEvent:
		set .@usr_map$, strcharinfo(3);
		getpartymember $@TeamID1,1; getpartymember $@TeamID1,2; set .team1, $@partymembercount;
		copyarray .party_name_desu[0], $@partymemberaid[0],128;
		while(set(.@f,.@f+1)<=.team1) {
			if(getmapxy(.@map$,.@x,.@y,0,rid2name(.party_name_desu[.@f-1]))!=0)
				set .team1,.team1-1;
			if(.@map$==.@usr_map$)
				set(.@i,.@i+1);
		}
		getpartymember $@TeamID2,1; getpartymember $@TeamID2,2; set .team2, $@partymembercount;
		copyarray .party_name_desu2[0], $@partymemberaid[0],128;
		while(set(.@h,.@h+1)<=.team2) {
			if(getmapxy(.@map$,.@x,.@y,0,rid2name(.party_name_desu2[.@h-1]))!=0)
				set .team2,.team2-1;
			if(.@map$==.@usr_map$) {
				set(.@i,.@i+1);
			}
		}
		if(.@i >= 4 && .team1 >= 2 && .team2 >= 2)
			pvpon "guild_vs2";
		end;

	OnPCDieEvent:
		if(strcharinfo(3)=="guild_vs2"&&getmapflag("guild_vs2",mf_pvp))
			if(getcharid(1)==$@TeamID1)
				if(!(set(.team1,.team1-1))) {
					dispbottom "Party 2 Wins";
					pvpoff "guild_vs2";
					while(set(.@h,.@h+1)<=getarraysize(.party_name_desu2))
						getitem 501,1,.party_name_desu2[.@h-1];
					deletearray .party_name_desu[0],128; deletearray .party_name_desu2[0],128;
				}
			else if(getcharid(1)==$@TeamID2)
				if(!(set(.team2,.team2-1))) {
					dispbottom "Party 1 Wins";
					pvpoff "guild_vs2";
					while(set(.@h,.@h+1)<=getarraysize(.party_name_desu))
						getitem 501,1,.party_name_desu[.@h-1];
					deletearray .party_name_desu[0],128; deletearray .party_name_desu2[0],128;
				}
}
guild_vs2	mapflag	loadevent

 

Sorry forgot about ghost party members.

Edited by Skorm
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  


guild_vs2<TAB>mapflag<TAB>loadevent

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Thanks! Hmm Sir patskie, I have another question.

 

What if I want to make it count the party member of party ID? (its attached)

 

I tried this, but doesn't work. >.<

 

-    script    pvpon    -1,{
OnPCLoadMapEvent:
if(getpartymember($@TeamID1) == 2 && getpartymember($@TeamID2) == 2);
    pvpon "guild_vs2";
    end;
}
guild_vs2    mapflag    loadevent
Edited by HristDead
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Thanks! Hmm Sir patskie, I have another question.

 

What if I want to make it count the party member of party ID? (its attached)

 

I tried this, but doesn't work. >.<

 

That was actually really close imo.

 

-	script	pvpon	-1,{
	OnPCLoadMapEvent:
		getpartymember $@TeamID1; set .@a, $@partymembercount;
		getpartymember $@TeamID2; set .@b, $@partymembercount;
		if(.@a >= 2 && .@b >= 2);
			pvpon "guild_vs2";
}
guild_vs2	mapflag	loadevent
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Hmm... it goes on instantly after warping.

 

How to wait to activate until all members of both parties are present?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Hmm... it goes on instantly after warping.

 

How to wait to activate until all members of both parties are present?

 

There might be a better way of doing this but bleh.

 

-	script	pvpon	-1,{
	OnPCLoadMapEvent:
		set .@usr_map$, strcharinfo(3);
		getpartymember $@TeamID1; set .@a, $@partymembercount;
		copyarray .@party_name_desu$[0], $@partymembername$[0],128;
		while(set(.@f,.@f+1)<=.@a) {
			getmapxy(.@map$,.@x,.@y,0,.@party_name_desu$[.@f-1]);
			if(.@map$==.@usr_map$)
				set(.@i,.@i+1);
		}
		getpartymember $@TeamID2; set .@b, $@partymembercount;
		copyarray .@party_name_desu2$[0], $@partymembername$[0],128;
		while(set(.@h,.@h+1)<=.@ {
			getmapxy(.@map$,.@x,.@y,0,.@party_name_desu2$[.@h-1]);
			if(.@map$==.@usr_map$)
				set(.@i,.@i+1);
		}
		if(.@i >= 4 && .@a >= 2 && .@b >= 2)
			pvpon "guild_vs2";
}
guild_vs2	mapflag	loadevent
Edited by Skorm
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Thanks you!

 

is it tested? :) It will difficult for me to quad client and test.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Thanks you!

 

is it tested? :) It will difficult for me to quad client and test.

 

Yes I've tested the above script and it appears to be working.

 


 

Just thought of a MUCH better way to do this...

 

-	script	pvpon	-1,{
	OnPCLoadMapEvent:
		set .@usr, getcharid(1);
		getpartymember $@TeamID1; set .@a, $@partymembercount;
		getpartymember $@TeamID2; set .@b, $@partymembercount;
		if(.@usr==$@TeamID1||.@usr==$@TeamID2)
			set(.i,.i+1);
		if(.i >= 4 && .@a >= 2 && .@b >= 2)
			pvpon "guild_vs2";
		end;
	
	OnEventEnd:
		set(.i,0);
		pvpoff "guild_vs2";
}
guild_vs2	mapflag	loadevent 

 

You will need to reset the npc variable when the event is by calling... OnEventEnd Like:

 

doevent "pvpon::OnEventEnd";

Edit- But I guess the same person could warp in twice with this method... could always save there information to an array and check it, but then again... they could always warp out after words.

Edited by Skorm
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

-	script	ComePvP	-1,{
OnInit:
	.map$ = "guild_vs2";
	.usersCount = 10;
	setmapflag .map$,mf_loadevent;
	setmapflag .map$,mf_partylock;
	if (getmapflag(.map$,mf_pvp) > 0)
		removemapflag .map$,mf_pvp;	
	end;

OnPCDieEvent:
	if (strcharinfo(3) == .map$ && getmapflag(.map$,mf_pvp) > 0) {
		if (getusers(0) <= .usersCount) {
			for (.@i = 0; .@i < getarraysize(.partyCount); .@i++)
				deletearray getd(".party_" + .partyCount[.@i]),128;
			deletearray .partyCount,128;
			mapwarp .map$,"prontera",0,0;
			pvpoff .map$;
		}
	}
	end;
			
OnPCLoadMapEvent:	
	.@_pid = getcharid(1);
	
	if (.@_pid == 0)
		end;
	
	.@str$ = ".party_" + .@_pid + "$";
	if (getd(.@str$) != "") {
		if (compare("#"+strcharinfo(0)+"#",implode(getd(.@str$),"#")))
			end;
	}
	
	getpartymember .@_pid,0;
	.partyCount[getarraysize(.partyCount)] = .@_pid;
	copyarray getd(".party_" + .@_pid + "$[0]"),$@partymembername$[0],$@partymembercount;
	
	if (getarraysize(.partyCount) > 1 && getmapflag(.map$,mf_pvp) < 1 && getusers(0) >= .usersCount)
		pvpon .map$;
		
	end;
} 

 

I'm unsure this is what you want.

PvP will be switched on, when there are more than 9 players and at least 2 parties.

And, will be switched off, when less than or left 9 players in the map.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Thanks guys that works great!! :)

 

Can I ask one more? >< Do you as well know how to reward the winning party thats left in guild_vs2 map?

 

I tried using a part of Skorms scirpt and made some edits. However now it procs every time a player is killed... but i want it to proc when there is only one party left

Is that possible?

 

    OnPCDieEvent:
        set .@usr_map$, strcharinfo(3);
        getpartymember $@TeamID1; set .@a, $@partymembercount;
        copyarray .@party_name_desu$[0], $@partymembername$[0],128;
        while(set(.@f,.@f+1)<=.@a) {
            getmapxy(.@map$,.@x,.@y,0,.@party_name_desu$[.@f-1]);
            if ( .@tmp$ != .@map$ ) {
            dispbottom "Party 1 Wins";
            end;
        }
        getpartymember $@TeamID2; set .@b, $@partymembercount;
        copyarray .@party_name_desu2$[0], $@partymembername$[0],128;
        while(set(.@h,.@h+1)<=.@  {
            getmapxy(.@map$,.@x,.@y,0,.@party_name_desu2$[.@h-1]);
        if(.@a < 1)
            dispbottom "Party 2 Wins";
            end;
}
}
guild_vs2   mapflag    loadevent
Edited by HristDead
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

This is kinda primitive but...

 

Edit--
Edited by Skorm
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Everything works except this doesn't trigger. but there's no error either...

 

    OnPCDieEvent:
        if(strcharinfo(3)=="guild_vs2")
            if(getcharid(1)==$@TeamID1)
                if(!set(.team1,.team1-1)) {
                    getpartymember $@TeamID2,2;
                    dispbottom "Party 2 Wins";
                    pvpoff "guild_vs2";
                    while(set(.@h,.@h+1)<=$@partymembercount)
                        getitem 501,1,$@partymemberaid[.@h-1];
                }
            else if(getcharid(1)==$@TeamID2)
                if(!set(.team2,.team2-1)) {
                    getpartymember $@TeamID1,2;
                    dispbottom "Party 1 Wins";
                    pvpoff "guild_vs2";
                    while(set(.@h,.@h+1)<=$@partymembercount)
                        getitem 501,1,$@partymemberaid[.@h-1];
                }
}
guild_vs2    mapflag    loadevent
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Everything works except this doesn't trigger. but there's no error either...

 

-	script	pvpon	-1,{
	OnPCLoadMapEvent:
		set .@usr_map$, strcharinfo(3);
		dispbottom ""+getcharid(1);
		getpartymember $@TeamID1,1; getpartymember $@TeamID1,2; set .team1, $@partymembercount;
		copyarray .party_name_desu[0], $@partymemberaid[0],128;
		while(set(.@f,.@f+1)<=.team1) {
			if(getmapxy(.@map$,.@x,.@y,0,rid2name(.party_name_desu[.@f-1]))!=0)
				set .team1,.team1-1;
			if(.@map$==.@usr_map$)
				set(.@i,.@i+1);
		}
		getpartymember $@TeamID2,1; getpartymember $@TeamID2,2; set .team2, $@partymembercount;
		copyarray .party_name_desu2[0], $@partymemberaid[0],128;
		while(set(.@h,.@h+1)<=.team2) {
			if(getmapxy(.@map$,.@x,.@y,0,rid2name(.party_name_desu2[.@h-1]))!=0)
				set .team2,.team2-1;
			if(.@map$==.@usr_map$) {
				set(.@i,.@i+1);
			}
		}
		if(.@i >= 4 && .team1 >= 2 && .team2 >= 2)
			pvpon "guild_vs2";
		end;

	OnPCDieEvent:
		if(strcharinfo(3)=="guild_vs2"&&getmapflag("guild_vs2",mf_pvp))
			if(getcharid(1)==$@TeamID1)
				if(!(set(.team1,.team1-1))) {
					dispbottom "Party 2 Wins";
					pvpoff "guild_vs2";
					while(set(.@h,.@h+1)<=getarraysize(.party_name_desu2))
						getitem 501,1,.party_name_desu2[.@h-1];
					deletearray .party_name_desu[0],128; deletearray .party_name_desu2[0],128;
				}
			else if(getcharid(1)==$@TeamID2)
				if(!(set(.team2,.team2-1))) {
					dispbottom "Party 1 Wins";
					pvpoff "guild_vs2";
					while(set(.@h,.@h+1)<=getarraysize(.party_name_desu))
						getitem 501,1,.party_name_desu[.@h-1];
					deletearray .party_name_desu[0],128; deletearray .party_name_desu2[0],128;
				}
}
guild_vs2	mapflag	loadevent

 

Sorry forgot about ghost party members.

 

 

Thank you Skorm it works now you're amazing!!

 

There's only one tiny thing left.... there's a random "4" popping up as message, could it have something to do with the dispbottom?

it occured since i put your fixed script

 

9lk211.png

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Thank you Skorm it works now you're amazing!!

 

 

 

There's only one tiny thing left.... there's a random "4" popping up as message, could it have something to do with the dispbottom?

it occured since i put your fixed script

 

9lk211.png

 

 

I've removed it from my last post. It was there because I didn't have the variables you were using for your parties, so I had to find the ID of the party I was in on each respective character. :D

 

And you're welcome.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

comment

dispbottom ""+getcharid(1);

it may be a debug

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