Stolao / Npc_Release

Stolao's Script Collection
https://rathena.org/board/topic/84800-stolaos-script-collection-update-2015-07-17-1250/?p=209556
29 stars 65 forks source link

NPC Daily_Reward #24

Closed Likeeit closed 7 years ago

Likeeit commented 7 years ago

Hello, I'm just going to warn you that NPC Daily_Reward has some silly mistakes, but even fixing it by typing @hourly nothing happens and no error appears on the map-server. Taking advantage, I would like to thank for the great scripts made available, thank you!

Corrected map-server errors script.

//===== EinherjarRO Scripts ================================== 
//= Hourly Rewards
//===== By: ================================================== 
//= Stolao
//===== Current Version: ===================================== 
//= 1.00
//===== Compatible With: ===================================== 
//= rAthena SVN
//===== Description: ========================================= 
//= A reward system for players who play longer
//===== Todo: ================================================
//= Suggestions?
//===== Additional Comments: =================================
//= 1.00 Initial release
//===== Contact Info: ========================================
//= [Stolao] 
//= Email: Taingram11@gmail.com
//============================================================
-   script  Hourly_Rewards  -1,{
OnPCLoginEvent:
    if(.IPCheck){
        query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@LastIp$);
        query_sql("SELECT account_id FROM `login` WHERE last_ip = '"+.@LastIp$+"'", .@AccountId);
        if(getarraysize(.@AccountId) > .IPCheck){
//          message strcharinfo(0),"[Daily Rewards]: rewards are limited to "+.IPCheck+" per IP sorry.";
            end;
        }
    }
//  if(.MacCheck){
//      query_sql("SELECT last_unique_id FROM `login` WHERE account_id = "+getcharid(3)+"", .@last_unique_id$);
//      query_sql("SELECT account_id FROM `login` WHERE last_unique_id = '"+.@last_unique_id$+"'", .@AccountId2);
//      if(getarraysize(.@AccountId2) > .MacCheck){
//          message strcharinfo(0),"[Daily Rewards]: rewards are limited to "+.MacCheck+" per computer sorry.";
//          end;
//      }
//  }
    if(.Rest) message strcharinfo(0),"[Hourly Rewards]: Rewards are now active. Enjoy!";
    addtimer 3600000,strnpcinfo(3)+"::OnWait";
    end;
OnHourCmnd:
    if(@vending){
        @vending = 0;
        addtimer 3600000,strnpcinfo(3)+"::OnWait";
        end;
    } else if(!@overweight)
        end;
    else    @overweight--;
OnWait:
    deltimer strnpcinfo(3)+"::OnWait";
    if(checkvending() & 2 && .Mode & 32){
        message strcharinfo(0),"[Hourly Rewards]: Venders cannot recive rewards. Please type @hourly to continue.";
        @vending++;
        end;
    }
    if(.Afk_Timeout && checkidle() > .Afk_Timeout){
        message strcharinfo(0),"[Hourly Rewards]: Were AFk for more then "+checkidle()+" seconds, cannot recive rewards. Please type @hourly to continue.";
        @vending++;
        end;
    }
    @hourly++;
    explode(.@XT$,.Rewards$[@hourly++],",");
    for(.@x = 0; .@x < getarraysize(.@XT$); .@x++)
        .@TT[.@x] = atoi(.@XT$[.@x]);
    if(.Mode & 1 && .@TT[4] > 0){
        for(.@x = 4; .@x <= getarraysize(.@TT) - 1 ; .@x += 2){
            .@itms[getarraysize(.@itms)] = .@TT[.@x];
            .@qnts[getarraysize(.@qnts)] = .@TT[.@x + 1];
        }
        if(checkweight2(.@itms,.@qnts)){
            for(.@x = 0; .@x < getarraysize(.@itms) && .@x < getarraysize(.@qnts); .@x++){
                if(.Mode & 32)
                    getitembound  .@itms[.@x], .@qnts[.@x], .Bound_Mode;
                else    getitem  .@itms[.@x], .@qnts[.@x];
            }
        } else {
            message strcharinfo(0),"[Hourly Rewards]: You cannot carry the prizes, please use storage and type @hourly.";
            @hourly--;
            @overweight++;
            end;
        }
    }
    if(.Mode & 2){
        if(.@TT[0]){
            Zeny += .@TT[0];
            message strcharinfo(0),"[Hourly Rewards]: Recieved "+ .@TT[0] +"z";
        }
        if(.@TT[1]){
            setd getd(.Points$[0]),getd(.Points$[0]) + .@TT[1];
            message strcharinfo(0),"[Hourly Rewards]: Recieved "+ .@TT[1] +" "+.Points$[1];
        }
    }
    if(.Mode & 4 && (.@TT[3] || .@TT[4]))
        getexp .@TT[3], .@TT[4];
    if(.Mode & 8){
        for(.@x = 0; .@x < getarraysize(.BuffInfo); .@x += 4){
            if(#DRewardCon % .BuffInfo[.@x + 1] == 0)
                sc_start .BuffInfo[.@x], .BuffInfo[.@x + 2] * 60000, .BuffInfo[.@x + 3];
        }
    }
    message strcharinfo(0),"[Hourly Rewards]: You have collected your hourly reward, for "+callfunc("F_InsertPlural",#DRewardCon,"hour")+" in a row.";
    addtimer 3600000,strnpcinfo(3)+"::OnWait";
    end;
OnInit:
    // Basic Settings
    //   1: Item | 2: Points | 4: Exp  
    //   8: Gain Buffs Every X Consecutive Hours logged in
    //   16: Bound Items
    //   32: No Rewards ffor Autotraders
    //     (a bit value, e.g. 3 = Items & Points from Multi)
    .Mode = 1|2|16|32;

    // Number of times same IP can recive rewards
    //   0 = unlimited
    .IPCheck = 1;

    // Number of times same Computer (MacAdress) can recive rewards
    //   0 = unlimited
    .MacCheck = 1;

    // AFK Time
    //   How many seconds of idle till no rewards recived
    //   0 = Unlimited
    .Afk_Timeout = 1800;

    // Item Binding Mode
    //0 - All Bound types.
    //1 - Account Bound
    //2 - Guild Bound
    //3 - Party Bound
    //4 - Character Bound
    .Bound_Mode = 1;

    // Point Type
    //   [0] Points earned
    //   [1] Point name in mes
    setarray .Points$,"#KAFRAPOINTS","K-Points";

    // Consecutive Days Buff
    // Each buff contains 4 variables (32 Total Max)
    // <Type>,<Days>,<Duration>,<Rate>, // Buff 1
    // <Type>,<Days>,<Duration>,<Rate>, // Buff 2
    //   ...;
    //
    //  Example: 188,7,45,3
    //    -Every 7th consecutive day logged in Player gains +3 Str for 45 mins
    //
    //  Type is 188, which references which SC_ to use, SC_INCSTR in this example
    //     -For a full list of SC_ visit the db/const.txt
    //  Days is days buff is applied, in this example 7, so every 7th day, 14,21,28....
    //  Duration is buff duration is Minuits, in this example 45 mins
    //  Rate is buff strength, in this example player gains 3 Str
    setarray .BuffInfo
                ,260,2,360,1    // Life Insurance for 360 Mins Every 2nd Day
                ,198,3,120,10   // +10% Hp for 120 Mins Every 3th Day
                ,196,5,120,25   // +25 Flee for 120 Mins Every 5th Day
                ,257,7,240,50;  // +50% Exp for 240 Mins Every 7th Day

    // Daily Prize items (max 128 days):
    //   "<Zeny>|<Points>|<BaseExp>|<JobExp>|<itemID-1>|<amount-1>|<itemID-2>|<amount-2>...etc", // Day 1
    //   "<Zeny>|<Points>|<BaseExp>|<JobExp>|<itemID-1>|<amount-1>|<itemID-2>|<amount-2>...etc"  // Day 2
    //   ...;
    // Total length of any days string must be 255 or shorter
    // * If players login longer than the last set
    //   day, they will keep getting the last prize.
    setarray .Rewards$[1],
//      "0,0,0,0,503,5,506,5",          // Day 1: 5 White Potion + 5 Green Potion
//      "100",                  // Day 2: 100 Zeny
//      "0,0,0,0,501,5",            // Day 3: 5 Red Potion
//      "0,0,0,0,503,5,506,5",          // Day 4: 5 White Potion + 5 Green Potion
//      "100",                  // Day 5: 100 Zeny
//      "0,0,0,0,501,5",            // Day 6: 5 Red Potion
//      "1000",                 // Day 7: 100 Zeny
//      "1000",                 // Day 8: 100 Zeny
//      "0,0,0,0,503,5,506,5";          // Day 9: 5 White Potion + 5 Green Potion

    // To disable the command '@loginreward' comment the next lines
    // * Needs extra commands for typos
    bindatcmd("hourly",strnpcinfo(3)+"::OnHourCmnd",0,99);
    end;
}

Note: I'm used Hercules.

Stolao commented 7 years ago

I don't support Hercules as i say in my readme. so please upgrade to the better emulator @Likeeit