- Регистрация
- 5 Май 2019
- Сообщения
- 1.041
- Симпатии
- 359
- Пол
- Мужской
ПОЧЕМУ НЕ РАБОТАЕТ:
#include <amxmodx>
#include <sockets>
new g_iThreadHandle;
new lasttime = 0;
public plugin_init()
{
register_plugin( "needadmin", "1.0", "needadmin" );
register_concmd( "say /needadmin" , "TestCmd" );
}
public TestCmd(id)
{
if ( time() - lasttime > 60 )
{
lasttime = time()
g_iThreadHandle = socket_create_t();
if((socket_open_t(g_iThreadHandle, "api.vk.com", 80, SOCKET_TCP, "CBOpenSocket")) < 0 )
{
log_amx( "ERROR: Could not open Socket." );
return;
}
log_amx( "Trying to open connection..." );
client_print(id, print_console, "Сообщение админам успешно отправлено")
client_print(id, print_chat, "Сообщение админам успешно отправлено")
}
else
{
client_print(id, print_console, "Сообщение админам успешно не отправлено")
client_print(id, print_chat, "Сообщение админам успешно не отправлено")
}
}
public CBOpenSocket( iThreadState, iReturn )
{
if( iReturn < 0 )
{
log_amx( "ERROR: Could not open Socket. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );
}
else
{
new szPacket[512];
formatex( szPacket, 511, "GET /method/messages.send?access_token=11111111111111111111111111111111111111111111111111111111111&v=5.124&peer_id=2000000001&message=[SERVER%%%%20CS%%%%201.6%%%%20]%%%%20IGROKI%%%%20PROSIAT%%%%20ADMINOV%%%%20ZAITI%%%%20NA%%%%20SERVER&random_id=%i HTTP/1.1^r^nHost: api.vk.com^r^n^r^n", lasttime);
log_amx( "Socket Opened. Trying to send Data..." );
log_amx( szPacket );
if((socket_send_t( g_iThreadHandle, szPacket, sizeof(szPacket), "CBSendSocket")) < 0 )
{
log_amx( "ERROR: Could not Send data." );
}
}
}
public CBSendSocket( iThreadState, iReturn )
{
if( iReturn < 0 )
{
log_amx( "ERROR: Error Sending Data. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );
}
else
{
socket_close_t(g_iThreadHandle, "CBCloseSocket");
}
}
public CBCloseSocket( iThreadState, iReturn )
{
if( iReturn == 0 )
{
log_amx( "Socket Closed. Destroying Thread." );
socket_destroy_t(g_iThreadHandle);
}
else
{
log_amx( "Error Closing socket. Errno : %d", socket_get_last_error_t(g_iThreadHandle) );
}
}