mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-11 11:35:14 +00:00
Compare commits
No commits in common. "19d2d6d33424fb7e0a8782d13300cf05ce6e8877" and "fb863fcd5e0d6aea0e98a35491cb07ed8c5554af" have entirely different histories.
19d2d6d334
...
fb863fcd5e
7 changed files with 18 additions and 145 deletions
Binary file not shown.
Binary file not shown.
|
@ -7,8 +7,6 @@
|
||||||
#define DEFAULT_SERVER_PORT 7888
|
#define DEFAULT_SERVER_PORT 7888
|
||||||
#define SOCKET_TIMEOUT_DURATION 90.0
|
#define SOCKET_TIMEOUT_DURATION 90.0
|
||||||
|
|
||||||
#define DATABASE_NAME "adminpanel"
|
|
||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
#include <sdktools>
|
#include <sdktools>
|
||||||
#include <ripext>
|
#include <ripext>
|
||||||
|
@ -16,7 +14,6 @@
|
||||||
#include <multicolors>
|
#include <multicolors>
|
||||||
#include <jutils>
|
#include <jutils>
|
||||||
#include <socket>
|
#include <socket>
|
||||||
#include <geoip>
|
|
||||||
#undef REQUIRE_PLUGIN
|
#undef REQUIRE_PLUGIN
|
||||||
#tryinclude <SteamWorks>
|
#tryinclude <SteamWorks>
|
||||||
|
|
||||||
|
@ -92,20 +89,12 @@ GameState g_gameState = State_Hibernating;
|
||||||
Buffer sendBuffer;
|
Buffer sendBuffer;
|
||||||
Buffer receiveBuffer; // Unfortunately there's no easy way to have this not be the same as BUFFER_SIZE
|
Buffer receiveBuffer; // Unfortunately there's no easy way to have this not be the same as BUFFER_SIZE
|
||||||
|
|
||||||
Database g_db;
|
|
||||||
|
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
||||||
// lateLoaded = late;
|
// lateLoaded = late;
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPluginStart() {
|
public void OnPluginStart() {
|
||||||
if(!SQL_CheckConfig(DATABASE_NAME)) {
|
|
||||||
SetFailState("No database entry for '%s'; no database to connect to.", DATABASE_NAME);
|
|
||||||
} else if(!ConnectDB()) {
|
|
||||||
SetFailState("Failed to connect to database.");
|
|
||||||
}
|
|
||||||
|
|
||||||
g_socket = new Socket(SOCKET_TCP, OnSocketError);
|
g_socket = new Socket(SOCKET_TCP, OnSocketError);
|
||||||
g_socket.SetOption(SocketKeepAlive, 1);
|
g_socket.SetOption(SocketKeepAlive, 1);
|
||||||
g_socket.SetOption(SocketReuseAddr, 1);
|
g_socket.SetOption(SocketReuseAddr, 1);
|
||||||
|
@ -137,7 +126,6 @@ public void OnPluginStart() {
|
||||||
cvar_difficulty.AddChangeHook(OnCvarChanged);
|
cvar_difficulty.AddChangeHook(OnCvarChanged);
|
||||||
gameDifficulty = GetDifficultyInt();
|
gameDifficulty = GetDifficultyInt();
|
||||||
|
|
||||||
HookEvent("player_info", Event_PlayerInfo);
|
|
||||||
HookEvent("game_init", Event_GameStart);
|
HookEvent("game_init", Event_GameStart);
|
||||||
HookEvent("game_end", Event_GameEnd);
|
HookEvent("game_end", Event_GameEnd);
|
||||||
HookEvent("heal_begin", Event_HealStart);
|
HookEvent("heal_begin", Event_HealStart);
|
||||||
|
@ -151,7 +139,6 @@ public void OnPluginStart() {
|
||||||
HookEvent("player_death", Event_PlayerDeath);
|
HookEvent("player_death", Event_PlayerDeath);
|
||||||
HookEvent("player_bot_replace", Event_PlayerToBot);
|
HookEvent("player_bot_replace", Event_PlayerToBot);
|
||||||
HookEvent("bot_player_replace", Event_BotToPlayer);
|
HookEvent("bot_player_replace", Event_BotToPlayer);
|
||||||
HookEvent("player_first_spawn", Event_PlayerFirstSpawn);
|
|
||||||
|
|
||||||
campaignStartTime = GetTime();
|
campaignStartTime = GetTime();
|
||||||
char auth[32];
|
char auth[32];
|
||||||
|
@ -173,101 +160,6 @@ public void OnPluginStart() {
|
||||||
|
|
||||||
CreateTimer(300.0, Timer_FullSync, _, TIMER_REPEAT);
|
CreateTimer(300.0, Timer_FullSync, _, TIMER_REPEAT);
|
||||||
}
|
}
|
||||||
bool ConnectDB() {
|
|
||||||
char error[255];
|
|
||||||
g_db = SQL_Connect(DATABASE_NAME, true, error, sizeof(error));
|
|
||||||
if (g_db == null) {
|
|
||||||
LogError("Database error %s", error);
|
|
||||||
delete g_db;
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
PrintToServer("Connected to database %s", DATABASE_NAME);
|
|
||||||
SQL_LockDatabase(g_db);
|
|
||||||
SQL_FastQuery(g_db, "SET NAMES \"UTF8mb4\"");
|
|
||||||
SQL_UnlockDatabase(g_db);
|
|
||||||
g_db.SetCharset("utf8mb4");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Setups a user, this tries to fetch user by steamid
|
|
||||||
void SetupUserInDB(int client) {
|
|
||||||
if(client > 0 && !IsFakeClient(client)) {
|
|
||||||
char country[128];
|
|
||||||
char region[128];
|
|
||||||
char ip[64];
|
|
||||||
if(GetClientIP(client, ip, sizeof(ip))) {
|
|
||||||
GeoipCountry(ip, country, sizeof(country));
|
|
||||||
GeoipRegion(ip, region, sizeof(region));
|
|
||||||
}
|
|
||||||
int time = GetTime();
|
|
||||||
|
|
||||||
char query[512];
|
|
||||||
g_db.Format(query, sizeof(query), "INSERT INTO panel_user "
|
|
||||||
..."(account_id,last_join_time,last_ip,last_country,last_region)"
|
|
||||||
..."VALUES ('%s',%d,'%s','%s','%s')"
|
|
||||||
..."ON DUPLICATE KEY UPDATE last_join_time=%d,last_ip='%s',last_country='%s',last_region='%s';",
|
|
||||||
steamidCache[client][10], // strip STEAM_#:#:##### returning only ending #######
|
|
||||||
// insert:
|
|
||||||
time,
|
|
||||||
ip,
|
|
||||||
country,
|
|
||||||
region,
|
|
||||||
// update:
|
|
||||||
time,
|
|
||||||
ip,
|
|
||||||
country,
|
|
||||||
region
|
|
||||||
);
|
|
||||||
g_db.Query(DBCT_PanelUser, query, GetClientUserId(client));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DBCT_PanelUser(Database db, DBResultSet results, const char[] error, int userId) {
|
|
||||||
if(db == null || results == null) {
|
|
||||||
LogError("DBCT_Insert returned error: %s", error);
|
|
||||||
}
|
|
||||||
int client = GetClientOfUserId(userId);
|
|
||||||
if(client > 0) {
|
|
||||||
char query[128];
|
|
||||||
g_db.Format(query, sizeof(query), "SELECT name FROM panel_user_names WHERE account_id = '%s' ORDER BY name_update_time DESC LIMIT 1", steamidCache[client][10]); // strip STEAM_#:#:##### returning only ending #######
|
|
||||||
g_db.Query(DBCT_CheckUserName, query, userId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DBCT_Insert(Database db, DBResultSet results, const char[] error, any data) {
|
|
||||||
if(db == null || results == null) {
|
|
||||||
LogError("DBCT_Insert returned error: %s", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DBCT_CheckUserName(Database db, DBResultSet results, const char[] error, int userId) {
|
|
||||||
if(db == null || results == null) {
|
|
||||||
LogError("DBCT_CheckUserName returned error: %s", error);
|
|
||||||
} else {
|
|
||||||
int client = GetClientOfUserId(userId);
|
|
||||||
if(client == 0) return; // Client left, ignore
|
|
||||||
|
|
||||||
// Insert new name if we have none, or prev differs
|
|
||||||
bool insertNewName = true;
|
|
||||||
if(results.FetchRow()) {
|
|
||||||
if(nameCache[client][0] == '\0') {
|
|
||||||
LogError("DBCT_CheckUserName user %N(#%d) missing namecache", client, userId);
|
|
||||||
}
|
|
||||||
char prevName[64];
|
|
||||||
results.FetchString(0, prevName, sizeof(prevName));
|
|
||||||
if(StrEqual(prevName, nameCache[client])) {
|
|
||||||
insertNewName = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(insertNewName) {
|
|
||||||
PrintToServer("[AdminPanel] Updating/Inserting name '%s' for %s", nameCache[client], steamidCache[client]);
|
|
||||||
char query[255];
|
|
||||||
g_db.Format(query, sizeof(query), "INSERT INTO panel_user_names (account_id,name,name_update_time) VALUES ('%s','%s',%d)", steamidCache[client][10], nameCache[client], GetTime());
|
|
||||||
g_db.Query(DBCT_Insert, query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stock void Debug(const char[] format, any ...) {
|
stock void Debug(const char[] format, any ...) {
|
||||||
if(!cvar_debug.BoolValue) return;
|
if(!cvar_debug.BoolValue) return;
|
||||||
|
@ -762,20 +654,6 @@ void StopServer() {
|
||||||
ServerCommand("exit");
|
ServerCommand("exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event_PlayerInfo(Event event, const char[] name, bool dontBroadcast) {
|
|
||||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
|
||||||
if(client && !IsFakeClient(client)) {
|
|
||||||
GetClientName(client, nameCache[client], 32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroadcast) {
|
|
||||||
int userid = event.GetInt("userid");
|
|
||||||
int client = GetClientOfUserId(userid);
|
|
||||||
if(client > 0)
|
|
||||||
SetupUserInDB(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Event_GameStart(Event event, const char[] name, bool dontBroadcast) {
|
void Event_GameStart(Event event, const char[] name, bool dontBroadcast) {
|
||||||
campaignStartTime = GetTime();
|
campaignStartTime = GetTime();
|
||||||
g_gameState = State_NewGame;
|
g_gameState = State_NewGame;
|
||||||
|
@ -1047,8 +925,7 @@ void OnCvarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
if(serverPort == 0) serverPort = DEFAULT_SERVER_PORT;
|
if(serverPort == 0) serverPort = DEFAULT_SERVER_PORT;
|
||||||
}
|
}
|
||||||
PrintToServer("[AdminPanel] Sending data to %s:%d", serverIp, serverPort);
|
PrintToServer("[AdminPanel] Sending data to %s:%d", serverIp, serverPort);
|
||||||
if(authToken[0] != '\0')
|
ConnectSocket();
|
||||||
ConnectSocket();
|
|
||||||
}
|
}
|
||||||
} else if(cvar_gamemode == convar) {
|
} else if(cvar_gamemode == convar) {
|
||||||
strcopy(gamemode, sizeof(gamemode), newValue);
|
strcopy(gamemode, sizeof(gamemode), newValue);
|
||||||
|
|
|
@ -336,6 +336,7 @@ Action Command_DoAHat(int client, int args) {
|
||||||
// Find a new hatable entity
|
// Find a new hatable entity
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if(args > 0 && isForced) {
|
if(args > 0 && isForced) {
|
||||||
|
char arg[16];
|
||||||
entity = GetCmdArgInt(1);
|
entity = GetCmdArgInt(1);
|
||||||
} else {
|
} else {
|
||||||
entity = GetLookingEntity(client, Filter_ValidHats);
|
entity = GetLookingEntity(client, Filter_ValidHats);
|
||||||
|
@ -813,6 +814,10 @@ void EquipHat(int client, int entity, const char[] classname = "", int flags = H
|
||||||
SetParentAttachment(modifyEntity, attachPoint, true);
|
SetParentAttachment(modifyEntity, attachPoint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(HasFlag(client, HAT_COMMANDABLE)) {
|
||||||
|
ChooseRandomPosition(hatData[client].offset);
|
||||||
|
L4D2_CommandABot(entity, client, BOT_CMD_MOVE, hatData[client].offset);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SetParent(entity, client);
|
SetParent(entity, client);
|
||||||
SetParentAttachment(modifyEntity, attachPoint, true);
|
SetParentAttachment(modifyEntity, attachPoint, true);
|
||||||
|
|
|
@ -34,9 +34,9 @@ ConVar enabledBlacklist;
|
||||||
#include <editor>
|
#include <editor>
|
||||||
|
|
||||||
public Plugin myinfo = {
|
public Plugin myinfo = {
|
||||||
name = "L4D2 Editor",
|
name = "L4D2 Hats & Editor",
|
||||||
author = "jackzmc",
|
author = "jackzmc",
|
||||||
description = "Advanced prop spawner and entity editing",
|
description = "",
|
||||||
version = PLUGIN_VERSION,
|
version = PLUGIN_VERSION,
|
||||||
url = "https://github.com/Jackzmc/sourcemod-plugins"
|
url = "https://github.com/Jackzmc/sourcemod-plugins"
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,7 +78,7 @@ PlayerItems items[MAXPLAYERS+1];
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "L4D2 5+ Extra Tools & Director",
|
name = "L4D2 Extra Player Tools",
|
||||||
author = "jackzmc",
|
author = "jackzmc",
|
||||||
description = "Automatic system for management of 5+ player games. Provides extra kits, items, and more",
|
description = "Automatic system for management of 5+ player games. Provides extra kits, items, and more",
|
||||||
version = PLUGIN_VERSION,
|
version = PLUGIN_VERSION,
|
||||||
|
|
|
@ -15,7 +15,6 @@ static float EMPTY_ANG[3] = { 0.0, 0.0, 0.0 };
|
||||||
#include <gamemodes/ents>
|
#include <gamemodes/ents>
|
||||||
#include <smlib/effects>
|
#include <smlib/effects>
|
||||||
#include <multicolors>
|
#include <multicolors>
|
||||||
#include <left4dhooks>
|
|
||||||
#include <adminmenu>
|
#include <adminmenu>
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,13 +41,14 @@ char g_currentMap[64];
|
||||||
#include <hats/hat_presets.sp>
|
#include <hats/hat_presets.sp>
|
||||||
|
|
||||||
public Plugin myinfo = {
|
public Plugin myinfo = {
|
||||||
name = "L4D2 Hats",
|
name = "L4D2 Hats & Editor",
|
||||||
author = "jackzmc",
|
author = "jackzmc",
|
||||||
description = "Hat props and cause problems",
|
description = "",
|
||||||
version = PLUGIN_VERSION,
|
version = PLUGIN_VERSION,
|
||||||
url = "https://github.com/Jackzmc/sourcemod-plugins"
|
url = "https://github.com/Jackzmc/sourcemod-plugins"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ArrayList NavAreas;
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
}
|
}
|
||||||
|
@ -343,10 +343,10 @@ void Event_PlayerOutOfIdle(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
|
||||||
void Frame_FixClient(int client) {
|
void Frame_FixClient(int client) {
|
||||||
if(IsClientConnected(client) && GetClientTeam(client) == 2) {
|
if(IsClientConnected(client) && GetClientTeam(client) == 2) {
|
||||||
ClearParent(client);
|
ClearParent(client);
|
||||||
SetEntProp(client, Prop_Send, "m_CollisionGroup", 5);
|
SetEntProp(client, Prop_Send, "m_CollisionGroup", 5);
|
||||||
SetEntProp(client, Prop_Send, "m_nSolidType", 2);
|
SetEntProp(client, Prop_Send, "m_nSolidType", 2);
|
||||||
SetEntityMoveType(client, MOVETYPE_WALK);
|
SetEntityMoveType(client, MOVETYPE_WALK);
|
||||||
}
|
}
|
||||||
// SetEntProp(client, Prop_Send, "movetype", MOVETYPE_ISOMETRIC);
|
// SetEntProp(client, Prop_Send, "movetype", MOVETYPE_ISOMETRIC);
|
||||||
}
|
}
|
||||||
|
@ -574,21 +574,12 @@ public void OnMapStart() {
|
||||||
tempGod[i] = false;
|
tempGod[i] = false;
|
||||||
}
|
}
|
||||||
GetCurrentMap(g_currentMap, sizeof(g_currentMap));
|
GetCurrentMap(g_currentMap, sizeof(g_currentMap));
|
||||||
}
|
NavAreas = GetSpawnLocations();
|
||||||
|
|
||||||
stock bool L4D_IsPlayerCapped(int client) {
|
|
||||||
if(GetEntPropEnt(client, Prop_Send, "m_pummelAttacker") > 0 ||
|
|
||||||
GetEntPropEnt(client, Prop_Send, "m_carryAttacker") > 0 ||
|
|
||||||
GetEntPropEnt(client, Prop_Send, "m_pounceAttacker") > 0 ||
|
|
||||||
GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker") > 0 ||
|
|
||||||
GetEntPropEnt(client, Prop_Send, "m_pounceAttacker") > 0 ||
|
|
||||||
GetEntPropEnt(client, Prop_Send, "m_tongueOwner") > 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnMapEnd() {
|
public void OnMapEnd() {
|
||||||
|
delete NavAreas;
|
||||||
ClearHats();
|
ClearHats();
|
||||||
}
|
}
|
||||||
public void OnPluginEnd() {
|
public void OnPluginEnd() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue