Jump to content
  • 0
Tdi123

[resolved] I'm trying to create the command @joinbg, but I can't release the command for all maps

Question

Posted (edited)

SCRIPT: 

function	script	F_ShuffleNumbers	{
	deletearray getarg(2);
	[email protected] = getarg(0);
	[email protected] = getarg(1) +1 - [email protected];
	[email protected] = getarg(3, [email protected]);
	if ([email protected] <= 0 || [email protected] <= 0)
		return 0;
	if ([email protected] > [email protected])
		[email protected] = [email protected];
	for ([email protected] = 0; [email protected] < [email protected]; [email protected])
		[email protected][[email protected]] = [email protected];
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]) {
		[email protected] = rand([email protected]);
		set getelementofarray( getarg(2), [email protected] ), [email protected][[email protected]] + [email protected];
		[email protected][[email protected]] = [email protected][[email protected]];
	}
	return [email protected];
}

-	script	RegistroBG	-1,{
OnJoinBG:
	[email protected]$ = strcharinfo(0);
	[email protected] = getvariableofnpc(.minplayer2start, "fortress#bg"); 
	[email protected] = getvariableofnpc(.start, "fortress#bg"); 
	if([email protected] == 1) {
		dispbottom "Batalha Campal : Desculpe, a bg está em andamento.";
		end;
	}
	while ( .aid[[email protected]] != getcharid(3) && [email protected] < .size ) [email protected];
	if ( [email protected] < .size ) {
		dispbottom "Batalha Campal : Por favor, aguarde a batalha começar.";
		end;
	}
	if (BaseLevel < 300) {
		dispbottom "Batalha Campal : Apenas jogadores de nível 300 podem participar da Batalha Campal!";
		end;
	}
	if( agitcheck() || agitcheck2() ){
		dispbottom "Batalha Campal : Neste momento a Guerra do Emperium está ativa e não é possível se inscrever na Batalha Campal!";
		end;
	}
	dispbottom "Batalha Campal : Por favor, permaneça no mapa atual para participar!";
	.aid[ .size++ ] = getcharid(3);
	for ( [email protected] = 0; [email protected] < .size; [email protected] ) {
		if ( !isloggedin( .aid[[email protected]] ) ) {
			deletearray .aid[[email protected]], 1;
			[email protected];
			--.size;
		}
		else {
			attachrid .aid[[email protected]];
			if ( strcharinfo(3) != strnpcinfo(4) ) {
				deletearray .aid[[email protected]], 1;
				[email protected];
				--.size;
			}
		}
	}
	detachrid;
	if ( .size == [email protected] * 2 ) {
		copyarray getvariableofnpc( .aid_, "fortress#bg" ), .aid, .size;
		donpcevent "fortress#bg::OnStart";
		deletearray .aid;
		.size = 0;
	}
	else
		announce [email protected]$ +" se inscreveu na Batalha Campal... ainda restam "+ .size +"/"+ [email protected] * 2 +" vagas para começar.", bc_npc | bc_all;
	end;

OnInit:
	bindatcmd("joinbg",strnpcinfo(0)+"::OnJoinBG",0,99);
	end;
}

-	script	fortress#bg	-1,{
OnInit:
	// =============
	// Game Settings
	// =============
	
	// Minimum players per team to start
	// default : 5 ( 5v5 )
	.minplayer2start = 1;
	
	// Event duration in minutes..
	// default : 5 mins
	.duration = 5; 
	
	// Reward settings
	setarray .rwd[0],
		7773, 5,	// win team reward
		7773, 1;		// lose team reward
	
	end;
	
OnStart:
	.start = 1;
	.red = bg_create ( strnpcinfo(4), 58, 123, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDie" );
	.blue =  bg_create ( strnpcinfo(4), 141, 60, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDie" ); 
	callfunc "F_ShuffleNumbers", 0, .minplayer2start *2 -1, [email protected];
	for ( [email protected] = 0; [email protected] < .minplayer2start * 2; [email protected] ) {
		attachrid .aid_[[email protected][[email protected]]];
		bg_join ( [email protected] % 2 )? .red : .blue;
	}
	detachrid;
	sleep 5000;
	announce "Destruam a Fortaleza Principal!", bc_npc | bc_map | bc_blue;
	sleep 5000;
	announce "A Batalha durará 5 minutos!", bc_npc | bc_map | bc_blue;
	
	bg_monster 0, "bat_c01", 99, 92, "Fortaleza Principal", 1911, strnpcinfo(3)+"::OnEmpDown";
	
	sleep .duration * 60000;
	
		
	if(.owner)
		callsub L_reward, (.owner == .red) ? .red : .blue, (.owner == .red) ? .blue : .red, (.owner == .red) ? "Red" : "Blue";
	else
		announce "A batalha terminou em empate!", bc_npc | bc_map | bc_blue;
	.owner = .start = 0;
	bg_destroy .red;
	bg_destroy .blue;
	mapwarp strnpcinfo(4),"prontera",150,150,0;
	end;
	
L_reward:
	announce getarg(2) +" team venceu!", bc_npc | bc_map | bc_blue;
	bg_get_data getarg(0), 1;
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
		getitem .rwd[0],.rwd[1], [email protected][[email protected]];
	sleep 1;
	bg_get_data getarg(1), 1;
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
		getitem .rwd[2],.rwd[3], [email protected][[email protected]];
	return;
	
OnEmpDown:
	.owner = getcharid(4);
	announce ((getcharid(4) == .red) ? "Red": "Blue") +" Team conquistou a Fortaleza Principal!", bc_npc | bc_map | bc_blue;
	bg_warp .red, strnpcinfo(4), 58, 123;
	bg_warp .blue, strnpcinfo(4), 141, 60;
	bg_monster .owner, "bat_c01", 99, 92, "Fortaleza Principal", (getcharid(4) == .red) ? 1912 : 1913, strnpcinfo(3)+"::OnEmpDown";
	//setnpcdisplay("#mainfort", "Fortaleza Principal", (getcharid(4) == .red) ? 1912 : 1913 );
	end;
	
	
OnRedQuit: callsub L_Quit, .red, "Red";
OnBlueQuit: callsub L_Quit, .blue, "Blue";
L_Quit:
	if ( bg_get_data( getarg(0), 0 ) ) end;
	announce "Todos "+ getarg(2) +" team membros saíram!", bc_npc | bc_map | bc_blue;
	sleep 1000;
	callsub L_reward, ( getarg(0) == .red ) ? .red : .blue, ( getarg(0) == .red ) ? .blue : .red, ( getarg(0) == .red ) ? "Red" : "Blue";
	awake instance_npcname( strnpcinfo(0) );
	end;

OnRedDie:
OnBlueDie:
	sleep2 1250;
	percentheal 100, 100;
	end;

}

bat_c01,99,92,0	script	#mainfort	-1,5,5,{
end;
OnTouch:
	getmapxy([email protected]$, [email protected], [email protected], BL_NPC, strnpcinfo(3));
	setarray [email protected]_mapx[0], [email protected], [email protected]+5;
	setarray [email protected]_mapy[0], [email protected], [email protected]+5;
	
	@ontouch = 1;
	[email protected] = getvariableofnpc( .owner, "fortress#bg" );
	
	while ( @ontouch && strcharinfo(3) == strnpcinfo(4) ) {
	if( [email protected] != getcharid(4) ) {
		if ( Hp > 1 )
			percentheal -10, 0;
		else
			percentheal -100, 0;
		specialeffect2 49;
	} 
	else if ( [email protected] == getcharid(4) ) {
		if ( Hp != MaxHP ) 
			specialeffect2 EF_HEAL;
		percentheal 10, 10;		
	}		  
	sleep2 1000;
		getmapxy(@mapname$, @mapx, @mapy, BL_PC);
		if ( @mapx < [email protected]_mapx[0] || @mapx > [email protected]_mapx[1] || @mapy < [email protected]_mapy[0] || @mapy > [email protected]_mapy[1]) {
			@ontouch = 0;
		}
	}
	end;	
}

bat_c01,55,126,0	script	#redminifort	1915,5,5,{
end;
OnTouch:
	getmapxy([email protected]$, [email protected], [email protected], BL_NPC, strnpcinfo(3));
	setarray [email protected]_mapx[0], [email protected], [email protected]+5;
	setarray [email protected]_mapy[0], [email protected], [email protected]+5;
	
	[email protected] = getvariableofnpc( .red, "fortress#bg" );
	@ontouch = 1;
	
	while ( @ontouch && strcharinfo(3) == strnpcinfo(4) ) {
	if ( [email protected] != getcharid(4) ) {
		if ( Hp > 10 )
			percentheal rand(-20,-40), 0;
		else
			percentheal -100, 0;
		specialeffect2 49;
	} else {
		if( HP != MaxHP )
			specialeffect2 EF_HEAL;
		percentheal 10, 10;
	}
	sleep2 1000;
		getmapxy(@mapname$, @mapx, @mapy, BL_PC);
		if ( @mapx < [email protected]_mapx[0] || @mapx > [email protected]_mapx[1] || @mapy < [email protected]_mapy[0] || @mapy > [email protected]_mapy[1]) {
			@ontouch = 0;
		}
	}
	end;	
}

bat_c01,144,57,0	script	#blueminifort	1914,5,5,{
end;
OnTouch:
	getmapxy([email protected]$, [email protected], [email protected], BL_NPC, strnpcinfo(3));
	setarray [email protected]_mapx[0], [email protected], [email protected]+5;
	setarray [email protected]_mapy[0], [email protected], [email protected]+5;
	
	[email protected] = getvariableofnpc( .blue, "fortress#bg" );
	@ontouch = 1;
	
	while ( @ontouch && strcharinfo(3) == strnpcinfo(4) ) {
	if ( [email protected] != getcharid(4) ) {
		if ( Hp > 10 )
			percentheal rand(-20,-40), 0;
		else
			percentheal -100, 0;
		specialeffect2 49;
	} else {
		if( HP != MaxHP )
			specialeffect2 EF_HEAL;
		percentheal 10, 10;
	}
	sleep2 1000;
		getmapxy(@mapname$, @mapx, @mapy, BL_PC);
		if ( @mapx < [email protected]_mapx[0] || @mapx > [email protected]_mapx[1] || @mapy < [email protected]_mapy[0] || @mapy > [email protected]_mapy[1]) {
			@ontouch = 0;
		}
	}
	end;	
}

bat_c01	mapflag	battleground	2
bat_c01	mapflag	nosave	SavePoint
bat_c01	mapflag	nowarp
bat_c01	mapflag	nowarpto
bat_c01	mapflag	noteleport
bat_c01	mapflag	nomemo
bat_c01	mapflag	nopenalty
bat_c01	mapflag	nobranch
bat_c01	mapflag	noicewall

 

If I put the map name + the coordinate, the npc works only on the npc map, example:

prontera,0,0,0    script    RegistroBG    100,{
OnJoinBG:

 

So, it will only work on the prontera map

 

I wanted to release the command for all maps

Thank you for your help now!

Edited by Tdi123
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

try change
 

OnInit:
	bindatcmd("joinbg",strnpcinfo(0)+"::OnJoinBG",0,99);
	end;

into 

OnInit:
	bindatcmd("joinbg",strnpcinfo(3)+"::OnJoinBG",0,99);
	end;
Link to comment
Share on other sites

  • 0
11 hours ago, Alzhea said:

try change
 

OnInit:
	bindatcmd("joinbg",strnpcinfo(0)+"::OnJoinBG",0,99);
	end;

into 

OnInit:
	bindatcmd("joinbg",strnpcinfo(3)+"::OnJoinBG",0,99);
	end;

Did not work

Link to comment
Share on other sites

  • 0
11 hours ago, Tdi123 said:

Did not work

it works to me.



better check if the script has error when you tried to @joinbg.

Untitled.png

Link to comment
Share on other sites

  • 0
On 5/8/2021 at 12:24 AM, Alzhea said:

it works to me.



better check if the script has error when you tried to @joinbg.

Untitled.png

 

I have already solved the script problem, it is a little more complex than that, you need to do queue checks, etc ...

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.