Advertisement
johnlol

Duel

May 10th, 2019
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ________________     ______            ________      
  3. ___    |_____  /________  /______      ___  __ \_____
  4. __  /| |  __  /_  __ \_  __ \  _ \     __  /_/ /  __ \
  5. _  ___ / /_/ / / /_/ /  /_/ /  __/     _  _, _// /_/ /
  6. /_/  |_\__,_/  \____//_.___/\___/      /_/ |_| \____/
  7.  
  8. */
  9.  
  10. // Comment if you already have this function
  11. function    script  int__   {
  12.    set .@num, getarg(0);
  13.    set .@numString$, getarg(0);
  14.    if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
  15.    set .@l, getstrlen(.@numString$);
  16.    for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
  17.        set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
  18.        if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
  19.    }
  20.    return .@num$;
  21. }
  22.  
  23. prontera,147,153,6  script  Duel Gambling   953,{
  24. set .@npcname$,"[ Duel Manager ]";
  25. L_mm:
  26. mes .@npcname$;
  27.  
  28. // If Duel cancel and player was not online.
  29. //-----------------------------------------
  30. if( dueling && .char$ != strcharinfo(0) && .char2$ != strcharinfo(0) ) {
  31.     set Zeny, Zeny + dueling;
  32.     dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  33.     set dueling, 0;
  34. }
  35.  
  36. //If already a duel is going on
  37. if( .gambling ) {
  38.     mes "A duel is starting, please wait until the duel is over.";
  39.     close;
  40. }
  41.  
  42. mes callfunc("F_Hi") +" "+ strcharinfo(0) +".";
  43. //If the challenger and the one accepting the duel have registred and the duel is ready to start
  44. if( .char$ == strcharinfo(0) && .char2$ != "" ) {
  45.     mes "^0000FF"+ .char2$ +"^000000 is waiting for you to start the duel!";
  46.     if( .zeny )
  47.         mes "Dueling for total ^FF0000"+ callfunc( "int__", .zeny ) +"^000000 zeny.";
  48.     mes "What would you like to do ?";
  49.     next;
  50.     menu "~ ^777777Start Duel.^000000",L_sduel,"~ ^777777Cancel Duel.^000000",L_cduel;
  51. }
  52.  
  53. //If the one accept the duel is going to talk to the npc
  54. if( .waiting ) {
  55.     mes "The duel gonna start soon !";
  56.     close;
  57. }
  58.  
  59. //If the challenger has registred, speaks again to the npc and no one accepted it
  60. if( .char$ == strcharinfo(0) ) {
  61.     mes "Please wait for your challenger.";
  62.     next;
  63.     menu "~ ^777777Cancel Duel.^000000",L_cduel,"~ ^777777I will wait.^000000",-;
  64.     close;
  65. }
  66. //If a challenger has registred, another person speaks to the npc and no one has accepted before
  67. if( .char$ != "" ) {
  68.     mes "There is a player is waiting for gambling.";
  69.     mes "What would you like to do ?";
  70.     next;
  71.     menu "~ ^777777Player and Gamble Information.^000000",-,"~ ^777777Send Duel invitation to the player.^000000",L_iduel,"~ ^777777Duel Gambling ?^000000",L_info;
  72.     mes .@npcname$;
  73.     mes "The player that challenge is named ^0000FF"+ .char$ +"^000000";
  74.     if( .zeny )
  75.         mes "The player duel for ^FF0000"+ callfunc( "int__", .zeny ) +"^000000 zeny.";
  76.     next;
  77.     goto L_mm;
  78. }
  79. //If no challenger is registred.
  80. else {
  81.     mes "No one is waiting for gamble currently.";
  82.     mes "What would you like to do ?";
  83.     next;
  84.  
  85.     menu "~ ^777777Start a duel.^000000",-,"~ ^777777Duel Gambling ?^000000",L_info;
  86.     set .zeny, callsub( L_PDZeny, 0, .@npcname$ );
  87.     initnpctimer;
  88.     set .char$, strcharinfo(0);
  89.     mes .@npcname$;
  90.     mes "Please wait for your opponent.";
  91.     announce "[ "+ .char$ +" ] bet "+ callfunc( "int__", dueling ) +" Zeny that no one could kill him ! He is waiting for an opponent !",bc_map|bc_blue;
  92.     close;
  93. }
  94.  
  95. //This party will run after someone accepted the challenge of a challenger
  96. L_iduel:
  97. if( .char2$ != "" || .char$ == "" ) {
  98.     mes "Sorry you are too slow.";
  99.     close;
  100. }
  101. set .zeny, callsub( L_PDZeny, .zeny, .@npcname$ );
  102. set .char2$, strcharinfo(0);
  103. set .waiting, 1;
  104.  
  105. mes .@npcname$;
  106. mes "Please wait while I inform your opponent.";
  107. announce "[ "+ .char$ +" ] your challenger is [ "+ .char2$ +" ] !",bc_map|bc_blue;
  108. close;
  109.  
  110. //After both players registred and the challenger starts the duel.
  111. L_sduel:
  112. if( .char2$ == "" ) {
  113.     mes "Sorry the duel is cancelled.";
  114.     close;
  115. }
  116. mes .@npcname$;
  117. mes "We will start the duel immediately.";
  118. close2;
  119.  
  120. if( !isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
  121.     dispbottom "Sorry, "+ .char2$ +" is not online.";
  122.     end;
  123. }
  124. percentheal 100, 100;
  125. attachrid( getcharid( 3,.char2$ ) );
  126. warp "1@pvp",25,45;
  127. percentheal 100, 100;
  128.  
  129. attachrid( getcharid( 3,.char$ ) );
  130. warp "1@pvp",78,45;
  131. atcommand "@duel "+ .char2$;
  132.  
  133. attachrid( getcharid( 3,.char2$ ) );
  134. atcommand "@accept";
  135. set .gambling, 1;
  136. announce "[ "+ .char$ +" ] start a duel with [ "+ .char2$ +" ] !",bc_map|bc_blue;
  137. end;
  138.  
  139. //If only the challenger is registred and cancels or if both registred and the challenger cancels the duel.
  140. L_cduel:
  141. if( .char$ != strcharinfo(0) ) {
  142.     mes "Sorry the duel is already cancelled.";
  143.     close;
  144. }
  145. announce "The duel was canceled by [ "+ .char$ +" ].",bc_map|bc_blue;
  146. mes .@npcname$;
  147. mes "Very well, "+ callfunc("F_Bye");
  148. set Zeny, Zeny + dueling;
  149. dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  150. set dueling, 0;
  151. close2;
  152. if( .char2$ != "" && isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
  153.     attachrid( getcharid( 3,.char2$ ) );
  154.     set Zeny, Zeny + dueling;
  155.     dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  156.     set dueling, 0;
  157. }
  158.  
  159. L_resetvar:
  160. set .char$, "";
  161. set .char2$, "";
  162. set .gambling, 0;
  163. set .waiting, 0;
  164. set .zeny, 0;
  165. stopnpctimer;
  166. end;
  167.  
  168. //If you click on information for the duel.
  169. L_info:
  170. mes .@npcname$;
  171. mes "I will allow 2 players to duel each other,";
  172. mes "players have to duel with gambling.";
  173. next;
  174. mes .@npcname$;
  175. mes "The gamble zeny must be same amount as opponent gamble.";
  176. next;
  177. mes .@npcname$;
  178. mes "Maximum time for waiting duel and dueling is 5 minutes.";
  179. next;
  180. goto L_mm;
  181.  
  182. //If 5 Minutes passed after the challenger registred and no one accepts it.
  183. OnTimer300000:
  184. announce "No challenger or the time is over, the duel was canceled.",bc_blue|bc_npc;
  185. if( .char$ != "" && isloggedin( getcharid( 3,.char$ ),getcharid( 0,.char$ ) ) ) {
  186.     attachrid( getcharid( 3,.char$ ) );
  187.     set Zeny, Zeny + dueling;
  188.     dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  189.     set dueling, 0;
  190. }
  191. if( .char2$ != "" && isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
  192.     attachrid( getcharid( 3,.char2$ ) );
  193.     set Zeny, Zeny + dueling;
  194.     dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  195.     set dueling, 0;
  196. }
  197. goto L_resetvar;
  198.  
  199. //When a player kills his opponent.
  200. OnPCKillEvent:
  201. if( !dueling || ( dueling && strcharinfo(0) != .char$ && strcharinfo(0) != .char2$ ) ) end;
  202.  
  203. set Zeny, Zeny + dueling * 2;
  204. dispbottom "You win "+ callfunc( "int__", dueling * 2 ) +" Zeny !";
  205. set dueling, 0;
  206. atcommand "@leave";
  207. announce "[ "+ strcharinfo(0)+ " ] win the duel!",bc_map|bc_blue;
  208. mapwarp "1@pvp","prontera",157,198;
  209.  
  210. attachrid killedrid;
  211. set dueling, 0;
  212. goto L_resetvar;
  213.  
  214.  
  215. //When a player dies.. (Just incase he doesnt get killed by his oppenent)
  216. OnPCDieEvent:
  217. if( !dueling || ( dueling && strcharinfo(0) != .char$ && strcharinfo(0) != .char2$ ) ) end;
  218. if( !killerrid ) {
  219.     announce "The duel has been cancelled because "+ strcharinfo(0) +" died.", bc_map|bc_blue;
  220.     set dueling, 0;
  221.     atcommand "@leave";
  222.     if( strcharinfo(0) == .char$ && isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
  223.         attachrid( getcharid( 3,.char2$ ) );
  224.         set Zeny, Zeny + dueling;
  225.         dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  226.         mapwarp "1@pvp","prontera",154,198;
  227.         set dueling, 0;
  228.     }
  229.     else if( strcharinfo(0) == .char2$ && isloggedin( getcharid( 3,.char$ ),getcharid( 0,.char$ ) ) ) {
  230.         attachrid( getcharid( 3,.char$ ) );
  231.         set Zeny, Zeny + dueling;
  232.         dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
  233.         mapwarp "1@pvp","prontera",154,198;
  234.         set dueling, 0;
  235.     }
  236.     goto L_resetvar;
  237. }
  238. end;
  239.  
  240. // Label for gambling Zeny
  241. // -----------------------------
  242.  
  243. L_PDZeny:
  244. set .@npcname$, getarg(1);
  245. if( !getarg(0) ) {
  246.     mes .@npcname$;
  247.     mes "How many zeny you would like to bet ?";
  248.     next;
  249.     if( input( .@zeny, 1, Zeny ) != 0 ) {
  250.         mes .@npcname$;
  251.         mes "You don't have enough zeny to duel! I won't allow that!";
  252.         close;
  253.     }
  254.     if( .char$ != "" ) {
  255.         mes .@npcname$;
  256.         mes "Sorry you were too slow. Someone already bet.";
  257.         close;
  258.     }
  259.     set Zeny, Zeny - .@zeny;
  260.     set dueling, .@zeny;
  261. }
  262. else {
  263.     if( getarg(0) > Zeny ) {
  264.         mes .@npcname$;
  265.         mes "You don't have enough zeny to duel! I won't allow that!";
  266.         close;
  267.     }
  268.     else {
  269.         if( .char2$ != "" || .char$ == "" ) {
  270.             mes .@npcname$;
  271.             mes "Sorry you were too slow."+ ( .char2$ != "" ? " Someone already bet." : "" );
  272.             close;
  273.         }
  274.         set Zeny, Zeny - getarg(0);
  275.         set dueling, getarg(0);
  276.         set .@zeny, getarg(0) * 2;
  277.     }
  278. }
  279. return .@zeny;
  280. }
  281.  
  282. 1@pvp   mapflag noreturn
  283. 1@pvp   mapflag noteleport
  284. 1@pvp   mapflag nowarp
  285. 1@pvp   mapflag nowarpto
  286. 1@pvp   mapflag nogo
  287. 1@pvp   mapflag nosave
  288. 1@pvp   mapflag nomemo
  289. 1@pvp   mapflag notrade
  290. 1@pvp   mapflag nodrop
  291. 1@pvp   mapflag nochat
  292. 1@pvp   mapflag novending
  293. 1@pvp   mapflag nobranch
  294. 1@pvp   mapflag pvp
  295. 1@pvp   mapflag clouds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement