Various fixes and additions.

This commit is contained in:
2017-05-01 23:59:38 +02:00
parent e7597639c2
commit b09747346f
9 changed files with 770 additions and 97 deletions

View File

@ -168,6 +168,7 @@ public OnPluginStart()
public OnAllPluginsLoaded()
{
// Forward event to modules.
RoundEndOnAllPluginsLoaded();
WeaponsOnAllPluginsLoaded();
ConfigOnAllPluginsLoaded();
}
@ -252,8 +253,12 @@ public OnConfigsExecuted()
ConfigOnModulesLoaded();
ClassOnModulesLoaded();
// Fake roundstart
EventRoundStart(INVALID_HANDLE, "", false);
if(g_bLate)
{
new bool:bZombieSpawned = false;
for(new client = 1; client <= MaxClients; client++)
{
if(!IsClientConnected(client))
@ -265,12 +270,24 @@ public OnConfigsExecuted()
{
OnClientPutInServer(client);
if(AreClientCookiesCached(client))
OnClientCookiesCached(client);
if(IsClientAuthorized(client))
OnClientPostAdminCheck(client);
}
if(AreClientCookiesCached(client))
OnClientCookiesCached(client);
if(IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_T)
{
InfectHumanToZombie(client);
bZombieSpawned = true;
}
}
}
if(bZombieSpawned)
{
// Zombies have been infected.
g_bZombieSpawned = true;
}
g_bLate = false;

View File

@ -464,9 +464,6 @@ public Action:InfectMotherZombie(Handle:timer)
return;
}
// Prune list of immune clients.
//eligibleclients = InfectRemoveImmuneClients(arrayEligibleClients);
// Move all clients to CT.
InfectMoveAllToCT();
@ -1187,6 +1184,8 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
else
strcopy(adminname, sizeof(adminname), "Console");
new bool:success = false;
// x = Client index.
for (new x = 0; x < count; x++)
{
@ -1196,13 +1195,6 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
// Check if client is a human before turning into zombie.
if (!InfectIsClientHuman(targets[x]))
{
// If there was only 1 player targetted, then let admin know the command was unsuccessful.
if (count == 1)
{
// Tell admin command was unsuccessful.
TranslationReplyToCommand(client, "Infect command infect unsuccessful", targetname);
}
continue;
}
@ -1211,29 +1203,42 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
{
// Turn client into a mother zombie.
InfectHumanToZombie(targets[x], _, true, respawnoverride, respawn);
LogAction(client, targets[x], "\"%L\" turned \"%L\" into a mother zombie", client, targets[x]);
TranslationPrintToChatAll(false, false, "Infect command infect mother successful public", adminname, targetname);
// If there was only 1 player targetted, then let admin know the outcome of the command.
if (count == 1)
{
TranslationReplyToCommand(client, "Infect command infect mother successful", targetname);
}
// Log action to game events.
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Infect, "Manual Infect", "\"%L\" turned \"%L\" into a mother zombie", client, targets[x]);
success = true;
continue;
}
// Turn client into a zombie.
InfectHumanToZombie(targets[x], _, false, respawnoverride, respawn);
LogAction(client, targets[x], "\"%L\" turned \"%L\" into a zombie", client, targets[x]);
TranslationPrintToChatAll(false, false, "Infect command infect successful public", adminname, targetname);
// If there was only 1 player targetted, then let admin know the outcome of the command.
if (count == 1)
// Log action to game events.
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Infect, "Manual Infect", "\"%L\" turned \"%L\" into a zombie", client, targets[x]);
success = true;
}
// Tell admin the outcome of the command.
if(success)
{
if (!zombiespawned)
{
TranslationReplyToCommand(client, "Infect command infect mother successful", targetname);
TranslationPrintToChatAllExcept(false, false, client, "Infect command infect mother successful public", adminname, targetname);
}
else
{
TranslationReplyToCommand(client, "Infect command infect successful", targetname);
TranslationPrintToChatAllExcept(false, false, client, "Infect command infect successful public", adminname, targetname);
}
}
else
{
// Tell admin command was unsuccessful.
TranslationReplyToCommand(client, "Infect command infect unsuccessful", targetname);
}
}
/**
@ -1256,6 +1261,8 @@ stock InfectManualHuman(client, targets[], count, bool:respawn = false, bool:pro
else
strcopy(adminname, sizeof(adminname), "Console");
new bool:success = false;
// x = Client index.
for (new x = 0; x < count; x++)
{
@ -1267,26 +1274,24 @@ stock InfectManualHuman(client, targets[], count, bool:respawn = false, bool:pro
{
// Turn client into a zombie.
InfectZombieToHuman(targets[x], respawn, protect);
LogAction(client, targets[x], "\"%L\" turned \"%L\" into a human", client, targets[x]);
TranslationPrintToChatAll(false, false, "Infect command human successful public", adminname, targetname);
// If there was only 1 player targetted, then let admin know the outcome of the command.
if (count == 1)
{
// Tell admin command was successful.
TranslationReplyToCommand(client, "Infect command human successful", targetname);
}
}
else
{
// If there was only 1 player targetted, then let admin know the command was unsuccessful.
if (count == 1)
{
// Tell admin command was unsuccessful.
TranslationReplyToCommand(client, "Infect command human unsuccessful", targetname);
}
// Log action to game events.
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Infect, "Manual Human", "\"%L\" turned \"%L\" into a human", client, targets[x]);
success = true;
}
}
// Tell admin the outcome of the command.
if (success)
{
TranslationReplyToCommand(client, "Infect command human successful", targetname);
TranslationPrintToChatAllExcept(false, false, client, "Infect command human successful public", adminname, targetname);
}
else
{
TranslationReplyToCommand(client, "Infect command human unsuccessful", targetname);
}
}
/**

View File

@ -1202,8 +1202,11 @@ ClassClientSetDefaultIndexes(client = -1)
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = humanindex;
ClassSelected[client][ZR_CLASS_TEAM_ADMINS] = adminindex;
// Copy human class data to player cache.
ClassReloadPlayerCache(client, humanindex);
// Copy class data to player cache.
if (InfectIsClientInfected(client))
ClassReloadPlayerCache(client, zombieindex);
else
ClassReloadPlayerCache(client, humanindex);
// Save indexes in cookies if enabled, and not already saved.
if (saveclasses)

View File

@ -25,6 +25,22 @@
* ============================================================================
*/
/* Decide whether topmenus should be required */
#if !defined REQUIRE_PLUGIN
#if defined REQUIRE_EXTENSIONS
#define TEMP_REQUIRE_EXTENSIONS
#undef REQUIRE_EXTENSIONS
#endif
#endif
#tryinclude "sourcetvmanager.inc"
/* Restore old REQUIRE_EXTENSIONS value if necessary */
#if defined TEMP_REQUIRE_EXTENSIONS
#define REQUIRE_EXTENSIONS
#undef TEMP_REQUIRE_EXTENSIONS
#endif
/**
* @section All round end reasons.
*/
@ -69,6 +85,19 @@ enum RoundEndOutcome
*/
new Handle:g_tRoundEnd = INVALID_HANDLE;
new bool:g_SourceTVManagerLoaded = false;
/**
* All plugins have finished loading.
*/
RoundEndOnAllPluginsLoaded()
{
#if defined _stvmngr_included
g_SourceTVManagerLoaded = LibraryExists("sourcetvmanager");
LogMessage("SourceTV Manager: %s", (g_SourceTVManagerLoaded ? "loaded" : "not loaded"));
#endif
}
/**
* Map is starting.
*/
@ -239,6 +268,14 @@ RoundEndDisplayStats()
PrintToConsole(client, "# %8s %40s %24s %5s %6s",
sPlayerID, sPlayerName, sPlayerAuth, sPlayerState, sPlayerTeam);
}
#if defined _stvmngr_included
if(g_SourceTVManagerLoaded)
{
SourceTV_PrintToDemoConsole("# %8s %40s %24s %5s %6s",
sPlayerID, sPlayerName, sPlayerAuth, sPlayerState, sPlayerTeam);
}
#endif
}
}

View File

@ -179,6 +179,67 @@ stock TranslationPrintToChatAll(bool:server, bool:admin, any:...)
}
}
/**
* Format the string to the plugin's style.
*
* @param server True to also print text to server console, false just to clients.
* @param admin True to only print text to admins, false to print to everyone.
* @param ... Translation formatting parameters.
*/
stock TranslationPrintToChatAllExcept(bool:server, bool:admin, client, any:...)
{
decl String:translation[TRANSLATION_MAX_LENGTH_CHAT];
if (server)
{
// Set translation target
SetGlobalTransTarget(LANG_SERVER);
// Translate phrase.
VFormat(translation, sizeof(translation), "%t", 4);
// Format string to create plugin style.
TranslationPluginFormatString(translation, sizeof(translation), false);
// Print phrase to server.
PrintToServer(translation);
}
// x = client index.
for (new x = 1; x <= MaxClients; x++)
{
// Ignore this client
if (x == client)
{
continue;
}
// If client isn't in-game, then stop.
if (!IsClientInGame(x))
{
continue;
}
// If client isn't an admin, and we're only printing to admins, then stop.
if (admin && !ZRIsClientAdmin(x))
{
continue;
}
// Set translation target to client.
SetGlobalTransTarget(x);
// Translate phrase.
VFormat(translation, sizeof(translation), "%t", 4);
// Format string to create plugin style.
TranslationPluginFormatString(translation, sizeof(translation));
// Print translated phrase to client.
PrintToChat(x, translation);
}
}
/**
* Print console text to client. (with style)
*

View File

@ -329,17 +329,26 @@ public ZSpawnForceHandle(Handle:menu_zspawn_force, MenuAction:action, client, sl
}
// Get the target's name for future use.
decl String:targetname[MAX_NAME_LENGTH];
decl String:targetname[MAX_NAME_LENGTH], String:adminname[MAX_NAME_LENGTH];
GetClientName(target, targetname, sizeof(targetname));
// Get admin's name for future use.
if(client > 0)
GetClientName(client, adminname, sizeof(adminname));
else
strcopy(adminname, sizeof(adminname), "Console");
// Force ZSpawn on the target.
new bool:success = ZSpawnClient(target, true);
// Tell admin the outcome of the action.
if (success)
{
LogAction(client, target, "\"%L\" forced a ZSpawn on \"%L\"", client, target);
// Log action to game events.
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_ZSpawn, "Force ZSpawn", "\"%L\" force zspawned \"%L\" as human", client, target);
TranslationReplyToCommand(client, "ZSpawn command force successful", targetname);
TranslationPrintToChatAllExcept(false, false, client, "ZSpawn command force successful public", adminname, targetname, "human");
}
else
{
@ -441,35 +450,31 @@ public Action:ZSpawnForceCommand(client, argc)
// Copy value of second (optional) parameter to 'zombie'.
// It will be false if the parameter wasn't specified.
new bool:zombie = bool:StringToInt(strZombie);
new bool:success = false;
// x = Client index.
for (new x = 0; x < result; x++)
{
// Give client the item.
new bool:success = ZSpawnClient(targets[x], true, zombie);
if(success)
// Spawn client
if (ZSpawnClient(targets[x], true, zombie))
{
LogAction(client, targets[x], "\"%L\" forced a ZSpawn on \"%L\"%s", client, targets[x], zombie ? " and made them zombie" : "");
TranslationPrintToChatAll(false, false, "ZSpawn command force successful public", adminname, targetname, zombie ? "zombie" : "human");
}
// Log action to game events.
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_ZSpawn, "Force ZSpawn", "\"%L\" force zspawned \"%L\" as %s", client, targets[x], zombie ? "zombie" : "human");
// Tell admin the outcome of the command if only 1 client was targetted.
if (result == 1)
{
if (success)
{
TranslationReplyToCommand(client, "ZSpawn command force successful", targetname);
}
else
{
TranslationReplyToCommand(client, "ZSpawn command force unsuccessful", targetname);
}
success = true;
}
}
// Log action to game events.
//LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_ZSpawn, "Force ZSpawn", "Admin \"%L\" forced player(s) to spawn. (zr_zspawn_force)", client);
// Tell admin the outcome of the command.
if (success)
{
TranslationReplyToCommand(client, "ZSpawn command force successful", targetname);
TranslationPrintToChatAllExcept(false, false, client, "ZSpawn command force successful public", adminname, targetname, zombie ? "zombie" : "human");
}
else
{
TranslationReplyToCommand(client, "ZSpawn command force unsuccessful", targetname);
}
return Plugin_Handled;
}

View File

@ -34,7 +34,7 @@
/**
* Array to store client's spawn location.
*/
float g_vecZTeleSpawn[MAXPLAYERS + 1][3];
float g_vecZTeleSpawn[MAXPLAYERS + 1][2][3];
/**
* Array to store client's current location.
@ -56,7 +56,7 @@ Handle tZTele[MAXPLAYERS + 1];
*/
int g_iZTeleTimeLeft[MAXPLAYERS + 1];
float g_vecZTeleSpawnPoints[MAX_PLAYER_SPAWNS][3];
float g_vecZTeleSpawnPoints[MAX_PLAYER_SPAWNS][2][3];
int g_iZTeleSpawnPointsCount = 0;
/**
@ -82,7 +82,8 @@ void ZTeleOnRoundStart()
GetEntityClassname(entity, classname, sizeof(classname));
if (StrEqual(classname, "info_player_terrorist", true) || StrEqual(classname, "info_player_counterterrorist", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", g_vecZTeleSpawnPoints[g_iZTeleSpawnPointsCount]);
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", g_vecZTeleSpawnPoints[g_iZTeleSpawnPointsCount][0]);
GetEntPropVector(entity, Prop_Send, "m_angRotation", g_vecZTeleSpawnPoints[g_iZTeleSpawnPointsCount][1]);
g_iZTeleSpawnPointsCount++;
if (g_iZTeleSpawnPointsCount >= MAX_PLAYER_SPAWNS)
@ -114,7 +115,8 @@ void ZTele_OnClientSpawn(int client)
g_iZTeleCount[client] = 0;
// Get spawn location.
GetClientAbsOrigin(client, g_vecZTeleSpawn[client]);
GetClientAbsOrigin(client, g_vecZTeleSpawn[client][0]);
GetClientAbsAngles(client, g_vecZTeleSpawn[client][1]);
ZTele_StopTimer(client);
}
@ -245,11 +247,11 @@ void ZTele_TeleportClient(int client)
if (ZTele_IsRandomSpawnEnabled() && g_iZTeleSpawnPointsCount)
{
int select = Math_GetRandomInt(0, g_iZTeleSpawnPointsCount - 1);
TeleportEntity(client, g_vecZTeleSpawnPoints[select], NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
TeleportEntity(client, g_vecZTeleSpawnPoints[select][0], g_vecZTeleSpawnPoints[select][1], NULL_VECTOR);
}
else
{
TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
TeleportEntity(client, g_vecZTeleSpawn[client][0], g_vecZTeleSpawn[client][1], NULL_VECTOR);
}
}
@ -445,7 +447,7 @@ public Action ZTele_Timer(Handle timer, int client)
if (g_iZTeleTimeLeft[client] <= 0)
{
// Teleport client.
TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, NULL_VECTOR);
TeleportEntity(client, g_vecZTeleSpawn[client][0], g_vecZTeleSpawn[client][1], NULL_VECTOR);
// Increment teleport count.
g_iZTeleCount[client]++;