updated syntax slightly, updated socket, made silly stuff for postforwards

This commit is contained in:
christian 2021-10-17 23:01:05 +02:00
parent 554c88a7ea
commit 050ad4e022
3 changed files with 81 additions and 45 deletions

View File

@ -194,7 +194,7 @@ if __name__ == '__main__':
elif data == "bot kicked server full": elif data == "bot kicked server full":
print('bot kicked server full: ', datetime.datetime.now().time()) print('bot kicked server full: ', datetime.datetime.now().time())
elif "connected to" in data: elif "connected to" in data:
connected_to_other = True connected_to_other = True
elif "not connected" in data: elif "not connected" in data:
connected_to_other = False connected_to_other = False
elif "connect to" in data: elif "connect to" in data:
@ -254,3 +254,4 @@ if [[ $DISPLAY ]]; then
fi fi
""" """

View File

@ -1,9 +1,9 @@
#pragma semicolon 1 #pragma semicolon 1
#pragma newdecls required
#define DEBUG #define DEBUG
#define PLUGIN_AUTHOR "jenz" #define PLUGIN_AUTHOR "jenz"
#define PLUGIN_VERSION "1.6" #define PLUGIN_VERSION "1.7"
#define generic_length 256 #define generic_length 256
#include <sourcemod> #include <sourcemod>
@ -13,7 +13,6 @@
#include <cstrike> #include <cstrike>
#include <socket> #include <socket>
//#pragma newdecls required
int target_human_afk_counter[MAXPLAYERS + 1]; int target_human_afk_counter[MAXPLAYERS + 1];
int targethuman[MAXPLAYERS + 1]; int targethuman[MAXPLAYERS + 1];
int target_enemy[MAXPLAYERS + 1]; int target_enemy[MAXPLAYERS + 1];
@ -190,11 +189,11 @@ public Action cmd_botrtv(int client, int args)
{ {
if (vips[client] || admins[client]) if (vips[client] || admins[client])
{ {
char msg[generic_length];
for (int i = 1; i <= MaxClients; i++) for (int i = 1; i <= MaxClients; i++)
{ {
if (IsValidClient(i) && !IsFakeClient(i)) if (IsValidClient(i) && !IsFakeClient(i))
{ {
char msg[generic_length];
Format(msg, sizeof(msg), "rtv"); Format(msg, sizeof(msg), "rtv");
if (is_autism_bot1(i)) if (is_autism_bot1(i))
{ {
@ -222,6 +221,7 @@ public Action cmd_talk(int client, int args)
{ {
char info[generic_length]; char info[generic_length];
GetCmdArgString(info, sizeof(info)); GetCmdArgString(info, sizeof(info));
if (strlen(info) == 0) if (strlen(info) == 0)
{ {
PrintToChat(client, "Add a message to the command if autism bot is ingame and running on discord"); PrintToChat(client, "Add a message to the command if autism bot is ingame and running on discord");
@ -288,7 +288,7 @@ public void OnMapStart()
//0.2 too spammmy, 1.5 too slow //0.2 too spammmy, 1.5 too slow
chat_cooldown = false; chat_cooldown = false;
CreateTimer(0.30, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(0.30, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(35.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
} }
public void send_socket_msg(char[] query_msg, int len, int port) public void send_socket_msg(char[] query_msg, int len, int port)
@ -393,26 +393,49 @@ public Action bot_check_connect(Handle timer, any data)
} }
} }
} }
//this check ensures servers dont overlap each other //this check ensures servers dont overlap each other regarding not connected messages
if (!is_host_ze) if (!is_host_ze)
{ {
Format(msg, sizeof(msg), "not connected"); Format(msg, sizeof(msg), "not connected");
if (!found_bot1 && i_port == server_ports[1])
{
//gg
send_socket_msg(msg, strlen(msg), ports[0]);
}
if (!found_bot2 && i_port == server_ports[2])
{
//zr
send_socket_msg(msg, strlen(msg), ports[1]);
}
if (!found_bot3 && i_port == server_ports[2])
{
//zr
send_socket_msg(msg, strlen(msg), ports[2]);
}
if (!found_bot4 && i_port == server_ports[2])
{
//zr
send_socket_msg(msg, strlen(msg), ports[3]);
}
} }
if (!found_bot1) else
{ {
send_socket_msg(msg, strlen(msg), ports[0]); if (!found_bot1)
} {
if (!found_bot2) send_socket_msg(msg, strlen(msg), ports[0]);
{ }
send_socket_msg(msg, strlen(msg), ports[1]); if (!found_bot2)
} {
if (!found_bot3) send_socket_msg(msg, strlen(msg), ports[1]);
{ }
send_socket_msg(msg, strlen(msg), ports[2]); if (!found_bot3)
} {
if (!found_bot4) send_socket_msg(msg, strlen(msg), ports[2]);
{ }
send_socket_msg(msg, strlen(msg), ports[3]); if (!found_bot4)
{
send_socket_msg(msg, strlen(msg), ports[3]);
}
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -889,7 +912,7 @@ public void OnClientPostAdminCheck(int client)
{ {
target_human_afk_counter[client] = 0; target_human_afk_counter[client] = 0;
bot_avoid_edge[client] = -1; bot_avoid_edge[client] = -1;
char auth[50]; char auth[64];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
char msg[generic_length]; char msg[generic_length];
Format(msg, sizeof(msg), "autismo connected"); Format(msg, sizeof(msg), "autismo connected");
@ -922,7 +945,16 @@ public void OnClientPostAdminCheck(int client)
client_old_coords[client][2] = 0.0; client_old_coords[client][2] = 0.0;
} }
public OnSocketError(Handle socket, const int errorType, const int errorNum, any args) //this feels pretty fucking autistic why cant the forward just trigger, am i retarded?
public void OnClientAuthorized(int client, const char[] auth)
{
if (IsValidClient(client))
{
OnClientPostAdminCheck(client);
}
}
public void OnSocketError(Handle socket, const int errorType, const int errorNum, any args)
{ {
CloseHandle(socket); CloseHandle(socket);
LogError("[MR] Socket error: %d (errno %d)", errorType, errorNum); LogError("[MR] Socket error: %d (errno %d)", errorType, errorNum);
@ -955,9 +987,12 @@ stock void connect_socket()
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
admins[client] = false; if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
admins[client] = false;
else if (CheckCommandAccess(client, "sm_reserved", ADMFLAG_RESERVATION))
vips[client] = false;
bot_avoid_edge[client] = -1; bot_avoid_edge[client] = -1;
vips[client] = false;
client_old_coords[client][0] = 0.0; client_old_coords[client][0] = 0.0;
client_old_coords[client][1] = 0.0; client_old_coords[client][1] = 0.0;
client_old_coords[client][2] = 0.0; client_old_coords[client][2] = 0.0;
@ -965,18 +1000,18 @@ public void OnClientDisconnect(int client)
} }
//Socket callback //Socket callback
public OnSocketConnected(Handle socket, any arg) public void OnSocketConnected(Handle socket, any arg)
{ {
} }
//manage message //manage message
public OnSocketReceive(Handle socket, char[] receiveData, const dataSize, any hFile) public void OnSocketReceive(Handle socket, char[] receiveData, const char dataSize, any hFile)
{ {
//PrintToChatAll("receiveData: %s", receiveData);
} }
public OnSocketDisconnected(Handle socket, any arg) public void OnSocketDisconnected(Handle socket, any arg)
{ {
CreateTimer(10.0, TimerConnect, INVALID_HANDLE, TIMER_HNDL_CLOSE); CreateTimer(10.0, TimerConnect, INVALID_HANDLE, TIMER_HNDL_CLOSE);
} }
@ -1133,7 +1168,7 @@ public bool IsRectangleVisible(const float start[3], const float end[3], const f
SubtractVectors(vTemp, fwd, vRectangle[3]); SubtractVectors(vTemp, fwd, vRectangle[3]);
} }
// Run traces on all corners. // Run traces on all corners.
for (new i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
if (IsPointVisible(start, vRectangle[i])) if (IsPointVisible(start, vRectangle[i]))
return true; return true;
return false; return false;

View File

@ -294,7 +294,7 @@ typeset SocketErrorCB
* @param socket Socket handle to check * @param socket Socket handle to check
* @return bool The connection status * @return bool The connection status
*/ */
native bool:SocketIsConnected(Handle:socket); native bool SocketIsConnected(Handle socket);
/** /**
@ -316,7 +316,7 @@ native Handle SocketCreate(SocketType protocol=SOCKET_TCP, SocketErrorCB efunc);
* @param cell_t port The port to bind the socket to. * @param cell_t port The port to bind the socket to.
* @return bool true on success * @return bool true on success
*/ */
native bool:SocketBind(Handle:socket, const String:hostname[], port); native bool SocketBind(Handle socket, const char[] hostname, char port);
/** /**
* Connects a socket * Connects a socket
@ -333,7 +333,7 @@ native bool:SocketBind(Handle:socket, const String:hostname[], port);
* @param cell_t port The port to connect to. * @param cell_t port The port to connect to.
* @noreturn * @noreturn
*/ */
native SocketConnect(Handle:socket, SocketConnectCB:cfunc, SocketReceiveCB:rfunc, SocketDisconnectCB:dfunc, const String:hostname[], port); native void SocketConnect(Handle socket, SocketConnectCB cfunc, SocketReceiveCB rfunc, SocketDisconnectCB dfunc, const char[] hostname, char port);
/** /**
* Disconnects a socket * Disconnects a socket
@ -343,7 +343,7 @@ native SocketConnect(Handle:socket, SocketConnectCB:cfunc, SocketReceiveCB:rfunc
* *
* @noreturn * @noreturn
*/ */
native bool:SocketDisconnect(Handle:socket); native bool SocketDisconnect(Handle socket);
/** /**
* Makes a socket listen for incoming connections * Makes a socket listen for incoming connections
@ -352,7 +352,7 @@ native bool:SocketDisconnect(Handle:socket);
* @param SocketIncomingCB ifunc The callback for incoming connections * @param SocketIncomingCB ifunc The callback for incoming connections
* @return bool true on success * @return bool true on success
*/ */
native bool:SocketListen(Handle:socket, SocketIncomingCB:ifunc); native bool SocketListen(Handle socket, SocketIncomingCB ifunc);
/** /**
* Sends data through the socket. * Sends data through the socket.
@ -368,7 +368,7 @@ native bool:SocketListen(Handle:socket, SocketIncomingCB:ifunc);
* @param String data The data to send. * @param String data The data to send.
* @noreturn * @noreturn
*/ */
native SocketSend(Handle:socket, const String:data[], size=-1); native void SocketSend(Handle socket, const char[] data, int size=-1);
/** /**
* Sends UDP data through the socket to a specific destination. * Sends UDP data through the socket to a specific destination.
@ -386,7 +386,7 @@ native SocketSend(Handle:socket, const String:data[], size=-1);
* @param cell_t port The port to send to. * @param cell_t port The port to send to.
* @noreturn * @noreturn
*/ */
native SocketSendTo(Handle:socket, const String:data[], size=-1, const String:hostname[], port); native void SocketSendTo(Handle socket, const char[] data, int size=-1, const char[] hostname, int port);
/** /**
* Set a socket option. * Set a socket option.
@ -396,7 +396,7 @@ native SocketSendTo(Handle:socket, const String:data[], size=-1, const String:ho
* @param cellt_ value The value to set the option to. * @param cellt_ value The value to set the option to.
* @return cell_t 1 on success. * @return cell_t 1 on success.
*/ */
native SocketSetOption(Handle:socket, SocketOption:option, value); native void SocketSetOption(Handle socket, SocketOption option, int value);
/** /**
@ -409,7 +409,7 @@ native SocketSetOption(Handle:socket, SocketOption:option, value);
* @param SocketReceiveCB rfunc The receive callback * @param SocketReceiveCB rfunc The receive callback
* @noreturn * @noreturn
*/ */
native SocketSetReceiveCallback(Handle:socket, SocketReceiveCB:rfunc); native void SocketSetReceiveCallback(Handle socket, SocketReceiveCB rfunc);
/** /**
* Defines the callback function for when the socket sent all items in its send queue * Defines the callback function for when the socket sent all items in its send queue
@ -422,7 +422,7 @@ native SocketSetReceiveCallback(Handle:socket, SocketReceiveCB:rfunc);
* @param SocketDisconnectCB dfunc The disconnect callback * @param SocketDisconnectCB dfunc The disconnect callback
* @noreturn * @noreturn
*/ */
native SocketSetSendqueueEmptyCallback(Handle:socket, SocketSendqueueEmptyCB:sfunc); native void SocketSetSendqueueEmptyCallback(Handle socket, SocketSendqueueEmptyCB sfunc);
/** /**
* Defines the callback function for when the socket was properly disconnected by the remote side * Defines the callback function for when the socket was properly disconnected by the remote side
@ -434,7 +434,7 @@ native SocketSetSendqueueEmptyCallback(Handle:socket, SocketSendqueueEmptyCB:sfu
* @param SocketDisconnectCB dfunc The disconnect callback * @param SocketDisconnectCB dfunc The disconnect callback
* @noreturn * @noreturn
*/ */
native SocketSetDisconnectCallback(Handle:socket, SocketDisconnectCB:dfunc); native void SocketSetDisconnectCallback(Handle socket, SocketDisconnectCB dfunc);
/** /**
* Defines the callback function for when the socket triggered an error * Defines the callback function for when the socket triggered an error
@ -446,7 +446,7 @@ native SocketSetDisconnectCallback(Handle:socket, SocketDisconnectCB:dfunc);
* @param SocketErrorCB efunc The error callback * @param SocketErrorCB efunc The error callback
* @noreturn * @noreturn
*/ */
native SocketSetErrorCallback(Handle:socket, SocketErrorCB:efunc); native void SocketSetErrorCallback(Handle socket, SocketErrorCB efunc);
/** /**
@ -456,7 +456,7 @@ native SocketSetErrorCallback(Handle:socket, SocketErrorCB:efunc);
* @param any arg The argument to set * @param any arg The argument to set
* @noreturn * @noreturn
*/ */
native SocketSetArg(Handle:socket, any:arg); native void SocketSetArg(Handle socket, any arg);
/** /**
* Retrieve the local system's hostname as the command "hostname" does. * Retrieve the local system's hostname as the command "hostname" does.
@ -466,12 +466,12 @@ native SocketSetArg(Handle:socket, any:arg);
* *
* @return 1 on success * @return 1 on success
*/ */
native SocketGetHostName(String:dest[], destLen); native void SocketGetHostName(char[] dest, int destLen);
/** /**
* _________________Do not edit below this line!_______________________ * _________________Do not edit below this line!_______________________
*/ */
public Extension:__ext_smsock = public Extension __ext_smsock =
{ {
name = "Socket", name = "Socket",
file = "socket.ext", file = "socket.ext",