yuhsing

Untitled

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