sm-zombiereloaded-3/src/zr/playerclasses/classevents.inc
richard 4117519b39 Added command for modifying or scaling class attributes. Minior fixes, see details.
Fixed error getting default classes on early player connect (bots, source tv, etc.).
Fixed jump boost not resetting height velocity. Changed to add to velocity. Jump from boost platform still doesn't work because the velocity is set too early.
Added check for reserved class names when validating.
Updated class default attributes and jump limits.
2009-05-10 18:49:47 +02:00

140 lines
3.9 KiB
SourcePawn

/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: classevents.inc
* Type: Core
* Description: Functions for handling class related events.
*
* ============================================================================
*/
/* ------------------------------------
*
* GAME EVENTS
*
* ------------------------------------
*/
/**
* To be called when a client connect to the server.
* (OnClientPutInServer)
*/
ClassClientInit(client)
{
// Check if there are valid classes and the client is valid.
if (ClassValidated && ZRIsClientValid(client))
{
// Set default class indexes on the player.
ClassClientSetDefaultIndexes(client);
}
}
/**
* Called when all modules are done loading.
*/
ClassOnModulesLoaded()
{
// Set default classes on all player slots.
ClassClientSetDefaultIndexes();
}
ClassOnClientDisconnect(client)
{
// Disable class attributes with timers.
ClassHealthRegenStop(client);
ClassOverlayStop(client);
}
ClassOnClientSpawn(client)
{
// Check if the player is alive.
if (!IsPlayerAlive(client))
{
return;
}
// Check if there are valid classes. Block this event if classes aren't
// done loading.
if (!ClassValidated)
{
return;
}
new bool:randomclass = GetConVarBool(g_hCvarsList[CVAR_CLASSES_RANDOM]);
decl String:steamid[16];
decl String:classname[64];
// Assign random classes if enabled. Always do it for bots.
GetClientAuthString(client, steamid, sizeof(steamid));
if (randomclass || StrEqual(steamid, "BOT"))
{
// Get random classes for each type.
new randomzombie = ClassGetRandomClass(ZR_CLASS_TEAM_ZOMBIES);
new randomhuman = ClassGetRandomClass(ZR_CLASS_TEAM_HUMANS);
// Mark zombie class as selected.
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = randomzombie;
ClassGetName(randomzombie, classname, sizeof(classname), ZR_CLASS_TEAM_ZOMBIES);
ZR_PrintToChat(client, "Auto-assign", classname);
// Mark human class as selected.
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = randomhuman;
ClassGetName(randomhuman, classname, sizeof(classname), ZR_CLASS_TEAM_HUMANS);
ZR_PrintToChat(client, "Auto-assign", classname);
// Update player cache with the human class data, and apply it.
ClassReloadPlayerCache(client, randomhuman);
ClassApplyAttributes(client);
}
// Check if the player should spawn in admin mode.
if (ClassPlayerAdminMode[client])
{
// Mark player as in admin mode.
ClassPlayerInAdminMode[client] = true;
// Update player cache with the admin class and apply attributes.
new adminindex = ClassPlayerNextAdminClass[client];
ClassReloadPlayerCache(client, adminindex);
ClassApplyAttributes(client);
}
else
{
// Mark player as not in admin mode.
ClassPlayerInAdminMode[client] = false;
// Apply class attributes for the currently active class.
ClassReloadPlayerCache(client, ClassGetActiveIndex(client));
ClassApplyAttributes(client);
}
}
ClassOnClientDeath(client)
{
// Disable class attributes with timers.
ClassHealthRegenStop(client);
ClassOverlayStop(client);
// Set client's FOV back to normal.
ToolsSetClientDefaultFOV(client, 90);
}
ClassOnClientInfected(client, bool:motherzombie = false)
{
new classindex = ClassGetActiveIndex(client);
// Disable class attributes with timers.
ClassHealthRegenStop(client);
ClassOverlayStop(client);
// Update the players cache with zombie attributes.
ClassReloadPlayerCache(client, classindex);
// Apply the new attributes.
ClassApplyAttributes(client, motherzombie);
}