plane/test.sp

158 lines
3.6 KiB
SourcePawn
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <sourcemod>
#include <string>
#include "socket.inc"
#define MY_SOCKET_IP "localhost"
#define MY_SOCKET_PORT 3500
#define STEAMID_LENGTH 128
char teamCT[6][150];
char teamT[6][150];
public Plugin myinfo =
{
name = "InfoLan 2021 Bot",
author = "rick@gnous.eu",
description = "Bot communiquant avec le bot discord \
https://github.com/Lunki51/cs-picker afin dautomatiser \
lInfoLan 2021",
version = "1.0",
url = "https://git.gnous.eu/Rick/infolanBot"
};
/* bool = GetClientAuthId()
public void OnClientConnected(int client)
{
char clientId[65];
bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId,
sizeof(clientId), true);
if (!allGood)
{
PrintToServer("Erreur Fatale !");
}
else
{
allGood = false;
int i = 1;
while (!allGood && i < sizeof(teamCT))
{
if (teamCT[i] == clientId)
{
CS_SwitchTeam(client, 3);
CS_SetClientClanTag(client, teamCT[0]);
allGood = true;
}
else if (teamT[i] == clientId)
{
CS_SwitchTeam(client, 2);
CS_SetClientClanTag(client, teamT[0]);
allGood = true;
}
i++;
}
if (!allGood)
{
KickClient(client, "Vous nêtes pas autorisé à suivre / jouer \
sur ce serveur !");
// check si casteur ou admin
// sinon ban
}
}
}
/*
* !team
*
*
*/
public Action SetTeam(int args)
{
char arg[128];
char full[256];
GetCmdArgString(full, sizeof(full));
PrintToServer("Je reçois %d arguments qui sont : %s", args, full);
GetCmdArg(1, arg, sizeof(arg));
int team = (!strcmp(arg, "ct", false) ? 1 : 2);
PrintToServer("L,équipe choisi est %d", team);
if (args == 7)
{
for(int i = 2; i <= args; i++)
{
GetCmdArg(i, arg, sizeof(arg));
if (team == 1)
{
teamCT[i - 2] = arg;
}
else
{
teamT[i - 2] = arg;
}
PrintToServer("%d cest la demande %s", i - 2, arg);
}
}
else
{
PrintToServer("Erreur, pas assez dargs");
}
return Plugin_Handled;
}
public void OnSocketReceive(Handle socket, const char[] datas, const int data, any arg) {}
/* envoie information plugin */
public void OnMapEnd()
{
/* kick tout le monde */
}
public void OnSocketConnected(Handle socket, any arg)
{
char requestStr[150];
Format(requestStr, sizeof(requestStr), "%s", "Source Engine Query");
/*
FormatEx(
requestStr,
sizeof(requestStr),
"GET /%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n",
"prout",
"mario"
);
*/
SocketSend(socket, requestStr, 150);
}
public OnSocketDisconnected(Handle socket, any arg)
{
CloseHandle(socket);
}
public void OnSocketError(Handle socket, const int errorType, const int errorNum, any arg)
{
PrintToServer("[ERROR] Le socket a rencontré une erreur !");
CloseHandle(socket);
}
public void EnvoiInfo(Event event, const char[] name, bool dontBroadcast)
{
Handle socket = SocketCreate(SOCKET_TCP, OnSocketError);
SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT);
}
public void OnPluginStart()
{
/*cs_win_panel_match*/
HookEvent("cs_win_panel_match", EnvoiInfo);
RegServerCmd("!team", SetTeam);
PrintToServer("Hello world!");
PrintToServer("==== REQUETE ENVOYÉE ====");
}