Member
|
07-29-2019
, 15:51
Re: [Req] a give coins
|
#2
|
Quote:
/* Plugin generated by AMXX-Studio */
#include < amxmodx >
#include < fvault >
native set_user_cash( id, cash );
native get_user_cash( id );
new szVault[ ] = "PayCheckVault";
#define MAX_PLAYERS 32
#define PAYCHECK_GIVES 2500
#define TIME_TO_TAKE_PAYCHECK 30
#define VOX_STARTS_FROM 5
#define PAYCHECK_SOUND "JB/paycheck.mp3"
#define TASK_COUNT 4455
new iNextPayCheck;
new iCount, iTimeSpent[ MAX_PLAYERS + 1 ], iConnected[ MAX_PLAYERS + 1 ], bool:bChecked[ MAX_PLAYERS + 1 ];
public plugin_init( )
{
register_plugin( "Paycheck - cash every round hour.", "1.0", "slzzzzzzz" );
register_saycmd( "playerstime", "Show_Players_Time" );
register_saycmd( "pt", "Show_Players_Time" );
register_saycmd( "paycheck", "CmdPayCheck" );
register_saycmd( "pc", "CmdPayCheck" );
set_next_paycheck( );
set_task( float( iNextPayCheck - get_systime( ) ), "PayCheck_Ready" );
}
public plugin_precache( )
{
#if defined PAYCHECK_SOUND
precache_sound( PAYCHECK_SOUND );
#endif
}
public client_authorized( id )
{
static szData[ 5 ];
bChecked[ id ] = false;
iConnected[ id ] = floatround( get_gametime( ) );
if( ! ( fvault_get_data( szVault, GetAuth( id ), szData, charsmax( szData ) ) ) )
{
iTimeSpent[ id ] = 0;
return;
}
iTimeSpent[ id ] = str_to_num( szData );
}
public client_disconnect( id )
{
new iTemp, szData[ 5 ];
iTemp = iTimeSpent[ id ] + ( floatround( get_gametime( ) ) - iConnected[ id ] );
num_to_str( iTemp, szData, charsmax( szData ) );
fvault_set_data( szVault, GetAuth( id ), szData );
}
public CmdPayCheck( id )
{
if( get_systime( ) < iNextPayCheck )
{
ColorChat( id, "Paycheck will be ready in ^4%.1f ^1minutes.", ( iNextPayCheck - get_systime( ) ) / 60.0 );
return 1;
}
if( bChecked[ id ] )
{
ColorChat( id, "You already took your paycheck" );
return 1;
}
new Float:iTotal = float( iTimeSpent[ id ] + ( floatround( get_gametime( ) ) - iConnected[ id ] ) );
iTotal/=60.0; // Amount of minutes the player has spent in the last hour.
if( iTotal < 1.0 )
{
ColorChat( id, "You haven't even spent a minute in the last hour, ^4fuck off mate^1." );
return 1;
}
fvault_remove_key( szVault, GetAuth( id ) );
new Float:fPerMinute = PAYCHECK_GIVES / 60.0; // Amount of cash players recieve per minute.
new iCash = floatround( fPerMinute * iTotal );
set_user_cash( id, get_user_cash( id ) + iCash );
bChecked[ id ] = true;
ColorChat( id, "You got ^4%d^1 cash, for playing ^3%.1f ^1minutes in the last ^4hour^1.", iCash, iTotal );
return 1;
}
public Show_Players_Time( id )
{
new iMenu = menu_create( "\wPaycheck Menu \d- \rHow much time players spent in the last hour\w?", "Handler" );
new Float:iTotal;
new iCallback = menu_makecallback( "cb_disabled" );
static szMenu[ 120 ];
for( new i = 1 ; i <= MAX_PLAYERS ; i++ )
{
if( !is_user_connected( i ) )
continue;
iTotal = float( iTimeSpent[ i ] + ( floatround( get_gametime( ) ) - iConnected[ i ] ) );
iTotal/=60.0;
formatex( szMenu, charsmax( szMenu ), "%s \d- \y%.1f \wMinutes", GetName( i ), iTotal );
menu_additem( iMenu, szMenu, _, _, iCallback );
}
menu_setprop( iMenu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, iMenu );
}
public Handler( id, iMenu, item )
{
menu_destroy( iMenu );
return 1;
}
public cb_disabled( id, iMenu, item )
{
return ITEM_DISABLED;
}
public PayCheck_Ready( )
{
iCount = TIME_TO_TAKE_PAYCHECK;
#if defined PAYCHECK_SOUND
client_cmd( 0, "mp3 play ^"sound/%s^"", PAYCHECK_SOUND );
#endif
arrayset( bChecked, false, MAX_PLAYERS );
set_task( 1.0, "CmdCountDown", TASK_COUNT, _, _, "b" );
}
public CmdCountDown( )
{
if( iCount <= 0 )
{
remove_task( TASK_COUNT );
fvault_clear( szVault );
arrayset( iTimeSpent, 0, MAX_PLAYERS );
arrayset( iConnected, floatround( get_gametime( ) ), MAX_PLAYERS );
set_next_paycheck( );
set_task( float( iNextPayCheck - get_systime( ) ), "PayCheck_Ready" );
ColorChat( 0, "You can no longer take your ^4paycheck^1, the next paycheck will be available in ^3one hour^1." );
return;
}
set_hudmessage( 255, 0, 0, -1.0, 0.16, 0, 6.0, 1.0 );
show_hudmessage( 0, "Time left to use paycheck:^n%d", iCount );
if( iCount <= VOX_STARTS_FROM )
client_cmd( 0, "spk vox/%s", GetWord( iCount ) );
iCount--;
}
/* Coldwar ahatih */
stock set_next_paycheck( )
iNextPayCheck = get_systime() + 3600 - (get_systime() % 3600);
/* */
stock GetAuth( id )
{
static szAuth[ 45 ];
get_user_authid( id, szAuth, charsmax( szAuth ) );
if( containi( szAuth, "VALVE_" ) != -1 || containi( szAuth, "ID_LAN" ) != -1 )
get_user_ip( id, szAuth, charsmax( szAuth ), 1 );
return szAuth;
}
stock GetWord( iNum )
{
static szWord[ 17 ];
num_to_word( iNum, szWord, charsmax( szWord ) );
return szWord;
}
stock GetName( id )
{
static szName[ 32 ];
get_user_name( id, szName, charsmax( szName ) );
return szName;
}
stock register_saycmd( const cmd[ ], const function[ ] )
{
static Func[ 60 ];
static const szSymbols[ ] [ ] = { "/", "!", "" };
for( new i = 0 ; i < sizeof( szSymbols ) ; i++ )
{
formatex( Func, charsmax( Func ), "say %s%s", szSymbols[ i ], cmd );
register_clcmd( Func, function );
}
}
stock ColorChat( const id, const string[ ], { Float, Sql, Resul,_ }:... )
{
new msg[ 191 ], players[ 32 ], count = 1;
static len;
len = formatex( msg, charsmax( msg ), "^4[AMXX]^1 " );
vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
if( id )
players[ 0 ] = id;
else
get_players( players, count, "ch" );
for( new i = 0; i < count; i++ )
{
if( is_user_connected( players[ i ] ) )
{
message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ),_, players[ i ] );
write_byte( players[ i ] );
write_string( msg );
message_end( );
}
}
return 1;
}
|
change natives + change command.
and its every 1 hour i mean 15:00 16:00 17:00 18:00 and etc.
|
|