[Cerere Plugin] vip

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
BoGdAnMoNs
Membru, skill +1
Membru, skill +1
Posts: 104
Joined: 30 Mar 2021, 23:14
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 4 times
Been thanked: 1 time

26 Jan 2023, 19:15

Plugin Cerut: vip , vip test , vip event cu tag VIP in si in chat si in tab score
Descriere (adica ce face el mai exact): meniu arme gold si normale m4 - ac47 ,depinde ce grad ii pui acum am btix flag-urile si de exemplu bti sa fie pentru silver si btix sa fie pentru gold , comanda de vip test pentru 24 de ore , sa activeze /viptest o singura data pe luna si sa nu se incurce cu steam bonus , sa nu apara doua meni-uri daca ai vip sa nu apara cel de la steam bonus , iar daca esti jucator normal cu steam sa apara meniul de la steam bonus , si dupa o anumita ora sa inceapa vip event pana a doua zi , de exemplu de la 22 seara pana la 8 dimineata
Ai cautat pluginul?(daca da, precizeaza cum): am cautat am gasit altele dar nu face ce vreau eu
Serverul impune conditii strict HLDS/REHLDS?: rehlds
Necesita mod special?: nu
Versiune AMXX Server: 1.9.0
RoyalServer 2
eVolyno
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 11 Feb 2023, 14:34
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0

12 Feb 2023, 13:19

Cu vipul test cred ca te pot ajuta eu...

vip_test.sma

Code: Select all

#include <amxmodx>
#include <reapi>
#include <gm_time>
#include <nvault_array>

#define GetCvarDesc(%0) fmt("%L", LANG_SERVER, %0)

enum _:PCVAR
{
    TIME,
    TIMEOUT,
    REMOVE,
    FLAGS[26],
    IGN_FLAGS[64]
}
new g_pCvar[PCVAR];

enum ePlayerInfo
{
    AuthId[MAX_AUTHID_LENGTH],
    sTime,
    Set
}
new g_PlayerInfo[MAX_PLAYERS + 1][ePlayerInfo];

new g_hVault = INVALID_HANDLE;
new const VAULT_FILE[] = "gm_viptest_data";

public plugin_init()
{
    register_plugin("[GM] VIP Test","1.2.0","[GM] NWC");

    register_dictionary("gm_vip_test.txt");
    register_dictionary("gm_time.txt");

    register_clcmd("say /viptest","VipTest");
    register_clcmd("say_team /viptest","VipTest");

    CreateCvars();

    AutoExecConfig(true, "viptest", "gm_plugins");

    RegisterHookChain(RG_RoundEnd, "RG_RoundEnd_Pre", false);
}

public plugin_cfg()
{
	if((g_hVault = nvault_open(VAULT_FILE)) == INVALID_HANDLE)
    {
		set_fail_state("[GM VIPTEST] ERROR: Opening nVault failed!");
    }
}

public plugin_end() 
{
	if(g_hVault != INVALID_HANDLE)
    {
		nvault_close(g_hVault);
    }
}

public client_putinserver(id)
{
    g_PlayerInfo[id][AuthId][0] = 0;

    if(is_user_bot(id) || is_user_hltv(id))
    {
        return;
    }

    get_user_authid(id, g_PlayerInfo[id][AuthId], MAX_AUTHID_LENGTH - 1);

    if(nvault_get_array(g_hVault, g_PlayerInfo[id][AuthId], g_PlayerInfo[id], ePlayerInfo) > 0)
    {
        if(g_PlayerInfo[id][Set] == 1 && (g_PlayerInfo[id][sTime] + g_pCvar[TIME] * 60) > get_systime())
        {
            if(!is_access(id))
            {
                set_user_flags(id, read_flags(g_pCvar[FLAGS]));
                
                if(g_pCvar[REMOVE])
                {
                    remove_user_flags(id, ADMIN_USER);
                }
            }
        }
        else
        if(g_PlayerInfo[id][Set] == 1 && (g_PlayerInfo[id][sTime] + g_pCvar[TIME] * 60) < get_systime())
        {
            g_PlayerInfo[id][Set] = 0;
        }
    }
}

public VipTest(id)
{
    if(get_user_flags(id) & read_flags(g_pCvar[FLAGS]) || is_access(id))
    {
        client_print_color(id, print_team_red, "%L %L", -1, "VIPTEST_PREFIX", -1, "VIPTEST_YOU_VIP");
    }
    else 
    if(g_PlayerInfo[id][Set] == 0 && (g_PlayerInfo[id][sTime] + g_pCvar[TIMEOUT] * 86400) > get_systime())
    {
        new cTimeLength[128], iSecondsLeft = g_PlayerInfo[id][sTime] + g_pCvar[TIMEOUT]* 86400 - get_systime();

        get_str_time(id, iSecondsLeft, cTimeLength, charsmax(cTimeLength));

        client_print_color(id, print_team_red, "%L %L", -1, "VIPTEST_PREFIX", -1, "VIPTEST_TIMEOUT_VIP", cTimeLength);
    }
    else
    if(g_PlayerInfo[id][Set] == 0 && (g_PlayerInfo[id][sTime] + g_pCvar[TIMEOUT] * 86400) < get_systime())
    {
        g_PlayerInfo[id][Set] = 1;
        g_PlayerInfo[id][sTime] = get_systime();

        set_user_flags(id, read_flags(g_pCvar[FLAGS]));

        if(g_pCvar[REMOVE])
        {
            remove_user_flags(id, ADMIN_USER);
        }

        SaveUserInfo(id);

        new cTimeLength[128], iSecondsLeft = g_pCvar[TIME] * 60;

        get_str_time(id, iSecondsLeft, cTimeLength, charsmax(cTimeLength));

        client_print_color(id, print_team_blue, "%L %L", -1, "VIPTEST_PREFIX", -1, "VIPTEST_YOU_GIVE_VIP", cTimeLength);
    }

    return PLUGIN_HANDLED;
}

public RG_RoundEnd_Pre(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
    for(new id=1; id <= MaxClients; id++)
    {
        if((g_PlayerInfo[id][sTime] + g_pCvar[TIME] * 60) < get_systime() && g_PlayerInfo[id][Set] == 1)
        {
            g_PlayerInfo[id][Set] = 0;
            remove_user_flags(id, read_flags(g_pCvar[FLAGS]));

            if(g_pCvar[REMOVE])
            {
                set_user_flags(id, ADMIN_USER);
            }

            SaveUserInfo(id);

            new cTimeLength[128], iSecondsLeft = g_pCvar[TIMEOUT] * 86400;

            get_str_time(id, iSecondsLeft, cTimeLength, charsmax(cTimeLength));

            client_print_color(id, print_team_red, "%L %L", -1, "VIPTEST_PREFIX", -1, "VIPTEST_END", cTimeLength);
        }
    }
}

public client_disconnected(id)
{
    SaveUserInfo(id);
}

CreateCvars()
{
    bind_pcvar_num(create_cvar("viptest_time", "60", 
        .description = GetCvarDesc("VIPTEST_CVAR_TIME"), 
        .has_min = true, .min_val = 0.0),
        g_pCvar[TIME]
    );

    bind_pcvar_num(create_cvar("viptest_timeout", "30",
        .description = GetCvarDesc("VIPTEST_CVAR_TIMEOUT"),
        .has_min = true, .min_val = 1.0),
        g_pCvar[TIMEOUT]
    );

    bind_pcvar_num(create_cvar("viptest_remove_flag_z", "0",
        .description = GetCvarDesc("VIPTEST_CVAR_REMOVE"),
        .has_min = true, .min_val = 0.0,
        .has_max = true, .max_val = 1.0),
        g_pCvar[REMOVE]
    );

    bind_pcvar_string(create_cvar("viptest_flags", "t",
        .flags = FCVAR_NOEXTRAWHITEPACE, 
        .description = GetCvarDesc("VIPTEST_CVAR_FLAGS")), 
        g_pCvar[FLAGS], charsmax(g_pCvar[FLAGS])
    );
    
    bind_pcvar_string(create_cvar("viptest_ignor_flags", "t",
        .flags = FCVAR_NOEXTRAWHITEPACE, 
        .description = GetCvarDesc("VIPTEST_CVAR_IGN_FLAGS")), 
        g_pCvar[IGN_FLAGS], charsmax(g_pCvar[IGN_FLAGS])
    );
}

stock SaveUserInfo(const id)
{
	if(!is_user_bot(id) && !is_user_hltv(id))
    {
        nvault_set_array(g_hVault, g_PlayerInfo[id][AuthId], g_PlayerInfo[id], ePlayerInfo);
	}
}

stock is_access(const iPlayer)  // If you know a better function, then write)
{
    if(equal(g_pCvar[IGN_FLAGS], "")) return false;

    new flag[2], iFlags = get_user_flags(iPlayer);

    if(contain(g_pCvar[IGN_FLAGS], ":") != -1)
    {
        for(new i, y, str_len = strlen(g_pCvar[IGN_FLAGS]); i <= str_len; i++)
        {   
            copy(flag, 1, g_pCvar[IGN_FLAGS][i]);

            if(!equal(flag, ":") && !equal(flag, ""))
            {
                ++y;
            }

            if(equal(flag, ":") || equal(flag, "")) 
            {
                if(!y) continue;

                for(new x = i - y; x < i; x++)
                {
                    copy(flag, 1, g_pCvar[IGN_FLAGS][x]);
                    if(!(iFlags & read_flags(flag))) break;
                    if(x + 1 == i) return true;
                }

                y = 0;

                continue;
            }
            
            continue;
        }

        return false;
    }

    for(new i, str_len = strlen(g_pCvar[IGN_FLAGS]); i < str_len ; i++)
    {   
        copy(flag, 1, g_pCvar[IGN_FLAGS][i]);
        if(!(iFlags & read_flags(flag))) return false;
        if(i + 1 == str_len) return true;
    }

    return false;
}
gm_time.inc

Code: Select all

#if defined _gm_time_included
  #endinput
#endif
#define _gm_time_included

/**
 * Stock by [GM] NWC.
 *
 * @note You must add register_dictionary("gm_time.txt") in plugin_init()
 *
 * @param id    		The player whose language the length should be translated to
 * @param iSeconds		The number of time units you want translated into verbose text
 * @param output		The variable you want the verbose text to be placed in
 * @param outputLen		The length of the output variable
 *
 * @noreturn
 */

stock get_str_time(const id, iSeconds, output[], outputLen)
{
    new iLen, szText[128];

    new iDays = iSeconds / 86400;
    iSeconds -= iDays * 86400;
    new iHours = iSeconds / 3600;
    iSeconds -= iHours * 3600;
    new iMinutes = iSeconds / 60;
    iSeconds -= iMinutes * 60;

    if(iDays > 0)
    {
        if(iDays > 10 && ((iDays % 100) / 10) == 1)
        {
            iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_DAY_PLURAL", iDays);
        }
        else
        {
            switch(iDays % 10)
            {
                case 1: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_DAY_NOMINATIVE", iDays); }
                case 2, 3, 4: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_DAY_SINGULAR", iDays); }
                default: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_DAY_PLURAL", iDays); }
            }
        }
    }
    if(iHours > 0)
    {
        if(iHours > 10 && ((iHours % 100) / 10) == 1)
        {
            iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_HOUR_PLURAL", iHours);
        }
        else
        {
            switch(iHours % 10)
            {
                case 1: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_HOUR_NOMINATIVE", iHours); }
                case 2, 3, 4: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_HOUR_SINGULAR", iHours); }
                default: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_HOUR_PLURAL", iHours); }
            }
        }
    }
    if(iMinutes > 0)
    {
        if(iMinutes > 10 && ((iMinutes % 100) / 10) == 1)
        {
            iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_MINUTE_PLURAL", iMinutes);
        }
        else
        {
            switch(iMinutes % 10)
            {
                case 1: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_MINUTE_NOMINATIVE", iMinutes); }
                case 2, 3, 4: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_MINUTE_SINGULAR", iMinutes); }
                default: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_MINUTE_PLURAL", iMinutes); }
            }
        }
    }
    if(iSeconds > 0)
    {
        if(iSeconds > 10 && ((iSeconds % 100) / 10) == 1)
        {
            iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_SECOND_PLURAL", iSeconds);
        }
        else
        {
            switch(iSeconds % 10)
            {
                case 1: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_SECOND_NOMINATIVE", iSeconds); }
                case 2, 3, 4: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_SECOND_SINGULAR", iSeconds); }
                default: { iLen += formatex(szText[iLen], charsmax(szText) - iLen, "%L ", id, "GM_SECOND_PLURAL", iSeconds); }
            }
        }
    }

    formatex(output, outputLen, "%s", szText);
}
nvault_array.inc

Code: Select all

/*	
	nVault Array
	    v0.1
	  by bugsy
*/

#if defined _nvault_array_included
	#endinput
#endif
#define _nvault_array_included

#if !defined _nvault_included
	#include <nvault>
#endif

//********************************************************************************************
//   Increase this value if your plugin throws the below error:
//   "Array size too large, you must increase NVAULT_ARRAY_MAXARRAYSIZE in nvault_array.inc"   

const _NVAULT_ARRAY_MAXARRAYSIZE = 500;
//********************************************************************************************

const _NVAULT_ARRAY_CELLSIZE = 5;
const _NVAULT_ARRAY_BUFFERSIZE = ( ( _NVAULT_ARRAY_MAXARRAYSIZE * _NVAULT_ARRAY_CELLSIZE ) + 1 );
const _NVAULT_ARRAY_BYTEMAP = 0b11110000;
const _NVAULT_ARRAY_NULLBYTE = 0b10101010;

/* Description: Set array data in a vault

   Param(s):
   vault - Vault file handle ID that was returned by nvault_open(). Do not pass an nvault utility file ID.
   key[] - Key for data to store.
   array[] - Array of data to store.
   size - Size of array to store (use sizeof(array)).
   
   Return value: 1 on success, 0 on failure.
	
   Comments: None.
*/
stock nvault_set_array( vault , const key[] , const any:array[] , size )
{
	new iArrayPos , iOutputPos , iValue[ 1 ] , szString[ _NVAULT_ARRAY_BUFFERSIZE ];
	
	if ( size > _NVAULT_ARRAY_MAXARRAYSIZE )
		set_fail_state( "[nVault Array] Array size too large, you must increase NVAULT_ARRAY_MAXARRAYSIZE in nvault_array.inc." );
	
	while ( ( iArrayPos < size ) && ( iOutputPos < charsmax( szString ) ) )
	{
		iValue[ 0 ] = array[ iArrayPos++ ];
		
		if ( !( cellmin <= iValue[ 0 ] <= cellmax ) )
			set_fail_state( "[nVault Array] Value exceeds valid long value range." );

		szString[ iOutputPos++ ] = _nvault_array_byte_map( iValue );

		for ( new i = 0 ; i < 4 ; i++ )
			szString[ iOutputPos++ ] = !iValue{ i } ? _NVAULT_ARRAY_NULLBYTE : iValue{ i };
	}
	
	szString[ iOutputPos ] = EOS;
	
	return nvault_set( vault , key , szString );
}

/* Description: Get array data in a vault

   Param(s):
   vault - Vault file handle ID that was returned by nvault_open(). Do not pass an nvault utility file ID.
   key[] - Key for record to retrieve
   array[] - Array to store retrieved data in.
   size - Size of array that data is being retrieved in.
   timestamp - Timestamp of record (passed by reference)
   
   Return value: The number of array elements that were stored in the nvault array record.
	
   Comments: Do not read an nvault record as an array when it was not stored with nvault_set_array()..
*/
stock nvault_get_array( vault , const key[] , any:array[] , size , &timestamp=0 )
{
	new iStringPos , iArrayPos , iValue[ 1 ] , bmByteMap , szString[ _NVAULT_ARRAY_BUFFERSIZE ];
	
	if ( size > _NVAULT_ARRAY_MAXARRAYSIZE )
		set_fail_state( "[nVault Array] Array size too large, you must increase _NVAULT_ARRAY_MAXARRAYSIZE in nvault_array.inc." );
	
	if ( nvault_lookup( vault , key , szString , charsmax( szString ) , timestamp ) )
	{
		while ( szString[ iStringPos ] && ( iStringPos < charsmax( szString ) ) && ( iArrayPos < size ) )
		{
			bmByteMap = szString[ iStringPos++ ];
			
			for ( new i = 0 ; i < 4 ; i++ )
			{
				iValue{ i } = bmByteMap & ( 1 << i ) ? szString[ iStringPos ] : 0;
				iStringPos++;
			}
		
			array[ iArrayPos++ ] = iValue[ 0 ];
		}
	}
	
	return iArrayPos;
}

/* Description: Check if an nvault entry is an array

   Param(s):
   vault - Vault file handle ID that was returned by nvault_open(). Do not pass an nvault utility file ID.
   key[] - Key for record to check
   
   Return value: true / false
*/
stock bool:nvault_isarray( vault , const key[] )
{
	new szData[ _NVAULT_ARRAY_BUFFERSIZE ] , iTS , iDataLen , bool:bRetVal;
	
	if ( nvault_lookup( vault , key , szData , charsmax( szData ) , iTS ) && ( iDataLen = strlen( szData ) ) )
	{
		bRetVal = true;
			
		for ( new i = 0 ; i < iDataLen ; i += _NVAULT_ARRAY_CELLSIZE )
		{
			if ( ( szData[ i ] & _NVAULT_ARRAY_BYTEMAP ) != _NVAULT_ARRAY_BYTEMAP )
			{
				bRetVal = false;
				break;
			}
		}
	}
	
	return bRetVal;
}

/* Description: Get the size of an nvault array

   Param(s):
   vault - Vault file handle ID that was returned by nvault_open(). Do not pass an nvault utility file ID.
   key[] - Key for record to check
   
   Return value:  0 = Record does not exist or is not an nvault array record
		 >0 = How large the array is (in cells)
*/
stock nvault_arraysize( vault , const key[] )
{
	new szData[ _NVAULT_ARRAY_BUFFERSIZE ] , iTS , iDataLen , bool:bIsArray , iRetVal;
	
	if ( nvault_lookup( vault , key , szData , charsmax( szData ) , iTS ) && ( iDataLen = strlen( szData ) ) )
	{
		if ( ( iDataLen < charsmax( szData ) ) && !( iRetVal % _NVAULT_ARRAY_CELLSIZE ) )
		{
			bIsArray = true;
			
			for ( new i = 0 ; i < iDataLen ; i += _NVAULT_ARRAY_CELLSIZE )
			{
				if ( ( szData[ i ] & _NVAULT_ARRAY_BYTEMAP ) != _NVAULT_ARRAY_BYTEMAP )
				{
					bIsArray = false;
					break;
				}
			}
			
			if ( bIsArray == true )
			{
				iRetVal = ( iDataLen / _NVAULT_ARRAY_CELLSIZE );
			}
		}
	}
	
	return iRetVal;
}

stock _nvault_array_byte_map( iValue[ 1 ] )
{
	new iOut[ 1 ] = { _NVAULT_ARRAY_BYTEMAP };

	for ( new i = 0 ; i < 4 ; i++)
		iOut[ 0 ] |= !iValue{ i } ? 0 : ( 1 << i );

	return iOut[ 0 ];
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
gm_time.txt

Code: Select all

[en]
GM_DAY_PLURAL = ^3%i ^4days
GM_DAY_NOMINATIVE = ^3%i ^4day
GM_DAY_SINGULAR = ^3%i ^4days
GM_HOUR_PLURAL = ^3%i ^4hours
GM_HOUR_NOMINATIVE = ^3%i ^4hours
GM_HOUR_SINGULAR = ^3%i ^4hours
GM_MINUTE_PLURAL = ^3%i ^4minutes
GM_MINUTE_NOMINATIVE = ^3%i ^4minutes
GM_MINUTE_SINGULAR = ^3%i ^4minutes
GM_SECOND_PLURAL = ^3%i ^4seconds
GM_SECOND_NOMINATIVE = ^3%i ^4second
GM_SECOND_SINGULAR = ^3%i ^4seconds
gm_vip_test.txt

Code: Select all

[en]
VIPTEST_PREFIX = [^3GM VIP TEST^1]
VIPTEST_TIMEOUT_VIP = You can get ^4free ^3VIP ^1again only through ^4%s
VIPTEST_YOU_VIP = You ^3can't use ^4/vip test ^1because you ^3already have it^1!
VIPTEST_YOU_GIVE_VIP = ^3You got ^4/viptest^1 on ^3%s^1!
VIPTEST_END = ^3You have run out of ^4/viptest^1! ^nYou can only get it again after ^3%s^1!
gm_time.inc si nvault_array.inc in scripting/include pentru compilare
gm_time.txt si gm_vip_test.txt in data
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests