Existing user? Sign in
Sign up
Games
Servers
Useful
User
Pass
2FA
[Tutorial]Licentierea pluginurilor.
Freakz Forum Index
->
Trash Bin
->
CS 2006-2019 (Archived)
->
Tutorials
Author
Message
1566
ThunderJB
[Freakz * Thunder]
Status: Offline
(since 12-10-2022 06:25)
Joined: 06 Sep 2013
Posts: 4652
,
Topics: 262
Location:
Back in the business.
Reputation:
878.8
Votes
: 266
Posted: 04-08-2014, 21:30:49
| Translate post to:
... (
Click for more languages
)
Au existat cateva persoane care au dorit sa creeze pluginuri care sa ruleze doar pe anumite ip-uri.Am avut si eu nevoie de asta si acum o dau mai departe.Gasisem ceva in legatura cu subiectul asta pe un forum dar nu mergea.Asa ca mi-am facut ceva timp si in cateva ore m-am prins.
Autor: KronoS # GG
Credite: Sylwester (detectarea ip-ului extern)
Licentierea unui DNS
Licentierea unui DNS presupune ca serverul pe care ruleaza pluginul sa contina in nume adresa setata de noi.Aveti aici codul complet:
DNS-ul se modifica de aici:
Citat:
#define DNS_LICENTIAT "dns.server.ro"
Licentierea unui singur IP
Folosirea acestei metode necesita activarea modulului sockets din fisierul modules.ini
Pentru a licentia un plugin, o sa aveti nevoie sa includeti biblioteca sockets.
Imediat dupa
Cod:
#include < amxmodx >
adaugati
Cod:
#include < sockets >
In partea declarativa, dupa includerea bibliotecilor, adaugati:
Cod:
#define IP_SERVER_LICENTIAT "79.116.43.34"
O sa trebuiasca sa declarati niste variabile si constante (dupa ce ati definit ip-ul licentiat)
Cod:
new g_ServerIP[ 16 ], g_Socket;
new const licenseMsg[ 2 ][ ] =
{
"IP-ul serverului este licentiat!Pluginul ruleaza!",
"IP-ul serverului nu este licentiat iar pluginul nu poate rula pe acesta!"
}
In
Cod:
public plugin_init( )
adaugati
Cod:
Get_ServerIP( );
Ultimul pas il reprezinta adaugarea urmatorului cod oriunde in sursa (preferabil dupa public plugin_init)
Code:
public Get_ServerIP( )
{
static error;
if ( g_Socket > 0 )
{
log_amx( "Error occurred while trying to retrieve server ip (socket is in use)" );
return;
}
g_Socket = socket_open( "checkip.dyndns.com", 80, SOCKET_TCP, error );
if ( g_Socket > 0 )
{
socket_send( g_Socket, "GET / HTTP/1.1^nHost: checkip.dyndns.com^n^n", 64 );
set_task( 0.1, "Verif_Request" );
}
else
{
log_amx( "Error occurred while trying to retrieve server ip (%d)", error );
set_fail_state( licenseMsg[ 1 ] );
}
}
public Verif_Request( )
{
if ( !socket_change( g_Socket, 1 ) )
set_task( 0.1, "Verif_Request" );
else
{
new data[ 256 ], i, j, d, pos;
socket_recv( g_Socket, data, 255 );
pos = containi( data, "<body>Current IP Address: " );
if ( pos > -1 )
{
pos += 26;
while ( '0' <= data[ pos + i ] <= '9' )
{
g_ServerIP[ i ] = data[ pos + i ];
i++;
if ( data[ pos + i ] == '.' )
{
g_ServerIP[ i ] = data[ pos + i ];
j = ++i;
d++;
}
}
if ( j != i || d == 3 )
Verif_License( );
else
set_fail_state( licenseMsg[ 1 ] );
}
socket_close( g_Socket );
g_Socket = 0;
}
}
public Verif_License( )
{
if ( !equal( g_ServerIP, IP_SERVER_LICENTIAT ) )
set_fail_state( licenseMsg[ 1 ] );
else
server_print( licenseMsg[ 0 ] );
}
Exemplu de plugin:
Code:
#include < amxmodx >
#include < sockets >
#define IP_SERVER_LICENTIAT "79.116.43.34"
new g_ServerIP[ 16 ], g_Socket;
new const licenseMsg[ 2 ][ ] =
{
"IP-ul serverului este licentiat!Pluginul ruleaza!",
"IP-ul serverului nu este licentiat iar pluginul nu poate rula pe acesta!"
}
public plugin_init( )
{
Get_ServerIP( );
}
public Get_ServerIP( )
{
static error;
if ( g_Socket > 0 )
{
log_amx( "Error occurred while trying to retrieve server ip (socket is in use)" );
return;
}
g_Socket = socket_open( "checkip.dyndns.com", 80, SOCKET_TCP, error );
if ( g_Socket > 0 )
{
socket_send( g_Socket, "GET / HTTP/1.1^nHost: checkip.dyndns.com^n^n", 64 );
set_task( 0.1, "Verif_Request" );
}
else
{
log_amx( "Error occurred while trying to retrieve server ip (%d)", error );
set_fail_state( licenseMsg[ 1 ] );
}
}
public Verif_Request( )
{
if ( !socket_change( g_Socket, 1 ) )
set_task( 0.1, "Verif_Request" );
else
{
new data[ 256 ], i, j, d, pos;
socket_recv( g_Socket, data, 255 );
pos = containi( data, "<body>Current IP Address: " );
if ( pos > -1 )
{
pos += 26;
while ( '0' <= data[ pos + i ] <= '9' )
{
g_ServerIP[ i ] = data[ pos + i ];
i++;
if ( data[ pos + i ] == '.' )
{
g_ServerIP[ i ] = data[ pos + i ];
j = ++i;
d++;
}
}
if ( j != i || d == 3 )
Verif_License( );
else
set_fail_state( licenseMsg[ 1 ] );
}
socket_close( g_Socket );
g_Socket = 0;
}
}
public Verif_License( )
{
if ( !equal( g_ServerIP, IP_SERVER_LICENTIAT ) )
set_fail_state( licenseMsg[ 1 ] );
else
server_print( licenseMsg[ 0 ] );
}
Licentierea unei clase de IP
Folosirea acestei metode necesita activarea modulului sockets din fisierul modules.ini
Pentru a licentia un plugin, o sa aveti nevoie sa includeti biblioteca sockets.
Imediat dupa
Cod:
#include < amxmodx >
adaugati
Cod:
#include < sockets >
In partea declarativa, dupa includerea bibliotecilor, adaugati:
Cod:
#define CLASA_SERVER_LICENTIAT "79.116."
Clasa este de forma XXX.XXX.
O sa trebuiasca sa declarati niste variabile si constante (dupa ce ati definit clasa licentiata)
Cod:
new g_ServerIP[ 16 ], g_Socket;
new const licenseMsg[ 2 ][ ] =
{
"Clasa de IP a serverului este licentiata!Pluginul ruleaza!",
"Clasa de IP a serverului nu este licentiata iar pluginul nu poate rula pe acesta!"
}
In
Cod:
public plugin_init( )
adaugati
Cod:
Get_ServerIP( );
Ultimul pas il reprezinta adaugarea urmatorului cod oriunde in sursa (preferabil dupa public plugin_init)
Spoiler:
public Get_ServerIP( )
{
static error;
if ( g_Socket > 0 )
{
log_amx( "Error occurred while trying to retrieve server ip (socket is in use)" );
return;
}
g_Socket = socket_open( "checkip.dyndns.com", 80, SOCKET_TCP, error );
if ( g_Socket > 0 )
{
socket_send( g_Socket, "GET / HTTP/1.1^nHost: checkip.dyndns.com^n^n", 64 );
set_task( 0.1, "Verif_Request" );
}
else
{
log_amx( "Error occurred while trying to retrieve server ip (%d)", error );
set_fail_state( licenseMsg[ 1 ] );
}
}
public Verif_Request( )
{
if ( !socket_change( g_Socket, 1 ) )
set_task( 0.1, "Verif_Request" );
else
{
new data[ 256 ], i, j, d, pos;
socket_recv( g_Socket, data, 255 );
pos = containi( data, "<body>Current IP Address: " );
if ( pos > -1 )
{
pos += 26;
while ( '0' <= data[ pos + i ] <= '9' )
{
g_ServerIP[ i ] = data[ pos + i ];
i++;
if ( data[ pos + i ] == '.' )
{
g_ServerIP[ i ] = data[ pos + i ];
j = ++i;
d++;
}
}
if ( j != i || d == 3 )
Verif_License( );
else
set_fail_state( licenseMsg[ 1 ] );
}
socket_close( g_Socket );
g_Socket = 0;
}
}
public Verif_License( )
{
if ( !( -1 != containi( g_ServerIP, CLASA_SERVER_LICENTIAT ) ) )
set_fail_state( licenseMsg[ 1 ] );
else
server_print( licenseMsg[ 0 ] );
}
Exemplu de plugin
Code:
#include < amxmodx >
#include < sockets >
#define CLASA_SERVER_LICENTIAT "79.116."
new g_ServerIP[ 16 ], g_Socket;
new const licenseMsg[ 2 ][ ] =
{
"Clasa de IP a serverului este licentiata!Pluginul ruleaza!",
"Clasa de IP a serverului nu este licentiata iar pluginul nu poate rula pe acesta!"
}
public plugin_init( )
{
Get_ServerIP( );
}
public Get_ServerIP( )
{
static error;
if ( g_Socket > 0 )
{
log_amx( "Error occurred while trying to retrieve server ip (socket is in use)" );
return;
}
g_Socket = socket_open( "checkip.dyndns.com", 80, SOCKET_TCP, error );
if ( g_Socket > 0 )
{
socket_send( g_Socket, "GET / HTTP/1.1^nHost: checkip.dyndns.com^n^n", 64 );
set_task( 0.1, "Verif_Request" );
}
else
{
log_amx( "Error occurred while trying to retrieve server ip (%d)", error );
set_fail_state( licenseMsg[ 1 ] );
}
}
public Verif_Request( )
{
if ( !socket_change( g_Socket, 1 ) )
set_task( 0.1, "Verif_Request" );
else
{
new data[ 256 ], i, j, d, pos;
socket_recv( g_Socket, data, 255 );
pos = containi( data, "<body>Current IP Address: " );
if ( pos > -1 )
{
pos += 26;
while ( '0' <= data[ pos + i ] <= '9' )
{
g_ServerIP[ i ] = data[ pos + i ];
i++;
if ( data[ pos + i ] == '.' )
{
g_ServerIP[ i ] = data[ pos + i ];
j = ++i;
d++;
}
}
if ( j != i || d == 3 )
Verif_License( );
else
set_fail_state( licenseMsg[ 1 ] );
}
socket_close( g_Socket );
g_Socket = 0;
}
}
public Verif_License( )
{
if ( !( -1 != containi( g_ServerIP, CLASA_SERVER_LICENTIAT ) ) )
set_fail_state( licenseMsg[ 1 ] );
else
server_print( licenseMsg[ 0 ] );
}
PS:Nu am respectat modelul deoarece vroiam sa-l fac concis.
Black magic
0
0
Back to top
Freakz Forum Index
->
Trash Bin
->
CS 2006-2019 (Archived)
->
Tutorials
The time now is 05-02-2025, 23:58:03
Copyright info
Based on phpBB
ro
/
com
B
Login
I forgot my password
World of Warcraft
Login for more...
Download WoW 7.3.5
Misc
eSports
Achievements
Buy reputation with votes
Reputation trades
Forum rules
Ban list
Members list
User guide (FAQ)
World of Warcraft
View details