Jump to content
  • 0

Participating X time at mini-game/event?


AtomikGrafik

Question


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

After my first post, I noticed that my error is not really affecting my script upload, which I am relieved.

Anyways, I have a questions. I am working on a mini-game script and I was wondering if it was feasable to put an account based limit on how many times a player can acess and play the mini-game?

I was thinking 3 times a day.

Thanks a lot!

Edited by AtomikGrafik
Link to comment
Share on other sites

17 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

I think this will do...

if ( #mg_time_1 != gettimestr(%Y%m%d,9) )
{
set #mg_time_1, gettimestr(%Y%m%d,9);
set #mg_time_2, 0;
}
if ( #mg_time_2 > 3 )
{
// Have played this event for 3 times ...
}
set #mg_time_2, #mg_time_2 + 1;
// Start Event ...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

@Joseph: Wow, thank you so much! I will try it out as well as trying to get a better understanding of gettimestr and such. ^^

Oh, silly me, I forgot to ask if someone could give a deeper explanation (while keeping it simple) about gettimestr since it doesn't say much on the wiki.

Here is the script I am working on currently and yes, it's as basic as it can get and it's far from completion.

What I am trying to do is after a player participated 3 times in the mini-game, is for the NPC to say that the person reached the daily limit. Of course the limit is per account, not per character.

Thank you for assisting me. :)

//========================================================
       //TREASURE CHEST MINI-GAME        
//========================================================

//=====================NPC: Hylian========================

prontera,159,186,3    script    Hylian::hyl_warp    51,{
       mes "[Hylian]";
       mes "Hello, my name is Hylian";
       mes "and I'm the one in charge of";
       mes "the Treasure Chest mini-game.";
       next;
       mes "[Hylian]";
       mes "Do you want me to explain";
       mes "how the mini-game works?";
       next;
       switch(select("Yes, please!::Skip it and go!"))
           {
               case 1:
                   mes "[Hylian]";
                   mes "You'll have 1 minute to pick";
                   mes "1 treasure chest out of 3.";
                   next;
                   mes "[Hylian]";
                   mes "If lucky, you can end up with";
                   mes "a really nice prize!";
                   next;
                   mes "[Hylian]";
                   mes "Do you wish to play?";
                   switch(select("Sure!::I'll pass."))
                       {
                           case 1:
                               mes "[Hylian]";
                               mes "Let's go!";
                               warp "poring_w02",95,200;
                               end;

                           case 2:
                               mes "[Hylian]";
                               mes "You're missing all the fun!";
                               close;
                       }
               case 2:
                   mes "[Hylian]";
                   mes "Alright!";
                   warp "poring_w02",95,200;
                   end;
           }
}




//========================================================
         //TREASURE CHEST MINI-GAME        
//========================================================

//=======================WAITING ROOM=====================

poring_w02,96,200,5    script    Hylian::hyl_wait    51,{
   end;
       OnInit:
           delwaitingroom "Treasure Chest";
           waitingroom "Treasure Chest",8,"play_wait::OnWarpToArea",1;
           end;

       OnWarpToArea:
               warpwaitingpc "poring_c01",104,102;
               end;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Basically, it gets the date and/or time data (%Y - Year; %m - Month; %d - Day; %H - Hour; %M - Minute; %S - Second).

Script:

http://upaste.me/1163480d0d50146

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

I figured that Y M D part but what about that number that comes afterward? I have seen in different scripts that is varies (9, 21, 40 etc.).

Does it mean anything?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Its the total length of it.

*gettimestr(<format string>,<max length>)
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

Its the total length of it.

*gettimestr(<format string>,<max length>)

I'm not sure that I get it... max lenght of what exactly? Sorry if I come off like an idiot, I can be a bit slow in understanding. ^^;

Edit: Nevermind, I re-read and it says the max lenght of the string... but what I don't understand is how that is determined?

Edited by AtomikGrafik
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Lets say %Y gives 2012 (4 digits), so your max length must be higher than 4. You can put 5 or even 100, as long the max length value is always higher.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

Lets say %Y gives 2012 (4 digits), so your max length must be higher than 4. You can put 5 or even 100, as long the max length value is always higher.

I see, I get it now! :D

Well, I have applied the script but I am getting an error as well as 3 debug.

[error]: script: op_2: invalid data for operator C_NE

[debug]: data: number value=0

[debug[: string value="20120611"

[debug]: source (NPC): Hylianne at prontera (159,186)

I still haven't figured out what could be causing this.

Any clue?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Post the script.. /wah

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

Woops, here it is. Thanks a lot for helping me out, I appreciate it. : )

//========================================================
		    //TREASURE CHEST MINI-GAME			  
//========================================================

//=====================NPC: Hylian========================
prontera,159,186,3    script    Hylianne::hyl_warp    51,{
   mes "[Hylianne]";
   mes "Hello, my name is Hylianne";
   mes "and I'm the one in charge of";
   mes "the Treasure Chest mini-game.";
   next;
   mes "[Hylian]";
   mes "Do you want me to explain";
   mes "how the mini-game works?";
   next;
   switch(select("Yes, please!::Skip it and go!"))
       {
       case 1:
           mes "[Hylianne]";
           mes "You'll have 1 minute to pick";
           mes "1 treasure chest out of 3.";
           next;
           mes "[Hylianne]";
           mes "If lucky, you can end up with";
           mes "a really nice prize!";
           next;
           mes "[Hylianne]";
           mes "Do you wish to play?";
           next;
           switch(select("Sure!::I'll pass."))
               {
               case 1:
                   break;

               case 2:
                   mes "[Hylianne]";
                   mes "You're missing all the fun!";
                   close;
               }
       case 2:
           break;
       }
       if(#t_1 != gettimestr("%Y%m%d",9))
           {
           set #t_1, gettimestr("%Y%m%d",9);
           set #t_2, 0;
           }    
           if(#t_2 > 3)
               {
               mes "[Hylianne]";
               mes "I'm sorry, you can only play this event 3 times a day.";
               close;
               }
               mes "[Hylianne]";
               mes "Alright! Let's go!";
               close2;
               set #t_2, #t_2 + 1;
               warp "poring_w02",95,200;
               end;                    
}




//========================================================
         //TREASURE CHEST MINI-GAME        
//========================================================

//=======================WAITING ROOM=====================

poring_w02,96,200,5    script    Hylianne::hyl_wait    51,{
   end;
       OnInit:
           delwaitingroom "Treasure Chest";
           waitingroom "Treasure Chest",8,"play_wait::OnWarpToArea",1;
           end;

       OnWarpToArea:
               warpwaitingpc "poring_c01",104,102;
               end;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

Hello again.

I finally managed to make the limit work by tweaking the script. I also deleted unecessary dialogue to make the script shorter and the game's explanation will be done through NPC broadcast when the player enters the gaming room.

Here is my most recent problem, which baffles me since eAthena does not mention of my script having an error whatsoever.

My switch function somehow borks up whenever I select the second option of not wanting to play. The window with the dialogue "Do you want to play?" remains after I click "No thanks!" and I have to log off because it gets me stuck.

Here is the script

prontera,159,186,3    script    Airily::air_warp    51,{
   set .@tmp_time, gettimestr("%Y%m%d",9);
       if(#t_1 != .@tmp_time)
           {
           set #t_1, gettimestr("%Y%m%d",9);
           set #t_2, 0;
           }
           if(#t_2 > 3)
               {
               mes "[Airily]";
               mes "I'm sorry, you can only play this event 3 times a day.";
               close;
               }
               else
               {
               mes "[Airily]";
               mes "Hello, my name is Airily";
               mes "and I'm the one in charge of";
               mes "the Treasure Chest mini-game.";
               next;
               mes "[Airily]";
               mes "Do you want to play?";
               next;
               switch(select("Yes, please!::No thanks!"))
                   {
                       case 1:
                           mes "[Airily]";
                           mes "Alright! Let's go!";
                           close2;
                           set #t_2, #t_2 + 1;
                           warp "poring_w02",95,200;
                           end;

                       case 2:
                           mes "[Airily]";
                           mes "Bah!";
                           close;
                   }
               }
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Ah I saw your problem.

						    switch(select("Yes, please!::No thanks!"))

Remove one of the ":" and it should work fine.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

Oh wow! Talk about a typo I didn't see! Haha! Thanks a lot Joseph!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

I am not sure if I should post a new topic since I have 3 slight issues with the same script.

My first issue is setting up a RID, since warp does not work with this kind of script. I did check the Wiki and read about it but somehow I cannot fully understand when it goes in-depth. Can someone explain to me in a simpler way, with an example on how it works? Unless there is an alternative, please let me know?

My second issue is with the monster spawn. The script I have currently works well but it's not really what I am aiming for. My goal is to make 3 treasure chests spawn with each their respective drops (ex. 1 chest drops 2 gold coins, another one drops 1 etc.) and making them spawn randomly on the map. I am not sure if I will need to use arrays for this, which is another thing that I will need to learn eventually.

The last issue is if I can set @autoloot on the map. Since the event is timed, it would suck if someone didn't have the time to pick up the drops. I'd rather be safe than sorry.

Here is what I have so far in the last part of the script:

poring_w02,96,200,5	script	Airily::air_wait	51,{
end;
	OnInit:
		delwaitingroom "Treasure Chest";
		waitingroom "Treasure Chest",8,"air_wait::OnWarpToArea",1;
		end;

	OnWarpToArea:
			warpwaitingpc "poring_c01",104,102;
			initnpctimer "air_invis";
			end;
}



poring_c01,104,102,0	script	Airily::air_invis	-1,{
end;

	OnTCKill:
		set $TCAmount, $TCAmount - 1;
			if($TCAmount <= 2)
				{
				killmonsterall "poring_c01","air_invis::OnTCKill";
				areaannounce "poring_C01",0,0,350,350, "Come play again!",0;
				stopnpctimer "air_invis";
				detachnpctimer "air_invis";
				end;
				}

	OnTimer3000:
		areaannounce "poring_c01",0,0,350,350, "You have 1 minute to destroy the treasure chest of your

choice.",0;
		end;

	OnTimer8000:
		areaannounce "poring_c01",0,0,350,350, "If lucky, you can get a pretty nice prize!",0;
		end;

	OnTimer13000:
		areaannounce "poring_c01",0,0,350,350, "Are you ready? Get set! Go!",0;
		areamonster "poring_c01",109,100,99,90,"Treasure Chest",1348,3,"air_invis::OnTCKill";
		end;

	OnTimer88600:
		areaannounce "poring_c01",0,0,350,350, "Time's up! Come play again!",0;
		killmonsterall "poring_c01","air_invis::OnTCKill";
		warp "SavePoint",0,0; //currently not working since I need to attach the player with RID.
		stopnpctimer "air_invis";
		detachnpctimer "air_invis";
		end;

}

Thanks a lot! It's almost done thanks to Joseph, so far. I'm getting excited!

Edited by AtomikGrafik
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

Instead of areaannounce, you can use mapannounce

mapannounce "poring_c01","Message",0;

Is this what you're trying to search for?

Warp all the players away from a map.

*areawarp "<from map name>",<x1>,<y1>,<x2>,<y2>,"<to map name>",<x3>,<y3>;

This mapflag will disable all the monster drops:

// Enable Mapflag
setmapflag "poring_c01",mf_nomobloot;  
// Disable Mapflag
removemapflag "poring_c01",mf_nomobloot;	  

Directly obtain items into players' inventory without using @autoloot.

OnTCKill:
set .@r, 671; // Reward
setarray .@a, 1,1,2; // Amount(Random)
getitem .@r, .@a[rand(getarraysize(.@a))];

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  06/09/12
  • Last Seen:  

Thanks a lot, managed to make everything work! I guess my script is done! Although it still looks kind of clustered, it works well and I'm happy.

But WOW! I have learned so much more from this. :D

Joseph, if you can teach me about arrays, I'd be real happy! It's quite a hassle to learn it on my own! You can PM me about it with simple explanations and examples of what arrays can do, that is if you want. I'll still attempt on my own as well.

Finished.

//========================================================
			//TREASURE CHEST MINI-GAME			  
//========================================================

//=====================NPC: Airily======================

prontera,159,186,3	script	Airily::air_warp	51,{
set .@tmp_time, gettimestr("%Y%m%d",9);
	if(#t_1 != .@tmp_time)
		{
		set #t_1, gettimestr("%Y%m%d",9);
		set #t_2, 0;
		}
		if(#t_2 > 3)
			{
			mes "[Airily]";
			mes "I'm sorry, you can only play this event 3 times a day.";
			close;
			}
			else
			{
			mes "[Airily]";
			mes "Hello, my name is Airily";
			mes "and I'm the one in charge of";
			mes "the Treasure Chest mini-game.";
			next;
			mes "[Airily]";
			mes "Ready to play?";
			next;
			switch(select("Yes, please!:I'm not here to play..."))
				{
					case 1:
						mes "[Airily]";
						mes "Alright! Let's go!";
						close2;
						set #t_2, #t_2 + 1;
						setmapflag "poring_w02",mf_nosave;
						setmapflag "poring_c01",mf_nosave;
						warp "poring_w02",95,200;
						end;
					case 2:
						mes "[Airily]";
						mes "What a bummer...";
						close;
				}
			}
}




//========================================================
	  //TREASURE CHEST MINI-GAME		
//========================================================

//=======================WAITING ROOM=====================

poring_w02,96,200,5	script	Airily::air_wait	51,{
end;
	OnInit:
		delwaitingroom "Treasure Chest";
		waitingroom "Treasure Chest",8,"air_wait::OnWarpToArea",1;
		end;

	OnWarpToArea:
			setmapflag "poring_c01",mf_nomobloot;
		    setmapflag "poring_c01",mf_noskill;
			warpwaitingpc "poring_c01",104,102;
			initnpctimer "air_invis";
			end;
}




//========================================================
	  //TREASURE CHEST MINI-GAME		
//========================================================

//========================GAME ROOM=======================

poring_c01,104,102,0	script	Airily::air_invis	-1,{
end;

	OnTCKill:
		set .@r, 671;
		setarray .@a, 1,1,2;
		getitem .@r, .@a[rand(getarraysize(.@a))];
		set $TCAmount, $TCAmount - 1;
			if($TCAmount <= 2)
				{
				killmonsterall "poring_c01","air_invis::OnTCKill";
				mapannounce "poring_C01","Come play again!",0;
				areawarp "poring_c01",97,115,119,95,"prontera",158,185;
				stopnpctimer "air_invis";
				detachnpctimer "air_invis";
				end;
				}

	OnTimer3000:
		mapannounce "poring_c01","You have 1 minute to destroy the treasure chest of your choice.",0;
		end;

	OnTimer8000:
		mapannounce "poring_c01","If lucky, you can get a pretty nice prize!",0;
		end;

	OnTimer13000:
		mapannounce "poring_c01","Are you ready? Get set! Go!",0;
		areamonster "poring_c01",109,100,99,90,"Treasure Chest",1348,3,"air_invis::OnTCKill";
		end;

	OnTimer88600:
		mapannounce "poring_c01","Time's up! Come play again!",0;
		killmonsterall "poring_c01","air_invis::OnTCKill";
		areawarp "poring_c01",97,115,119,95,"prontera",158,185;
		stopnpctimer "air_invis";
		detachnpctimer "air_invis";
		end;

	OnPCLogoutEvent:
		savepoint "prontera",158,185;
			if($TCAmount <= 3)
				{
				killmonster "poring_c01","air_invis::OnTCKill";
				stopnpctimer"air_invis";
				detachnpctimer "air_invis";
				end;
				}				
}

Edited by AtomikGrafik
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...