08.01.2016, 13:23
Estou a fazer um anti-cheat para o SAMP. O client й em C#. Para o servidor, pensei em utilizar sockets mas o plugin estб a dar-me alguns problemas. A ъltima versгo (0.2b) nem carrega no servidor. Tentei compilar o source, mas nem isso consigo. O Visual Studio diz que nгo consegue aceder a algumas includes. Jб tentei de tudo, consegui resolver alguns erros mas outros nгo desaparecem.
Na primeira versгo, o servidor carrega o plugin, cria o socket e recebe bem os dados, mas nгo os envia.
Ou seja, ele recebe o pedido do client mas nгo envia nenhum return. Se alguйm me arranjar a .dll do plugin e o .so da nova versгo para testar, agradecia.
Se nгo, hб mais alguma maneira de conectar o client ao servidor? Pensei em MySQL mas ia ficar muito lento.
Na primeira versгo, o servidor carrega o plugin, cria o socket e recebe bem os dados, mas nгo os envia.
Код:
// A simple TCP server sample
#include <a_samp>
#include <socket>
new Socket:g_Socket;
public OnFilterScriptInit()
{
g_Socket = socket_create(TCP);
if(is_socket_valid(g_Socket))
{
socket_set_max_connections(g_Socket, 10);
socket_listen(g_Socket, 420);
}
return 1;
}
public OnFilterScriptExit()
{
if(is_socket_valid(g_Socket))
{
socket_destroy(g_Socket);
}
}
public onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid)
{
printf("Incoming connection from [%d:%s]", remote_clientid, remote_client); // [id:ip]
return 1;
}
public onSocketRemoteDisconnect(Socket:id, remote_clientid)
{
printf("Remote client [%d] has disconnected.", remote_clientid); // [id:ip]
return 1;
}
public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
{
printf("Remote client [%d] has sent: %s", remote_clientid, data); // id & data
socket_send(id, "teste", sizeof(id));
return 1;
}
public onSocketAnswer(Socket:id, data[], data_len)
{
printf("Data sent %s data lenght %d", data, data_len); // id & data
return 1;
}
Se nгo, hб mais alguma maneira de conectar o client ao servidor? Pensei em MySQL mas ia ficar muito lento.

