nuclearsilo583 / zephyrus-store-preview-new-syntax

My rewritten zephyrus store
61 stars 40 forks source link

Can you convert this Shop Core plugin to Zephyrus Store? i want to add buy vip core to this shop #154

Open xshadowbringer opened 1 year ago

xshadowbringer commented 1 year ago

include

include

include

define PLUGIN_AUTHOR "Pr[E]fix | vk.com/cyxaruk1337"

define PLUGIN_NAME "[Shop] Buy ViP"

define PLUGIN_VERSION "2.0"

define PLUGIN_DESCRIPTION "Возможность добавить покупку vip за кредиты в shop"

KeyValues kv;

public Plugin:myinfo = { name = PLUGIN_NAME, author = PLUGIN_AUTHOR, description = PLUGIN_DESCRIPTION, version = PLUGIN_VERSION, url = "hlmod.ru/members/pr-e-fix.110719" };

public void OnPluginStart() { if (Shop_IsStarted()) Shop_Started(); }

public void OnPluginEnd() { Shop_UnregisterMe(); }

public void Shop_Started() {
CategoryId category = Shop_RegisterCategory("vip", "Покупка VIP", "");

if(kv)
    delete kv;
kv = new KeyValues("Shop_Vip");

char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "configs/shop/shop_vip.ini");

if (!kv.ImportFromFile(path) || !kv.GotoFirstSubKey()) SetFailState("(%s) is not found", path);

char buffer[64];

do 
{
    kv.GetString("vip_group", buffer, sizeof(buffer));

    if (VIP_IsValidVIPGroup(buffer))
    {
        kv.GetSectionName(buffer, sizeof(buffer))

        if(Shop_StartItem(category, buffer))
        {
            kv.GetString("name", buffer, sizeof(buffer));
            Shop_SetLuckChance(kv.GetNum("luckchance", 10));
            if(buffer[0])
            {
                Shop_SetInfo(buffer, "", kv.GetNum("price"), -1, Item_BuyOnly);
                Shop_SetCallbacks(_, _, _, _, _, _, CallBack_Shop_OnBuy);
                Shop_EndItem();
            }
        }
    }
}
while (kv.GotoNextKey());

}

public bool CallBack_Shop_OnBuy(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int price, int sell_price, int value) { if (VIP_IsClientVIP(client)) { PrintToChat(client, "У вас уже имеется VIP Статус"); return false; } else { char buff[64]; kv.Rewind(); if(kv.JumpToKey(item)) { kv.GetString("vip_group", buff, sizeof(buff)); VIPGiveClientVIP(, client, kv.GetNum("duration"), buff); } }

return true;

}

xshadowbringer commented 1 year ago

And in Items.txt, something like this

"BuyVip" { "vip1" { "name" "vip1" "type" "buyvipcore" "unique_id" "uid_buyvipcore" "Plans" { "7 days" { "price" "700000" "time" "604800" } } } }

originalaidn commented 1 year ago

Hi, please test my PR. In your case the items.txt should look like this:

"VIP - 1 week" { "type" "buyvip-r1ko" "group" "vip1" "time" "604800" "price" "700000" }

xshadowbringer commented 1 year ago

Hi, please test my PR. In your case the items.txt should look like this:

"VIP - 1 week" { "type" "buyvip-r1ko" "group" "vip1" "time" "604800" "price" "700000" }

in the VIP_Remove() function i think before "return 0;" should be "VIP_RemoveClientVIP2(0, client, false, true); PrintToChat(client, "~# VipSHOP$ Your Vip status was unequipped");"

because if the client sold, traded the item the vip status won't get removed.

also in VIP_Equip() the duration of the vip should be based on the remaining time of the store item if its not removed from store

PS: BTW Thank you so much for doing this

originalaidn commented 1 year ago

As far as i remember, you can't sell/trade the item, as it disappears from your inventory as soon as you equip it. --> Store_RemoveItem(client, id);

In VIP_Equip() i don't know what you want, the duration is based on the "time" which is in the CFG, u can add for 2 weeks, 1 month, 6 months, etc.. just need to edit the "time". or u want same as u send, in Plans section?

xshadowbringer commented 1 year ago

As far as i remember, you can't sell/trade the item, as it disappears from your inventory as soon as you equip it. --> Store_RemoveItem(client, id);

In VIP_Equip() i don't know what you want, the duration is based on the "time" which is in the CFG, u can add for 2 weeks, 1 month, 6 months, etc.. just need to edit the "time". or u want same as u send, in Plans section?

Yes, (As far as i remember, you can't sell/trade the item, as it disappears from your inventory as soon as you equip it. -->) this is true but if you equip it and immediately trade it you get the vip and also trade it to another person maybe better to block the trade for this item entirely

originalaidn commented 1 year ago

Ahh I see, just add "trade" "0" to the config, but I'll check what you wrote

azalty commented 1 year ago

If it's possible to trade an item after using it, then it is a pretty serious exploit indeed. Thanks for notifying us.

However, I think you're talking about an equipable item. The VIP is another type of item: "the 1 use item". You can't equip them, but you can use them. After using it, the item will be removed from your inventory.

adyshark commented 1 year ago

store plugin already haves "ignore_vip" option, but works only with flags, can this be implemented with this vip core plugin?

adyshark commented 1 year ago

also,after vip expires, in database vip players must be removed, to cleanup table.