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

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


Post New Thread Reply   
 
Thread Tools Display Modes
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 - 3104 views - 10.4 KB)
    File Type: smx auto_vip.smx (9.0 KB, 1090 views)
    __________________

    Last edited by SkySky; 01-29-2018 at 13:05.
    SkySky is offline
    nguyenbaodanh
    AlliedModders Donor
    Join Date: Jun 2007
    Location: HCMC, Vietnam
    Old 01-29-2018 , 03:48   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #2

    how about I want only 6hrs and only once in a month per steamid ??
    __________________
    nguyenbaodanh is offline
    SkySky
    New Member
    Join Date: Jan 2018
    Location: Slovakia
    Old 01-29-2018 , 09:37   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #3

    Quote:
    Originally Posted by nguyenbaodanh View Post
    how about I want only 6hrs and only once in a month per steamid ??
    In my plugin you can't give flags in hours.Minimal time is 1day.
    __________________
    SkySky is offline
    SkySky
    New Member
    Join Date: Jan 2018
    Location: Slovakia
    Old 01-29-2018 , 13:06   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #4

    UPDATE 0.2:
    SetAdminFlag changed to AddUserFlags !
    __________________
    SkySky is offline
    InS4ne
    AlliedModders Donor
    Join Date: Jan 2018
    Location: TheMiddleOfNowhere
    Old 01-29-2018 , 13:41   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #5

    does the VIP's also safe the STEAM_ID afther they had it? so they can not do the !testvip twice?
    InS4ne is offline
    SkySky
    New Member
    Join Date: Jan 2018
    Location: Slovakia
    Old 01-29-2018 , 14:18   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #6

    Quote:
    Originally Posted by InS4ne View Post
    does the VIP's also safe the STEAM_ID afther they had it? so they can not do the !testvip twice?
    Player what first time used !testvip he won't able use this command second time.
    __________________
    SkySky is offline
    szogun
    Senior Member
    Join Date: Apr 2016
    Old 02-16-2018 , 11:28   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #7

    L 02/16/2018 - 17:268: [auto_vip.smx] Save error: Duplicate entry 'STEAM_1:1:106536404key-STEAM_1:1:106536404' for key 'keyid'
    L 02/16/2018 - 17:268: [auto_vip.smx] Save error: Duplicate entry 'STEAM_1:0:135412590key-STEAM_1:0:135412590' for key 'keyid'
    szogun is offline
    Enki_hardwar
    Junior Member
    Join Date: Jul 2017
    Old 02-20-2018 , 09:04   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #8

    Why does it sometimes work and sometimes not?
    Enki_hardwar is offline
    roosteridk
    Junior Member
    Join Date: Feb 2018
    Old 02-22-2018 , 17:34   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #9

    Hello. I really liked the plugin but can you change it to do an admin group instead of just a flag?
    roosteridk is offline
    paulo_crash
    AlliedModders Donor
    Join Date: May 2016
    Location: Brazil
    Old 04-24-2018 , 16:04   Re: [CS:GO] AUTOMATIC VIP (flags) - !testvip
    Reply With Quote #10

    Quote:
    Originally Posted by nguyenbaodanh View Post
    how about I want only 6hrs and only once in a month per steamid ??
    It would be interesting idea, but instead of hours, days even and every 6 months, or how much we want to set up.
    paulo_crash 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 15:54.


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