Advertisement
Emistry

[RO] Item to Guild Point

May 21st, 2017
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. // https://rathena.org/board/topic/110783-npc-that-records-when-trading-an-item/
  2.  
  3.  
  4. /* Please make sure you run this in your SQL.
  5.  
  6. ALTER TABLE `guild` ADD COLUMN `guild_point` INT(11) NOT NULL DEFAULT 0;
  7. */
  8.  
  9.  
  10. prontera,155,181,5 script Sample#guildpoint 4_F_KAFRA1,{
  11.  
  12. switch ( select(
  13. "Exchange Point",
  14. "View Ranking"
  15. )) {
  16. case 1:
  17. .@gid = getcharid(2);
  18. if ( !.@gid ) {
  19. mes "You didnt join any guild.";
  20. }
  21. else if ( getguildmasterid(.@gid) != getcharid(0) ) {
  22. mes "only guild master can use this.";
  23. }
  24. else {
  25. getinventorylist;
  26. for ( .@i = 0; .@i < @inventorylist_count; .@i++ ) {
  27. .@menu$ = .@menu$ + getitemname( @inventorylist_id[.@i] ) + ":";
  28. }
  29. mes "What items you want to exchange for Guild Point?";
  30. .@i = select( .@menu$ ) - 1;
  31. switch ( @inventorylist_id[.@i] ) {
  32. default:
  33. mes "Sorry this items worth nothing to me. Try again with others.";
  34. break;
  35. // case <item ID>: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], <MIN_AMOUNT>, <POINT_GAIN> );
  36. case 512: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], 1, 1 ); break;
  37. case 909: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], 2, 2 ); break;
  38. case 1010: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], 3, 10 ); break;
  39. }
  40. }
  41. break;
  42. case 2:
  43. query_sql( "SELECT `name`, `guild_point` FROM `guild` WHERE `guild_point` > 0 ORDER BY `guild_point` DESC LIMIT 10", .@guild_name$, .@guild_point );
  44. .@size = getarraysize( .@guild_name$ );
  45. mes "Guild Point Rank:";
  46. for ( .@i = 0; .@i < .@size; .@i++ ) {
  47. mes "["+( .@i + 1 )+".] "+.@guild_name$[.@i]+" - "+.@guild_point[.@i];
  48. }
  49. break;
  50. }
  51. close;
  52.  
  53. L_Exchange:
  54. .@nameid = getarg( 0,0 );
  55. .@countitem = getarg( 1,0 );
  56. .@min_amount = getarg( 2,1 );
  57. .@point = getarg( 3,1 );
  58.  
  59. mes "How many you want to exchange?";
  60. mes "Every "+.@min_amount+"x "+getitemname( .@nameid )+" will give you "+.@point+" Guild Point(s)";
  61. input .@amount,0,.@countitem;
  62. if ( .@amount ) {
  63. .@total_amount = ( .@amount / .@min_amount );
  64. delitem .@nameid,( .@total_amount * .@min_amount );
  65. mes "Exchanged "+( .@total_amount * .@min_amount )+"x "+getitemname( .@nameid )+" into "+.@total_amount+" Guild Point(s)";
  66. query_sql( "UPDATE `guild` SET `guild_point` = `guild_point` + "+.@total_amount+" WHERE `guild_id` = "+getcharid(2)+" LIMIT 1" );
  67. }
  68. return;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement