update to latest version
This commit is contained in:
parent
a78558ac2e
commit
80a79eb635
@ -1,11 +1,10 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdkhooks>
|
||||
#include <sdktools>
|
||||
#include <multicolors>
|
||||
#include <zombiereloaded>
|
||||
|
||||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
/* CONVARS */
|
||||
@ -29,7 +28,6 @@ bool g_bPreAdminChecked[MAXPLAYERS+1];
|
||||
bool g_bResponseFailed[MAXPLAYERS+1];
|
||||
bool g_bResponsePassed[MAXPLAYERS+1];
|
||||
|
||||
|
||||
/* INTEGERS */
|
||||
int g_iCollected[MAXPLAYERS+1];
|
||||
int g_iCounter = 0;
|
||||
@ -42,7 +40,7 @@ public Plugin myinfo =
|
||||
name = "UNLOZE Season Event (XMAS)",
|
||||
author = "Neon",
|
||||
description = "UNLOZE Season Event (XMAS)",
|
||||
version = "2.0",
|
||||
version = "2.1",
|
||||
url = "https://steamcommunity.com/id/n3ontm"
|
||||
};
|
||||
|
||||
@ -69,13 +67,6 @@ public void OnPluginStart()
|
||||
RegConsoleCmd("sm_highscore", Command_HighScore, "Shows the Present HighScore");
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
char sError[256];
|
||||
if (SQL_CheckConfig("season"))
|
||||
g_hDatabase = SQL_Connect("season", true, sError, sizeof(sError));
|
||||
|
||||
if (g_hDatabase == null)
|
||||
LogError("Could not connect to database: %s", sError);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -242,6 +233,45 @@ public void OnMapStart()
|
||||
CreateTimer(fRandomInterval, SpawnCollectable, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
Database.Connect(SQL_OnDatabaseConnect, "season");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
||||
{
|
||||
if(!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_hDatabase = db;
|
||||
|
||||
char sQuery[256];
|
||||
Format(sQuery, sizeof(sQuery), "CREATE TABLE IF NOT EXISTS xmas_table (`steam_auth` varchar(64), `name` varchar(256), `collected` int(16), PRIMARY KEY (`steam_auth`), INDEX (`collected`))");
|
||||
|
||||
g_hDatabase.Query(SQL_OnTableCreated, sQuery, _, DBPrio_High);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void SQL_OnTableCreated(Database db, DBResultSet results, const char[] error, any data)
|
||||
{
|
||||
if(!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -300,30 +330,35 @@ public void OnClientAuthorized(int client, const char[] sSteamID32)
|
||||
char sSteamID[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
||||
|
||||
char sQuery[255];
|
||||
char sQuery[256];
|
||||
Format(sQuery, sizeof(sQuery), "SELECT collected FROM xmas_table WHERE steam_auth = '%s'", sSteamID);
|
||||
SQL_TQuery(g_hDatabase, TQueryCBConnect, sQuery, GetClientUserId(client));
|
||||
g_hDatabase.Query(SQL_OnQueryCompletedFetch, sQuery, GetClientSerial(client));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TQueryCBConnect(Handle owner, Handle rs, const char[] error, any data)
|
||||
public void SQL_OnQueryCompletedFetch(Database db, DBResultSet results, const char[] error, int iSerial)
|
||||
{
|
||||
int client = 0;
|
||||
|
||||
if ((client = GetClientOfUserId(data)) == 0)
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(iSerial)) == 0)
|
||||
return;
|
||||
|
||||
if (SQL_GetRowCount(rs) > 0)
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
int iField;
|
||||
SQL_FetchRow(rs);
|
||||
SQL_FieldNameToNum(rs, "collected", iField);
|
||||
g_iCollected[client] = SQL_FetchInt(rs, iField);
|
||||
LogError("Query error: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
delete rs;
|
||||
if (results.RowCount && results.FetchRow())
|
||||
{
|
||||
int iFieldNum;
|
||||
|
||||
results.FieldNameToNum("collected", iFieldNum);
|
||||
g_iCollected[client] = results.FetchInt(iFieldNum);
|
||||
}
|
||||
else
|
||||
g_iCollected[client] = 0;
|
||||
|
||||
g_bResponsePassed[client] = true;
|
||||
if (g_bPreAdminChecked[client])
|
||||
@ -357,6 +392,9 @@ public void OnClientPostAdminFilter(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
if (!g_hCVar_CollectablesEnabled.BoolValue)
|
||||
return;
|
||||
|
||||
g_iCounter = 0;
|
||||
CreateTimer(10.0, CheckPlayerCount, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
@ -381,39 +419,44 @@ public Action Command_HighScore(int client, int args)
|
||||
{
|
||||
char sQuery[255];
|
||||
Format(sQuery, sizeof(sQuery), "SELECT * from xmas_table order by collected desc limit %d", g_hCVar_HighscoreDisplay.IntValue);
|
||||
SQL_TQuery(g_hDatabase, TQueryCBHighscore, sQuery, GetClientUserId(client));
|
||||
g_hDatabase.Query(SQL_OnQueryCompletedHighscore, sQuery, GetClientSerial(client));
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TQueryCBHighscore(Handle owner, Handle rs, const char[] error, any data)
|
||||
public void SQL_OnQueryCompletedHighscore(Database db, DBResultSet results, const char[] error, int iSerial)
|
||||
{
|
||||
int client = 0;
|
||||
|
||||
if ((client = GetClientOfUserId(data)) == 0)
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(iSerial)) == 0)
|
||||
return;
|
||||
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
LogError("Query error: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
char sBuffer[2048] = "{green}[UNLOZE XMAS] {white}TOP COLLECTORS:\n";
|
||||
char sTempBuffer[1024] = "";
|
||||
|
||||
for(int i = 1; i <= g_hCVar_HighscoreDisplay.IntValue; i++)
|
||||
{
|
||||
int iField;
|
||||
SQL_FetchRow(rs);
|
||||
int iFieldNum;
|
||||
if (!results.FetchRow())
|
||||
break;
|
||||
|
||||
SQL_FieldNameToNum(rs, "name", iField);
|
||||
SQL_FetchString(rs, iField, sName, sizeof(sName));
|
||||
results.FieldNameToNum("name", iFieldNum);
|
||||
results.FetchString(iFieldNum, sName, sizeof(sName));
|
||||
|
||||
SQL_FieldNameToNum(rs, "collected", iField);
|
||||
int iCollected = SQL_FetchInt(rs, iField);
|
||||
results.FieldNameToNum("collected", iFieldNum);
|
||||
int iCollected = results.FetchInt(iFieldNum);
|
||||
|
||||
Format(sTempBuffer, sizeof(sTempBuffer), "{green}%d: %s - {red}%d \n", i, sName, iCollected);
|
||||
StrCat(sBuffer, sizeof(sBuffer), sTempBuffer);
|
||||
}
|
||||
delete rs;
|
||||
|
||||
CPrintToChat(client, sBuffer);
|
||||
}
|
||||
@ -426,34 +469,37 @@ public Action Command_Collected(int client, int args)
|
||||
char sSteamID[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
||||
|
||||
char sQuery[255];
|
||||
char sQuery[256];
|
||||
Format(sQuery, sizeof(sQuery), "SELECT collected FROM xmas_table WHERE steam_auth = '%s'", sSteamID);
|
||||
SQL_TQuery(g_hDatabase, TQueryCBCollected, sQuery, GetClientUserId(client));
|
||||
g_hDatabase.Query(SQL_OnQueryCompletedCheck, sQuery, GetClientSerial(client));
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void TQueryCBCollected(Handle owner, Handle rs, const char[] error, any data)
|
||||
public void SQL_OnQueryCompletedCheck(Database db, DBResultSet results, const char[] error, int iSerial)
|
||||
{
|
||||
int client = 0;
|
||||
|
||||
if ((client = GetClientOfUserId(data)) == 0)
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(iSerial)) == 0)
|
||||
return;
|
||||
|
||||
if (SQL_GetRowCount(rs) > 0)
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
int iField;
|
||||
SQL_FetchRow(rs);
|
||||
SQL_FieldNameToNum(rs, "collected", iField);
|
||||
g_iCollected[client] = SQL_FetchInt(rs, iField);
|
||||
LogError("Query error: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (results.RowCount && results.FetchRow())
|
||||
{
|
||||
int iFieldNum;
|
||||
|
||||
results.FieldNameToNum("collected", iFieldNum);
|
||||
g_iCollected[client] = results.FetchInt(iFieldNum);
|
||||
}
|
||||
else
|
||||
g_iCollected[client] = 0;
|
||||
|
||||
delete rs;
|
||||
|
||||
CPrintToChat(client, "{green}[UNLOZE XMAS] {white}You have collected {green}%d {white}presents so far.", g_iCollected[client]);
|
||||
|
||||
if ((g_iCollected[client] > g_hCVar_MilestoneInfection.IntValue) && (g_iCollected[client] > g_hCVar_MilestoneSkin.IntValue))
|
||||
@ -497,7 +543,6 @@ public Action SpawnCollectable(Handle timer)
|
||||
SetEntityBBox(iRotating, view_as<float>({-10.0, -1.0, -1.0}), view_as<float>({1.0, 1.0, 1.0}));
|
||||
SetEntityProps(iRotating);
|
||||
|
||||
|
||||
// Model
|
||||
int iModel = CreateEntityAtOrigin("prop_dynamic_override", fOrigin);
|
||||
DispatchKeyFormat(iModel, "targetname", "season_prop_%d", g_iCounter);
|
||||
@ -645,10 +690,12 @@ public void HookCallback(const char[] output, int caller, int activator, float d
|
||||
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
char sSafeName[(2*MAX_NAME_LENGTH)+1];
|
||||
g_hDatabase.Escape(sName, sSafeName, sizeof(sSafeName));
|
||||
|
||||
char sQuery[255];
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO xmas_table (steam_auth,name,collected) VALUES ('%s','%s',1) ON DUPLICATE KEY UPDATE collected=collected+1;", sSteamID, sName);
|
||||
SQL_FastQuery(g_hDatabase, sQuery);
|
||||
char sQuery[256];
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO xmas_table (steam_auth,name,collected) VALUES ('%s','%s',1) ON DUPLICATE KEY UPDATE collected=collected+1;", sSteamID, sSafeName);
|
||||
g_hDatabase.Query(SQL_OnQueryCompletedUpdate, sQuery);
|
||||
|
||||
g_iCollected[client] += 1;
|
||||
CheckAndAddFlag(client);
|
||||
@ -666,12 +713,30 @@ public void HookCallback(const char[] output, int caller, int activator, float d
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void SQL_OnQueryCompletedUpdate(Database db, DBResultSet results, const char[] error, any data)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
LogError("Query error: %s", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||
{
|
||||
if (!g_hCVar_InfectionEffectEnabled.BoolValue)
|
||||
return;
|
||||
|
||||
if (!IsValidClient(attacker))
|
||||
return;
|
||||
|
||||
if (g_hCVar_InfectionEffectEnabled.BoolValue && ((g_iCollected[client] >= g_hCVar_MilestoneInfection.IntValue) || g_iCollected[attacker] >= g_hCVar_MilestoneInfection.IntValue))
|
||||
if (g_iCollected[client] >= g_hCVar_MilestoneInfection.IntValue || g_iCollected[attacker] >= g_hCVar_MilestoneInfection.IntValue)
|
||||
{
|
||||
float fInfectionOrigin[3];
|
||||
GetClientAbsOrigin(client, fInfectionOrigin);
|
||||
@ -749,57 +814,60 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo
|
||||
|
||||
public void OnEntitySpawned(int Entity, const char[] sClassname)
|
||||
{
|
||||
if (StrContains(sClassname, "_projectile", false) == -1)
|
||||
return;
|
||||
|
||||
int iOwner = GetEntPropEnt(Entity, Prop_Data, "m_hOwnerEntity");
|
||||
if(!IsValidClient(iOwner))
|
||||
return;
|
||||
|
||||
if (g_iCollected[iOwner] >= g_hCVar_MilestoneGrenade.IntValue)
|
||||
if (g_iCollected[iOwner] < g_hCVar_MilestoneGrenade.IntValue)
|
||||
return;
|
||||
|
||||
SetEntityRenderMode(Entity, RENDER_NONE);
|
||||
|
||||
float fNadeOrigin[3];
|
||||
GetEntPropVector(Entity, Prop_Send, "m_vecOrigin", fNadeOrigin);
|
||||
|
||||
int iNadeProp = CreateEntityAtOrigin("prop_dynamic_override", fNadeOrigin);
|
||||
DispatchKeyFormat(iNadeProp, "targetname", "season_nade_prop_%d", g_iCounter);
|
||||
DispatchKeyFormat(iNadeProp, "disableshadows", "1");
|
||||
DispatchKeyFormat(iNadeProp, "disablereceiveshadows", "1");
|
||||
DispatchKeyFormat(iNadeProp, "DisableBoneFollowers", "1");
|
||||
|
||||
int iRandomSkin = GetRandomInt(0, 3);
|
||||
if (iRandomSkin == 0)
|
||||
{
|
||||
SetEntityRenderMode(Entity, RENDER_NONE);
|
||||
|
||||
float fNadeOrigin[3];
|
||||
GetEntPropVector(Entity, Prop_Send, "m_vecOrigin", fNadeOrigin);
|
||||
|
||||
int iNadeProp = CreateEntityAtOrigin("prop_dynamic_override", fNadeOrigin);
|
||||
DispatchKeyFormat(iNadeProp, "targetname", "season_nade_prop_%d", g_iCounter);
|
||||
DispatchKeyFormat(iNadeProp, "disableshadows", "1");
|
||||
DispatchKeyFormat(iNadeProp, "disablereceiveshadows", "1");
|
||||
DispatchKeyFormat(iNadeProp, "DisableBoneFollowers", "1");
|
||||
|
||||
int iRandomSkin = GetRandomInt(0, 3);
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/weapons/w_snowball_thrown.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "3.0");
|
||||
}
|
||||
else if (iRandomSkin == 1)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/zombieden/xmas/giftbox.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "0.6");
|
||||
iRandomSkin = GetRandomInt(0, 1);
|
||||
if (iRandomSkin == 0)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/weapons/w_snowball_thrown.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "3.0");
|
||||
DispatchKeyFormat(iNadeProp, "skin", "0");
|
||||
}
|
||||
else if (iRandomSkin == 1)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/zombieden/xmas/giftbox.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "0.6");
|
||||
iRandomSkin = GetRandomInt(0, 1);
|
||||
if (iRandomSkin == 0)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "skin", "0");
|
||||
}
|
||||
else if (iRandomSkin == 1)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "skin", "1");
|
||||
}
|
||||
DispatchKeyFormat(iNadeProp, "skin", "1");
|
||||
}
|
||||
else if (iRandomSkin == 2)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/weapons/w_ornament_thrown.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "2.0");
|
||||
}
|
||||
else if (iRandomSkin == 3)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/weapons/w_santa_hat_thrown.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "2.3");
|
||||
}
|
||||
|
||||
SpawnAndActivate(iNadeProp);
|
||||
ParentToEntity(iNadeProp, Entity);
|
||||
}
|
||||
else if (iRandomSkin == 2)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/weapons/w_ornament_thrown.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "2.0");
|
||||
}
|
||||
else if (iRandomSkin == 3)
|
||||
{
|
||||
DispatchKeyFormat(iNadeProp, "model", "models/weapons/w_santa_hat_thrown.mdl");
|
||||
DispatchKeyFormat(iNadeProp, "modelscale", "2.3");
|
||||
}
|
||||
|
||||
SpawnAndActivate(iNadeProp);
|
||||
ParentToEntity(iNadeProp, Entity);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user