Skocz do zawartości

Nowy szablon forum

mygo.pl

Stworzyliśmy dla Was nowy wygląd forum. Z pewnością znajdziesz rzeczy, które wg Ciebie mogą zostać zmienione - wspomnij o tym w specjalnym wątku.

Czytaj więcej

Jak założyć własną sieć

serwerów CS

Zastanawiasz się nad prowadzeniem własnej sieci serwerów? Przeczytaj podstawowe informacje, na które należy zwrócić uwagę, przy takim projekcie.

Czytaj więcej

Tworzymy spis sieci

dodaj swoją

Dodaj sieć do której należysz, pozwoli to na promocję i budowę ogólnopolskiej bazy sieci CS.

Czytaj więcej

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


MYGO.pl
 Udostępnij

Rekomendowane odpowiedzi

  • RSSy
AUTOMATIC VIP (flags) - !testvip 0.1

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 :
68747470733a2f2f692e696d6775722e636f6d2f


PHP Code:

#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <cstrike>

#define FLAG_LETTERS_SIZE 26

#define MAX_PLAYERS 32 // maksymalna ilosc graczy na serwerze


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.1",
    
//url = "<- URL ->"
}

public 
OnPluginStart()
{
    
CreateConVar("auto_vip""0.1""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[512];
        
        
        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("steam"player_authid); 
                        
SetAdminFlag(AdminId:adming_FlagLetters[flags[i]-'a'], true);
                        
                    }
                    
                }    
            }
        }
    }
    
    
}



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: smx auto_vip.smx (9.1 KB)
File Type: sp Get Plugin or Get Source (auto_vip.sp - 10.3 KB)

Wyświetl pełny artykuł

Odnośnik do komentarza
Udostępnij na innych stronach

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...