Raised This Month: $32 Target: $400
 8% 

Buy VIP Request


Post New Thread Reply   
 
Thread Tools Display Modes
menkisa
Junior Member
Join Date: Sep 2011
Old 08-18-2022 , 10:53   Re: Buy VIP Request
Reply With Quote #11

It should be added nvault_set in client_disconnected forward in order to prevent such cases.
menkisa is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-18-2022 , 12:23   Re: Buy VIP Request
Reply With Quote #12

this can't happen because the plugin saves player vip time right after he buy it

anyway your server shouldn t restart or crash in 2022
lexzor is offline
QuickDroLLL
Senior Member
Join Date: Dec 2021
Location: AMX Mod X Land
Old 08-18-2022 , 12:58   Re: Buy VIP Request
Reply With Quote #13

can some one fix problem like this?

lexzor the vip not registed when player disconnect so when player disconnect and login again it found his vip gone
and there to many ddos attackers atack me server so that why me server got crash.

Last edited by QuickDroLLL; 08-18-2022 at 13:01.
QuickDroLLL is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 08-18-2022 , 16:30   Re: Buy VIP Request
Reply With Quote #14

They cant lose their vip on disconnect or server crash unless their steam id changes, which means you are running a non-steam server? or people are changing steam accounts
ZaX is offline
QuickDroLLL
Senior Member
Join Date: Dec 2021
Location: AMX Mod X Land
Old 08-18-2022 , 16:35   Re: Buy VIP Request
Reply With Quote #15

ok thanks for your reply

Last edited by QuickDroLLL; 08-24-2022 at 13:31.
QuickDroLLL is offline
QuickDroLLL
Senior Member
Join Date: Dec 2021
Location: AMX Mod X Land
Old 08-24-2022 , 13:32   Re: Buy VIP Request
Reply With Quote #16

its realy don't save vip players when map change and when player disconnect and reconnect the vip it will dispeer i using steam so i try it by my self and it do the same
i hope someone fix it

Last edited by QuickDroLLL; 08-24-2022 at 13:33.
QuickDroLLL is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-25-2022 , 09:42   Re: Buy VIP Request
Reply With Quote #17

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"^4%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"^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;



Last edited by lexzor; 08-25-2022 at 09:43.
lexzor is offline
QuickDroLLL
Senior Member
Join Date: Dec 2021
Location: AMX Mod X Land
Old 08-25-2022 , 15:11   Re: Buy VIP Request
Reply With Quote #18

not working
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 19:59.


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