yuhsing

Untitled

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