/* Прописываем в Init.c данный конфиг
#include "$CurrentDir:mpmissions\"Папка Миссии"\Speedrun.c"
*/
ref SpeedrunTimer m_SpeedrunTimer = new SpeedrunTimer();
class SpeedrunTimer
{
ref TStringArray unlimitedStamina = {
//"ClassName предмета, с помощью которого будет бесканечная стамина"
};
ref TStringArray gasMaskTimer = {
//"ClassName предмета, с помощью которого будет заторможенная стамина"
};
ref array<EntityAI> objects = new array<EntityAI>;
void SpeedrunTimer()
{
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.SpeedTimer, 1 * 500, true)
}
void SpeedTimer()
{
//GetGame().GetServerFPS();
//Print();
int MASK_TIMER = 5000 * 2;
ref array<Man> players = new array<Man>;
GetGame().GetPlayers( players );
for ( int i = 0; i < players.Count(); i++ )
{
PlayerBase player = PlayerBase.Cast(players.Get(i));
if(!player.IsAlive())
return;
int attachmentCount = player.GetInventory().AttachmentCount();
for (int aItem = 0; aItem < attachmentCount; aItem++)
{
EntityAI attachment = player.GetInventory().GetAttachmentFromIndex(aItem);
if (attachment.IsItemBase())
{
ItemBase item = ItemBase.Cast(attachment);
if (unlimitedStamina.Find(item.GetType()) >= 0 )
{
player.GetStaminaHandler().SetStamina(100);
}
if (gasMaskTimer.Find(item.GetType()) >= 0 )
{
float health_remove = 0;
int attachCount = item.GetInventory().AttachmentCount();
if (attachCount > 0) {
for ( int x = 0; x < attachCount; x++ )
{
ItemBase itemFilter = ItemBase.Cast( item.GetInventory().GetAttachmentFromIndex( x ) );
if (itemFilter.GetHealth("", "Health") > 0) {
health_remove = itemFilter.GetMaxHealth()/MASK_TIMER;
itemFilter.DecreaseHealth( "", "", health_remove );
itemFilter.AddHealth("", "", -health_remove);
itemFilter.SetQuantity(Math.Round(itemFilter.GetQuantityMax()*(itemFilter.GetHealth()))/(itemFilter.GetMaxHealth()));
}
else {
player.AddHealth("", "Health", -0.1);
}
}
}
else {
if (item.GetHealth("", "Health") > 0 ) {
health_remove = item.GetMaxHealth()/MASK_TIMER;
item.DecreaseHealth( "", "", health_remove );
item.AddHealth("", "", -health_remove);
item.SetQuantity(Math.Round(item.GetQuantityMax()*(item.GetHealth()))/(item.GetMaxHealth()));
}
else {
player.AddHealth("", "Health", -0.1);
}
}
}
}
}
}
}
}
Возможно есть ошибки, но у меня корректно работает на чистом серве... Приятного пользования!
мой диск: ᴍᴇʟɴɪᴋᴏᴠ#3249