Jump to content
  • 0

Shop that has purchasing limit


Eross

Question


  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.09
  • Content Count:  377
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

Hi ! I would like to request for a zeny shop that has limit.

1. Players can only buy maximum of 3 quantity daily. This will apply for each of players. 

2. The shop will reset every 6AM and allow players to have a 3x purchase again.

3. Has a ordinary shop like tool dealer looks. 

 

Is it possible ? Please help. I will greatly appreciate your efforts . Thankyou !!

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   11
  • Joined:  12/16/11
  • Last Seen:  

Here you are, enjoy.

 

limited_shop.txt

Edited by rokimoki
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.09
  • Content Count:  377
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

2 hours ago, rokimoki said:

Woah bro! it worked ! Thank you ! can we allow the VIP players to buy 5 daily ?? also one question, why does players needs to relogin after reset ?? just curious ..Thanks !!!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.09
  • Content Count:  377
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

3 hours ago, rokimoki said:

Also, is it possible sir to use different sql table instead of char_reg_num ? so players wont need to relogin ? 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  43
  • Reputation:   1
  • Joined:  11/16/14
  • Last Seen:  

I don't know what you want to change but here you go:

 

This should check if the player if vip
 

//===== rAthena Script =======================================
//= Limited Shop
//===== Description: =========================================
//= Request: https://rathena.org/board/topic/143699-shop-that-has-purchasing-limit/
//===== Additional Comments: =================================
//= Author: Rokimoki
//============================================================

shop LimitedShop -1,501:-1,705:-1,1101:-1 prontera,146,170,3 script LimitedShop NPC 860,{
    // Check if the player is a VIP
    if (query_sql("SELECT `group_id` FROM `login` WHERE `account_id` = "+getcharid(0)+" AND `group_id` = '5'", .@vipCheck) > 0) {
        .maxItemQuantity = 5; // VIP limit
    } else {
        .maxItemQuantity = 3; // Non-VIP limit
    }

    if (currentAmountBought >= .maxItemQuantity) {
        .@npcName$ = "[^c77978Limited Shop^000000]";
        mes .@npcName$;
        mes "Limit reached " + currentAmountBought + "/" + .maxItemQuantity + " items.";
        mes "Wait until reset and relog after reset.";
        close;
    }
    
    callshop "LimitedShop", 1;
    npcshopattach "LimitedShop";
    end;

    OnBuyItem:
        .@npcName$ = "[^c77978Limited Shop^000000]";
        set .@totalItems, 0;
        for (.@i = 0; .@i < getarraysize(@bought_nameid); .@i++) {
            if (@bought_quantity[.@i] <= 0){
                mes .@npcName$;
                mes "This shouldn't happen!";
                close;
            }
            set .@totalItems, .@totalItems + @bought_quantity[.@i];
        }
        set .@checkTotalItems, currentAmountBought + .@totalItems;
        if (.@checkTotalItems > .maxItemQuantity) {
            mes .@npcName$;
            mes "You are buying too much items!";
            mes "You picked: " + .@totalItems;
            mes "Current status: " + currentAmountBought + "/" + .maxItemQuantity;
            mes "I recommend you to buy one item by one.";
            close;
        }
        set .@itemZeny, 0;
        for (.@i = 0; .@i < getarraysize(@bought_nameid); .@i++) {
            set .@itemZeny, .@itemZeny + getiteminfo(@bought_nameid[.@i], ITEMINFO_BUY) * @bought_quantity[.@i];
        }
        if (Zeny < .@itemZeny) {
            mes .@npcName$;
            mes "You can't afford this shopping cart!";
            mes "Your Zeny: " + Zeny + " zeny.";
            mes "Total shopping cart: " + .@itemZeny + " zeny.";
            set .@zenyNeeded, .@itemZeny - Zeny;
            mes "You need " + .@zenyNeeded + " more zeny.";
            close;
        }
        for (.@i = 0; .@i < getarraysize(@bought_nameid); .@i++) {
            getitem @bought_nameid[.@i], @bought_quantity[.@i];
        }
        set currentAmountBought, currentAmountBought + .@totalItems;
        set Zeny, Zeny - .@itemZeny;
        deletearray @bought_quantity, getarraysize(@bought_quantity);
        deletearray @bought_nameid, getarraysize(@bought_nameid);
        end;

    OnInit:
        .maxItemQuantity = 3; // Set the default max quantity for non-VIP players
        end;

    OnClock0600:
        query_sql("UPDATE `char_reg_num` SET `value` = 0 WHERE `key` = 'currentAmountBought' AND `char_id` <> 0;");
        npctalk "Shop has been reseted. Relog your character.";
        end;
}


 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   11
  • Joined:  12/16/11
  • Last Seen:  

Character variables are attached to a player, so, how is it possible to modify value if I cant attach a player on OnClock0600? Well I can do a trick getting players online attaching and detaching, but solution is just by sql, and that table is managed by char_server so they have to relog to get sql changes. Just relog at 6am, I dont think is a big deal xd. If you were offline and log after 6am you get changes applied.

but if you dont want to use char_server table, we can create a new table for this script

Edited by rokimoki
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.09
  • Content Count:  377
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

1 hour ago, rokimoki said:

Character variables are attached to a player, so, how is it possible to modify value if I cant attach a player on OnClock0600? Well I can do a trick getting players online attaching and detaching, but solution is just by sql, and that table is managed by char_server so they have to relog to get sql changes. Just relog at 6am, I dont think is a big deal xd. If you were online and log after 6am you get changes applied.

but if you dont want to use char_server table, we can create a new table for this script

I understand sir thanks to your efforts !!!!

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...