added SharedPlugin code and SetNTVOptional()

added public printing for zr_human, zr_infect and zr_zspawn_force command
fixed zombiereloaded changing player colors
updated sample cfg
updated makefile
This commit is contained in:
2016-04-22 01:24:10 +02:00
parent a732205f8c
commit 2d1cdf7a36
12 changed files with 218 additions and 13 deletions

View File

@ -34,3 +34,34 @@
#include <zr/infect.zr>
#include <zr/respawn.zr>
#include <zr/class.zr>
public SharedPlugin:__pl_zombiereloaded =
{
name = "zombiereloaded",
file = "zombiereloaded.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_zombiereloaded_SetNTVOptional()
{
MarkNativeAsOptional("ZR_IsValidClassIndex");
MarkNativeAsOptional("ZR_GetActiveClass");
MarkNativeAsOptional("ZR_SelectClientClass");
MarkNativeAsOptional("ZR_GetClassByName");
MarkNativeAsOptional("ZR_GetClassDisplayName");
MarkNativeAsOptional("ZR_IsClientZombie");
MarkNativeAsOptional("ZR_IsClientHuman");
MarkNativeAsOptional("ZR_InfectClient");
MarkNativeAsOptional("ZR_HumanClient");
MarkNativeAsOptional("ZR_RespawnClient");
MarkNativeAsOptional("ZR_SetKilledByWorld");
MarkNativeAsOptional("ZR_GetKilledByWorld");
}
#endif

View File

@ -38,12 +38,14 @@
/**
* Results when selecting a class for a player.
*/
#if !defined INCLUDED_BY_ZOMBIERELOADED
enum ClassSelectResult
{
ClassSelected_NoChange, /** No class change was necessary (class already selected). */
ClassSelected_Instant, /** Class was instantly changed. */
ClassSelected_NextSpawn /** Class will be used next spawn. */
}
#endif
/**
* Returns whether a class index is valid or not.

View File

@ -33,6 +33,9 @@
#include <sdktools>
#include <clientprefs>
#include <cstrike>
#define INCLUDED_BY_ZOMBIERELOADED
#include <zombiereloaded>
#undef INCLUDED_BY_ZOMBIERELOADED
#if defined USE_SDKHOOKS
#include <sdkhooks>
@ -145,6 +148,9 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
// Load API.
APIInit();
// Register library
RegPluginLibrary("zombiereloaded");
// Let plugin load.
return APLRes_Success;
}

View File

@ -284,8 +284,7 @@ InfectOnClientSpawn(client)
CS_RespawnPlayer(client);
}
// Unglitch kevlar. (Reset hitbox to HITBOX_GENERIC)
SetEntData(client, 4444, 0, 4);
InfectUnglitchKevlar(client);
}
/**
@ -875,8 +874,7 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
SpawnProtectStart(client);
}
// Unglitch kevlar. (Reset hitbox to HITBOX_GENERIC)
SetEntData(client, 4444, 0, 4);
InfectUnglitchKevlar(client);
// Forward event to modules.
SEffectsOnClientHuman(client);
@ -1185,6 +1183,13 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
}
decl String:targetname[MAX_NAME_LENGTH];
decl String:adminname[MAX_NAME_LENGTH];
// Get admin's name for later use.
if(client > 0)
GetClientName(client, adminname, sizeof(adminname));
else
strcopy(adminname, sizeof(adminname), "Console");
// x = Client index.
for (new x = 0; x < count; x++)
@ -1211,6 +1216,7 @@ 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)
@ -1224,6 +1230,7 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
// 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)
@ -1245,6 +1252,13 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
stock InfectManualHuman(client, targets[], count, bool:respawn = false, bool:protect = false)
{
decl String:targetname[MAX_NAME_LENGTH];
decl String:adminname[MAX_NAME_LENGTH];
// Get admin's name for later use.
if(client > 0)
GetClientName(client, adminname, sizeof(adminname));
else
strcopy(adminname, sizeof(adminname), "Console");
// x = Client index.
for (new x = 0; x < count; x++)
@ -1258,6 +1272,7 @@ 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)
@ -1486,3 +1501,14 @@ InfectMode:InfectGetModeOrFail()
return mode;
}
InfectUnglitchKevlar(client)
{
// Unglitch kevlar. (Reset hitbox to HITBOX_GENERIC)
// Example: You get hit in the head by a bullet as a zombie
// the round ends, you spawn as a human.
// You get damaged by a trigger, the game still thinks you
// are getting damaged in the head hitgroup, >mfw source engine.
// Thanks to leaked 2007 Source Engine Code.
SetEntData(client, 4444, 0, 4);
}

View File

@ -194,8 +194,12 @@ stock ToolsSetClientAlpha(client, alpha)
// Turn rendermode on, on the client.
SetEntityRenderMode(client, RENDER_TRANSALPHA);
// Get current client colors.
new color[4];
ToolsGetEntityColor(client, color);
// Set alpha value on the client.
SetEntityRenderColor(client, _, _, _, alpha);
SetEntityRenderColor(client, color[0], color[1], color[2], alpha);
// Forward event to modules.
WeaponAlphaOnClientAlphaChanged(client, alpha);
@ -230,3 +234,34 @@ stock ToolsGetEntityAlpha(entity)
return GetEntData(entity, offset + 3, 1);
}
/**
* Gets an entity's color and alpha.
*
* @param client The client index.
* @param color 4 dimensional array where [r,g,b,a] values are stored
*/
stock ToolsGetEntityColor(entity, color[4])
{
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_clrRender");
}
gotconfig = true;
}
new offset = GetEntSendPropOffs(entity, prop);
for (new i = 0; i < 4; i++)
color[i] = GetEntData(entity, offset + i, 1);
}

View File

@ -412,12 +412,18 @@ public Action:ZSpawnForceCommand(client, argc)
return Plugin_Handled;
}
decl String:target[MAX_NAME_LENGTH], String:targetname[MAX_NAME_LENGTH];
decl String:target[MAX_NAME_LENGTH], String:targetname[MAX_NAME_LENGTH], String:adminname[MAX_NAME_LENGTH];
new targets[MAXPLAYERS], bool:tn_is_ml, result;
// Get targetname.
GetCmdArg(1, target, sizeof(target));
// Get admin's name for later use.
if(client > 0)
GetClientName(client, adminname, sizeof(adminname));
else
strcopy(adminname, sizeof(adminname), "Console");
// Find a target.
result = ProcessTargetString(target, client, targets, sizeof(targets), COMMAND_FILTER_DEAD, targetname, sizeof(targetname), tn_is_ml);
@ -441,7 +447,12 @@ public Action:ZSpawnForceCommand(client, argc)
{
// Give client the item.
new bool:success = ZSpawnClient(targets[x], true, zombie);
LogAction(client, targets[x], "\"%L\" forced a ZSpawn on \"%L\"%s", client, targets[x], zombie ? " and made them zombie" : "");
if(success)
{
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");
}
// Tell admin the outcome of the command if only 1 client was targetted.
if (result == 1)