Tdi123 Posted May 6, 2021 Group: Members Topic Count: 93 Topics Per Day: 0.03 Content Count: 195 Reputation: 3 Joined: 12/12/17 Last Seen: January 19 Share Posted May 6, 2021 (edited) SCRIPT: function script F_ShuffleNumbers { deletearray getarg(2); .@static = getarg(0); .@range = getarg(1) +1 - .@static; .@count = getarg(3, .@range); if (.@range <= 0 || .@count <= 0) return 0; if (.@count > .@range) .@count = .@range; for (.@i = 0; .@i < .@range; ++.@i) .@temparray[.@i] = .@i; for (.@i = 0; .@i < .@count; ++.@i) { .@rand = rand(.@range); set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static; .@temparray[.@rand] = .@temparray[--.@range]; } return .@count; } - script RegistroBG -1,{ OnJoinBG: .@name$ = strcharinfo(0); .@minplayer2start = getvariableofnpc(.minplayer2start, "fortress#bg"); .@start = getvariableofnpc(.start, "fortress#bg"); if(.@start == 1) { dispbottom "Batalha Campal : Desculpe, a bg está em andamento."; end; } while ( .aid[.@i] != getcharid(3) && .@i < .size ) ++.@i; if ( .@i < .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 ( .@i = 0; .@i < .size; ++.@i ) { if ( !isloggedin( .aid[.@i] ) ) { deletearray .aid[.@i], 1; --.@i; --.size; } else { attachrid .aid[.@i]; if ( strcharinfo(3) != strnpcinfo(4) ) { deletearray .aid[.@i], 1; --.@i; --.size; } } } detachrid; if ( .size == .@minplayer2start * 2 ) { copyarray getvariableofnpc( .aid_, "fortress#bg" ), .aid, .size; donpcevent "fortress#bg::OnStart"; deletearray .aid; .size = 0; } else announce .@name$ +" se inscreveu na Batalha Campal... ainda restam "+ .size +"/"+ .@minplayer2start * 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, .@r; for ( .@i = 0; .@i < .minplayer2start * 2; ++.@i ) { attachrid .aid_[.@r[.@i]]; bg_join ( .@i % 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 ( .@i = 0; .@i < $@arenamemberscount; ++.@i ) getitem .rwd[0],.rwd[1], $@arenamembers[.@i]; sleep 1; bg_get_data getarg(1), 1; for ( .@i = 0; .@i < $@arenamemberscount; ++.@i ) getitem .rwd[2],.rwd[3], $@arenamembers[.@i]; 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(.@mapname$, .@mapx, .@mapy, BL_NPC, strnpcinfo(3)); setarray .@n_mapx[0], .@mapx-5, .@mapx+5; setarray .@n_mapy[0], .@mapy-5, .@mapy+5; @ontouch = 1; .@owner = getvariableofnpc( .owner, "fortress#bg" ); while ( @ontouch && strcharinfo(3) == strnpcinfo(4) ) { if( .@owner != getcharid(4) ) { if ( Hp > 1 ) percentheal -10, 0; else percentheal -100, 0; specialeffect2 49; } else if ( .@owner == getcharid(4) ) { if ( Hp != MaxHP ) specialeffect2 EF_HEAL; percentheal 10, 10; } sleep2 1000; getmapxy(@mapname$, @mapx, @mapy, BL_PC); if ( @mapx < .@n_mapx[0] || @mapx > .@n_mapx[1] || @mapy < .@n_mapy[0] || @mapy > .@n_mapy[1]) { @ontouch = 0; } } end; } bat_c01,55,126,0 script #redminifort 1915,5,5,{ end; OnTouch: getmapxy(.@mapname$, .@mapx, .@mapy, BL_NPC, strnpcinfo(3)); setarray .@n_mapx[0], .@mapx-5, .@mapx+5; setarray .@n_mapy[0], .@mapy-5, .@mapy+5; .@owner = getvariableofnpc( .red, "fortress#bg" ); @ontouch = 1; while ( @ontouch && strcharinfo(3) == strnpcinfo(4) ) { if ( .@owner != 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 < .@n_mapx[0] || @mapx > .@n_mapx[1] || @mapy < .@n_mapy[0] || @mapy > .@n_mapy[1]) { @ontouch = 0; } } end; } bat_c01,144,57,0 script #blueminifort 1914,5,5,{ end; OnTouch: getmapxy(.@mapname$, .@mapx, .@mapy, BL_NPC, strnpcinfo(3)); setarray .@n_mapx[0], .@mapx-5, .@mapx+5; setarray .@n_mapy[0], .@mapy-5, .@mapy+5; .@owner = getvariableofnpc( .blue, "fortress#bg" ); @ontouch = 1; while ( @ontouch && strcharinfo(3) == strnpcinfo(4) ) { if ( .@owner != 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 < .@n_mapx[0] || @mapx > .@n_mapx[1] || @mapy < .@n_mapy[0] || @mapy > .@n_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 May 12, 2021 by Tdi123 Quote Link to comment Share on other sites More sharing options...
0 Alzhea Posted May 7, 2021 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 8 Reputation: 0 Joined: 06/16/13 Last Seen: Saturday at 10:51 AM Share Posted May 7, 2021 try change OnInit: bindatcmd("joinbg",strnpcinfo(0)+"::OnJoinBG",0,99); end; into OnInit: bindatcmd("joinbg",strnpcinfo(3)+"::OnJoinBG",0,99); end; Quote Link to comment Share on other sites More sharing options...
0 Tdi123 Posted May 7, 2021 Group: Members Topic Count: 93 Topics Per Day: 0.03 Content Count: 195 Reputation: 3 Joined: 12/12/17 Last Seen: January 19 Author Share Posted May 7, 2021 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 Quote Link to comment Share on other sites More sharing options...
0 Alzhea Posted May 8, 2021 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 8 Reputation: 0 Joined: 06/16/13 Last Seen: Saturday at 10:51 AM Share Posted May 8, 2021 11 hours ago, Tdi123 said: Did not work it works to me. better check if the script has error when you tried to @joinbg. Quote Link to comment Share on other sites More sharing options...
0 Tdi123 Posted May 12, 2021 Group: Members Topic Count: 93 Topics Per Day: 0.03 Content Count: 195 Reputation: 3 Joined: 12/12/17 Last Seen: January 19 Author Share Posted May 12, 2021 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. I have already solved the script problem, it is a little more complex than that, you need to do queue checks, etc ... Quote Link to comment Share on other sites More sharing options...
0 olivertsu Posted September 19, 2021 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 1 Reputation: 0 Joined: 09/09/21 Last Seen: September 26, 2021 Share Posted September 19, 2021 (edited) Hey man, I've read one post that you solved the -@joinbg script for a guy But you forgot to let us know the final solution can you share the correction that you did in the script please? Edited March 6, 2022 by Emistry remove text format Quote Link to comment Share on other sites More sharing options...
Question
Tdi123
SCRIPT:
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 Tdi123Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.