yuhsing

Untitled

Apr 3rd, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.96 KB | None | 0 0
  1.  
  2.  
  3. function script ValueConvert {
  4. set .@num, atoi(""+getarg(0));
  5. if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
  6. set .@l, getstrlen(""+.@num);
  7. for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
  8. set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
  9. if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
  10. }
  11. return .@num$;
  12. }
  13.  
  14.  
  15. umbala,148,163,5 script Party vs Party#myro 118,{
  16. set .@gmlevel,getgmlevel();
  17. set .@partyid,getcharid(1);
  18.  
  19. callsub display_event_info;
  20. next;
  21. switch( select( ( .status == 1 )?"Register":( .status == 2 )?"Join / Quit Match":"",
  22. ( .@gmlevel < .gm_level || .status )?"":"Configurations",
  23. ( .@gmlevel < .gm_level || !.status )?"":"Stop Event" ) ){
  24.  
  25. Case 1:
  26. if( getcharid(0) != getpartyleader( .@partyid,2 ) ){
  27. mes "Only Party Leader can register.";
  28. }else if( .@partyid == .team[0] ){
  29. if( !.team[1] ){
  30. if( select("Quit Match","Cancel") == 1 ){
  31. set .team[0],0;
  32. set .status,1;
  33. stopnpctimer;
  34. if( $match_amount && $match_itemid ){
  35. message strcharinfo(0),"Retrieved "+callfunc( "ValueConvert", $match_amount )+" x "+getitemname( $match_itemid )+".";
  36. getitem $match_itemid,$match_amount;
  37. }
  38. if( $zeny ){
  39. message strcharinfo(0),"Retrieved "+callfunc( "ValueConvert", $zeny )+" Zeny.";
  40. set Zeny,Zeny + $zeny;
  41. }
  42. }
  43.  
  44. }else{
  45. mes "Cant quit since team 2 already joined.";
  46. }
  47. close;
  48. }else{
  49.  
  50. set .@count,callsub( count_party_member,.@partyid );
  51. if( .@count != $party_member ){
  52. mes "Please make a party of ^FF0000"+$party_member+" online members^000000.";
  53. mes " ";
  54. mes "You have "+.@count+" members online now.";
  55.  
  56. }else{
  57.  
  58. if( $match_itemid )
  59. if( countitem( $match_itemid ) < $match_amount ){
  60. mes "You need "+callfunc( "ValueConvert", $match_amount )+" x "+getitemname( $match_itemid );
  61. close;
  62. }
  63.  
  64. if( $zeny )
  65. if( Zeny < $zeny ){
  66. mes "You need "+callfunc( "ValueConvert", $zeny )+" Zeny";
  67. close;
  68. }
  69.  
  70. if( $match_itemid ){
  71. set .@amount,$match_amount;
  72. message strcharinfo(0),"Paid "+callfunc( "ValueConvert", .@amount )+" x "+getitemname( $match_itemid )+".";
  73. delitem $match_itemid,.@amount;
  74. }
  75.  
  76. if( $zeny ){
  77. message strcharinfo(0),"Total of "+callfunc( "ValueConvert", $zeny )+" Zeny deducted.";
  78. set Zeny,Zeny - $zeny;
  79. }
  80.  
  81. switch( .status ){
  82. Case 1:
  83. mes "You may decide the map now.";
  84. set .map,select( .map_name_menu$ ) - 1;
  85. mes "Your team has been registered.";
  86. set .team[0],.@partyid;
  87. set .status,2;
  88. set .minute,0;
  89. initnpctimer;
  90. break;
  91. Case 2:
  92. mes "Your team has joined the match.";
  93. set .team[1],.@partyid;
  94. set .status,3;
  95. stopnpctimer;
  96. close2;
  97. donpcevent strnpcinfo(0)+"::OnEventStart";
  98. end;
  99. break;
  100. default:
  101. mes "Registration closed.";
  102. close;
  103. }
  104. }
  105. }
  106. break;
  107. Case 2:
  108. while( 1 ){
  109.  
  110. callsub display_event_info;
  111. next;
  112. switch( select( "Edit Party Member","Required Item","Required Zeny","^FF0000Start Event^000000" ) ){
  113. Case 1:
  114. mes "Enter the Amount of Party Member required.";
  115. mes "^777777( 0 ~ 10 )^000000";
  116. input $party_member,0,10;
  117. break;
  118. Case 2:
  119. mes "Enter item ID :";
  120. do{
  121. input .@input;
  122. }while( getitemname( .@input ) == "null" );
  123. mes "Enter Amount : "+getitemname( .@input );
  124. mes "^777777( 0 ~ "+callfunc( "ValueConvert", 30000 )+" )^000000";
  125. input $match_amount,0,30000;
  126. if( $match_amount ) set $match_itemid,.@input;
  127. break;
  128. Case 3:
  129. mes "Enter Zeny amount :";
  130. mes "^777777( 0 ~ "+callfunc( "ValueConvert", 10000000 )+" )^000000";
  131. input $zeny,0,10000000;
  132. break;
  133. Case 4:
  134. if( $party_member < 1 ){
  135. mes "^FF0000Invalid^000000. Minimum 1 Party Member.";
  136. }else if( !$match_amount && !$zeny ){
  137. mes "^FF0000Invalid^000000. Required 1 item or Zeny.";
  138. }else{
  139. mes "Event started.";
  140. // announce "An Event has been started by GM, registration are now opened.",0;
  141. mapannounce "umbala","MAP ANNOUNCE: Party vs. Party event has been started by a GM, registrations are now opened.",0;
  142. mapannounce "guild_vs2-2","An Event has been started by GM, registration are now opened.",0;
  143. set .status,1;
  144. close;
  145. }
  146. break;
  147. }
  148. next;
  149. }
  150. break;
  151. Case 3:
  152. mes "Event Cancelled";
  153. close2;
  154. // announce "Event has been cancelled by GM.",0;
  155. mapannounce "umbala","MAP ANNOUNCE: The Event has been cancelled by a GM.",0;
  156. mapannounce "guild_vs2-2","Event has been cancelled by GM.",0;
  157. mapwarp .map_list$[.map],.npc_map$,.npc_x,.npc_y;
  158. callsub( clear_variable );
  159. end;
  160. default: break;
  161. }
  162. close;
  163.  
  164.  
  165.  
  166. OnInit:
  167. // Minimum GM Level to access cp.
  168. set .gm_level,80;
  169. // Map Name List
  170. setarray .map_name$,"guild_vs1-3","guild_vs2-2";
  171. setarray .map_list$,"guild_vs1-3","guild_vs2-2";
  172.  
  173. // map flag initialize
  174. set .map_size,getarraysize( .map_list$ );
  175. for( set .@i,0; .@i < .map_size; set .@i,.@i + 1 ){
  176. set .map_name_menu$,.map_name_menu$ + .map_name$[.@i] +":";
  177. setmapflag .map_list$[.@i],mf_partylock;
  178. setmapflag .map_list$[.@i],mf_nogo;
  179. setmapflag .map_list$[.@i],mf_pvp;
  180. setmapflag .map_list$[.@i],mf_battleground,2;
  181. bg_updatescore .map_list$[.@i],.score[ 0 ],.score[ 1 ];
  182. }
  183.  
  184. // npc locations
  185. getmapxy( .npc_map$,.npc_x,.npc_y,1 );
  186. end;
  187.  
  188. display_event_info:
  189. mes "^FF0000[ PARTY MATCH EVENT ]^000000";
  190. mes "Status : ^777777"+(( !.status )?"^FF0000Not Running":( .status == 1 )?"Waiting Team 1":( .status == 2 )?"Waiting Team 2":"Running" )+"^000000";
  191. if( .status || getgmlevel() >= .gm_level ){
  192. mes "Party Member : ^777777"+$party_member+"^000000";
  193. if( .status == 2 ) mes "Location : ^777777"+.map_name$[.map]+"^000000";
  194. }
  195. mes " ";
  196. if( $match_amount ) mes "Required Item : ^777777"+callfunc( "ValueConvert", $match_amount )+" x "+getitemname( $match_itemid )+"^000000";
  197. if( $zeny ) mes "Required Zeny : ^777777"+callfunc( "ValueConvert", $zeny )+" Zeny^000000";
  198. if( .status == 2 ) mes "Registration Countdown : "+( 15 - .minute )+" minutes.";
  199. return;
  200.  
  201. count_party_member:
  202. set .@getarg,getarg(0);
  203.  
  204. getpartymember .@getarg,1;
  205. getpartymember .@getarg,2;
  206. for( set .@i,0; .@i < $@partymembercount; set .@i,.@i + 1 )
  207. if( isloggedin( $@partymemberaid[.@i],$@partymembercid[.@i] ) )
  208. set .@count,.@count + 1;
  209.  
  210. return .@count;
  211.  
  212. clear_variable:
  213. set .minute,0;
  214. set .status,0;
  215. deletearray .team;
  216. deletearray .score;
  217. end;
  218.  
  219. OnTimer60000:
  220. set .minute,.minute + 1;
  221. if( .minute < 15 ){
  222. // announce "[ Party : "+getpartyname( .team[0] )+" ] is waiting for a "+$party_member+" vs "+$party_member+" event. ( "+( 15 - .minute )+" minutes to go )",0;
  223. mapannounce "umbala","[ Party : "+getpartyname( .team[0] )+" ] is waiting for a "+$party_member+" vs "+$party_member+" event. ( "+( 15 - .minute )+" minutes to go )",0;
  224. initnpctimer;
  225. }else{
  226. stopnpctimer;
  227. // announce "Event Cancelled, 2 Teams failed to register.",0;
  228. mapannounce "umbala","MAP ANNOUNCE: Event Cancelled, 2 Teams failed to register.",0;
  229. mapannounce "guild_vs2-2","Event Cancelled, 2 Teams failed to register.",0;
  230. callsub clear_variable;
  231. }
  232. end;
  233.  
  234. OnEventStart:
  235. // announce "Both team success to register for the events. Get ready while you're being warped within 1 minutes.",0;
  236. mapannounce "umbala","Both team success to register for the events. Get ready while you're being warped within 1 minutes.",0;
  237. sleep 55000;
  238.  
  239. for( set .@i,5; .@i; set .@i,.@i - 1 ){
  240. // announce " ::: Warp within "+.@i+" seconds ::: ",0;
  241. mapannounce "umbala","MAP ANNOUNCE: ::: Warp within "+.@i+" seconds ::: ",0;
  242. mapannounce "guild_vs2-2"," ::: Warp within "+.@i+" seconds ::: ",0;
  243. sleep 1000;
  244. }
  245.  
  246. // re-count for party members..
  247. set .@count[0],callsub( count_party_member,.team[0] );
  248. set .@count[1],callsub( count_party_member,.team[1] );
  249.  
  250. // check party.
  251. if( .@count[0] != $party_member || .@count[1] != $party_member ){
  252. // announce "Event stopped, one of the registered team doesnt meet the requirements of "+$party_member+" members.",0;
  253. mapannounce "umbala","Event stopped, one of the registered teams did not meet the requirements of "+$party_member+" members.",0;
  254. }else{
  255. // announce "Event Start now......",0;
  256. mapannounce "umbala","MAP ANNOUNCE: Event Starts now......",0;
  257. mapannounce "guild_vs2-2","Event Start now......",0;
  258.  
  259. for( set .@i,0; .@i < 2; set .@i,.@i + 1 ){
  260. attachrid getpartyleader( .team[.@i],1 );
  261. warpparty .map_list$[.map],0,0,.team[.@i];
  262. detachrid;
  263. }
  264.  
  265. warpparty .map_list$[.map],0,0,.team[1];
  266. deletearray .score;
  267. bg_updatescore .map_list$[.map],.score[ 0 ],.score[ 1 ];
  268.  
  269. sleep 5000;
  270. mapannounce .map_list$[.map],"Kill all opponents within 15 minutes to win.",0;
  271.  
  272. sleep ( 10 * 60000 );
  273.  
  274. // check and set winner
  275. if( .score[0] > .score[1] ) set .winner,.team[0];
  276. else if( .score[0] < .score[1] ) set .winner,.team[1];
  277. else if( .score[0] == .score[1] ) set .winner,0;
  278.  
  279.  
  280. // if got winner
  281. if( .winner ){
  282. mapannounce .map_list$[.map],"WINNING PARTY : [ "+getpartyname( .winner )+" ] : Match has ended.",0;
  283.  
  284. set .@party_leader,getpartyleader( .winner,1 );
  285. if( attachrid( .@party_leader ) ){
  286. if( $zeny ){
  287. mapannounce .map_list$[.map],"Party Leader received "+callfunc( "ValueConvert", $zeny )+" Zeny",bc_blue;
  288. set Zeny,Zeny + ( $zeny * 2 );
  289. }
  290. if( $match_amount ){
  291. mapannounce .map_list$[.map],"Party Leader received "+callfunc( "ValueConvert", $match_amount )+" x "+getitemname( $match_itemid ),bc_blue;
  292. getitem $match_itemid,( $match_amount * 2 ),.@party_leader;
  293. }
  294. detachrid;
  295.  
  296. }else{
  297. mapannounce .map_list$[.map],"Failed to claim rewards because Party Leader not found / offline.",0;
  298. }
  299.  
  300. // draw game
  301. }else{
  302. mapannounce .map_list$[.map],"This Game is a DRAW !!!",0;
  303. }
  304.  
  305. // clear map users.
  306. sleep 3500;
  307. mapwarp .map_list$[.map],.npc_map$,.npc_x,.npc_y;
  308. }
  309. callsub( clear_variable );
  310.  
  311. // OnMinute00:
  312. if( $party_member && ( $match_amount || $zeny ) && !.status ){
  313. // announce "Registration are now opened.",0;
  314. mapannounce "umbala","Registrations are now opened.",0;
  315. set .status,1;
  316. }
  317. end;
  318.  
  319. OnPCKillEvent:
  320. if( .status > 2 && strcharinfo(3) == .map_list$[.map] ){
  321. set .@team,( ( getcharid(1) == .team[0] )? 0:1 );
  322. mapannounce .map_list$[.map],"[ Party : "+getpartyname( .team[ .@team ] )+" ] "+strcharinfo(0)+" has "+( ( killedrid == getcharid(3) )?"commit suicide":"killed "+rid2name( killedrid ) )+" .",0;
  323.  
  324. set .score[ .@team ],.score[ .@team ] + 1;
  325. bg_updatescore .map_list$[.map],.score[ 0 ],.score[ 1 ];
  326.  
  327. if( attachrid( killedrid ) ){
  328. sleep2 1000;
  329. atcommand "@alive";
  330. warp "Save",0,0;
  331. detachrid;
  332. }
  333.  
  334. if( .score[0] >= $party_member || !.score[1] >= $party_member )
  335. awake strnpcinfo(0);
  336. }
  337. end;
  338. }
Advertisement
Add Comment
Please, Sign In to add comment