Made a admin command for refreshing class data on one or more players.
Updated infect module to use new reload function. Fixed typo in command description. Known issue: Models isn't always restored on zr_human. If "default" is used, there's practically no model change. Possible solution: Store path in a buffer when the player join a team and select a model. Then read from that buffer when "default" is used.
This commit is contained in:
parent
9cac025358
commit
4d48cd65de
@ -694,7 +694,7 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
|
||||
TranslationPrintToChat(client, "Infect human");
|
||||
|
||||
// Forward event to modules.
|
||||
ClassOnClientInfected(client, false);
|
||||
ClassReloadPlayer(client);
|
||||
RoundEndOnClientInfected();
|
||||
ZTeleOnClientInfected(client);
|
||||
|
||||
|
@ -34,7 +34,8 @@ ClassOnCommandsCreate()
|
||||
RegConsoleCmd("zr_class_dump", ClassDumpCommand, "Dumps class data at a specified index in the specified cache. Usage: zr_class_dump <cachetype> <index|targetname>");
|
||||
RegConsoleCmd("zr_class_dump_multipliers", ClassDumpMultipliersCommand, "Dumps class attribute multipliers for the specified team. Usage: zr_class_dump_multipliers <\"zombies\"|\"humans\">");
|
||||
RegAdminCmd("zr_class_modify", ClassModifyCommand, ADMFLAG_CONFIG, "Modify class data on one or more classes. Usage: zr_class_modify <classname|\"zombies\"|\"humans\"|\"admins\"> <attribute> <value> [is_multiplier]");
|
||||
RegAdminCmd("zr_class_set_multiplier", ClassSetMultiplierCommand, ADMFLAG_CONFIG, "Sets the multiplier on a class attribute. Usage: zr_class_set multiplier <\"zombies\"|\"humans\"> <attribute> <value>");
|
||||
RegAdminCmd("zr_class_set_multiplier", ClassSetMultiplierCommand, ADMFLAG_CONFIG, "Sets the multiplier on a class attribute. Usage: zr_class_set_multiplier <\"zombies\"|\"humans\"> <attribute> <value>");
|
||||
RegAdminCmd("zr_class_reload", ClassReloadCommand, ADMFLAG_GENERIC, "Refreshes the player cache and reloads class attributes on one or more players. Usage: zr_class_reload <target>");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -483,7 +484,7 @@ public Action:ClassSetMultiplierCommand(client, argc)
|
||||
if (argc < 3)
|
||||
{
|
||||
// Write syntax info.
|
||||
StrCat(syntax, sizeof(syntax), "Sets the multiplier on a class attribute. Usage: zr_class_set multiplier <\"zombies\"|\"humans\"> <attribute> <value>\n\n");
|
||||
StrCat(syntax, sizeof(syntax), "Sets the multiplier on a class attribute. Usage: zr_class_set_multiplier <\"zombies\"|\"humans\"> <attribute> <value>\n\n");
|
||||
StrCat(syntax, sizeof(syntax), "Valid attributes:\n----------------------------------------\n");
|
||||
StrCat(syntax, sizeof(syntax), "napalm_time\nhealth\nhealth_regen_interval\nhealth_regen_amount\nhealth_infect_gain\nspeed\nknockback\njump_height\njump_distance");
|
||||
ReplyToCommand(client, syntax);
|
||||
@ -538,6 +539,59 @@ public Action:ClassSetMultiplierCommand(client, argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Command callback. (zr_class_reload)
|
||||
* Dumps class data at a specified index in the specified cache.
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param argc Argument count.
|
||||
*/
|
||||
public Action:ClassReloadCommand(client, argc)
|
||||
{
|
||||
decl String:arg[MAX_TARGET_LENGTH];
|
||||
decl String:targetname[MAX_TARGET_LENGTH];
|
||||
new targetlist[MAXPLAYERS + 1];
|
||||
new targetcount;
|
||||
new bool:tn_is_ml;
|
||||
|
||||
if (argc < 1)
|
||||
{
|
||||
// Write syntax info.
|
||||
ReplyToCommand(client, "Refreshes the player cache and reloads class attributes on one or more players. Usage: zr_class_reload <target>");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
// Get the target string.
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
// Get target clients.
|
||||
if ((targetcount = ProcessTargetString(arg, client, targetlist, sizeof(targetlist), 0, targetname, sizeof(targetname), tn_is_ml)) <= 0)
|
||||
{
|
||||
// Failed to get targets.
|
||||
ReplyToTargetError(client, targetcount);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
// Loop through each target.
|
||||
for (new target = 0; target < targetcount; target++)
|
||||
{
|
||||
ClassReloadPlayer(targetlist[target]);
|
||||
}
|
||||
|
||||
// Check phrase format.
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ReplyToCommand(client, "Refreshed cache to %t.", targetname);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToCommand(client, "Refreshed cache to %s.", targetname);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify class boolean attribute on a class.
|
||||
*
|
||||
|
@ -18,8 +18,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* To be called when a client connect to the server.
|
||||
* (OnClientPutInServer)
|
||||
* Called when a client connects to the server (OnClientPutInServer).
|
||||
*/
|
||||
ClassClientInit(client)
|
||||
{
|
||||
@ -45,6 +44,9 @@ ClassOnModulesLoaded()
|
||||
ClassClientSetDefaultIndexes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called a client disconnects.
|
||||
*/
|
||||
ClassOnClientDisconnect(client)
|
||||
{
|
||||
// Disable class attributes with timers.
|
||||
@ -127,6 +129,12 @@ ClassOnClientSpawn(client)
|
||||
ClassOverlayOnClientSpawn(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client died. Stops timers and reset certain attributes. Call this event to
|
||||
* clean up class related stuff.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
ClassOnClientDeath(client)
|
||||
{
|
||||
// Disable class attributes with timers.
|
||||
@ -139,6 +147,11 @@ ClassOnClientDeath(client)
|
||||
ClassOverlayOnClientDeath(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client got infected. Reloads class attributes.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
ClassOnClientInfected(client, bool:motherzombie = false)
|
||||
{
|
||||
new classindex = ClassGetActiveIndex(client);
|
||||
|
@ -717,6 +717,33 @@ bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIF
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the specified player's cache and re-apply attributes.
|
||||
*
|
||||
* @param client The client index.
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
bool:ClassReloadPlayer(client)
|
||||
{
|
||||
new activeclass;
|
||||
|
||||
// Get active class index.
|
||||
activeclass = ClassGetActiveIndex(client);
|
||||
|
||||
// Validate index.
|
||||
if (activeclass < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Refresh cache and re-apply attributes.
|
||||
ClassOnClientDeath(client); // Dummy event to clean up stuff.
|
||||
ClassReloadPlayerCache(client, activeclass);
|
||||
ClassApplyAttributes(client);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all class attribute multipliers to 1.0.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user