Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
Sign in to follow this  
Melnikov

Бесконечная стамина при ношении предмета NEW 06.02.2023

Recommended Posts

/* Прописываем в 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

Share this post


Link to post
Share on other sites



🤦‍♂️ это при каком онлайне работает корректно? Один, два? Запусти на сервере с 30+

Share this post


Link to post
Share on other sites
8 часов назад, Equadro сказал:

🤦‍♂️ это при каком онлайне работает корректно? Один, два? Запусти на сервере с 30+

Проверили на серваке, при онлайне 50+, работает, да не совсем корректно (Скорее всего серверный ФПС страдает, ибо 200/300 ну такое)...
Стамина нормально восстанавливается. В добавок, я указывал, что могут быть ошибки... я не указывал, что конфиг идеален.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.