yuhsing

Untitled

Dec 19th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1.  
  2.  
  3. function script setCoordinate {
  4. .@npc_id = getnpcid(0);
  5.  
  6. .@map$ = getvariableofnpc( .map$,"Sample#main");
  7. if( getarg(0) == 0 ){
  8. do{
  9. .@x = rand( 50,200 );
  10. .@y = rand( 50,180 );
  11. }while( !checkcell( .@map$,.@x,.@y,cell_chkpass ) );
  12.  
  13. }else{
  14. .@x = 50;
  15. .@y = 50;
  16. }
  17.  
  18. unitwarp .@npc_id,.@map$,.@x,.@y;
  19. return;
  20. }
  21.  
  22. - script Sample#main -1,{
  23. OnInit:
  24. // event map
  25. .map$ = "xmas_fild01";
  26. // event duration
  27. .event_minute = 1;
  28.  
  29. // mapflags
  30. setarray .@mapflag[0],0,1,2,3,9,13,22,33,34,42,45;
  31. .@mf_size = getarraysize( .@mapflag );
  32. for( .@i = 0; .@i < .@mf_size; .@i++ )
  33. setmapflag .map$,.@mapflag[.@i];
  34.  
  35. // remove all players from the map
  36. mapwarp .map$,"prontera",155,181;
  37. end;
  38.  
  39.  
  40. OnPCLoadMapEvent:
  41. if( strcharinfo(3) == .map$ ){
  42. if( .status && getcharid(2) ){
  43. @collected_points = 0;
  44. .@guild_size = getarraysize( .guild_list );
  45.  
  46. for( .@i = 0; .@i <= .@guild_size; .@i++ )
  47. if( .@i == .@guild_size ){
  48. .guild_list[.@i] = getcharid(2);
  49. break;
  50. }else if( .guild_list[.@i] == getcharid(2) ){
  51. break;
  52. }
  53. @guild_index = .@i;
  54.  
  55. }else{
  56. mes "You cant enter this map if the event is not started / you are guildless";
  57. close2;
  58. warp "SavePoint",0,0;
  59. }
  60. }
  61. end;
  62.  
  63. OnWhisperGlobal:
  64. OnMinute00:
  65.  
  66. // start event if not started yet
  67. if( !.status ){
  68.  
  69. // remove all player
  70. mapwarp .map$,"prontera",155,181;
  71.  
  72. // clear data
  73. deletearray .winner;
  74. deletearray .guild_list;
  75. deletearray .guild_score;
  76.  
  77. // event start
  78. .status = 1;
  79.  
  80. announce "event start",0;
  81. donpcevent "::OnEventStart";
  82.  
  83. sleep2 ( .event_minute * 60000 );
  84.  
  85. // event end
  86. .status = 0;
  87. announce "event end",0;
  88. donpcevent "::OnEventEnd";
  89.  
  90. // Check for highest score guild with minimum of 1 point
  91. for( .@i = 0; .@i < getarraysize( .guild_list ); .@i++ )
  92. if( .guild_score[.@i] && .guild_score[.@i] >= .winner[1] ){
  93. .winner[0] = .guild_list[.@i];
  94. .winner[1] = .guild_score[.@i];
  95. }
  96.  
  97. // announce winner guild
  98. if( getarraysize( .winner ) == 2 ){
  99. announce "Guild "+getguildname( .winner[0] )+" win the game with "+.winner[1]+" scores.",0;
  100. }
  101. }
  102. end;
  103.  
  104. // update points when clicked
  105. OnCollectPoint:
  106. if( .status && getcharid(2) && @collected_points ){
  107. .guild_score[ @guild_index ] += @collected_points;
  108. @collected_points = 0;
  109. announce "Guild "+getguildname( .guild_list[ @guild_index ] )+" scored "+.guild_score[ @guild_index ]+" points already.",0;
  110. }
  111. end;
  112. }
  113.  
  114.  
  115. xmas_fild01,73,73,4 script Point Collector 757,{
  116. doevent "Sample#main::OnCollectPoint";
  117. }
  118.  
  119.  
  120.  
  121.  
  122.  
  123. prontera,1,1,1 script item#0 723,{
  124. if( getvariableofnpc( .status,"Sample#main") && getcharid(2) ){
  125. progressbar "ffffff",1;
  126.  
  127. // generate points
  128. .@point = rand( 1,4 );
  129. @collected_points += .@point;
  130. mes "this item have ^0055ff"+.@point+" points^000000.";
  131. mes " ";
  132. mes "total points : ^ff0000"+@collected_points+" points^000000";
  133.  
  134. // hide npc and re-coordinate the npc
  135. hideonnpc strnpcinfo(0);
  136. close2;
  137. setCoordinate( 0,getnpcid(0) );
  138. sleep ( ( 10 + .@point * 20 ) * 100 );
  139. hideoffnpc strnpcinfo(0);
  140. }
  141. end;
  142.  
  143. OnEventStart:
  144. setCoordinate( 0,getnpcid(0) );
  145. hideoffnpc strnpcinfo(0);
  146. end;
  147.  
  148. OnEventEnd:
  149. setCoordinate( 1,getnpcid(0) );
  150. hideonnpc strnpcinfo(0);
  151. end;
  152. }
Advertisement
Add Comment
Please, Sign In to add comment