Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xshadowbringer opened this issue Feb 17, 2023 · 9 comments

Comments

@xshadowbringer
Copy link

xshadowbringer commented Feb 17, 2023

#include
#include
#include <vip_core>

#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));
VIP_GiveClientVIP(_, client, kv.GetNum("duration"), buff);
}
}

return true;

}

@xshadowbringer xshadowbringer changed the title I'm trying to create a module Can you convert this Shop Core plugin to Zephyrus Store? i want to add buy vip core to this shop Feb 17, 2023
@xshadowbringer
Copy link
Author

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 added a commit to originalaidn/zephyrus-store-preview-new-syntax that referenced this issue Feb 19, 2023
@originalaidn
Copy link
Contributor

originalaidn commented Feb 19, 2023

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
Copy link
Author

xshadowbringer commented Feb 23, 2023

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
Copy link
Contributor

originalaidn commented Feb 23, 2023

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
Copy link
Author

xshadowbringer commented Feb 23, 2023

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
Copy link
Contributor

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

@azalty
Copy link
Contributor

azalty commented Feb 23, 2023

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
Copy link

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

@adyshark
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants