Raised This Month: $ Target: $400
 0% 

Buy VIP Request


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
QuickDroLLL
Member
Join Date: Dec 2021
Location: Algeria
Old 08-16-2022 , 08:19   Buy VIP Request
Reply With Quote #1

Hello Every one QuickDroLLL here , so can someone create Buy VIP by those nativs:

native jb_get_user_coins(id);
native jb_set_user_coins(id, iNum);

so basicly when someone type /coins it will apear a menu with those functions:

Buy VIP For 1 Day for 150 Coins
Buy VIP For 3 Days for 450 Coins
Buy VIP For 7 Days for 1050 Coins

when player don't have a coins it tell him You don't have enough coins
when player buy vip it tell him You bought vip time
when player join server and he is vip it tell him how much time he have before expired
when player buy vip it will be saved without pw only steamid
when player is already vip and try to buy vip its tell him you are already vip
players that buys vip it will be saved in ini file on configs
vip flags is ADMIN_KICK
QuickDroLLL is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 08-16-2022 , 09:41   Re: Buy VIP Request
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <nvault>
#include <unixtime>

#define TAG "^4[VIP]"
#define VIP_FLAG ADMIN_KICK
#define is_vip(%0) (get_user_flags(%0) & VIP_FLAG)

#if !defined MAX_PLAYERS 
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const DAY_IN_SECONDS 86400

enum _
:VIP_INFO
{
    
szMenuName[64],
    
iTime,
    
iPrice
}

new const 
g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},
}

native jb_get_user_coins(id);
native jb_set_user_coins(idamount);

new 
g_nVault;
new const 
g_sznVaultName[] = "vip_jb";
new 
g_iVIPTime[MAX_PLAYERS 1];
new const 
g_szAuthID[MAX_PLAYERS 1][MAX_AUTHID_LENGTH];

public 
plugin_init()
{
    
register_plugin("Buy VIP""0.1""AMXX Community");

    
register_clcmd("say /buyvip""buyCmd");
    
register_clcmd("say_team /buyvip""buyCmd");

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
    {
        
set_fail_state("Couldn't open ^"%s^" nvault file"g_sznVaultName);
    }
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

public 
client_authorized(id)
{
    
g_iVIPTime[id] = -1;
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
check_vip(id);
}

check_vip(const id)
{
    new 
iTsszData[12];
    if(
nvault_lookup(g_nVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_iVIPTime[id] = str_to_num(szData);

        if(
g_iVIPTime[id] <= get_systime())
            
set_user_flags(idVIP_FLAG);
        else 
g_iVIPTime[id] = -1;
    }
}

public 
buyCmd(id)
{
    new 
iMenu menu_create("\r[VIP]\w Buy temporar\y VIP""menu_handler");

    for(new 
isizeof(g_eVIPINFO); i++)
    {
        
menu_additem(iMenug_eVIPINFO[i][szMenuName]);
    }

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id))
    {
        new 
iYeariMonthiDayiHouriMinuteiSecond;
        
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
        
client_print_color(idprint_team_default"^4%s^1 You already have^4 VIP^1 until^3 %i/%i/%i^1 at^3 %i:%i:%i",
        
TAGiDayiMonthiYeariHouriMinuteiSecond);
        
buyCmd(id);
        return 
PLUGIN_HANDLED;
    }

    
give_user_vip(iditem);

    return 
PLUGIN_CONTINUE;
}

give_user_vip(const id, const level)
{
    new 
iCoins jb_get_user_coins(id);
    if(
iCoins g_eVIPINFO[level][iPrice] < 0)
    {
        
client_print_color(idprint_team_default"%s^1 You don't have enough^4 coins^1! You need^3 %i^1 more^4 coins^1."TAGg_eVIPINFO[level][iPrice] - iCoins);
        return 
PLUGIN_HANDLED;
    }

    
jb_set_user_coins(idiCoins g_eVIPINFO[level][iPrice]);
    
set_user_flags(idVIP_FLAG);
    new 
szData[12];
    
g_iVIPTime[id] = get_systime(g_eVIPINFO[level][iTime] * DAY_IN_SECONDS);
    
num_to_str(g_iVIPTime[id], szDatacharsmax(szData));
    
nvault_set(g_nVaultg_szAuthID[id], szData);
    new 
iYeariMonthiDayiHouriMinuteiSecond;
    
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 You bought^4 VIP^1 for^3 %i day%s^1. Expire time:^3 %i/%i/%i^1 at^3 %i:%i:%i^1.",
    
TAGg_eVIPINFO[level][iTime], g_eVIPINFO[level][iTime] > "s" ""iDayiMonthiYeariHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 Price:^3 %i^1. Balance:^3 %i^1"TAGg_eVIPINFO[level][iPrice], jb_get_user_coins(id));

    return 
PLUGIN_CONTINUE;

you can add/change/remove vip packs from here

PHP Code:
new const g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},

lexzor is offline
QuickDroLLL
Member
Join Date: Dec 2021
Location: Algeria
Old 08-17-2022 , 03:20   Re: Buy VIP Request
Reply With Quote #3

Quote:
Originally Posted by lexzor View Post
PHP Code:
#include <amxmodx>
#include <nvault>
#include <unixtime>

#define TAG "^4[VIP]"
#define VIP_FLAG ADMIN_KICK
#define is_vip(%0) (get_user_flags(%0) & VIP_FLAG)

#if !defined MAX_PLAYERS 
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const DAY_IN_SECONDS 86400

enum _
:VIP_INFO
{
    
szMenuName[64],
    
iTime,
    
iPrice
}

new const 
g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},
}

native jb_get_user_coins(id);
native jb_set_user_coins(idamount);

new 
g_nVault;
new const 
g_sznVaultName[] = "vip_jb";
new 
g_iVIPTime[MAX_PLAYERS 1];
new const 
g_szAuthID[MAX_PLAYERS 1][MAX_AUTHID_LENGTH];

public 
plugin_init()
{
    
register_plugin("Buy VIP""0.1""AMXX Community");

    
register_clcmd("say /buyvip""buyCmd");
    
register_clcmd("say_team /buyvip""buyCmd");

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
    {
        
set_fail_state("Couldn't open ^"%s^" nvault file"g_sznVaultName);
    }
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

public 
client_authorized(id)
{
    
g_iVIPTime[id] = -1;
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
check_vip(id);
}

check_vip(const id)
{
    new 
iTsszData[12];
    if(
nvault_lookup(g_nVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_iVIPTime[id] = str_to_num(szData);

        if(
g_iVIPTime[id] <= get_systime())
            
set_user_flags(idVIP_FLAG);
        else 
g_iVIPTime[id] = -1;
    }
}

public 
buyCmd(id)
{
    new 
iMenu menu_create("\r[VIP]\w Buy temporar\y VIP""menu_handler");

    for(new 
isizeof(g_eVIPINFO); i++)
    {
        
menu_additem(iMenug_eVIPINFO[i][szMenuName]);
    }

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id))
    {
        new 
iYeariMonthiDayiHouriMinuteiSecond;
        
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
        
client_print_color(idprint_team_default"^4%s^1 You already have^4 VIP^1 until^3 %i/%i/%i^1 at^3 %i:%i:%i",
        
TAGiDayiMonthiYeariHouriMinuteiSecond);
        
buyCmd(id);
        return 
PLUGIN_HANDLED;
    }

    
give_user_vip(iditem);

    return 
PLUGIN_CONTINUE;
}

give_user_vip(const id, const level)
{
    new 
iCoins jb_get_user_coins(id);
    if(
iCoins g_eVIPINFO[level][iPrice] < 0)
    {
        
client_print_color(idprint_team_default"%s^1 You don't have enough^4 coins^1! You need^3 %i^1 more^4 coins^1."TAGg_eVIPINFO[level][iPrice] - iCoins);
        return 
PLUGIN_HANDLED;
    }

    
jb_set_user_coins(idiCoins g_eVIPINFO[level][iPrice]);
    
set_user_flags(idVIP_FLAG);
    new 
szData[12];
    
g_iVIPTime[id] = get_systime(g_eVIPINFO[level][iTime] * DAY_IN_SECONDS);
    
num_to_str(g_iVIPTime[id], szDatacharsmax(szData));
    
nvault_set(g_nVaultg_szAuthID[id], szData);
    new 
iYeariMonthiDayiHouriMinuteiSecond;
    
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 You bought^4 VIP^1 for^3 %i day%s^1. Expire time:^3 %i/%i/%i^1 at^3 %i:%i:%i^1.",
    
TAGg_eVIPINFO[level][iTime], g_eVIPINFO[level][iTime] > "s" ""iDayiMonthiYeariHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 Price:^3 %i^1. Balance:^3 %i^1"TAGg_eVIPINFO[level][iPrice], jb_get_user_coins(id));

    return 
PLUGIN_CONTINUE;

you can add/change/remove vip packs from here

PHP Code:
new const g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},

there an erros:
Error: Number of arguments does not match definition on line 53
Error: Number of arguments does not match definition on line 93
QuickDroLLL is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 08-17-2022 , 07:40   Re: Buy VIP Request
Reply With Quote #4

update your compiler at 1.9.0


a little update i use it now for my server too
PHP Code:
#include <amxmodx>
#include <nvault>
#include <unixtime>

#define TAG "^4[VIP]"
#define VIP_FLAG ADMIN_KICK
#define is_vip(%0) (get_user_flags(%0) & VIP_FLAG)

#if !defined MAX_PLAYERS 
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const DAY_IN_SECONDS 86400

enum _
:VIP_INFO
{
    
szMenuName[64],
    
iTime,
    
iPrice
}

new const 
g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},
}

native jb_get_user_coins(id);
native jb_set_user_coins(idamount);

new 
g_nVault;
new const 
g_sznVaultName[] = "vip_jb";
new 
g_iVIPTime[MAX_PLAYERS 1];
new const 
g_szAuthID[MAX_PLAYERS 1][MAX_AUTHID_LENGTH];

public 
plugin_init()
{
    
register_plugin("Buy VIP""0.1""AMXX Community");

    
register_clcmd("say /buyvip""buyCmd");
    
register_clcmd("say_team /buyvip""buyCmd");

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
    {
        
set_fail_state("Couldn't open ^"%s^" nvault file"g_sznVaultName);
    }
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

public 
client_authorized(id)
{
    
g_iVIPTime[id] = -1;
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
check_vip(id);
}

check_vip(const id)
{
    new 
iTsszData[12];
    if(
nvault_lookup(g_nVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_iVIPTime[id] = str_to_num(szData);

        if(
g_iVIPTime[id] <= get_systime())
            
set_user_flags(idVIP_FLAG);
        else 
g_iVIPTime[id] = -1;
    }
}

public 
buyCmd(id)
{
    new 
iMenu menu_create("\r[VIP]\w Buy temporar\y VIP""menu_handler");

    for(new 
isizeof(g_eVIPINFO); i++)
    {
        
menu_additem(iMenug_eVIPINFO[i][szMenuName]);
    }

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id) && g_iVIPTime[id] == -1)
    {
        new 
iYeariMonthiDayiHouriMinuteiSecond;
        
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
        
client_print_color(idprint_team_default"^4%s^1 You already have^4 VIP^1 until^3 %i/%i/%i^1 at^3 %i:%i:%i",
        
TAGiDayiMonthiYeariHouriMinuteiSecond);
        
buyCmd(id);
        return 
PLUGIN_HANDLED;
    }

    
give_user_vip(iditem);

    return 
PLUGIN_CONTINUE;
}

give_user_vip(const id, const level)
{
    new 
iCoins jb_get_user_coins(id);
    if(
iCoins g_eVIPINFO[level][iPrice] < 0)
    {
        
client_print_color(idprint_team_default"%s^1 You don't have enough^4 coins^1! You need^3 %i^1 more^4 coins^1."TAGg_eVIPINFO[level][iPrice] - iCoins);
        return 
PLUGIN_HANDLED;
    }

    
jb_set_user_coins(idiCoins g_eVIPINFO[level][iPrice]);
    
set_user_flags(idVIP_FLAG);
    new 
szData[12];
    
g_iVIPTime[id] = get_systime(g_eVIPINFO[level][iTime] * DAY_IN_SECONDS);
    
num_to_str(g_iVIPTime[id], szDatacharsmax(szData));
    
nvault_set(g_nVaultg_szAuthID[id], szData);
    new 
iYeariMonthiDayiHouriMinuteiSecond;
    
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 You bought^4 VIP^1 for^3 %i day%s^1. Expire time:^3 %i/%i/%i^1 at^3 %i:%i:%i^1.",
    
TAGg_eVIPINFO[level][iTime], g_eVIPINFO[level][iTime] > "s" ""iDayiMonthiYeariHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 Price:^3 %i^1. Balance:^3 %i^1"TAGg_eVIPINFO[level][iPrice], jb_get_user_coins(id));

    return 
PLUGIN_CONTINUE;

lexzor is offline
QuickDroLLL
Member
Join Date: Dec 2021
Location: Algeria
Old 08-17-2022 , 08:28   Re: Buy VIP Request
Reply With Quote #5

Quote:
Originally Posted by lexzor View Post
update your compiler at 1.9.0


a little update i use it now for my server too
PHP Code:
#include <amxmodx>
#include <nvault>
#include <unixtime>

#define TAG "^4[VIP]"
#define VIP_FLAG ADMIN_KICK
#define is_vip(%0) (get_user_flags(%0) & VIP_FLAG)

#if !defined MAX_PLAYERS 
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const DAY_IN_SECONDS 86400

enum _
:VIP_INFO
{
    
szMenuName[64],
    
iTime,
    
iPrice
}

new const 
g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},
}

native jb_get_user_coins(id);
native jb_set_user_coins(idamount);

new 
g_nVault;
new const 
g_sznVaultName[] = "vip_jb";
new 
g_iVIPTime[MAX_PLAYERS 1];
new const 
g_szAuthID[MAX_PLAYERS 1][MAX_AUTHID_LENGTH];

public 
plugin_init()
{
    
register_plugin("Buy VIP""0.1""AMXX Community");

    
register_clcmd("say /buyvip""buyCmd");
    
register_clcmd("say_team /buyvip""buyCmd");

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
    {
        
set_fail_state("Couldn't open ^"%s^" nvault file"g_sznVaultName);
    }
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

public 
client_authorized(id)
{
    
g_iVIPTime[id] = -1;
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
check_vip(id);
}

check_vip(const id)
{
    new 
iTsszData[12];
    if(
nvault_lookup(g_nVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_iVIPTime[id] = str_to_num(szData);

        if(
g_iVIPTime[id] <= get_systime())
            
set_user_flags(idVIP_FLAG);
        else 
g_iVIPTime[id] = -1;
    }
}

public 
buyCmd(id)
{
    new 
iMenu menu_create("\r[VIP]\w Buy temporar\y VIP""menu_handler");

    for(new 
isizeof(g_eVIPINFO); i++)
    {
        
menu_additem(iMenug_eVIPINFO[i][szMenuName]);
    }

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id) && g_iVIPTime[id] == -1)
    {
        new 
iYeariMonthiDayiHouriMinuteiSecond;
        
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
        
client_print_color(idprint_team_default"^4%s^1 You already have^4 VIP^1 until^3 %i/%i/%i^1 at^3 %i:%i:%i",
        
TAGiDayiMonthiYeariHouriMinuteiSecond);
        
buyCmd(id);
        return 
PLUGIN_HANDLED;
    }

    
give_user_vip(iditem);

    return 
PLUGIN_CONTINUE;
}

give_user_vip(const id, const level)
{
    new 
iCoins jb_get_user_coins(id);
    if(
iCoins g_eVIPINFO[level][iPrice] < 0)
    {
        
client_print_color(idprint_team_default"%s^1 You don't have enough^4 coins^1! You need^3 %i^1 more^4 coins^1."TAGg_eVIPINFO[level][iPrice] - iCoins);
        return 
PLUGIN_HANDLED;
    }

    
jb_set_user_coins(idiCoins g_eVIPINFO[level][iPrice]);
    
set_user_flags(idVIP_FLAG);
    new 
szData[12];
    
g_iVIPTime[id] = get_systime(g_eVIPINFO[level][iTime] * DAY_IN_SECONDS);
    
num_to_str(g_iVIPTime[id], szDatacharsmax(szData));
    
nvault_set(g_nVaultg_szAuthID[id], szData);
    new 
iYeariMonthiDayiHouriMinuteiSecond;
    
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 You bought^4 VIP^1 for^3 %i day%s^1. Expire time:^3 %i/%i/%i^1 at^3 %i:%i:%i^1.",
    
TAGg_eVIPINFO[level][iTime], g_eVIPINFO[level][iTime] > "s" ""iDayiMonthiYeariHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 Price:^3 %i^1. Balance:^3 %i^1"TAGg_eVIPINFO[level][iPrice], jb_get_user_coins(id));

    return 
PLUGIN_CONTINUE;

thx its compiled
whats to little update that you add ?
QuickDroLLL is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 08-17-2022 , 08:32   Re: Buy VIP Request
Reply With Quote #6

bug resolve
lexzor is offline
QuickDroLLL
Member
Join Date: Dec 2021
Location: Algeria
Old 08-17-2022 , 14:42   Re: Buy VIP Request
Reply With Quote #7

Quote:
Originally Posted by lexzor View Post
bug resolve
its working fine but you are already vip not working i can spam vip buying

Last edited by QuickDroLLL; 08-17-2022 at 14:48.
QuickDroLLL is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 08-17-2022 , 15:04   Re: Buy VIP Request
Reply With Quote #8

PHP Code:
#include <amxmodx>
#include <nvault>
#include <unixtime>

#define TAG "^4[VIP]"
#define VIP_FLAG ADMIN_KICK
#define is_vip(%0) (get_user_flags(%0) & VIP_FLAG)

#if !defined MAX_PLAYERS 
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const DAY_IN_SECONDS 86400

enum _
:VIP_INFO
{
    
szMenuName[64],
    
iTime,
    
iPrice
}

new const 
g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},
}

native jb_get_user_coins(id);
native jb_set_user_coins(idamount);

new 
g_nVault;
new const 
g_sznVaultName[] = "vip_jb";
new 
g_iVIPTime[MAX_PLAYERS 1];
new const 
g_szAuthID[MAX_PLAYERS 1][MAX_AUTHID_LENGTH];

public 
plugin_init()
{
    
register_plugin("Buy VIP""0.1""AMXX Community");

    
register_clcmd("say /buyvip""buyCmd");
    
register_clcmd("say_team /buyvip""buyCmd");

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
    {
        
set_fail_state("Couldn't open ^"%s^" nvault file"g_sznVaultName);
    }
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

public 
client_authorized(id)
{
    
g_iVIPTime[id] = -1;
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
check_vip(id);
}

check_vip(const id)
{
    new 
iTsszData[12];
    if(
nvault_lookup(g_nVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_iVIPTime[id] = str_to_num(szData);

        if(
g_iVIPTime[id] <= get_systime())
            
set_user_flags(idVIP_FLAG);
        else 
g_iVIPTime[id] = -1;
    }
}

public 
buyCmd(id)
{
    new 
iMenu menu_create("\r[VIP]\w Buy temporar\y VIP""menu_handler");

    for(new 
isizeof(g_eVIPINFO); i++)
    {
        
menu_additem(iMenug_eVIPINFO[i][szMenuName]);
    }

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id))
    {
        
client_print_color(idprint_team_default"%s^1 You already have^4 VIP^1!"TAG);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id) && g_iVIPTime[id] == -1)
    {
        new 
iYeariMonthiDayiHouriMinuteiSecond;
        
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
        
client_print_color(idprint_team_default"%s^1 You already have^4 VIP^1 until^3 %i/%i/%i^1 at^3 %i:%i:%i",
        
TAGiDayiMonthiYeariHouriMinuteiSecond);
        
buyCmd(id);
        return 
PLUGIN_HANDLED;
    }

    
give_user_vip(iditem);

    return 
PLUGIN_CONTINUE;
}

give_user_vip(const id, const level)
{
    new 
iCoins jb_get_user_coins(id);
    if(
iCoins g_eVIPINFO[level][iPrice] < 0)
    {
        
client_print_color(idprint_team_default"%s^1 You don't have enough^4 coins^1! You need^3 %i^1 more^4 coins^1."TAGg_eVIPINFO[level][iPrice] - iCoins);
        return 
PLUGIN_HANDLED;
    }

    
jb_set_user_coins(idiCoins g_eVIPINFO[level][iPrice]);
    
set_user_flags(idVIP_FLAG);
    new 
szData[12];
    
g_iVIPTime[id] = get_systime(g_eVIPINFO[level][iTime] * DAY_IN_SECONDS);
    
num_to_str(g_iVIPTime[id], szDatacharsmax(szData));
    
nvault_set(g_nVaultg_szAuthID[id], szData);
    new 
iYeariMonthiDayiHouriMinuteiSecond;
    
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 You bought^4 VIP^1 for^3 %i day%s^1. Expire time:^3 %i/%i/%i^1 at^3 %i:%i:%i^1.",
    
TAGg_eVIPINFO[level][iTime], g_eVIPINFO[level][iTime] > "s" ""iDayiMonthiYeariHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 Price:^3 %i^1. Balance:^3 %i^1"TAGg_eVIPINFO[level][iPrice], jb_get_user_coins(id));

    return 
PLUGIN_CONTINUE;


Last edited by lexzor; 08-17-2022 at 15:04.
lexzor is offline
QuickDroLLL
Member
Join Date: Dec 2021
Location: Algeria
Old 08-17-2022 , 16:07   Re: Buy VIP Request
Reply With Quote #9

Quote:
Originally Posted by lexzor View Post
PHP Code:
#include <amxmodx>
#include <nvault>
#include <unixtime>

#define TAG "^4[VIP]"
#define VIP_FLAG ADMIN_KICK
#define is_vip(%0) (get_user_flags(%0) & VIP_FLAG)

#if !defined MAX_PLAYERS 
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const DAY_IN_SECONDS 86400

enum _
:VIP_INFO
{
    
szMenuName[64],
    
iTime,
    
iPrice
}

new const 
g_eVIPINFO[][VIP_INFO] = 
{
    
//MENU NAME          DAYS   PRICE
    
{"Buy VIP for 1 day",   1,  150},
    {
"Buy VIP for 3 days",  3,  450},
    {
"Buy VIP for 7 days",  7,  1050},
}

native jb_get_user_coins(id);
native jb_set_user_coins(idamount);

new 
g_nVault;
new const 
g_sznVaultName[] = "vip_jb";
new 
g_iVIPTime[MAX_PLAYERS 1];
new const 
g_szAuthID[MAX_PLAYERS 1][MAX_AUTHID_LENGTH];

public 
plugin_init()
{
    
register_plugin("Buy VIP""0.1""AMXX Community");

    
register_clcmd("say /buyvip""buyCmd");
    
register_clcmd("say_team /buyvip""buyCmd");

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
    {
        
set_fail_state("Couldn't open ^"%s^" nvault file"g_sznVaultName);
    }
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

public 
client_authorized(id)
{
    
g_iVIPTime[id] = -1;
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]))
    
check_vip(id);
}

check_vip(const id)
{
    new 
iTsszData[12];
    if(
nvault_lookup(g_nVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_iVIPTime[id] = str_to_num(szData);

        if(
g_iVIPTime[id] <= get_systime())
            
set_user_flags(idVIP_FLAG);
        else 
g_iVIPTime[id] = -1;
    }
}

public 
buyCmd(id)
{
    new 
iMenu menu_create("\r[VIP]\w Buy temporar\y VIP""menu_handler");

    for(new 
isizeof(g_eVIPINFO); i++)
    {
        
menu_additem(iMenug_eVIPINFO[i][szMenuName]);
    }

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id))
    {
        
client_print_color(idprint_team_default"%s^1 You already have^4 VIP^1!"TAG);
        return 
PLUGIN_HANDLED;
    }

    if(
is_vip(id) && g_iVIPTime[id] == -1)
    {
        new 
iYeariMonthiDayiHouriMinuteiSecond;
        
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
        
client_print_color(idprint_team_default"%s^1 You already have^4 VIP^1 until^3 %i/%i/%i^1 at^3 %i:%i:%i",
        
TAGiDayiMonthiYeariHouriMinuteiSecond);
        
buyCmd(id);
        return 
PLUGIN_HANDLED;
    }

    
give_user_vip(iditem);

    return 
PLUGIN_CONTINUE;
}

give_user_vip(const id, const level)
{
    new 
iCoins jb_get_user_coins(id);
    if(
iCoins g_eVIPINFO[level][iPrice] < 0)
    {
        
client_print_color(idprint_team_default"%s^1 You don't have enough^4 coins^1! You need^3 %i^1 more^4 coins^1."TAGg_eVIPINFO[level][iPrice] - iCoins);
        return 
PLUGIN_HANDLED;
    }

    
jb_set_user_coins(idiCoins g_eVIPINFO[level][iPrice]);
    
set_user_flags(idVIP_FLAG);
    new 
szData[12];
    
g_iVIPTime[id] = get_systime(g_eVIPINFO[level][iTime] * DAY_IN_SECONDS);
    
num_to_str(g_iVIPTime[id], szDatacharsmax(szData));
    
nvault_set(g_nVaultg_szAuthID[id], szData);
    new 
iYeariMonthiDayiHouriMinuteiSecond;
    
UnixToTime(g_iVIPTime[id], iYeariMonthiDayiHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 You bought^4 VIP^1 for^3 %i day%s^1. Expire time:^3 %i/%i/%i^1 at^3 %i:%i:%i^1.",
    
TAGg_eVIPINFO[level][iTime], g_eVIPINFO[level][iTime] > "s" ""iDayiMonthiYeariHouriMinuteiSecond);
    
client_print_color(idprint_team_default"%s^1 Price:^3 %i^1. Balance:^3 %i^1"TAGg_eVIPINFO[level][iPrice], jb_get_user_coins(id));

    return 
PLUGIN_CONTINUE;

thanks very much for your help work perfectly
QuickDroLLL is offline
QuickDroLLL
Member
Join Date: Dec 2021
Location: Algeria
Old 08-18-2022 , 08:56   Re: Buy VIP Request
Reply With Quote #10

another problem xd, on server crash or server restart or when player disconnected his vip will gone.
QuickDroLLL is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:02.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode