Raised This Month: $51 Target: $400
 12% 

[CSGO/ANY?] Zephyrus Store Daily Credits [1.0] [25 Aug 20]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Plugin ID:
7269
Plugin Version:
1.0
Plugin Category:
All
Plugin Game:
Counter-Strike: GO
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Old 08-25-2020 , 09:18   [CSGO/ANY?] Zephyrus Store Daily Credits [1.0] [25 Aug 20]
    Reply With Quote #1

    Description: Players are able to collect 50 Credits every 24 hours through !daily Command

    Requirements: MySql Database

    Instalation:
    Put store_daily.smx in addons/sourcemod/plugins/ folder
    Add "skins_shop" configuration in addons/sourcemod/configs/database.cfg file

    This Plugin Is fully tested and working in CS:GO

    Sourcecode:
    PHP Code:
    #pragma semicolon 1

    #include <sourcemod>
    #include <sdktools>
    #include <store>

    #pragma newdecls required

    public Plugin myinfo 
    {
        
    name "[Store] Daily Credits",
        
    author "kRatoss"
    };

    Handle g_hDataBase;

    public 
    void OnPluginStart()
    {
        
    SQL_TConnect(OnDBConnected"skins_shop");
        
    RegConsoleCmd("sm_daily"Command_Daily);
    }

    public 
    Action Command_Daily(int Clientint Args)
    {
        if(
    IsValidClient(Client) && g_hDataBase != INVALID_HANDLE)
        {
            
    char Steam[32], Buffer[128];
            if(
    GetClientAuthId(ClientAuthId_SteamID64Steamsizeof(Steam)))
            {
                
    Format(Buffersizeof(Buffer), "SELECT reward_time FROM skins_daily WHERE steamid = '%s';"Steam);
                
    SQL_TQuery(g_hDataBaseSQLT_LoadDailyBufferClient);
            }
        }
    }

    public 
    void SQLT_LoadDaily(Handle DataBaseHandle Results, const char[] sErrorany Client)
    {
        if(
    strlen(sError))
        {
            
    LogError("Error: %s"sError);
            return;
        }
            
        if(
    DataBase == INVALID_HANDLE)
        {
            
    SetFailState("Databases Error( %s )"sError);
            return;
        }
        
        if(
    IsValidClient(Client))
        {
            
    SQL_FetchRow(Results);
            if(
    SQL_GetRowCount(Results) == 0)
            {
                
    char Steam[32], Buffer[128];
                
    GetClientAuthId(ClientAuthId_SteamID64Steamsizeof(Steam));
                
                
    Format(Buffersizeof(Buffer), "\
                INSERT INTO skins_daily \
                    (steamid, reward_time) \
                VALUES \
                    ('%s', '%i'); "
    SteamGetTime() + 86400);
                
    kQuery(g_hDataBaseBuffer"SQLT_LoadDaily");
            }
            else
            {
                
    Menu Daily = new Menu(DailyMenuHandler);
                
    char Title[128], Time[32];
                
    int Hours 0Minutes 0Seconds SQL_FetchInt(Results0); 
                
                if (
    GetTime() > Seconds)
                {
                    
    PrintToChat(Client"test");
                        
                    
    Format(Titlesizeof(Title), "\
                    Daily Bonus\n\
                    --------------------------- \n\
                    You can colect your bonus now \n\
                    ---------------------------\n"
    );
                    
    Daily.AddItem("1""Get 50 Credits"ITEMDRAW_DEFAULT);
                }
                else
                {
                    
    Seconds Seconds GetTime();
                    while(
    Seconds 3600)
                    {
                        
    Hours++;
                        
    Seconds -= 3600;
                    }
                    while(
    Seconds 60)
                    {
                        
    Minutes++;
                        
    Seconds -= 60;
                    }
                    
                    if(
    Hours >= 1)
                        
    Format(Timesizeof(Time), "%d Hrs %d Mins %d Secs"HoursMinutesSeconds );
                    else if(
    Minutes >= 1)
                        
    Format(Timesizeof(Time), "%d Mins %d Secs"MinutesSeconds );
                    else
                        
    Format(Timesizeof(Time), "%d Secs"Seconds );
                    
                    
    PrintToChat(Client"test 2");
                    
    Format(Titlesizeof(Title), "\
                    Daily Bonus\n\
                    --------------------------- \n\
                    You will be able to collect in %s\n\
                    ---------------------------\n"
    Time);        
                    
    Daily.AddItem("1""Get 50 Credits"ITEMDRAW_DISABLED);
                }
                
    Daily.SetTitle(Title);
                
    Daily.Display(ClientMENU_TIME_FOREVER);
            }
        }
    }

    public 
    int DailyMenuHandler(Handle hMenuMenuAction pActionint Clientint Selection)
    {
        if (
    pAction == MenuAction_Select)
        {
            if(
    g_hDataBase != INVALID_HANDLE)
            {
                
    char Steam[32], sQuery[128];
                if(
    GetClientAuthId(ClientAuthId_SteamID64Steamsizeof(Steam)))
                {
                    
    PrintToChat(Client"[\x04SHOP\x01] You've Collected\x04 50\x01 Credits!");
                    
    Format(sQuerysizeof(sQuery), "UPDATE skins_daily SET reward_time = '%i' WHERE steamid = '%s';"GetTime() + 86400Steam);
                    
    kQuery(g_hDataBasesQuery"DailyMenuHandler");
                    
    //SS_SetTokens(Client, SS_GetTokens(Client) + 50);
                    
    Store_SetClientCredits(ClientStore_GetClientCredits(Client) + 50);
                }
            }
        }
    }

    public 
    int OnDBConnected(Handle hOwnerHandle hHandlechar [] sErrorany Data)
    {
        if(
    hHandle == INVALID_HANDLE)
        {
            
    SetFailState("Databases does not work. Error: %s"sError);
        }
        else
        {
            
    g_hDataBase hHandle;
            
    kQuery(g_hDataBase"\
            CREATE TABLE IF NOT EXISTS `skins_daily` (`steamid` varchar(32) PRIMARY KEY NOT NULL, `reward_time` int(16) NOT NULL); "
    "OnDBConnected(1)");
        }
    }

    stock void kQuery(Handle pDatabasechar[] szQuery, const char[] sFunction)
    {
        if (!
    SQL_FastQuery(pDatabaseszQuery))
        {
            
    char szError[255];
            
    SQL_GetError(pDatabaseszErrorsizeof(szError));
            
    //SetFailState("MySQL Error @%s : %s", sFunction, szError);
            
    LogError("MySQL Error @%s : %s"sFunctionszError);
        }
    }

    stock bool IsValidClient(int client)

        if (
    client <= || client MaxClients || !IsClientConnected(client) || client 0)
        {
            return 
    false
        }
        return 
    IsClientInGame(client); 

    Attached Files
    File Type: sp Get Plugin or Get Source (store_daily.sp - 254 views - 4.3 KB)
    File Type: smx store_daily.smx (6.7 KB, 186 views)
    __________________

    Last edited by kratoss1812; 08-26-2020 at 08:35.
    kratoss1812 is offline
    Nanochip
    Senior Member
    Join Date: Jan 2014
    Old 08-25-2020 , 19:09   Re: [CSGO/ANY?] Zephyrus Store Daily Credits [1.0] [25 Aug 20]
    Reply With Quote #2

    Please also upload a compiled version since it has a custom include & won't compile through the forum.
    __________________
    Nanochip is offline
    Reply



    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 14:55.


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