Advertisement
johnlol

Duel

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