Jump to content
  • 0

Brancher


Question

Posted

Hi, please help me to fix this script; this is a npc who spawn a random monster

The problem who i find are:

On: StartEvent i can't insert the "close"

if on the map there are 30 mob the event is turned off until at least one monster is killed

If is possible automatizate the event: "StartEvent and StopEvent" if there is at least one player

thx a lot

pvp_n_3-5,99,99,5	script	Brancher	757,{


menu "Start",StartEvent,"Stop",StopEvent,"Cancel",cancel;


StartEvent: // To turn the event on...
set .active,1;
dispbottom "Started";
goto OnInit;


StopEvent: // To turn it off...
set .active,0;
dispbottom "Stopped";
close2;
goto OnInit;

cancel:
close;




OnInit:
while (.active == 1) { // Loop until event is turned off.
	monster "pvp_n_3-5",0,0,"--ja--",-1,1; // Summon a random monster at random coordinates.
	sleep 5000; // Wait 5 seconds.
}

}

10 answers to this question

Recommended Posts

Posted (edited)

how about like this?

OnInit:
while( 1){
 if( getmapusers("pvp_n_3-5") ) monster "pvp_n_3-5",0,0,"--ja--",-1,1;
 sleep 5000; // Wait 5 seconds.
}
end;
}

i have used this:

while (getmapusers("pvp_n_3-5") >= 1) { // Loop until event is turned off.
	monster "pvp_n_3-5",0,0,"--ja--",-1,1;
	sleep 5000; // Wait 5 seconds.
}

how can i start automatically the npc when a player join the map? :/

Edited by Belkan
Posted

Emistry's code works, yours doesn't. Another instance of the "don't copy code if you don't know what it means" rule: your while() loop ends immediately if a player is not found after a 5 second interval.

Posted (edited)

Emistry's code works, yours doesn't. Another instance of the "don't copy code if you don't know what it means" rule: your while() loop ends immediately if a player is not found after a 5 second interval.

but i wanna to active the npc only if there is at least one player on the map so it isn't wrong in my opinion O.o

Edited by Belkan
Posted

try this ?

pvp_n_3-5,99,99,5 script Brancher 757,{
if( select( (( .Event )?"STOP":"START" ),"Cancel" ) == 1 ){
set .Event,!.Event;
mes ""+( ( .Event )?"STARTED":"STOPPED" );
}
close;

OnInit:
while( 1 ){
if( .Event && getmapusers("pvp_n_3-5") && mobcount("pvp_n_3-5","All") < 30 )
 monster "pvp_n_3-5",0,0,"--ja--",-1,1; // Summon a random monster at random coordinates.
sleep 5000; // Wait 5 seconds.
}
end;
}

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