Enregistrement du numéro de port

This commit is contained in:
rick 2021-05-19 00:30:56 +02:00
parent 702693e156
commit 5f669ede19
Signed by: Rick
GPG key ID: 2B593F087240EE99

35
test.sp
View file

@ -12,6 +12,8 @@ char teamCT[6][150];
char teamT[6][150];
char clientId[128];
int port = -1;
public Plugin myinfo =
{
name = "InfoLan 2021 Bot",
@ -33,6 +35,14 @@ public void OnPluginStart()
PrintToServer("Hello world!");
}
public void OnConfigsExecuted()
{
if (port < 0)
{
port = GetConVarInt(FindConVar("hostport"));
}
}
//public void OnClientAuthorized(int client, const char[] auth)
public void SuperTest(Event event, const char[] name, bool dontBroadcast)
{
@ -127,14 +137,25 @@ public void ServeurLibre(Event event, const char[] name, bool dontBroadcast)
{
// requete post pour match fini et serveur libre
Handle socket = SocketCreate(SOCKET_TCP, OnSocketError);
//SocketSetArg(socket, CS_GetTeamScore(CS_TEAM_T), CS_GetTeamScore(CS_TEAM_CT));
//SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT);
SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT);
}
public void SocketUpdateScore(Handle socket, int t, int ct) {}
public void SocketUpdateScore(Handle socket, int t, int ct)
{
char requestStr[512];
FormatEx(
requestStr,
sizeof(requestStr),
"POST /api/csgo/updatescore HTTP/1.0\r\n\
Host: Serveur\r\n\
Content-type: text/json\r\n\
{\"port\": %d, \"ct\": %d, \"t\": %d}", port,
CS_GetTeamScore(CS_TEAM_CT), CS_GetTeamScore(CS_TEAM_T)
);
SocketSend(socket, requestStr, 512);
}
public void SocketEnvoieVictoire(Handle socket, int t, int ct)
public void SocketEnvoieVictoire(Handle socket, any arg)
{
char requestStr[512];
FormatEx(
@ -143,8 +164,8 @@ public void SocketEnvoieVictoire(Handle socket, int t, int ct)
"POST /api/csgo/matchend HTTP/1.0\r\n\
Host: Serveur\r\n\
Content-type: text/json\r\n\
{\"serverport\": XXXXXX, \"available\": \"true\"}"
)
{\"serverport\": %s, \"available\": \"true\"}"
);
}
public void OnSocketConnected(Handle socket, any arg)