Commit bacbc4f3 authored by Neoony's avatar Neoony
Browse files

v0.1 WIP2

Fixed fail to start the vote first time
Changed lobby redirect command to client command
parent 26647a20
Pipeline #3338 passed with stages
in 1 minute and 57 seconds
......@@ -6,6 +6,15 @@ Latest **dev** version: https://sourcemod.docs.empiresmod.com/Lobby/addons/sourc
--
**Server Commands:**
**"l_query"**
*"Debug, query the servers status"*
**"l_queryx"**
*"Debug, query the servers status and print data to server console"*
**"l_startvote"**
*"Force start the server vote"*
**Cvars:**
**"l_minplayers"** *"def. 8"*
......
......@@ -20,7 +20,7 @@
#include <sdkhooks>
//#include <emputils>
#define PluginVer "v0.1 WIP1.1"
#define PluginVer "v0.1 WIP2"
public Plugin myinfo =
{
......@@ -85,6 +85,8 @@ public void OnPluginStart()
RegServerCmd("l_query", SCommand_LQuery);
RegServerCmd("l_queryx", SCommand_LQueryx);
RegServerCmd("l_startvote", SCommand_StartVote);
StartSQL();
//Cvars
......@@ -94,6 +96,7 @@ public void OnPluginStart()
l_threshold = CreateConVar("l_threshold", "50", "Percantage needed for successful vote (Percentage, max 100)");
l_restrictvote = CreateConVar("l_restrictvote", "30", "For how long to restrict the vote starting, after a vote happened (Seconds)");
//Updater
if (LibraryExists("updater"))
{
Updater_AddPlugin(UPDATE_URL);
......@@ -359,18 +362,18 @@ public void InfoOfServer(Handle hDriver, Handle hResult, const char[] sError, in
SQL_FetchRow(hResult);
//Name
SQL_FetchString(hResult, 0, namex[ServerIndex], 256);
PrintToServer("[Database] name: %s", namex[ServerIndex]);
//PrintToServer("[Database] name: %s", namex[ServerIndex]);
//Address
SQL_FetchString(hResult, 1, addrx[ServerIndex], 256);
PrintToServer("[Database] addr: %s", addrx[ServerIndex]);
//PrintToServer("[Database] addr: %s", addrx[ServerIndex]);
//Players
SQL_FetchString(hResult, 2, playersx[ServerIndex], 256);
PrintToServer("[Database] players: %s", playersx[ServerIndex]);
//PrintToServer("[Database] players: %s", playersx[ServerIndex]);
//Maxplayers
SQL_FetchString(hResult, 3, maxplayersx[ServerIndex], 256);
PrintToServer("[Database] maxplayers: %s", maxplayersx[ServerIndex]);
PrintToServer("[Database] rowCount: %i", rowCount);
PrintToServer("[Database] ServerIndex: %i", ServerIndex);
//PrintToServer("[Database] maxplayers: %s", maxplayersx[ServerIndex]);
//PrintToServer("[Database] rowCount: %i", rowCount);
//PrintToServer("[Database] ServerIndex: %i", ServerIndex);
// Use SQL_FetchRow(hResult) to fetch a row
// and then SQL_FetchInt(hResult, 0) to get the first column in the fetched row of the result
......@@ -395,6 +398,7 @@ public Action PlayerCountChk(Handle timer)
PrintToChatAll("\x04[L] \x01Player amount required has been reached");
PrintToChatAll("\x04[L] \x01Creating a vote to join a server in\x073399ff 5\x01 seconds");
StartVoteTimer = CreateTimer(5.0, StartVoteTmr, _, TIMER_REPEAT);
QueryNumberOfServers();
votestarted = 1;
//Clear timer
if (PlayerCountCheck != INVALID_HANDLE)
......@@ -413,23 +417,20 @@ public Action StartVoteTmr(Handle timer)
KillTimer(StartVoteTimer);
StartVoteTimer = INVALID_HANDLE;
}
QueryNumberOfServers();
StartVote();
}
public Action StartVote()
{
{
int[] Players = new int[MaxClients+1];
int PlayersCount;
for (int i = 1; i <= MaxClients; i++)
if (IsClientInGame(i) && !IsFakeClient(i))
{
//&& !IsFakeClient(i))
if (IsClientInGame(i) && !IsFakeClient(i))
{
Players[PlayersCount++] = i;
}
Players[PlayersCount++] = i;
}
VoteInfo[VOTE_INFO_NUMCLIENTS] = PlayersCount;
......@@ -512,7 +513,11 @@ public Action VoteSuccessful(int param1)
public Action StartConnectDialog(int param1)
{
ServerCommand("lobby_redirect %s", addrx[param1]);
for (int client = 1; client <= MaxClients; client++)
if (IsClientInGame(client))
{
ClientCommand(client, "lobby_redirect %s", addrx[param1]);
}
}
public Action RestrictVt(Handle timer)
......@@ -537,5 +542,28 @@ public Action ConnectDialogTmr(Handle timer, int param1)
KillTimer(ConnectDialogTimer);
ConnectDialogTimer = INVALID_HANDLE;
}
PrintToChatAll("\x04[L] \x01Connect dialog\x07008000 started");
PrintToChatAll("\x04[L] \x01Redirecting\x07008000 players...");
}
public Action SCommand_StartVote(int args)
{
if (votestarted == 0 && IsVoteInProgress() == false)
{
PrintToChatAll("\x04[L] \x01Server forced a vote to join a server in\x073399ff 5\x01 seconds");
StartVoteTimer = CreateTimer(5.0, StartVoteTmr, _, TIMER_REPEAT);
QueryNumberOfServers();
votestarted = 1;
//Clear timer
if (PlayerCountCheck != INVALID_HANDLE)
{
KillTimer(PlayerCountCheck);
PlayerCountCheck = INVALID_HANDLE;
}
//Clear timer
if (RestrictVote != INVALID_HANDLE)
{
KillTimer(RestrictVote);
RestrictVote = INVALID_HANDLE;
}
}
}
\ No newline at end of file
......@@ -4,12 +4,14 @@
{
"Version"
{
"Latest" "v0.1 WIP1.1"
"Latest" "v0.1 WIP2"
}
"Notes" "First release"
"Notes" "WIP1: Updated database name"
"Notes" "WIP1.1: Downgraded SM version for compile on git."
"Notes" "WIP1.1: Downgraded SM version for compile on git"
"Notes" "WIP2: Fixed fail to start the vote first time"
"Notes" "WIP2: Changed lobby redirect command to client command"
}
"Files"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment