Jump to content
  • 0

Autocreate party using waitingroom? HELP


Lord Ganja

Question


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

Hi. I need help with this scripts. I have an event script that is triggered by waitingroomevent..

But what I need is:
        1) autocreate a party when the waitingroom is full
        2) assign a new party leader when the party leader logged out or changed map
 
I also don't know what is party id. And how is it generated. Is it the same as party name but in integer? /hmm  /hmm
Explaining party id will be much appreciated. /thx
 
1)
prontera,150,175,0    script    testparty    521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",10;
end;

OnFull:
//THIS ONE WILL AUTOMATICALLY ASSIGN A LEADER BASED FROM THE PLAYERS INSIDE THE WAITINGROOM
party_create "MyParty",getcharid. . . . . .

//THIS ONE WILL ADD THE REMAINING PLAYERS INSIDE THE WAITINGROOM TO THE PARTY
party_addmember <I DONT KNOW WHAT IS PARTY ID>,<character id>;

end;
}
 
2)
OnPCLoadMapEvent:
getmapxy (.@map$, .@x, .@y, 0);
if( .@map$ != "event_map" && getcharid(0) == getpartyleader(<partyid>,2) ){

//THIS ONE WILL AUTO ASSIGN A NEW LEADER FROM THE PARTY
//IF IT FAILS, IT WILL LOOK FOR ANOTHER MEMBER TO TRANSFER THE LEADERSHIP
party_changeleader <partyid>,<character id>;

//THIS ONE WILL DELETE THE PREVIOUS LEADER THAT CHANGED MAP
party_delmember getcharid(0),<party id>;
end;
}

//THIS ONE DELETE THE MEMBER THAT CHANGED MAP
if( .@map$ != "event_map" && getpartyname(<party id>) == "MyParty"){
party_delmember getcharid(0),<party id>;
end;
}

OnPCLogoutEvent:
getmapxy (.@map$, .@x, .@y, 0);
if( .@map$ == "event_map" && getcharid(0) == getpartyleader(<partyid>,2) ){

//THIS ONE WILL AUTO ASSIGN A NEW LEADER FROM THE PARTY
//IF IT FAILS, IT WILL LOOK FOR ANOTHER MEMBER TO TRANSFER THE LEADERSHIP
party_changeleader <partyid>,<character id>;

//THIS ONE WILL DELETE THE PREVIOUS LEADER THAT LOGGEDOUT
party_delmember getcharid(0),<party id>;
end;
}

//THIS ONE DELETE THE MEMBER THAT LOGGEDOUT
if( .@map$ == "event_map" && getpartyname(<party id>) == "MyParty"){
party_delmember getcharid(0),<party id>;
end;
}


 
 
Link to comment
Share on other sites

12 answers to this question

Recommended Posts


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

 

Thanks skorm.

 

Anyway I tried it and it successfully created a party, but the last one to enter the waitingroom is not included in the party.

and when the party leader logout or changemap, it doesn't change the party leader.

even for party members, when they logout or changemap, it doesn't kick them from party.

 

prontera,150,175,0	script	testparty	521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",3;
end;

OnFull:
	getmapxy .@map$, .@x, .@y, 1;
	warpwaitingpc .@map$, .@x, .@y;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ ) {
		.@name$ = rid2name($@warpwaitingpc[.@i]);
		.@char_id = getcharid( 0, .@name$ );
		if ( getcharid( 1, .@name$ ) > 0 )
			party_delmember( .@char_id );
		sleep 100;
		if ( .@create == 0 ) {
			while( party_create( "party"+ rand(10000), .@char_id ) == -3 );
			.@create = 1;
		}
		else if ( $@party_create_id )
			party_addmember $@party_create_id, .@char_id;
	}
	end;
	
OnPCLogoutEvent:
	.@logged = 1;
OnPCStatCalcEvent:
	if ( strcharinfo(3) == "prontera" && !.@logged
	||   strcharinfo(3) != "prontera" && .@logged
	||   getcharid(1) == 0 ) end;
	.@party_id = getcharid(1);
	if ( getcharid(0) != getpartyleader( .@party_id, 2 ) )
		party_delmember();
	else {
		.i = 0;
		if ( instance_check_party(.@party_id,2) == 0 )
			party_destroy(.@party_id);
		else {
			addrid( 2, 0, .@party_id );
			if( !.i && !.@party_id ) {
				.i = 1;
				party_changeleader getcharid(1), getcharid(0);
			} else if( .@party_id )
				party_delmember();
		}
	}
	end;
}

Remember to set where it says "prontera" to your map.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  142
  • Reputation:   8
  • Joined:  02/11/13
  • Last Seen:  

@party id:

 

Docs say:

 

[...] If successful, the command returns 1 and sets the global temporary variable
"$@party_create_id" to the ID of the party created. [...]

 

so the party_id you've to use is stored in $@party_create_id variable.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

@party id:

 

Docs say:

 

[...] If successful, the command returns 1 and sets the global temporary variable

"$@party_create_id" to the ID of the party created. [...]

 

so the party_id you've to use is stored in $@party_create_id variable.

can you give me an example of this?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  142
  • Reputation:   8
  • Joined:  02/11/13
  • Last Seen:  

OnFull:
//THIS ONE WILL AUTOMATICALLY ASSIGN A LEADER BASED FROM THE PLAYERS INSIDE THE WAITINGROOM
party_create "MyParty",getcharid. . . . . .

//THIS ONE WILL ADD THE REMAINING PLAYERS INSIDE THE WAITINGROOM TO THE PARTY
party_addmember $@party_create_id,<character id>;

That's all o.o

The variable $@party_create_id will be set by party_create function. There is nothing else to do to get the party id.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

I get it now. sorry. lol anyway do you have any idea how to create a party using a waitingroom? all players inside the waitingroom will be in party when it is full.

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:  

Try

prontera,150,175,0	script	testparty	521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",0;
end;

OnFull:
	getmapxy .@map$, .@x, .@y,1;
	warpwaitingpc .@map$,.@x,.@y;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ ) {
		.@name$ = rid2name($@warpwaitingpc[.@i]);
		.@char_id = getcharid( 0,.@name$ );
		if ( getcharid( 1,.@name$ ) > 0 )
			party_delmember( .@char_id );
		if ( .@create == 0 ) {
			while( party_create( "party_"+ rand(10000), .@char_id ) == -3 );
			.@create = 1;
		}
		else if ( $@party_create_id && party_addmember( $@party_create_id,.@char_id ) < 1 ) {
			npctalk "An error occur.";
			end;
		}
	}
	end;
OnPCStatCalcEvent:
OnPCLogoutEvent:
	if ( strcharinfo(3) != "alberta" || getcharid(1) == 0 ) end;
	.@party_id = getcharid(1);
	if ( getcharid(0) != getpartyleader( .@party_id,2) )
		party_delmember();
	else {
		if ( instance_check_party(.@party_id,2) == 0 )
			party_destroy(.@party_id);
		else {
			getpartymember .@party_id,1;
			getpartymember .@party_id,2;
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( isloggedin( $@partymemberaid[.@i],$@partymembercid[.@i] ) && $@partymembercid[.@i] != getcharid(0) ) {
					party_changeleader .@party_id,$@partymembercid[.@i];
					party_delmember $@partymembercid[.@i],.@party_id;
					break;
				}
			}
		}
	}
	end;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

 

Try

prontera,150,175,0	script	testparty	521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",0;
end;

OnFull:
	getmapxy .@map$, .@x, .@y,1;
	warpwaitingpc .@map$,.@x,.@y;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ ) {
		.@name$ = rid2name($@warpwaitingpc[.@i]);
		.@char_id = getcharid( 0,.@name$ );
		if ( getcharid( 1,.@name$ ) > 0 )
			party_delmember( .@char_id );
		if ( .@create == 0 ) {
			while( party_create( "party_"+ rand(10000), .@char_id ) == -3 );
			.@create = 1;
		}
		else if ( $@party_create_id && party_addmember( $@party_create_id,.@char_id ) < 1 ) {
			npctalk "An error occur.";
			end;
		}
	}
	end;
OnPCStatCalcEvent:
OnPCLogoutEvent:
	if ( strcharinfo(3) != "alberta" || getcharid(1) == 0 ) end;
	.@party_id = getcharid(1);
	if ( getcharid(0) != getpartyleader( .@party_id,2) )
		party_delmember();
	else {
		if ( instance_check_party(.@party_id,2) == 0 )
			party_destroy(.@party_id);
		else {
			getpartymember .@party_id,1;
			getpartymember .@party_id,2;
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( isloggedin( $@partymemberaid[.@i],$@partymembercid[.@i] ) && $@partymembercid[.@i] != getcharid(0) ) {
					party_changeleader .@party_id,$@partymembercid[.@i];
					party_delmember $@partymembercid[.@i],.@party_id;
					break;
				}
			}
		}
	}
	end;
}

 

Thanks Capuche! 

anyway, I tried your script, it creates a party but only the partyleader is in the party. the other player inside the waitingroom were not added in the party..

and when a player(which is already in a party) entered the waitingroom, after OnFull is triggered the player only leaves his current party, and not added in the new party.

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:  

prontera,150,175,0	script	testparty	521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",10;
end;

OnFull:
	getmapxy .@map$, .@x, .@y,1;
	warpwaitingpc .@map$,.@x,.@y;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ ) {
		.@name$ = rid2name($@warpwaitingpc[.@i]);
		.@char_id = getcharid( 0,.@name$ );
		if ( getcharid( 1,.@name$ ) > 0 )
			party_delmember( .@char_id );
		sleep 50;
		if ( .@create == 0 ) {
			while( party_create( "party"+ rand(10000), 1 ) == -3 );
			.@create = 1;
		}
		else if ( $@party_create_id ) {
			party_addmember $@party_create_id,.@char_id;
			// npctalk "An error occur.";
			end;
		}
	}
	end;
OnPCStatCalcEvent:
OnPCLogoutEvent:
	if ( strcharinfo(3) != "alberta" || getcharid(1) == 0 ) end;
	.@party_id = getcharid(1);
	if ( getcharid(0) != getpartyleader( .@party_id,2) )
		party_delmember();
	else {
		if ( instance_check_party(.@party_id,2) == 0 )
			party_destroy(.@party_id);
		else {
			getpartymember .@party_id,1;
			getpartymember .@party_id,2;
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( isloggedin( $@partymemberaid[.@i],$@partymembercid[.@i] ) && $@partymembercid[.@i] != getcharid(0) ) {
					party_changeleader .@party_id,$@partymembercid[.@i];
					party_delmember $@partymembercid[.@i],.@party_id;
					break;
				}
			}
		}
	}
	end;
}

just need a sleep in the script

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

prontera,150,175,0	script	testparty	521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",10;
end;

OnFull:
	getmapxy .@map$, .@x, .@y,1;
	warpwaitingpc .@map$,.@x,.@y;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ ) {
		.@name$ = rid2name($@warpwaitingpc[.@i]);
		.@char_id = getcharid( 0,.@name$ );
		if ( getcharid( 1,.@name$ ) > 0 )
			party_delmember( .@char_id );
		sleep 50;
		if ( .@create == 0 ) {
			while( party_create( "party"+ rand(10000), 1 ) == -3 );
			.@create = 1;
		}
		else if ( $@party_create_id ) {
			party_addmember $@party_create_id,.@char_id;
			// npctalk "An error occur.";
			end;
		}
	}
	end;
OnPCStatCalcEvent:
OnPCLogoutEvent:
	if ( strcharinfo(3) != "alberta" || getcharid(1) == 0 ) end;
	.@party_id = getcharid(1);
	if ( getcharid(0) != getpartyleader( .@party_id,2) )
		party_delmember();
	else {
		if ( instance_check_party(.@party_id,2) == 0 )
			party_destroy(.@party_id);
		else {
			getpartymember .@party_id,1;
			getpartymember .@party_id,2;
			for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
				if ( isloggedin( $@partymemberaid[.@i],$@partymembercid[.@i] ) && $@partymembercid[.@i] != getcharid(0) ) {
					party_changeleader .@party_id,$@partymembercid[.@i];
					party_delmember $@partymembercid[.@i],.@party_id;
					break;
				}
			}
		}
	}
	end;
}

just need a sleep in the script

 

 

Hi Capuche. Sorry for the late response.. anyway I tried this one but i got this:

[Debug]: Source (NPC): testparty at prontera (150,175)

and it doesn't create any party. and does this script autoremake party when there's already an existing party name?  Thanks Capuche!

Link to comment
Share on other sites


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

 

Hi Capuche. Sorry for the late response.. anyway I tried this one but i got this:

[Debug]: Source (NPC): testparty at prontera (150,175)

and it doesn't create any party. and does this script autoremake party when there's already an existing party name?  Thanks Capuche!

 

 

Replace:

while( party_create( "party"+ rand(10000), 1 ) == -3 );

With:

while( party_create( "party"+ rand(10000), .@char_id ) == -3 );

About your other question; yes it does.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

 

 

Hi Capuche. Sorry for the late response.. anyway I tried this one but i got this:

[Debug]: Source (NPC): testparty at prontera (150,175)

and it doesn't create any party. and does this script autoremake party when there's already an existing party name?  Thanks Capuche!

 

 

Replace:

while( party_create( "party"+ rand(10000), 1 ) == -3 );

With:

while( party_create( "party"+ rand(10000), .@char_id ) == -3 );

About your other question; yes it does.

 

Thanks skorm.

 

Anyway I tried it and it successfully created a party, but the last one to enter the waitingroom is not included in the party.

and when the party leader logout or changemap, it doesn't change the party leader.

even for party members, when they logout or changemap, it doesn't kick them from party.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

 

 

Thanks skorm.

 

Anyway I tried it and it successfully created a party, but the last one to enter the waitingroom is not included in the party.

and when the party leader logout or changemap, it doesn't change the party leader.

even for party members, when they logout or changemap, it doesn't kick them from party.

 

prontera,150,175,0	script	testparty	521,{
npctalk "You're required to enter the waitingroom.";
end;

OnInit:
waitingroom "test",11,"testparty::OnFull",3;
end;

OnFull:
	getmapxy .@map$, .@x, .@y, 1;
	warpwaitingpc .@map$, .@x, .@y;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ ) {
		.@name$ = rid2name($@warpwaitingpc[.@i]);
		.@char_id = getcharid( 0, .@name$ );
		if ( getcharid( 1, .@name$ ) > 0 )
			party_delmember( .@char_id );
		sleep 100;
		if ( .@create == 0 ) {
			while( party_create( "party"+ rand(10000), .@char_id ) == -3 );
			.@create = 1;
		}
		else if ( $@party_create_id )
			party_addmember $@party_create_id, .@char_id;
	}
	end;
	
OnPCLogoutEvent:
	.@logged = 1;
OnPCStatCalcEvent:
	if ( strcharinfo(3) == "prontera" && !.@logged
	||   strcharinfo(3) != "prontera" && .@logged
	||   getcharid(1) == 0 ) end;
	.@party_id = getcharid(1);
	if ( getcharid(0) != getpartyleader( .@party_id, 2 ) )
		party_delmember();
	else {
		.i = 0;
		if ( instance_check_party(.@party_id,2) == 0 )
			party_destroy(.@party_id);
		else {
			addrid( 2, 0, .@party_id );
			if( !.i && !.@party_id ) {
				.i = 1;
				party_changeleader getcharid(1), getcharid(0);
			} else if( .@party_id )
				party_delmember();
		}
	}
	end;
}

Remember to set where it says "prontera" to your map.

 

 

Thanks Skorm! This is working perfectly! :)

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