Jump to content
  • 0

PVP_Reward NPC im getting SQL DB error


koneko33

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  03/26/13
  • Last Seen:  

//===== rAthena Script =======================================
//= PvP Top 10 Ladder Weekly Reward


prontera,166,188,3    script    PVP REWARD    88,{
            .@cid = getcharid(0);
            query_sql( "SELECT `pvpreward` FROM `char` WHERE `char_id` = "+.@cid[.@i]+" LIMIT 1",.@pvpreward );    
            query_sql( "UPDATE `char` SET `pvpreward` = 0 WHERE `char_id` = "+.@cid[.@i]+" LIMIT 1" );
            
            set .PVP_Reward, 7227;
            set .TOP_1_PLAYER, 7227;
            set .TOP_2_PLAYER, 7227;
            
            // ITEM LISTED PRIZE
            switch ( .@pvpreward ) {
                case 1: getitem .TOP_1_PLAYER,50; break;
                case 2: getitem .TOP_2_PLAYER,45; break;
                case 3: getitem .PVP_Reward,40; break;
                case 4: getitem .PVP_Reward,30; break;
                case 5: getitem .PVP_Reward,20; break;
                case 6: getitem .PVP_Reward,10; break;
                case 7: getitem .PVP_Reward,5; break;
                case 8: getitem .PVP_Reward,5; break;
                case 9: getitem .PVP_Reward,5; break;
                case 10: getitem .PVP_Reward,5; break;
                default:
                    mes "[PVP Gate Keeper]";
                    mes "You're not top pvp for this week. or you already claimed the rewards.";
                    mes "The Reward Item is <ITEM>RTC<INFO>"+ .TOP_1_PLAYER +"</INFO></ITEM>.";
                    mes "The Reward giving days";
                    mes "Start Claiming: ^0000FFSun12:00 Noon^000000";
                    mes "End Claiming: ^0000FFMon 12:00 Noon^000000";
                    close;
            }
            mes "[PVP Gate Keeper]";
            mes "Congratulation "+ strcharinfo(0) +"";
            mes "You gained reward as top "+.@pvpreward+" PVP.";
            close;
            
            OnInit:
            // INITIATE THE LIMIT OF LADDER LISTED PRIZE 
                .limit = 10;
                waitingroom "[PVP Reward]",0;
            end;
            
            //DATE TIME ASSIGN
            OnSun1200:
            // **************************************************************
            // FIRST EMISTRY SCRIPT    
            // **************************************************************
            for ( .@i = 3; .@i > 0; .@i-- ){
                announce "Top "+ .limit +" PVP Rewards will be given in "+.@i+" minutes, please login your characters to get the auto assigned rewards.",bc_all;
                sleep 60000;
            }
            
            //ITEM NAME ANNOUNCE ON THE DAY OF CLAIMING PRIZE
            // item id reward for top 10 pvp
            setarray .@itemid,50058,50006,50006,50006,50006,50006,50006,50006,50006,50006;
            // item quantity reward for top 10 pvp
            setarray .@itemid_qty,1,7,7,7,5,5,5,2,2,2;
            .@itemid_size = getarraysize( .@itemid );
            
            query_sql ("SELECT c.`account_id`,c.`char_id` FROM `pvpladder` pvp INNER JOIN `char` c ON c.`char_id` = pvp.`char_id` WHERE pvp.`kills` > 0 ORDER BY pvp.`kills` DESC,pvp.`deaths` LIMIT "+.@itemid_size ,.@aid,.@cid );
            .@cid_size = getarraysize( .@cid );
                
            for ( .@i = 0; .@i < .@cid_size; .@i++ )
                if ( .@aid[.@i] && isloggedin( .@aid[.@i],.@cid[.@i] ) ) {
                    attachrid( .@aid[.@i] );
                    announce "Top "+( .@i+1 )+" PVP Rewards - "+strcharinfo(0)+" obtained "+.@itemid_qty[.@i]+"x "+getitemname( .@itemid[.@i] ),bc_all;
                }
            detachrid;
            
            query_sql( "SELECT `char_id` FROM `pvpladder` WHERE `kills` > 0 ORDER BY `kills` DESC,`deaths` LIMIT "+.limit,.@cid );
            .@cid_size = getarraysize( .@cid );
            for ( .@i = 0; .@i < .@cid_size; .@i++ )
                query_sql("UPDATE `char` SET `pvpreward` = "+( .@i+1 )+" WHERE `char_id` = "+.@cid[.@i]+" LIMIT 1");
                announce "Top 1 PVP Reward - "+.@cid_size+" players is selected as winner.",bc_all;
            
            //AUTO TRUNCATE DB
            announce "PVP Ladder Will Reset in Monday 12PM +8GMT. Claim your prize immediately",bc_all;    
            end;
            
}

/*
    ALTER TABLE `char` ADD `pvpreward` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `fame`;
//*/

-    script    PVPRESETLADDER#disable1    -1,{
//OnInit:
OnMon1800:
        query_sql( "TRUNCATE `pvpladder`" );
        announce "PVP Ladder completely reset.",bc_all;
end;
}


image.png.573ad2d0ce226f2d4a35da00958476d9.png

Edited by Mael
Use codebox
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  102
  • Reputation:   6
  • Joined:  03/02/18
  • Last Seen:  

check your database if you have pvprewards table exist

Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  226
  • Reputation:   83
  • Joined:  06/30/18
  • Last Seen:  

You need to alter the char table and add the pvpreward colum. The sql is even inside the script you posted.

ALTER TABLE `char` ADD `pvpreward` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `fame`;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  03/26/13
  • Last Seen:  

solve thank you 

On 11/19/2023 at 9:13 PM, Winterfox said:

You need to alter the char table and add the pvpreward colum. The sql is even inside the script you posted.

ALTER TABLE `char` ADD `pvpreward` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `fame`;

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...