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

Solved [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-04-2018 , 07:10   [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #1

Hello.

Is this possible? So if I buy an extra today it'll be stored in a keyvalue, I guess with a timestamp, and after 2 weeks(example) it will be autoremoved, either when a player joins and my plugins checkes when he redeemed the extra or automatically by the plugin - maybe another timestamp for when to remove.
__________________

Last edited by PinHeaDi; 04-24-2018 at 06:00.
PinHeaDi is offline
pride95
Senior Member
Join Date: Aug 2015
Old 04-04-2018 , 12:10   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #2

yes, you can. use database, not keyvalues for what you are trying.

create a database with steamid primary key and data (type data).
insert in the database the steamid and data

PHP Code:
insert in my_table values ('steam_0:1:232323232232'NOW()); 
and on player connect
PHP Code:
delete from my_table where steamid '%s' and data now() - interval 2 months
before asking if it is possible, try to search.
pride95 is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-05-2018 , 03:10   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #3

I wouldn't ask the community now, if I did found a noob friendly snipset or tutorial "how to do it" for example, would I?
__________________
PinHeaDi is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-09-2018 , 02:36   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #4

Is there a way that I can get a timestamp for example today + 1 month? I guess i can add a key value "WhenToExpire" and check for that on player connect, so if it's expired - it'll delete it.
__________________
PinHeaDi is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-09-2018 , 05:48   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #5

Timestamp is time in seconds passed from unix epoch start (January 1st, 1970 at UTC). You can get current timestamp using GetTime function. Obviously (today + 1 month) will be equal to
GetTime() + 60*60*24*30; // 60 seconds in one minute, 60 minutes in one hour, 24 hours in one day, 30 days in average in one month.

Last edited by Reiko1231; 04-09-2018 at 05:48.
Reiko1231 is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-09-2018 , 05:57   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #6

So if I want it gone in 2 weeks for example, it should be GetTime() + 60*60*24*14;, right?
__________________
PinHeaDi is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-09-2018 , 07:18   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #7

Yes.
Reiko1231 is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-10-2018 , 06:49   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #8

PHP Code:
#include <sourcemod>
#include <clientprefs>
#include <cstrike>
#include <sdktools>

#include <multicolors>
#include <hextags>
#include <mostactive>
#include <shop>
#include <vip_core>

#define TokensConfig "configs/minigames/tokenstore_config.cfg"

char UsedTokens[MAXPLAYERS+1];
char ConfigLocation[PLATFORM_MAX_PATH];
char SkinModelPath[MAXPLAYERS 1][128];
Handle UsedTokensCookie INVALID_HANDLE;

bool PlayerHasPrefix[MAXPLAYERS+1];
bool PlayerHasPaint[MAXPLAYERS+1];
bool PlayerHasSkin[MAXPLAYERS+1];

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
RegConsoleCmd("sm_mytokens"TokenShop);
    
RegConsoleCmd("sm_tshop"TokenShop);
    
RegConsoleCmd("sm_tokenshop"TokenShop);

    
UsedTokensCookie RegClientCookie("Minigames Tokens Shop""Used Tokens"CookieAccess_Private);
    for (
int i MaxClients0; --i)
    {
        if (!
AreClientCookiesCached(i))
        {
            continue;
        }
        
        
OnClientCookiesCached(i);
    }
    
HookEvent("player_spawn"PlayerSpawn);
}

public 
void OnMapStart()
{  
    
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
    if(!
FileExists(ConfigLocation))
    {
        
KeyValues generatecfgfile = new KeyValues("tokenstore");
        
generatecfgfile.ExportToFile(ConfigLocation);
        
delete generatecfgfile;
    }
}

public 
void OnClientPutInServer(int client)
{
    
CheckPlayer(client);
}

public 
void OnClientDisconnect(int client)
{
    
char tokenstostore[24];
    
IntToString(UsedTokens[client], tokenstostoresizeof(tokenstostore));
    
SetClientCookie(clientUsedTokensCookietokenstostore);
}

public 
void OnClientCookiesCached(int client)
{
    
char tokens[24];
    
GetClientCookie(clientUsedTokensCookietokens12);
    
UsedTokens[client] = StringToInt(tokens);
}

public 
Action PlayerSpawn(Handle event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(
PlayerHasSkin[client])
    {
        
CreateTimer(1.75ChangeVipModelGetClientUserId(client));
    }
}
    
public 
Action ChangeVipModel(Handle timerint userid)
{
   
int client GetClientOfUserId(userid);
   if(
client == 0) return;
   
SetEntityModel(clientSkinModelPath[client]);
}

public 
Action TokenShop(int clientint args)
{
    
ShowShopInfo(clientargs);
    return 
Plugin_Continue;
}

public 
void ShowShopInfo(int clientint args)
{
    
int tokens = ((MostActive_GetPlayTimeTotalExceptSpec(client) / 3600) / 35) - UsedTokens[client];
    
int ingame MostActive_GetPlayTimeTotalExceptSpec(client) / 3600;
    
Menu menu = new Menu(InfoShop_Menu);

    
menu.SetTitle("[Server Name] You have: %i token(s). You have %i hours ingame."tokensingame);
    
menu.AddItem("yes""Buy something.");
    
menu.AddItem("no""I just wanted to check my tokens.");

    
menu.ExitButton false;
    
menu.Display(client10);
}

public 
void ShowShop(int client)
{
    
int tokens = ((MostActive_GetPlayTimeTotalExceptSpec(client) / 3600) / 35) - UsedTokens[client];
    
Menu menu = new Menu(CreditsShop_Menu);

    
menu.SetTitle("Server Name Minigames Tokens Shop [You have: %i token(s)]"tokens);
    
    
menu.AddItem("2500""2500 credits [1 token]");
    
menu.AddItem("6000""6000 credits [2 tokens]");
    
menu.AddItem("prefix""[Uber Player] prefix. [3 weeks | 2 tokens]");
    
menu.AddItem("14k""12000 credits [25% change | 2 tokens]");
    
menu.AddItem("skins""Special Skin [1 month | 4 tokens]");
    
menu.AddItem("gameraffle""Steam game raffle -> [ 0/10 | 7 tokens] ~Under Construction~"ITEMDRAW_DISABLED);
    
menu.AddItem("1vip""VIP access [1 month | 10 tokens]");

    
menu.ExitButton true;
    
menu.Display(client10);
}

public 
int CreditsShop_Menu(Menu menuMenuAction actionint iClientint param2)
{
    
int tokens = ((MostActive_GetPlayTimeTotalExceptSpec(iClient) / 3600) / 35) - UsedTokens[iClient];
    
char PlayerSteamID[64];
    
GetClientAuthId(iClientAuthId_Steam2PlayerSteamIDsizeof(PlayerSteamID));

    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
char info[32];
            
menu.GetItem(param2infosizeof(info));

            if (
StrEqual(info"2500"))
            {
                if(
tokens == 0)
                {
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You don't have enough tokens to buy this.");
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You have: {green}%i {orange}| {default}Required: {green}1 {default}"tokens);
                }
                else
                {
                    
UsedTokens[iClient] += 1;
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}1 {default}token for {green}2500 {default}credits.");
                    
Shop_GiveClientCredits(iClient2500);
                }
            }
            if (
StrEqual(info"6000"))
            {
                if(
tokens <= 1)
                {
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You don't have enough tokens to buy this.");
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You have: {green}%i {orange}| {default}Required: {green}7 {default}"tokens);
                }
                else
                {
                    
UsedTokens[iClient] += 2;
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}2 {default}tokens for {green}6000 {default}credits.");
                    
Shop_GiveClientCredits(iClient6000);
                }
            }
            if (
StrEqual(info"14k"))
            {
                if(
tokens <= 1)
                {
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You don't have enough tokens to buy this.");
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You have: {green}%i {orange}| {default}Required: {green}2 {default}"tokens);
                }
                else
                {
                    
UsedTokens[iClient] += 2;
                    switch (
GetRandomInt(14))
                    {
                        case 
1CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}2 {default}token a change of {green}6000 {default}credits and you {lightred}lost{default}.");
                        case 
2CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}2 {default}token a change of {green}6000 {default}credits and you {lightred}lost{default}.");
                        case 
3CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}2 {default}token a change of {green}6000 {default}credits and you {lightred}lost{default}.");
                        case 
4
                        {
                            
CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}2 {default}tokens a change of {green}12000 {default}credits and you {green}!!!WON!!!{default}.");
                            
Shop_GiveClientCredits(iClient12000);
                        }
                    }
                }
            }
            if (
StrEqual(info"1vip"))
            {
                if(
tokens <= 9)
                {
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You don't have enough tokens to buy this.");
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You have: {green}%i {orange}| {default}Required: {green}10 {default}"tokens);
                }
                else
                {
                    if(
VIP_IsClientVIP(iClient))
                    {
                        
CPrintToChat(iClient"[{lightred}Server Name{default}] You already have a VIP status.");
                    }
                    else
                    {
                        
UsedTokens[iClient] += 10;     
                        
CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}10 {default}tokens for {green}a month of VIP access{default}.");
                        
VIP_GiveClientVIP(0iClient2592000"PremiumVIP"true);
                    }
                }
            }
            if(
StrEqual(info"prefix"))
            {
                if(
tokens <= 1)
                {
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You don't have enough tokens to buy this.");
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You have: {green}%i {orange}| {default}Required: {green}2 {default}"tokens);
                }
                else
                {
                    
UsedTokens[iClient] += 2

                    
char stringedtimer[128];
                    
int whentoexpire GetTime() + 60*60*24*21
                    
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                    
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                    
KeyValues addextras = new KeyValues("tokenstore");
                    
addextras.JumpToKey(PlayerSteamIDtrue);
                    
addextras.SetString("prefix""1");
                    
addextras.SetString("prefix_expires"stringedtimer);
                    
addextras.Rewind();
                    
addextras.ExportToFile(ConfigLocation);
                    
delete addextras;

                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a special prefix{default}.");
                    
CheckPlayer(iClient);
                }

            }
            if(
StrEqual(info"skins"))
            {
                if(
tokens <= 3)
                {
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You don't have enough tokens to buy this.");
                    
CPrintToChat(iClient"[{lightred}Server Name{default}] You have: {green}%i {orange}| {default}Required: {green}4 {default}"tokens);
                }
                else
                {
                    
OpenSkinSelection(iClient);
                } 
            }
        }   

        case 
MenuAction_End:{delete menu;}
    }

    return 
0;
}

public 
int InfoShop_Menu(Menu menuMenuAction actionint clientint param2)
{
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
char info[32];
            
menu.GetItem(param2infosizeof(info));

            if (
StrEqual(info"yes"))
            {
                
ShowShop(client);
            }
        }

        case 
MenuAction_End:{delete menu;}
    }

    return 
0;
}

//*******************************************************//
//                   EXTRAS                             //
//*****************************************************//

public void HexTags_OnTagsUpdated(int iClient)
{
    if (
PlayerHasPrefix[iClient])
    {
        
HexTags_SetClientTag(iClientChatTag"[{purble}Uber Player{grey}]");
    }



public 
void OpenSkinSelection(int client)
{
    
Menu menu = new Menu(SelectVipSkin);

    
menu.SetTitle("Which special skin do you want?");
    
menu.AddItem("flash""The Flash [VIPs Only]");
    
menu.AddItem("flashcw""The Flash (CW) [VIPs Only]");
    
menu.AddItem("revflash""Reverse Flash [VIPs Only]");
    
menu.AddItem("kruger""Freddy Krueger [VIPs Only]");
    
menu.AddItem("letherface""Letherface [VIPs Only]");
    
menu.AddItem("jigsaw""Jigsaw [VIPs Only]");
    
menu.AddItem("goku""Goku [VIPs Only]");
    
menu.AddItem("trager""Dr. Trager [VIPs Only]");
    
menu.AddItem("kotor""Kotori Itsuka [VIPs Only]");

    
menu.ExitButton false;
    
menu.Display(client15);
}

public 
int SelectVipSkin(Menu menuMenuAction actionint clientint param2)
{
    
char PlayerSteamID[64];
    
GetClientAuthId(clientAuthId_Steam2PlayerSteamIDsizeof(PlayerSteamID));
    
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
char info[32];
            
menu.GetItem(param2infosizeof(info));

            if (
StrEqual(info"flash"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kodua/flash52/flash.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"flashcw"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kodua/flash52/flash_cw.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"revflash"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kodua/flash52/reverse_flash.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"kruger"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kuristaja/krueger/krueger.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"letherface"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kuristaja/leatherface/leatherface.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"jigsaw"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kuristaja/billy/billy_normal.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"goku"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kodua/goku/goku.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"trager"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/kuristaja/trager/tragerv2.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
            if (
StrEqual(info"kotor"))
            {
                
UsedTokens[client] += 4

                
char stringedtimer[128];
                
int whentoexpire GetTime() + 60*60*24*30
                
IntToString(whentoexpirestringedtimersizeof(stringedtimer));
                
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
                
KeyValues addextras = new KeyValues("tokenstore");
                
addextras.JumpToKey(PlayerSteamIDtrue);
                
addextras.SetString("skins""1");
                
addextras.SetString("skins_expires"stringedtimer);
                
addextras.SetString("skin_path""models/player/custom_player/monsterko/qinli/qinli.mdl");
                
addextras.Rewind();
                
addextras.ExportToFile(ConfigLocation);
                
delete addextras;

                
CPrintToChat(client"[{lightred}Server Name{default}] You successfully redeemed {green}4 {default}tokens for {green}a month with a special skin{default}.");
                
CheckPlayer(client);
            }
        }

        case 
MenuAction_End:{delete menu;}
    }

    return 
0;
}

void CheckPlayer(int client)
{
    
char PlayerSteamID[64];
    
GetClientAuthId(clientAuthId_Steam2PlayerSteamIDsizeof(PlayerSteamID));

    
PlayerHasPrefix[client] = false;
    
PlayerHasPaint[client] = false;
    
PlayerHasSkin[client] = false;

    
BuildPath(Path_SMConfigLocationsizeof(ConfigLocation), TokensConfig);
    
KeyValues checkplayer = new KeyValues("tokenstore");
    if (
KvJumpToKey(checkplayerPlayerSteamID))
    {
        
int currenttime GetTime();
        
char path[128];

        
//// Prefix /////
        
int prefixenabled KvGetNum(checkplayer"prefix");
        
int prefixstatus KvGetNum(checkplayer"prefix_expires");
        
        
//// Paint /////
        
int paintenabled KvGetNum(checkplayer"paint");
        
int paintmakerstatus KvGetNum(checkplayer"paint_expires");

        
//// Skin /////
        
int skinenabled KvGetNum(checkplayer"skins");
        
int skinstatus KvGetNum(checkplayer"skins_paintexpires");
        
KvGetString(checkplayer"skin_path"pathsizeof(path));

        if(
prefixenabled && currenttime prefixstatus)
        {
            
PlayerHasPrefix[client] = true;
        }
    
        if(
paintenabled && currenttime paintmakerstatus)
        {
            
PlayerHasPaint[client] = true;
        }
    
        if(
skinenabled && currenttime skinstatus)
        {
            
PlayerHasSkin[client] = true;
            
SkinModelPath[client] = path;
        }
    }
    
delete checkplayer;

However... It doesnt create the config on map start and I guess all the keyvalues in the plugins won't work, I don't know why.
__________________

Last edited by PinHeaDi; 04-10-2018 at 06:54.
PinHeaDi is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-10-2018 , 07:41   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #9

Do you have folder minigames? If not, saving KeyValues will not work. This function doesn't create missing folders.
Moreover, you did one crucial mistake:
Code:
                BuildPath(Path_SM, ConfigLocation, sizeof(ConfigLocation), TokensConfig);
                KeyValues addextras = new KeyValues("tokenstore");
                addextras.JumpToKey(PlayerSteamID, true);
                addextras.SetString("skins", "1");
                addextras.SetString("skins_expires", stringedtimer);
                addextras.SetString("skin_path", "models/player/custom_player/kodua/flash52/flash.mdl");
                addextras.Rewind();
                addextras.ExportToFile(ConfigLocation);
                delete addextras;
When you create keyvalues:
Code:
KeyValues addextras = new KeyValues("tokenstore");
you create empty keyvalues. So your addextras will be:
Code:
"tokenstore"
{
}
Then you add one key for one steamid. And you save this structure to file. So your "database" will always have only one last entry. To prevent this you should always ImportFromFile() first. This way you will add to existing keyvalues, not override them.
Reiko1231 is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-10-2018 , 07:49   Re: [CS:GO] Remove X key from KeyValue after X time(2 weeks, 1 month)
Reply With Quote #10

How did I forgot .ImportFromFile();... FFS, silly me, also didn't know that I can't create directories.
__________________
PinHeaDi 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 18:51.


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