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

[CS:GO] AUTOMATIC VIP (flags) - !testvip


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author
SkySky
New Member
Join Date: Jan 2018
Location: Slovakia
Plugin ID:
6005
Plugin Version:
0.1
Plugin Category:
All
Plugin Game:
Counter-Strike: GO
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Plugin automatic givie flags for user and automatic delete flags for user.
    Old 01-28-2018 , 15:50   [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #1

    AUTOMATIC VIP (flags) - !testvip 0.2

    My FIRST PLUGIN.I created this plugin because long time i searched plugin which will automatic delete "vip".In the next updates i want add support with web (add flags for users to time ...).


    cvars:
    sm_testvip_flags = CreateConVar("sm_testvip_flags", "ar", "What flags get user ?");
    sm_testvip_days = CreateConVar("sm_testvip_days", "10", "How long time(days) user get flags");

    You must add to csgo/addons/sourcemod/configs/databases.cfg
    Quote:
    "autovip"
    {
    "driver" "mysql"
    "host" " "
    "database" " "
    "user" " "
    "pass" " "
    }
    IN MYSQL DATABASE :


    CHANGELOG:

    UPDATE 0.2:
    SetAdminFlag changed to AddUserFlags !

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

    #define FLAG_LETTERS_SIZE 26

    #define MAX_PLAYERS 32 


    new AdminFlag:g_FlagLetters[FLAG_LETTERS_SIZE];
    Handle sql;                                                                    
    new 
    Handle:sm_testvip_flags INVALID_HANDLE;
    new 
    Handle:sm_testvip_days INVALID_HANDLE;
    char dbError[512];    


    public 
    Plugin:myinfo 
    {
        
    name "VIP mysql",
        
    author "Sky",
        
    description "VIP automatic",
        
    version "0.2",
        
    //url = "<- URL ->"
    }

    public 
    OnPluginStart()
    {
        
    CreateConVar("auto_vip""0.2""AUTO-DELETE FLAGS FOR TIME"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
        
    HookEvent("player_spawn"PlayerSpawn);
        
    g_FlagLetters CreateFlagLetters();
        
    sm_testvip_flags CreateConVar("sm_testvip_flags""ar""What flags get user ?");
        
    sm_testvip_days CreateConVar("sm_testvip_days""10""How long time(days) user get flags");
        
    RegConsoleCmd("sm_testvip"testvip);
        
    DataBaseConnect();
    }



    public 
    Action:PlayerSpawn(Handle:event_spawnString:name[], bool:dontBroadcast)
    {
        new 
    client GetClientOfUserId(GetEventInt(event_spawn"userid"));
        if(!
    IsValidClient(client) || IsFakeClient(client))
            return;
        
        
        
        
    WriteToDatabase(client);
        
    GiveFlagBySteamid(client);
        
    UpdateTimeDatabase(client);
        
    GetDateBySteamid(client);// Every spawn Update/Delete flag,date to user
        
        
        
    }


    public 
    Action:GiveFlagBySteamid(client)
    {
        
        new 
    String:tmp[1024];
        
    decl String:player_authid[32];
        
        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
        {
            
    Format(tmpsizeof(tmp), "SELECT `flags` FROM `autovip` WHERE steamid = '%s';"player_authid);
            
    SQL_TQuery(sqlGiveFlagBySteamidContinuetmpclient);
        }
        
        
    }                

    public 
    GiveFlagBySteamidContinue(Handle:ownerHandle:query, const String:error[], any:client)
    {
        
    decl String:player_authid[32];
        
        if(
    query == INVALID_HANDLE)
        {
            
    LogError("Load error: %s"error);
            return;
        }
        
        
        if(
    SQL_GetRowCount(query))
        {
            new 
    String:flags[64];
            
            
            while(
    SQL_MoreRows(query))
            { 
                
                while(
    SQL_FetchRow(query))
                {
                    
    flags[client] = SQL_FetchString(query0flagssizeof(flags));
                    
                    
                    
    SQL_FetchString(query0flagssizeof(flags));
                    
                    
                    if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
                    {
                        
                        for (new 
    0strlen(flags); ++i)
                        {
                            if (
    flags[i] < 'a' || flags[i] > 'z')
                                continue;
                            
                            if (
    g_FlagLetters[flags[i]-'a'] < Admin_Reservation)
                                continue;
                            
                            
                            
                            
    /*new AdminId:admin;
                            admin = AdminId:FindAdminByIdentity(dupkey, player_authid);
                            SetAdminFlag(AdminId:admin, g_FlagLetters[flags[i]-'a'], true);*/
                            
                            
    AddUserFlags(clientg_FlagLetters[flags[i]-'a'])
                            
                        }
                        
                    }    
                }
            }
        }
        
        
    }


    public 
    Action:GetDateBySteamid(client)
    {
        
        new 
    String:tmp[1024];
        
    decl String:player_authid[32];
        
        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
        {
            
    Format(tmpsizeof(tmp), "SELECT UNIX_TIMESTAMP(`date`), UNIX_TIMESTAMP(`expirationdate`) FROM `autovip` WHERE steamid = '%s';"player_authid);
            
    SQL_TQuery(sqlGetDateBySteamidContinuetmpclient);
        }
        
        
    }    


    public 
    Action:testvip(clientargs)
    {
        
        
        new 
    String:tmp[1024];
        
    decl String:player_authid[32];
        
        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
        {
            
    Format(tmpsizeof(tmp), "SELECT `verify` FROM `autovip` WHERE steamid = '%s';"player_authid);
            
    SQL_TQuery(sqltestvipcointinuetmpclient);
        }
        
    }


    public 
    testvipcointinue(Handle:ownerHandle:query, const String:error[], any:client)
    {
        
    decl String:player_authid[32];
        new 
    String:tmp[1024];
        
    int daymonthyearenddayendmonth,endyear
        
    new String:sday[10]; 
        new 
    String:smonth[10]; 
        new 
    String:syear[10]; 
        new 
    Handle:testvip_flagstag FindConVar("sm_testvip_flags"); 
        new 
    String:testvip_flags[32];
        new 
    dayinmonth[13] = {0312830313031303130313031};
        
        
    FormatTime(sdaysizeof(sday), "%d"); // Obtain day 
        
    FormatTime(smonthsizeof(smonth), "%m"); // Obtain month 
        
    FormatTime(syearsizeof(syear), "%Y"); // Obtain year 
        
        
    day StringToInt(sday); 
        
    month StringToInt(smonth); 
        
    year StringToInt(syear); 
        
        
        
        new 
    testvip_days GetConVarInt(sm_testvip_days);
        
    GetConVarString(testvip_flagstagtestvip_flagssizeof(testvip_flags));
        
        
        
    endday day testvip_days;
        
    endmonth month;
        
    endyear year;
        
        if (
    endday dayinmonth[month]) 
        {
            
    endday endday dayinmonth[month];
            
    endmonth endmonth 1;
        }
        
        if (
    endmonth == 13
        {
            
    endyear endyear 1;
            
    endmonth 1;
        }
        
        if(
    query == INVALID_HANDLE)
        {
            
    LogError("Load error: %s"error);
            return;
        }
        if(
    SQL_GetRowCount(query))
        {
            new 
    String:verify[512];
            
    int verifyint;
            
            while(
    SQL_MoreRows(query))
            {
                
                while(
    SQL_FetchRow(query))
                {
                    
                    
    SQL_FetchString(query0verifysizeof(verify));
                    
                    
    verifyint StringToInt(verify);
                    
                    
                    if (
    verifyint == 0
                    {
                        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
                        {
                            
                            
    PrintToChat(client"\x01[\x04VIP\x01] You activated \x04VIP\x01");
                            
    Format(tmpsizeof(tmp), "UPDATE `autovip` SET flags = '%s' ,verify = '1', expirationdate = '%i-%i-%i' WHERE steamid = '%s';"testvip_flags,endyear,endmonth,endday,player_authid);
                            
    SQL_TQuery(sqlWriteToDatabase_Handlertmpclient);
                            
                        }
                    }
                    else
                    {
                        
    PrintToChat(client"\x01[\x04VIP\x01] You can't activate again \x04VIP\x01");
                    }
                }
            }
        }
        
        
    }


    public 
    GetDateBySteamidContinue(Handle:ownerHandle:query, const String:error[], any:client)
    {
        
    decl String:player_authid[32];
        new 
    String:tmp[1024];
        
        if(
    query == INVALID_HANDLE)
        {
            
    LogError("Load error: %s"error);
            return;
        }
        if(
    SQL_GetRowCount(query))
        {
            new 
    String:date[512];
            new 
    String:expirationdate[512];
            
    int dateint,expirationdateint;
            
            while(
    SQL_MoreRows(query))
            {
                
                while(
    SQL_FetchRow(query))
                {
                    
                    
                    
    SQL_FetchString(query0datesizeof(date));
                    
    SQL_FetchString(query1expirationdatesizeof(expirationdate));
                    
                    
    dateint StringToInt(date);
                    
    expirationdateint StringToInt(expirationdate);
                    
    dateint = ((expirationdateint dateint)/60/60/24);
                    
                    if (
    dateint >= 1)
                    {
                        
    PrintToChat(client"\x01[\x04VIP\x01] Your VIP will expire in \x04%i day(s)\x01",dateint);
                        
                        
                        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
                        {
                            
                            
    Format(tmpsizeof(tmp), "UPDATE `autovip` SET howmanydays = '%i' WHERE steamid = '%s';"dateint,player_authid);
                            
    SQL_TQuery(sqlWriteToDatabase_Handlertmpclient);
                            
                        }
                    } else if (
    dateint <= 0)
                    {
                        
    Format(tmpsizeof(tmp), "UPDATE `autovip` SET flags = ' ', howmanydays = '0' WHERE steamid = '%s';"player_authid);
                        
    SQL_TQuery(sqlWriteToDatabase_Handlertmpclient);
                    }
                }
            }
        }
        
        
    }


    public 
    Action:DataBaseConnect()
    {
        
    sql SQL_Connect("autovip"truedbErrorsizeof(dbError));
        if(
    sql == INVALID_HANDLE)
            
    PrintToServer("Could not connect: %s"dbError);
        
    SQL_LockDatabase(sql);
        
    SQL_FastQuery(sql"CREATE TABLE IF NOT EXISTS `autovip` (`id` INT(11) NOT NULL AUTO_INCREMENT, `steamid` VARCHAR(48) NOT NULL, `flags` VARCHAR(48) NOT NULL, `dupkey` VARCHAR(48), `date` VARCHAR(15), `expirationdate` VARCHAR(15), `howmanydays` INT(11), `verify` INT(4) DEFAULT 0  NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `keyid` (`dupkey`,`steamid`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
        
    SQL_UnlockDatabase(sql);
        
    }


    public 
    Action:WriteToDatabase(client)
    {
        
        new 
    String:tmp[1024];
        
    decl String:player_authid[32];
        
        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
        {
            
            
    Format(tmpsizeof(tmp), "INSERT INTO `autovip` (`steamid`,`dupkey`) VALUES ('%s','%skey');"player_authid,player_authid);
            
    SQL_TQuery(sqlWriteToDatabase_Handlertmpclient);
            
        }
    }

    public 
    Action:UpdateTimeDatabase(client)
    {
        
    int daymonthyear
        
    new String:sday[10]; 
        new 
    String:smonth[10]; 
        new 
    String:syear[10]; 
        
        
    FormatTime(sdaysizeof(sday), "%d"); // Obtain day 
        
    FormatTime(smonthsizeof(smonth), "%m"); // Obtain month 
        
    FormatTime(syearsizeof(syear), "%Y"); // Obtain year 
        
        
    day StringToInt(sday); 
        
    month StringToInt(smonth); 
        
    year StringToInt(syear); 
        
        new 
    String:tmp[1024];
        
    decl String:player_authid[32];
        
        if (
    GetClientAuthString(clientplayer_authidsizeof(player_authid)))
        {
            
            
    Format(tmpsizeof(tmp), "UPDATE `autovip` SET date = '%i-%i-%i' WHERE steamid = '%s';"year,month,day,player_authid);
            
    SQL_TQuery(sqlWriteToDatabase_Handler3tmpclient);
            
        }
        
    }


    public 
    WriteToDatabase_Handler(Handle:ownerHandle:query, const String:error[], any:client)
    {
        if(
    query == INVALID_HANDLE)
        {
            
    LogError("Save error: %s"error);
            return;
        }
    }

    public 
    WriteToDatabase_Handler2(Handle:ownerHandle:query, const String:error[], any:client)
    {
        if(
    query == INVALID_HANDLE)
        {
            
    LogError("Save error: %s"error);
            return;
        }
    }

    public 
    WriteToDatabase_Handler3(Handle:ownerHandle:query, const String:error[], any:client)
    {
        if(
    query == INVALID_HANDLE)
        {
            
    LogError("Save error: %s"error);
            return;
        }
    }



    public 
    bool:IsValidClient(client)
    {
        if(
    client >= && client <= MaxClients && IsClientInGame(client))
            return 
    true;
        
        return 
    false;
    }


    stock AdminFlag:CreateFlagLetters()
    {
        new 
    AdminFlag:FlagLetters[FLAG_LETTERS_SIZE];
        
        
    FlagLetters['a'-'a'] = Admin_Reservation;
        
    FlagLetters['b'-'a'] = Admin_Generic;
        
    FlagLetters['c'-'a'] = Admin_Kick;
        
    FlagLetters['d'-'a'] = Admin_Ban;
        
    FlagLetters['e'-'a'] = Admin_Unban;
        
    FlagLetters['f'-'a'] = Admin_Slay;
        
    FlagLetters['g'-'a'] = Admin_Changemap;
        
    FlagLetters['h'-'a'] = Admin_Convars;
        
    FlagLetters['i'-'a'] = Admin_Config;
        
    FlagLetters['j'-'a'] = Admin_Chat;
        
    FlagLetters['k'-'a'] = Admin_Vote;
        
    FlagLetters['l'-'a'] = Admin_Password;
        
    FlagLetters['m'-'a'] = Admin_RCON;
        
    FlagLetters['n'-'a'] = Admin_Cheats;
        
    FlagLetters['o'-'a'] = Admin_Custom1;
        
    FlagLetters['p'-'a'] = Admin_Custom2;
        
    FlagLetters['q'-'a'] = Admin_Custom3;
        
    FlagLetters['r'-'a'] = Admin_Custom4;
        
    FlagLetters['s'-'a'] = Admin_Custom5;
        
    FlagLetters['t'-'a'] = Admin_Custom6;
        
    FlagLetters['z'-'a'] = Admin_Root;
        
        return 
    FlagLetters;

    Attached Files
    File Type: sp Get Plugin or Get Source (auto_vip.sp - 3110 views - 10.4 KB)
    File Type: smx auto_vip.smx (9.0 KB, 1092 views)
    __________________

    Last edited by SkySky; 01-29-2018 at 13:05.
    SkySky is offline
     



    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 13:51.


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