Quote:
Originally Posted by SANTO37
Help me
|
c# its same like java, maybe my simple code will give you idea.
pay attention: the anti cheat in this case is act the server. (and i nub in amxmodx but its a good start).
its not my final work, but worked now its my current code
amxmodx check connection to client (that use anti cheat that listen to 1991 port)
the checking its when the round started (you can change it easily.
UPDATE 5.11.19
Code:
#include <amxmodx>
#include <sockets>
new g_socket;
public client_authorized(id) socket_DBClient(id);
public socket_DBClient(id) {
new ip[32], error;
get_user_ip(id, ip, charsmax(ip), 1);
client_print(id , print_chat, "%s", ip[0]);
g_socket = socket_open(ip, 1991, SOCKET_TCP, error);
if (error == 1 || error == 2 || error ==3) {
server_print("Player %d: ERROR: %d", id, error);
message_begin(MSG_ONE, SVC_DISCONNECT, {0, 0, 0}, id);
write_string("Please open DBClient!");
message_end();
} else {
socket_close(g_socket);
client_print(id, print_chat, "connected");
}
}
Java you need first do inner class for new thread
(because you need your program not waiting for the connection, and its loop all x time
you needed to check, if the anti cheat is opened):
Code:
Thread sThread = new Thread(new Runnable() {
@Override
public void run() {
try {
while(threadShutdown == false) {
ServerSocket server = new ServerSocket(1991);
Socket conSS = server.accept();
System.out.println(conSS.getRemoteSocketAddress());
conSS.close();
}
} catch(Exception e) {
e.printStackTrace();
}
}
});
sThread.start();
Java also you need some hook when the program closed, stop listen to the socket.
Code:
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
threadShutdown = false;
}
});
hope its help you (i in the middle my self of doing anti cheat , i thnik its will help you).