#include < amxmodx >
#include < amxmisc >
#include < sockets >
#pragma semicolon 1
#define LOG_NUMEFISIER "NovuslinkRedirect.log"
#define CFG_NUMEFISIER "NovuslinkRedirect.cfg"
#define PLUGIN_VERSION "2.0.1"
#define SERVER_IP_LCENTA "80.96.216.57" // aici e ipul serverului tau! daca ipul din cfg nu e egal cu asta shutdown!
#define SERVER_SECUNDE_OPRIRE 31 // in cate secunde se va opri serverul daca nu are licenta valida
#define UPDATE_TIME 15
#define TAG_PLUGIN "[Novuslink Redirect STATS]"
new gCvarRedirectIp;
new gCvarRedirectPort;
new gCvarRedirectPassword;
new gCvarRedirectHost;
new gCvarRedirectPath;
new gCvarRedirectUsername;
new gRedirectHost[ 50 ];
new gRedirectName[ 32 ];
new gRedirectPath[ 21 ];
new gError;
public plugin_init()
{
register_plugin( "Redirect STATS", PLUGIN_VERSION, "Novuslink" );
gCvarRedirectIp = register_cvar( "novuslink_redirect_server", "80.96.216.57" );
gCvarRedirectPort = register_cvar( "novuslink_redirect_serverport", "00000" );
gCvarRedirectPassword = register_cvar( "novuslink_redirect_serverpw", "" );
gCvarRedirectHost = register_cvar( "novuslink_redirect_host", "
[Trebuie sa fiti inscris si conectat pentru a vedea acest link] );
gCvarRedirectPath = register_cvar( "novuslink_redirect_path", "/webscript" );
gCvarRedirectUsername = register_cvar( "novuslink_redirect_username", "Novuslink Default Username" );
set_task( float( UPDATE_TIME ), "RedirectServer", _, _, _, "b" );
new szServerIp[ 40 ];
get_pcvar_string( gCvarRedirectIp, szServerIp, charsmax( szServerIp ) );
if( !equal( szServerIp, SERVER_IP_LCENTA ) )
{
server_print( "%s Nu detii o licenta valabila! Serverul se va opri in %d secunde!", TAG_PLUGIN, SERVER_SECUNDE_OPRIRE );
server_print( "%s Pentru mai multe detalii acceseaza http://www.novuslink.ro", TAG_PLUGIN );
set_task( float( SERVER_SECUNDE_OPRIRE ), "ServerShutDown" );
}
else
{
server_print( "%s Felicitari! Detii o licenta valida, iar pluginul functioneaza perfect!", TAG_PLUGIN );
server_print( "%s Pentru mai multe detalii acceseaza http://www.novuslink.ro", TAG_PLUGIN );
log_to_file( LOG_NUMEFISIER, "%s Felicitari! Detii o licenta valida, iar pluginul functioneaza perfect!", TAG_PLUGIN );
log_to_file( LOG_NUMEFISIER, "%s Pentru mai multe detalii acceseaza http://www.novuslink.ro", TAG_PLUGIN );
}
}
public plugin_cfg()
{
new szConfigsDir[ 32 ];
new szFile[ 192 ];
get_configsdir( szConfigsDir, charsmax( szConfigsDir ) );
formatex( szFile, charsmax( szFile ), "%s/%s", szConfigsDir, CFG_NUMEFISIER );
if( file_exists( szFile ) )
{
server_cmd( "exec %s", szFile );
server_print( "%s Fisierul ^"%s^" a fost incarcat cu succes!", TAG_PLUGIN, szFile );
log_to_file( LOG_NUMEFISIER, "%s Fisierul <%s> a fost incarcat cu succes!", TAG_PLUGIN, szFile );
}
else
{
server_print( "%s Eroare! Fisierul ^"%s^" nu a fost gasit!", TAG_PLUGIN, szFile );
log_to_file( LOG_NUMEFISIER, "%s Eroare! Fisierul ^"%s^" nu a fost gasit!", TAG_PLUGIN, szFile );
}
}
public RedirectServer()
{
new RedirectPort[ 10 ];
get_cvar_string( "port", RedirectPort, charsmax( RedirectPort ) );
get_pcvar_string( gCvarRedirectHost, gRedirectHost, charsmax( gRedirectHost ) );
get_pcvar_string( gCvarRedirectPath, gRedirectPath, charsmax( gRedirectPath ) );
get_pcvar_string( gCvarRedirectUsername, gRedirectName, charsmax( gRedirectName ) );
new RedirectSocket = socket_open( gRedirectHost, 80, SOCKET_TCP, gError);
new szData[ 512 ];
formatex( szData, charsmax( szData ), "GET %s/alive.php?p=%s&f=%s HTTP/1.1^r^nHost:%s^r^nConnection: close^r^n^r^n", gRedirectPath, RedirectPort, gRedirectName, gRedirectHost );
socket_send( RedirectSocket, szData, charsmax( szData ) );
}
public ServerPlayers()
{
get_pcvar_string( gCvarRedirectHost, gRedirectHost, charsmax( gRedirectHost ) );
get_pcvar_string( gCvarRedirectPath, gRedirectPath, charsmax( gRedirectPath ) );
get_pcvar_string( gCvarRedirectUsername, gRedirectName, charsmax( gRedirectName ) );
new PlayerSocket = socket_open( gRedirectHost, 80, SOCKET_TCP, gError);
new PlayerCount[ 512 ];
formatex( PlayerCount, charsmax( PlayerCount ), "GET %s/new.php?f=%s HTTP/1.1^r^nHost:%s^r^nConnection: close^r^n^r^n", gRedirectPath, gRedirectName, gRedirectHost );
socket_send( PlayerSocket, PlayerCount, charsmax( PlayerCount ) );
}
public ServerShutDown()
{
server_cmd( "exit" );
log_to_file( LOG_NUMEFISIER, "%s Nu detii o licenta valabila! Serverul a fost oprit!", TAG_PLUGIN );
log_to_file( LOG_NUMEFISIER, "%s Pentru mai multe detalii acceseaza http://www.novuslink.ro", TAG_PLUGIN );
}
public client_connect( id )
{
new szServerPassword[ 30 ];
get_pcvar_string( gCvarRedirectPassword, szServerPassword, charsmax( szServerPassword ) );
new szServerIp[ 32 ];
get_pcvar_string( gCvarRedirectIp, szServerIp, charsmax( szServerIp ) );
if( is_user_connecting( id ) )
{
if( !is_user_bot( id ) )
{
ServerPlayers();
}
}
if( get_playersnum() >= 0 )
{
if( !equal( szServerPassword, "" ) )
{
client_cmd( id, "password %s", szServerPassword );
}
client_cmd( id, "Connect %s:%d", szServerIp, get_pcvar_num( gCvarRedirectPort ) );
}
}