Advertisement
johnlol

Rewarder GM

Aug 2nd, 2023
1,116
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 12.65 KB | Gaming | 0 0
  1.  
  2.  
  3. /*
  4.  
  5. CREATE TABLE IF NOT EXISTS `ero_gm_reward` (
  6.     `id` int(11) NOT NULL AUTO_INCREMENT,
  7.     `gm_aid` int(11) NOT NULL default '0',
  8.     `gm_name` varchar(30) NOT NULL default '',
  9.     `nameid` int(11) NOT NULL default '0',
  10.     `amount` int(11) unsigned NOT NULL default '0',
  11.     `refine` tinyint(3) unsigned NOT NULL default '0',
  12.     `card1` smallint(4) unsigned NOT NULL default '0',
  13.     `card2` smallint(4) unsigned NOT NULL default '0',
  14.     `card3` smallint(4) unsigned NOT NULL default '0',
  15.     `card4` smallint(4) unsigned NOT NULL default '0',
  16.     `format_name` varchar(30) NOT NULL default 'null',
  17.     `reward_time` datetime NOT NULL default '0000-00-00 00:00:00',
  18.     `status` tinyint(1) NOT NULL default '0',
  19.     `claim_aid` int(11) NOT NULL default '0',
  20.     `claim_name` varchar(30) NOT NULL DEFAULT '',
  21.     `claim_time` datetime NOT NULL default '0000-00-00 00:00:00',
  22.     `note` varchar(255) NOT NULL default 'none',
  23.     PRIMARY KEY  (`id`)
  24. ) ENGINE=MyISAM;
  25.  
  26. */
  27.  
  28.  
  29. prontera,181,170,5  script  Rewarder#gmreward   110,{
  30.     doevent "gm_reward_main::OnTalk";
  31. }
  32.  
  33.  
  34. -   shop    gm_reward_shop  -1,909:-1
  35.  
  36. -   script  gm_reward_main  -1,{
  37.     function func_sql_reward;
  38.     function func_item_name;
  39.     function func_list_char;
  40.     function func_display_card;
  41.     function func_list_reward;
  42.     function func_view_reward;
  43.    
  44.     OnInit:
  45.         .gm_level = 60;
  46.         .shop_name$ = "gm_reward_shop";
  47.         end;
  48.        
  49.     OnTalk:
  50.         .@gm_level = getgmlevel();
  51.         .@not_gm = ( .@gm_level < .gm_level || !.gm_level || !.@gm_level );
  52.        
  53.         cutin "kafra_09",2;
  54.         mes "^FF0000[ GM Reward - Introduction ]^000000";
  55.         mes "Hi "+strcharinfo(0)+", what can I do for you today?";
  56.         next;
  57.         switch ( select(
  58.             ( .@not_gm )? "Check Pending Reward":"",
  59.             ( .@not_gm )? "Check Reward History":"",
  60.             ( .@not_gm )? "":"^FF0000[GM]^000000 Send Reward",
  61.             ( .@not_gm )? "":"^FF0000[GM]^000000 Delete Reward",
  62.             ( .@not_gm )? "":"^FF0000[GM]^000000 Check History",
  63.             "Information"
  64.         )) {
  65.             case 1:
  66.                 mes "^FF0000[ GM Reward - Pending Reward ]^000000";
  67.                 mes "I will show you a list of rewards that are still not yet claimed.";
  68.                 func_list_reward( "`claim_name` = '"+escape_sql( strcharinfo(0) )+"' AND `status` = 0" );
  69.                 break;
  70.             case 2:
  71.                 mes "^FF0000[ GM Reward - History ]^000000";
  72.                 mes "I will show you a list of rewards that are claimed previously.";
  73.                 func_list_reward( "`claim_name` = '"+escape_sql( strcharinfo(0) )+"' AND `status` = 1" );
  74.                 break;
  75.             case 3:
  76.                 mes "^FF0000[ GM Reward - Setup ]^000000";
  77.                 mes "Please place all the items that you want to sent to player into the selling shop window.";
  78.                 // close2;
  79.                 callshop .shop_name$,2;
  80.                 npcshopattach .shop_name$;
  81.                 end;
  82.             case 4:
  83.                 mes "^FF0000[ GM Reward - Remove Rewards ]^000000";
  84.                 mes "I will show you a list of rewards that are sent out but not yet claimed.";
  85.                 func_list_reward( "`status` = 0" );
  86.                 break;
  87.             case 5:
  88.                 mes "^FF0000[ GM Reward - Reward History ]^000000";
  89.                 mes "I will show you a list of recent rewards based on the status you selected.";
  90.                 .@i = select( "Pending Reward","Claimed Reward","Deleted Reward" ) - 1;
  91.                 func_list_reward( "`status` = "+.@i );
  92.                 break;
  93.             default:
  94.                 mes "^FF0000[ GM Reward - Information ]^000000";
  95.                 mes "Hi, I work for Game Master. I assist GM to distribute or manage the rewards setup by GM.";
  96.                 break;
  97.         }
  98.         close2;
  99.         cutin "",255;
  100.         end;
  101.        
  102.     OnSellItem:
  103.         cutin "kafra_09",2;
  104.         mes "^FF0000[ GM Reward - Checklist ]^000000";
  105.         if ( getgmlevel() < .gm_level ) {
  106.             mes "You're not authorized to perform this actions.";
  107.         }
  108.         else {
  109.             .@reward_size = getarraysize( @sold_nameid );
  110.             if ( .@reward_size < 1 ) {
  111.                 mes "Failed, no items found in the list.";
  112.             }
  113.             else {
  114.                 mes "Enter Player name:";
  115.                 mes "^777777------------------------------^000000";
  116.                 for ( .@i = 0; .@i < .@reward_size; .@i++ ) {
  117.                     mes "^6495ED# ^000000"+func_item_name( @sold_nameid[.@i],@sold_quantity[.@i],@sold_refine[.@i] );
  118.                     .@item_type = getiteminfo( @sold_nameid[.@i],2 );
  119.                     if ( .@item_type == IT_ARMOR || .@item_type == IT_WEAPON )
  120.                         func_display_card( @sold_card1[.@i],@sold_card2[.@i],@sold_card3[.@i],@sold_card4[.@i] );
  121.                 }
  122.                 .@player_name$ = func_list_char();
  123.                 if ( .@player_name$ != "" ) {
  124.                     next;
  125.                     mes "^FF0000[ GM Reward - Confirmation ]^000000";
  126.                     mes "Player: ^FF0000"+.@player_name$+"^000000";
  127.                     mes "^777777------------------------------^000000";
  128.                     for ( .@i = 0; .@i < .@reward_size; .@i++ ) {
  129.                         mes "^6495ED > ^000000"+func_item_name( @sold_nameid[.@i],@sold_quantity[.@i],@sold_refine[.@i] );
  130.                         .@item_type = getiteminfo( @sold_nameid[.@i],2 );
  131.                         if ( .@item_type == IT_ARMOR || .@item_type == IT_WEAPON )
  132.                             func_display_card( @sold_card1[.@i],@sold_card2[.@i],@sold_card3[.@i],@sold_card4[.@i] );
  133.                     }
  134.                     if ( select( "Confirm","Cancel" ) == 1 ) {
  135.                         next;
  136.                         mes "^FF0000[ GM Reward - Confirmation ]^000000";
  137.                         mes "Enter a Title:";
  138.                         do {
  139.                             .@length = input( .@note$,4,70 );
  140.                             .@check = ( compare( .@note$,":" ) || .@length );
  141.                             if ( .@check ) {
  142.                                 mes "^777777Invalid title^000000";
  143.                             }
  144.                         }while ( .@check );
  145.                        
  146.                         .@gm_aid = getcharid(3);
  147.                         .@gm_name$ = strcharinfo(0);
  148.                        
  149.                         query_sql( "SELECT `account_id`,`char_id`,`online` FROM `char` WHERE `name` = '"+escape_sql( .@player_name$ )+"' LIMIT 1",.@player_aid,.@player_cid,.@online );
  150.                        
  151.                         for ( .@i = 0; .@i < .@reward_size; .@i++ ) {
  152.                             .@formatted_name$ = func_item_name( @sold_nameid[.@i],@sold_quantity[.@i],@sold_refine[.@i] );
  153.                             if ( func_sql_reward( .@gm_aid,escape_sql( .@gm_name$ ),@sold_nameid[.@i],@sold_quantity[.@i],@sold_refine[.@i],escape_sql( .@formatted_name$ ),@sold_card1[.@i],@sold_card2[.@i],@sold_card3[.@i],@sold_card4[.@i],.@player_aid,.@player_name$,.@note$ ) )
  154.                                 dispbottom "[Reward Sent] "+.@player_name$+" - "+.@formatted_name$;
  155.                             else
  156.                                 dispbottom "[Reward Sent Failure] "+.@player_name$+" - "+.@formatted_name$;
  157.                         }
  158.                        
  159.                         if ( .@player_aid > 0 && isloggedin( .@player_aid,.@player_cid ) ) {
  160.                             message .@player_name$,"You received "+.@reward_size+" reward(s) from "+.@gm_name$;
  161.                             message .@gm_name$,"You sent "+.@reward_size+" reward(s) to "+.@player_name$;
  162.                         }
  163.                         mes "Rewards sent.";
  164.                     }
  165.                 }
  166.             }
  167.         }
  168.         close2;
  169.         cutin "",255;
  170.         end;
  171.        
  172.     function    func_sql_reward {
  173.  
  174.         if ( getargcount() >= 12 ) {
  175.             .@gm_aid = getarg(0);
  176.             .@gm_name$ = getarg(1);
  177.             .@sold_nameid = getarg(2);
  178.             .@sold_quantity = getarg(3);
  179.             .@sold_refine = getarg(4);
  180.             .@formatted_name$ = getarg(5);
  181.             .@sold_card1 = getarg(6);
  182.             .@sold_card2 = getarg(7);
  183.             .@sold_card3 = getarg(8);
  184.             .@sold_card4 = getarg(9);
  185.             .@player_aid = getarg(10);
  186.             .@player_name$ = getarg(11);
  187.             .@note$ = getarg(12);
  188.            
  189.             query_sql( "INSERT INTO `ero_gm_reward` ( `gm_aid`,`gm_name`,`nameid`,`amount`,`refine`,`format_name`,`card1`,`card2`,`card3`,`card4`,`reward_time`,`claim_aid`,`claim_name`,`note` ) VALUES ( "+.@gm_aid+",'"+escape_sql( .@gm_name$ )+"',"+.@sold_nameid+","+.@sold_quantity+","+.@sold_refine+",'"+escape_sql( .@formatted_name$ )+"',"+.@sold_card1+","+.@sold_card2+","+.@sold_card3+","+.@sold_card4+",NOW(),"+.@player_aid+",'"+escape_sql( .@player_name$  )+"','"+.@note$+"' )" );
  190.             return 1;
  191.         }
  192.        
  193.         return 0;
  194.     }
  195.  
  196.     function    func_item_name  {
  197.         .@item_id = getarg(0);
  198.         .@amount = getarg(1);
  199.         .@refine = getarg(2);
  200.        
  201.         .@string$ = getitemname( .@item_id );
  202.         .@type = getiteminfo( .@item_id,2 );
  203.            
  204.         if ( .@string$ == "null" )
  205.             return "none";
  206.            
  207.         if ( .@refine )
  208.             .@string$ = "+"+.@refine+" "+.@string$;
  209.         if ( .@type == IT_WEAPON || .@type == IT_ARMOR )
  210.             .@string$ = .@string$ + " ["+getitemslots( .@item_id )+"]";
  211.         if ( .@amount > 1 )
  212.             .@string$ = .@amount+" x "+.@string$;
  213.            
  214.         return .@string$;
  215.     }
  216.    
  217.     function    func_list_char  {
  218.         __OnInput:
  219.             while( input( .@player_name$,3,24 ) );
  220.             query_sql( "SELECT `name`,`class` FROM `char` WHERE `name` LIKE '%"+escape_sql( .@player_name$ )+"%' ORDER BY `name` LIMIT 50",.@temp_name$,.@class );
  221.             .@temp_name_size = getarraysize( .@temp_name$ );
  222.            
  223.             if ( .@temp_name_size <= 0 ) {
  224.                 dispbottom "[ GM Reward - Checklist ] '"+.@player_name$+"' doesnt exist.";
  225.                 // next;
  226.                 if( select( "Search another Name","Cancel" ) == 1 ) goto __OnInput;
  227.                 return "";
  228.             }
  229.             else if ( .@temp_name_size > 1 ) {
  230.                 dispbottom "[ GM Reward - Checklist ] Pick a player.";
  231.                 for ( .@i = 0; .@i < .@temp_name_size; .@i++ )
  232.                     .@menu$ = .@menu$ + "^FF0000["+jobname( .@class[.@i] )+"] ^000000" + .@temp_name$[.@i] +":";
  233.                 .@i = select( .@menu$ ) - 1;
  234.             }
  235.         return .@temp_name$[.@i];
  236.     }
  237.    
  238.     function    func_display_card   {
  239.         for ( .@i = 0; .@i < 4; .@i++ ) {
  240.             .@card_id = getarg( .@i );
  241.             if ( .@card_id ) {
  242.                 .@card_found++;
  243.                 .@card[.@i] = .@card_id;
  244.                 setd( ".@card_"+.@card_id+"_count" ),getd( ".@card_"+.@card_id+"_count" ) + 1;
  245.             }
  246.         }
  247.         if ( .@card_found ) {
  248.             .@exist_card$ = "#";
  249.             for ( .@i = 0; .@i < 4; .@i++ )
  250.                 if ( .@card[.@i] ) {
  251.                     if ( !compare( .@exist_card$,"#"+.@card[.@i]+"#" ) )
  252.                         mes "  ^6495ED>^000000 "+func_item_name( .@card[.@i],getd( ".@card_"+.@card[.@i]+"_count" ),0 );
  253.                     .@exist_card$ = .@exist_card$ + .@card[.@i] + "#";
  254.                 }
  255.         }
  256.         return;
  257.     }
  258.  
  259.     function    func_list_reward    {
  260.         .@condition$ = getarg( 0,"" );
  261.  
  262.         query_sql( "SELECT `id`,`nameid`,`amount`,`refine`,`status`,`note` FROM `ero_gm_reward` WHERE "+.@condition$+" ORDER BY `id` DESC LIMIT 50",.@id,.@nameid,.@amount,.@refine,.@status,.@note$ );
  263.         .@id_size = getarraysize( .@id );
  264.        
  265.         mes " ";
  266.         if ( .@id_size <= 0 ) {
  267.             mes "^FF0000No records are founds.^000000";
  268.         }
  269.         else {
  270.             mes "Found "+.@id_size+" Reward(s).";
  271.             while( .@id_size > 0 ) {
  272.                
  273.                 .@menu$ = "";
  274.                 for ( .@i = 0; .@i < .@id_size; .@i++ ) {
  275.                     // .@menu$ = .@menu$ + func_item_name( .@nameid[.@i],.@amount[.@i],.@refine[.@i] );
  276.                     .@menu$ = .@menu$ + .@note$[.@i];
  277.                     .@menu$ = .@menu$ + ":";
  278.                 }
  279.                 next;
  280.                 .@reward = select( .@menu$ ) - 1;
  281.            
  282.                 if ( func_view_reward( .@id[.@reward],.@status[.@reward] ) > 0 ) {
  283.                     deletearray .@id[.@reward],1;
  284.                     deletearray .@nameid[.@reward],1;
  285.                     deletearray .@amount[.@reward],1;
  286.                     deletearray .@amount[.@reward],1;
  287.                     deletearray .@status[.@reward],1;
  288.                     .@id_size--;
  289.                 }
  290.             }
  291.         }
  292.         return;
  293.     }
  294.    
  295.     function    func_view_reward    {
  296.         .@id = getarg(0);
  297.         .@status = getarg(1);
  298.        
  299.         if ( .@id <= 0 ) {
  300.             mes "Invalid Reward - "+.@id;
  301.             return 0;
  302.         }
  303.         else {
  304.             query_sql( "SELECT `gm_name`,`nameid`,`amount`,`refine`,`reward_time`,`claim_name`,`claim_time`,`note`,`card1`,`card2`,`card3`,`card4` FROM `ero_gm_reward` WHERE `id` = '"+.@id+"' LIMIT 1",.@gm_name$,.@nameid,.@amount,.@refine,.@reward_time$,.@claim_name$,.@claim_time$,.@note$,.@card1,.@card2,.@card3,.@card4 );
  305.            
  306.             .@item_name$ = func_item_name( .@nameid,.@amount,.@refine );
  307.             mes "^0055FF[ Reward # "+.@id+" ]^000000";
  308.             mes "GM : ^777777"+.@gm_name$+"^000000";
  309.             mes "Player : ^777777"+.@claim_name$+"^000000";
  310.             mes "Item: ^0055FF"+.@item_name$+"^000000";
  311.             .@item_type = getiteminfo( .@nameid,2 );
  312.             if ( .@item_type == IT_ARMOR || .@item_type == IT_WEAPON )
  313.                 func_display_card( .@card1,.@card2,.@card3,.@card4 );
  314.                
  315.             mes "Date: ^777777"+.@reward_time$+"^000000";
  316.             mes "Claimed: "+( ( .@status )? "^777777"+.@claim_time$:"^FF0000not yet" )+"^000000";
  317.             mes "GM Note : ";
  318.             mes "^777777"+.@note$+"^000000";
  319.            
  320.             .@char_name$ = strcharinfo(0);
  321.             .@is_gm = ( getgmlevel() >= .gm_level );
  322.            
  323.             switch( select(
  324.                 ( .@char_name$ == .@claim_name$ && !.@status && .@claim_time$ == "0000-00-00 00:00:00" ) ? "Claim Reward":"",
  325.                 ( .@is_gm && .@status == 0 ) ? "^FF0000Delete Reward^000000":"",
  326.                 ( .@is_gm && .@status == 2 ) ? "^FF0000Recover Reward^000000":"",
  327.                 "Back"
  328.             )){
  329.                 default: return 0;
  330.                 case 1:
  331.                     if ( !checkweight( .@nameid,.@amount ) ) {
  332.                         message .@char_name$,"Overweight Detected!";
  333.                     }
  334.                     else {
  335.                         query_sql( "UPDATE `ero_gm_reward` SET `status` = 1,`claim_time` = NOW() WHERE `id` = "+.@id+" LIMIT 1" );
  336.                         getitem2 .@nameid,.@amount,1,.@refine,0,.@card1,.@card2,.@card3,.@card4;
  337.                         message .@char_name$,"Claimed Reward # "+.@id+" - "+.@item_name$;
  338.                         break;
  339.                     }
  340.                 case 2:
  341.                     query_sql( "UPDATE `ero_gm_reward` SET `status` = 2 WHERE `id` = "+.@id+" LIMIT 1" );
  342.                     message .@char_name$,"Deleted Reward # "+.@id+" - "+.@item_name$;
  343.                     break;
  344.                 case 3:
  345.                     query_sql( "UPDATE `ero_gm_reward` SET `status` = 0 WHERE `id` = "+.@id+" LIMIT 1" );
  346.                     message .@char_name$,"Recovered Reward # "+.@id+" - "+.@item_name$;
  347.                     break;
  348.             }
  349.         }
  350.         return 1;
  351.     }
  352. }
  353.  
  354. prt_in,281,139,5    duplicate(Rewarder#gmreward)    Rewarder    464
  355.  
  356.  
  357.  
  358.  
Advertisement
Comments
  • prashant0695
    274 days
    # text 0.22 KB | 0 0
    1. Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
    2.  
    3. If you have questions, please contact your organization's network administrator and provide the codes shown below
  • prashant0695
    274 days
    # text 0.22 KB | 0 0
    1. Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
    2.  
    3. If you have questions, please contact your organization's network administrator and provide the codes shown below
Add Comment
Please, Sign In to add comment
Advertisement