Jump to content
  • 0

Grab the candy


donkeyg

Question


  • Group:  Members
  • Topic Count:  344
  • Topics Per Day:  0.08
  • Content Count:  1060
  • Reputation:   1
  • Joined:  02/13/12
  • Last Seen:  

warp into a room and in when every one ready spawn a dozen of candy. in 10 second player who grab the most candy is the winner and wil receive Poring Coin

Link to comment
Share on other sites

25 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

1. its better to do delitem when the event about to start ...

player might cheat to collect them from other means ( taken from previous round and drop on floor ... etc )

2. you can just store the value of highest value candy user in strcharinfo(0) or getcharid(3) .. then no need to reloop for 2nd time ..

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@Annie

thx for remind to remove the candy before they enter the event...

for the event .... there might be a small possibilities that several players might have same amount of candy when they "win" the event

so i just loop through to find the highest amount of candy holder ... and the loop again and give reward for those player who gained most candy than others....

the second suggestion that store the winner that annie suggest only work for 1 winner...it would be unfair to give only 1 player reward while there is more than 1 winner...

or maybe annie was refer another method for this ? currently didnt know if there is any other better method ....

http://pastebin.com/raw.php?i=KRpvRfNE

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Why not store the information into an array. While attaching each player, set array[0] as the highest. Then when someone has the same amount set it to array[1] and so on. And finally if someone has the highest, delete array and set at [0]. Lastly you can store the amount and players I'd in the same array slot so you can retrieve the information later using explode to reattach and give the prize. This way you wouldn't need to loop through all the players again, just the ones you know are winners.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

hmm ... it seems I have complicated a little bit

I used 2 dimension array to calculate the highest amount candy

prontera,155,184,5    script    kjdshfdkshf    100,{
   if ( .start == 0 ) {
       dispbottom "no event atm";
       end;
   }
   if ( .start == 2 ) {
       dispbottom "event is running";
       end;
   }
   if ( checkcart() ) { // common sense, countitem/delitem couldn't search into a cart, and a blacksmith can use greed ... hmm greed can be use without cart
       dispbottom "you can't bring a cart into this event";
       end;
   }
   if ( getarraysize( .register_aid ) >= 100 ) {
       dispbottom "limitation reach";
       end;
   }
   warp "guild_vs2", 0,0;
   .register_aid[ getarraysize( .register_aid ) ] = getcharid(3);
   end;
OnWhisperGlobal:
   if ( .start ) end;
   announce "pick up event registration start", 0;
   .start = 1;
   sleep 10000;
   announce "pick up event registration close", 0;
   .start = 2;
   sleep 3000;
   mapannounce "guild_vs2", "pick up as many items on floor as you can !", 0;
   sleep 1000;
   for ( .@i = 5; .@i >= 0; .@i-- ) {
       mapannounce "guild_vs2", "["+ .@i +"]", 0;
       sleep 1000;
   }
   .@drop_candy_amount = getarraysize( .register_aid ) * 12;
   freeloop 1;
   while ( .@i < .@drop_candy_amount ) {
       while ( checkcell( "guild_vs2", .@x = rand(150), .@y = rand(150), cell_chknopass ) );
       makeitem "Candy",1,"guild_vs2", .@x, .@y;
       .@i++;
   }
   freeloop 0;
   sleep 10000;
   .@size = getarraysize( .register_aid );
   for ( .@i = 0; .@i < .@size; .@i++ ) {
       if ( attachrid( .register_aid[.@i] ) ) {
           .@amount = countitem( "Candy" );
           if ( .@amount >= .@highest ) {
               setd ".@count"+ .@amount +"["+ getarraysize( getd( ".@count"+ .@amount ) ) +"]", getcharid(3);
               .@highest = .@amount;
           }
           delitem "Candy", countitem( "Candy" );
       }
   }
   atcommand "@cleanmap"; // randomly attach someone to @cleanmap
   .@size = getarraysize( getd( ".@count"+ .@highest ) );
   for ( .@i = 0; .@i < .@size; .@i++ ) {
       attachrid getd( ".@count"+ .@highest +"["+ .@i +"]" );
       getitem "Poring_Coin", 1;
       .@name$ = .@name$ +( ( .@i )? " , ":"" )+"["+ rid2name( getd( ".@count"+ .@highest +"["+ .@i +"]" ) ) +"]";
   }
   mapannounce "guild_vs2", "event end, there are "+ .@size +" player having most candy ! "+ .@name$, 0;
   sleep 5000;
   getmapxy .@map$, .@x, .@y, 1;
   mapwarp "guild_vs2", .@map$, .@x, .@y;
   deletearray .register_aid;
   .start = 0;
   end;
OnPCLogoutEvent:
   if ( .start ) {
       .@size = getarraysize( .register_aid );
       while ( getcharid(3) != .register_aid[.@i] && .@size < .@i ) .@i++;
       if ( .@i < .@size )
           deletearray .register_aid[.@i], 1;
   }
   end;
}
guild_vs2    mapflag    nowarp
guild_vs2    mapflag    nowarpto
guild_vs2    mapflag    noteleport
guild_vs2    mapflag    nomemo
guild_vs2    mapflag    noicewall
guild_vs2    mapflag    nobranch
guild_vs2    mapflag    nosave    SavePoint

btw now compare to mine, I just find out ... emistry still need to learn more about

how to use OnPCLogoutEvent / OnPCDieEvent / OnPCLoginEvent properly

if you guys want to master an event script, has to utilize these OnPC***Event properly

@GmOcean

I think you are the same, I also just realize your script also didn't make use of them properly

tomorrow I'll criticize your script

EDIT:

almost forgotten about @cleanmap

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   25
  • Joined:  11/23/11
  • Last Seen:  

You will have to set mapflags because a player can get into the room with Warp Portal and then exchange candys.

Or better solution, make a new item and put a new line in item_trade.txt (because some monsters drops candys), the only way to get that item will be on the event.

And I dunno, but the items deletion is before the winner check, so he will not have the user amount=maxcandy.

Edited by Omnipotent
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

O.o are you sure.. Well, I haven't tried making this script just suggested a method to store the information to reward all players who have the highest amount.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  71
  • Reputation:   25
  • Joined:  11/23/11
  • Last Seen:  

I little detail I see in Ruru's script is that everyone can win if they all don't pick any candy, so that would be somewhat exploitable.

I think a min amount to pick would be somewhat to prevent that exploit :P

set .@min, 5;
if ( .@amount > .@highest && .@amount > .@min ) {

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  344
  • Topics Per Day:  0.08
  • Content Count:  1060
  • Reputation:   1
  • Joined:  02/13/12
  • Last Seen:  

ahhhhh.. which event script shud i use??

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

@GmOcean

yeah, I felt like ... my way is more efficient

and what I'm trying to tell, is because event script is unlike any other kind of scripts

for algorithm or utility type scripts ...

you can just keep testing in test server and once you get the correct result, its good to release

but event script needs A LOT of experiences and many members feedback to know about the rare bugs and exploits

and the fastest way to learn about event script is learn from criticize from other scripters

just like Omnipotent doing atm

@Omnipotent

You will have to set mapflags because a player can get into the room with Warp Portal and then exchange candys.

yes, I already set nomemo mapflag

nowarp and nowarpto mapflag is also a common sense to set inside an event script

Or better solution, make a new item and put a new line in item_trade.txt (because some monsters drops candys), the only way to get that item will be on the event.

And I dunno, but the items deletion is before the winner check, so he will not have the user amount=maxcandy.

I think, do another delitem at the time during player register might be better xD

I little detail I see in Ruru's script is that everyone can win if they all don't pick any candy, so that would be somewhat exploitable.

I think a min amount to pick would be somewhat to prevent that exploit :P

set .@min, 5;
if ( .@amount > .@highest && .@amount > .@min ) {

WTF !! no wonder I already sense you are very high level scripter making this script

pro ! glad to see someone like you in this forum !

thx for finding this bug :P

gives you another rep up

@donkeyg

none of the above

every previous script has flaw and is exploitable

that's why we are discussing how to make a flawless event script for you :P

try this

candy_event_0.2.txt

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  344
  • Topics Per Day:  0.08
  • Content Count:  1060
  • Reputation:   1
  • Joined:  02/13/12
  • Last Seen:  

Thank you babe! XD

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  218
  • Topics Per Day:  0.05
  • Content Count:  1180
  • Reputation:   141
  • Joined:  01/27/12
  • Last Seen:  

I think I would have just made it say in the rules that incase of a tie the winner would be picked randomly, lol. Good job everybody.

Peopleperson49

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

change

	if ( .@size ) {
	for ( .@i = 0; .@i < .@size; .@i++ ) {
		attachrid getd( ".@count"+ .@highest +"["+ .@i +"]" );
		getitem .reward_item_id, .reward_item_amount;
		.@name$ = .@name$ +( ( .@i )? " , ":"" )+"["+ rid2name( getd( ".@count"+ .@highest +"["+ .@i +"]" ) ) +"]";
	}
	mapannounce "guild_vs2", "event end, there are "+ .@size +" player having most "+ getitemname( .candy_id ) +" ! "+ .@name$, 0;
}

into

	if ( .@size ) {
	.@winner_index = rand(.@size);
	attachrid getd( ".@count"+ .@highest +"["+ .@winner_index +"]" );
	getitem .reward_item_id, .reward_item_amount;
	mapannounce "guild_vs2", "event end, the winner is ["+ strcharinfo(0) +"] !!";, 0;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  1
  • Reputation:   0
  • Joined:  12/10/11
  • Last Seen:  

how to start this event ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

update this script

candy_event_0.3.txt

you can use Whisper to this npc

npc:Grab the Candy !

or use OnClockxxxx: ... just uncomment it

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  344
  • Topics Per Day:  0.08
  • Content Count:  1060
  • Reputation:   1
  • Joined:  02/13/12
  • Last Seen:  

update this script

candy_event_0.3.txt

you can use Whisper to this npc

npc:Grab the Candy !

or use OnClockxxxx: ... just uncomment it

i couldnt click the npc, nothing response after load the npc

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  218
  • Topics Per Day:  0.05
  • Content Count:  1180
  • Reputation:   141
  • Joined:  01/27/12
  • Last Seen:  

I may have missed something, but why not use bindatcmd instead of OnWhisperGlobal? Something like @grabcandy.

Peopleperson49

Edited by Peopleperson49
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

update this script

candy_event_0.3.txt

you can use Whisper to this npc

npc:Grab the Candy !

or use OnClockxxxx: ... just uncomment it

i couldnt click the npc, nothing response after load the npc

This uptade works with rAthena only (I guess you have eAthena) and it works perfectly.

Edited by Capuche
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  344
  • Topics Per Day:  0.08
  • Content Count:  1060
  • Reputation:   1
  • Joined:  02/13/12
  • Last Seen:  

lol, im using rathena=.=" 16815 version. and i use @loadnpc to load the npc

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  218
  • Topics Per Day:  0.05
  • Content Count:  1180
  • Reputation:   141
  • Joined:  01/27/12
  • Last Seen:  

I would just leave it loaded all the time and activate and deactivate it with bindatcmd. You can use one command and have it end if your not a gm. When it is used it will start the event if not running and end it if it is running. Very simple scripting!

Peopleperson49

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

lol, im using rathena=.=" 16815 version. and i use @loadnpc to load the npc

lol my apologies. Do you have used Whisper to activate the NPC like AnnieRuru said ?

you can use Whisper to this npc

npc:Grab the Candy !

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I've been making event scripts for 4 years, and this whisper system has been stuck into my scripting style =/

bindatcmd might be normal for you guys, but for me who have been scripting for 6 years, I need some time to adjust

so here I rewrite again

candy_event_0.4.txt

activate this event by @candy if you are GM60 or above

and damn ... now I got more scripts to update -.-"

@Capuche

I believe this script only works on recent SVN because I use *cleanmap script command

which only added recently

http://trac.rathena.org/changeset/16971/rathena

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

@Capuche

I believe this script only works on recent SVN because I use *cleanmap script command

which only added recently

http://trac.rathena....t/16971/rathena

I see... I was wrong /swt

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  84
  • Topics Per Day:  0.02
  • Content Count:  550
  • Reputation:   9
  • Joined:  11/06/12
  • Last Seen:  

I've been making event scripts for 4 years, and this whisper system has been stuck into my scripting style =/

bindatcmd might be normal for you guys, but for me who have been scripting for 6 years, I need some time to adjust

so here I rewrite again

attachicon.gifcandy_event_0.4.txt

activate this event by @candy if you are GM60 or above

and damn ... now I got more scripts to update -.-"

@Capuche

I believe this script only works on recent SVN because I use *cleanmap script command

which only added recently

http://trac.rathena.org/changeset/16971/rathena

im using r16797 how can i make it work mam?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@2834

update ur svn...or add the cleanmap script command.

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