Jump to content
  • 0
driver

On-Off event

Question

Hey, guys, how are you?
Before, I would like to wish everyone a great Christmas!

Guys, I'm starting to organize my scripts. I am still a layman on the subject. But I have a doubt ...
I would like to add the Cancel Event option in the GM script menu. I tried in a few ways, but the event just cancels the entry, but it still works. I wanted an example of variable for this script, please.

Script:
https://pastebin.com/WB6hRAm4

To connect works well.
 

			case 1:
			if(!$evento){
				mes "Event started successfully.";
				close2;
				callsub evento_start;
				end;
			}
			mes "The event has already started.";
			close;

But to hang up does not work. Even if I call '$event, 0;'

Could someone give me a hint for this script? in:
 

			case 2:
			*TURN OFF - EXAMPLE*
			}
			mes "The event has already been turned off";
			close;
		}

Thank you! ❤️

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

You can add a event, for example OnEndEvent: and kill all the monster of your event, announces, turn off event vars, etc...
and call the event in your menu

Share this post


Link to post
Share on other sites
  • 0

I have added:

			case 2:
			if(!$evento)
			{
				mes "Event canceled successfully.";
				close2;
				callsub Onendevent;
				end;
			}
			mes "The event has already been canceled.";
			close;

and in the end

Onendevent:
    if($evento) announce "Canceled Lucky Event!",bc_all;
	killmonster .Map$,"All";
	set .Event,0;
	end;
}

The portal closes, but the npc continues to announce '' 4 minutes for the event .. "

Share this post


Link to post
Share on other sites
  • 0

Try this i just made this on my phone

 

mes "Welcome Admin";
next;
switch((""+((!$EVENT)?"^ff0000Start Event!^000000":"^00AA00Finish Event^000000")+"^000000:Exit")){
	case 1:
			set $EVENT, ((!$EVENT)?1:0);
			if ($EVENT == 1){
				mes "Event Started";
				warp "mapname",x,y;
				announce "test",BC_ALL;
				sleep 5000;
				end;
				}else{
				mes "Event Ended!";
				end;
				}
				end;
			}
			end;
	case 2:
			end;
}

 

Share this post


Link to post
Share on other sites
  • 0

Thank you very much sir, but it seems to be wrong, the menu does not appear.

I've tried in several ways, but I can't understand ...

If I Replace OnInit: with OnEndEvent: npc cannot verify whether the event is open or closed.

If I add callsub; or goto; the event turns on / off but even turned off the portal closes but the script still insists on announcing the event with the portal closed.

I really want to learn, I think I don't know how to call variables or understand differences.

I'll leave the script below, please, if someone fixes the script I can understand the error and learn more about it.

Spoiler
			
			case 1:
			if(!$event){		//How to check if the event has already started, or shut down? 
				mes "Event started successfully.";
				close2;
				callsub OnstartEvent;		//I don't know if 'callsub' or 'goto' is a correct option to call the variable
				end;
				}
				mes "The event has already started.";
				close;
			
			case 2:
			if(!$event){
				mes "Event shut down successfully.";
				close2;
				callsub OnEndEvent;		//I don't know if 'callsub' or 'goto' is a correct option to call the variable. The 'if (! $ Event)' of case 1 causes it to damage the closed portal. 
				end;
				}
				mes "The event has already been turned off.";
				close;

				case 4:
		mes "Okay, come back when you need my services.";
		close;
	}

	OnClock0000: OnClock1200:

	OnStartEvent:

	set $event,1;
	announce "Lucky Event: The portal will close in [1] minute... Run!!!",bc_yellow|bc_all;
	sleep 60000;

	set $event,0;
	if(getmapusers("quiz_02") < 1)
	{
		announce "Lucky Event: The event was canceled due to lack of players...",bc_yellow|bc_all;
		end;
	}
OnPCDieEvent:
	if(strcharinfo(3) == "quiz_02"){
		dispbottom "You lost ... Try next time!";
		warp "SavePoint",0,0;
		end;
	}

OnInit:	//If I replace it with 'OnEndEvent:' the 'if (! $ Event)' menu cannot check if the event is open / closed.
	set $event,0;
	end;
}

 

Thank you for being patient with me and sorry for my amateurism.

Edited by driver

Share this post


Link to post
Share on other sites
  • 0
5 hours ago, driver said:

Thank you very much sir, but it seems to be wrong, the menu does not appear.

I've tried in several ways, but I can't understand ...

If I Replace OnInit: with OnEndEvent: npc cannot verify whether the event is open or closed.

If I add callsub; or goto; the event turns on / off but even turned off the portal closes but the script still insists on announcing the event with the portal closed.

I really want to learn, I think I don't know how to call variables or understand differences.

I'll leave the script below, please, if someone fixes the script I can understand the error and learn more about it.

  Hide contents

prontera,147,169,5	script	Lucky Event	4_M_LGTMAN,{

	mes @npc$;
	mes "Hi "+strcharinfo(0)+"!";
	mes	"Welcome to the Lucky event portal.";
	mes "What do you want?";
	if(getgmlevel() >= @lvlgm)
	switch(select("- Enter the Event","- Information",.@m$,"Exit")){
		next;
		mes @npc$;

		case 1:
		if(!$event)
		{
			mes "The event is closed. Come back later...";
			close;
		}
		mes "Good luck!";
		set @event, rand(1,4);
		if(@event == 1){ warp "quiz_02",37,52; }
		if(@event == 2){ warp "quiz_02",73,52; }
		if(@event == 3){ warp "quiz_02",49,52; }
		if(@event == 4){ warp "quiz_02",61,52; }
		end;

		case 2:
		mes "The event will demand a lot of luck and audacity.";
		next;
		mes @npc$;
		mes "The Lucky takes place every day within 3 hours.";
		next;
		mes @npc$;
		mes "After the event starts, you will need to survive 5 minutes of combat with other opponents.";
		next;
		mes @npc$;
		mes "If you manage to survive, you can destroy a treasure chest. Remembering that when you destroy it, you will need a lot of luck to receive a good prize!";
		next;
		mes @npc$;
		mes "The event times are:";
		mes "- ^FF000000:00^000000 / ^FF000003:00^000000 / ^FF000006:00^000000 / ^FF000009:00^000000";
		mes "- ^FF000012:00^000000 / ^FF000015:00^000000 / ^FF000018:00^000000 / ^FF000021:00^000000";
		close;
		
		
		case 3:
		mes "What do you want to do?";
		switch(select("Start the event:Turn off the event")){
			next;	
			mes @npc$;
			
			case 1:
			if(!$event){		//How to check if the event has already started, or shut down? 
				mes "Event started successfully.";
				close2;
				callsub OnstartEvent;		//I don't know if 'callsub' or 'goto' is a correct option to call the variable
				end;
				}
				mes "The event has already started.";
				close;
			
			case 2:
			if(!$event){
				mes "Event shut down successfully.";
				close2;
				callsub OnEndEvent;		//I don't know if 'callsub' or 'goto' is a correct option to call the variable. The 'if (! $ Event)' of case 1 causes it to damage the closed portal. 
				end;
				}
				mes "The event has already been turned off.";
				close;

				case 4:
		mes "Okay, come back when you need my services.";
		close;
	}

	OnClock0000: OnClock1200:
	OnClock0300: OnClock1500:
	OnClock0600: OnClock1800:
	OnClock0900: OnClock2100:
	OnStartEvent:

	set $event,1;
	killmonsterall "quiz_02";
	announce "Lucky Event: The portal is open, and will close in [5] minutes... Get ready!",bc_yellow|bc_all;
	sleep 60000;
	announce "Lucky Event: The portal is open, and will close in [4] minutes......",bc_yellow|bc_all;
	sleep 60000;
	announce "Lucky Event: The portal is open, and will close in [3] minutes......",bc_yellow|bc_all;
	sleep 60000;
	announce "Lucky Event: The portal is open, and will close in [2] minutes......",bc_yellow|bc_all;
	sleep 60000;
	announce "Lucky Event: The portal will close in [1] minute... Run!!!",bc_yellow|bc_all;
	sleep 60000;

	set $event,0;
	if(getmapusers("quiz_02") < 1)
	{
		announce "Lucky Event: The event was canceled due to lack of players...",bc_yellow|bc_all;
		end;
	}
	announce "Lucky Event: The event started ... good luck to all!",bc_blue|bc_all;
	pvpon "quiz_02";
	removemapflag "quiz_02",mf_noskill;
	sleep 240000;
	mapannounce "quiz_02","Lucky Event: In 1 minute buses will come! Run to destroy them..",bc_yellow|bc_all;
	sleep 60000;
	pvpoff "quiz_02";
	setmapflag "quiz_02",mf_noskill;
	mapannounce "quiz_02","Lucky Event: Destroy the chests!!!",bc_blue|bc_all;
	monster "quiz_02",34,69, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",39,60, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",51,69, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",46,60, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",58,69, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",63,60, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",75,69, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	monster "quiz_02",70,60, "Lucky Chest",1354,1,""+strnpcinfo(1)+"::OnPrize";
	end;

OnPrize:
	set @rand_prize, rand(1,6);
	if(@rand_prize == 1)
	{
		getitem $id_prize[0],$quantity_prize[0];
		announce "Lucky Event: "+strcharinfo(0)+" opened a Lucky Chest and won: "+$quantity_prize[0]+" "+getitemname($id_prize[0])+"",8;
	}
	if(@rand_prize == 2)
	{
		getitem $id_prize[1],$quantity_prize[1];
		announce "Lucky Event: "+strcharinfo(0)+" opened a Lucky Chest and won: "+$quantity_prize[1]+" "+getitemname($id_prize[1])+"",8;
	}
	if(@rand_prize == 3)
	{
		getitem $id_prize[2],$quantity_prize[2];
		announce "Lucky Event: "+strcharinfo(0)+" opened a Lucky Chest and won: "+$quantity_prize[2]+" "+getitemname($id_prize[2])+"",8;
	}
	if(@rand_prize == 4)
	{
		set Zeny,Zeny + $quantity_zeny;
		announce "Lucky Event: "+strcharinfo(0)+" opened a Lucky Chest and won: "+$quantity_zeny+" Zenys",8;
	}
	if(@rand_prize == 5)
	{
		set #CASHPOINTS,#CASHPOINTS + $quantity_cash;
		announce "Lucky Event: "+strcharinfo(0)+" opened a Lucky Chest and won: "+$quantity_cash+" Cash Point's",8;
	}
	if(@rand_prize == 6)
	{
		atcommand "@kill "+strcharinfo(0);
		announce "Lucky Event: "+strcharinfo(0)+" opened a Lucky Chest and won: The death! (muhaha)",8;
	}
	warp "prontera",156,191;
	end;

OnPCDieEvent:
	if(strcharinfo(3) == "quiz_02"){
		dispbottom "You lost ... Try next time!";
		warp "SavePoint",0,0;
		end;
	}

OnInit:	//If I replace it with 'OnEndEvent:' the 'if (! $ Event)' menu cannot check if the event is open / closed.
	set $event,0;
	end;
}

quiz_02	mapflag	nomemo
quiz_02	mapflag	nowarp
quiz_02	mapflag	nowarpto
quiz_02	mapflag	nosave	SavePoint
quiz_02	mapflag	noicewall
quiz_02	mapflag	nomemo
quiz_02	mapflag	noreturn

 

Thank you for being patient with me and sorry for my amateurism.

This is how we made a tweek on event


This is how we do the controls

OnInit:
	.Event = 0 // Meaning 0 = close | 1 = Open
	end;


So that mean when the event start we will do like this . We set .Event,1; to make it open 

set .Event,1;

After this you will add broadcast right ? after the broadcast countdown when the broadcast say it close this time we will set it to 0

This time the event is now close.

set .Event,0;



Now we will add condition statement

if (.Event = 1){
	mes "Add something here if the event is Open";
	mes "Ok i will warp you now to event warper
}else{
	mes "Add something here if the event is close";
	mes "Sorry the event are now close";
	end;
}
end;// to end the statement

 

Share this post


Link to post
Share on other sites
  • 0

Thanks for your explanation Mr @Poring King!
I made some changes to the script. I can start the event through the 'Manager' menu and also turn it off.
But when I hang up, the event closes the portal, but it continues to announce saying that there are x minutes left to start ... Even with it turned off. How can I fix this?

 

Spoiler
			case 1:
			if(!.LkEvent){
			mes "Starting the event now...";
			close2;			
			callsub OnStart;
			end;
			}
			mes "The event has already started.";
			close;
			
			case 2:
			if(!.LkEvent){
			mes "Turn off the event now...";
			close2;			
			callsub OnEndEvent;
			end;
			}
			mes "The event has already been turned off.";
			close;
		}

		case 4:
		mes "I will be available when you need my services.";
		mes "See you "+strcharinfo(0)+"!";
		close;
	}

	OnClock2330: OnClock1200:
	OnClock0300: OnClock1500:
	OnClock0600: OnClock1800:
	OnClock0900: OnClock2100:

OnStart:
	set .LkEvent,1;
	announce "Lucky: The portal is open, and will close in [1] minute ... Run !!!",0,0xFFFF00;
	sleep 60000;

	set .LkEvent,0;
	if(getmapusers("quiz_02") < 1){
		announce "Lucky: The event was canceled due to lack of participants ...",0,0xFFFF00;
		end;
	}

OnPCDieEvent:
	if(strcharinfo(3) == "quiz_02"){
		dispbottom "Lucky: You lost ... Try next time!";
		warp "SavePoint",0,0;
		end;
	}

OnEndEvent:
	set .LkEvent,0;
	end;
}

 

 

Edited by driver

Share this post


Link to post
Share on other sites
  • 0
7 hours ago, Poring King said:

Stop the timer 

Sorry, how do I do?

Share this post


Link to post
Share on other sites
  • 0

Thank you so much!

Problem solved.

Share this post


Link to post
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.