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
  • 0
nike871

Сообщение в чат через VPPAdminTools

Приветствую. Извиняюсь за нелепые вопросы, я новичок в этом деле.

Суть, при выполнении DisableBuildingStaticMisc.SelfChatMessage(#login") в чат падает сообщение, белого цвета (примерно такого формата: ": здесь строится нельзя")

SelfChatMessage как я понимаю - это собственное сообщение. в данном случае сообщение ни от кого. Т.Е нет идентификатора отправителя.

modded class ActionDeployObject
{
	override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
	{
 		if (super.ActionCondition(player, target, item))
		{
			if (GetGame().IsClient())
			{
				if ((!player.GetDisableBuildManager().CanBuildInThisZone(item) && !player.GetDisableBuildManager().HasAllowItem(item)))
				{
					player.CancelPlacing();
					return false;
				}
			}
		}
		return super.ActionCondition(player, target, item);
	}
}
modded class ActionTogglePlaceObject
{
	override void Start( ActionData action_data ) //Setup on start of action
	{
		PlayerBase player = PlayerBase.Cast(action_data.m_Player);
		if (!player.GetDisableBuildManager().CanBuildInThisZone() && !player.GetDisableBuildManager().HasAllowItem(action_data.m_MainItem))
		{
			DisableBuildingStaticMisc.SelfChatMessage(#login");
			return;
		}
		else
		{
			super.Start( action_data );
		}
	}
}	

 

Далее, есть кусок кода где реализовано такое же сообщение, но уже через средства VPPAdminTools (т.е как я понимаю используются уведомления VPPAdminTools)

 

ref NoBuildZonesSettings m_NoBuildZonesSettings;

class NoBuildZonesSettings
{
    protected static string NoBZ_CONFIG = "$profile:NoBuildZones.json";

    bool EnableMessages = true;
    bool UseNotifications = true;
    float RefreshTimer = 1;
    static string Prefix = "NO BUILD ZONE";
    static string WarningMessage = "You are too close to $$0$$ to build.";
    ref array<string> IgnoredItems;
    ref array<ref NoBZ_Location> NoBuildZones;

    void NoBuildZonesSettings()
    {
        IgnoredItems = new ref array<string>;
        NoBuildZones = new ref array<ref NoBZ_Location>;
    }

    static string GetWarningMessage( string Description = "" )
    {
        string NewWarningMessage = m_NoBuildZonesSettings.WarningMessage;
        NewWarningMessage.Replace( "$$0$$", Description );
        return NewWarningMessage;
    }

    void SendWarningMessage( PlayerBase player )
    {
        bool NotificationWasSent = false;
        string message = GetWarningMessage( player.GetNoBZDesc() );
        if ( EnableMessages )
        {
            if ( UseNotifications )
            {
                string icon = "nobuild/Data/NoBuildZoneIcon.edds";
                PlayerIdentity sender = player.GetIdentity();
                #ifdef JM_COT
                if ( !NotificationWasSent )
                {
                    NotificationSystem.CreateNotification( new StringLocaliser( m_NoBuildZonesSettings.Prefix ), new StringLocaliser( message ), icon, ARGB( 255, 231, 76, 60 ), 7, sender );
                    NotificationWasSent = false;
                }
                #endif
                #ifdef VPPADMINTOOLS
                if ( !NotificationWasSent && GetGame().IsClient() )
                {
                    VPPNotificationManager.SendMessage( new VPPMessageProps( m_NoBuildZonesSettings.Prefix, message, 5.0, 1.0, icon ), sender );
                    NotificationWasSent = false;
                }
                #endif
                if ( !NotificationWasSent ) SendChatMessage( player )

            } else {
                SendChatMessage( player );
            }
        }
    }

    void SendChatMessage( PlayerBase player )
    {
        Param2<string, string> NoBZVars = new Param2<string, string>( player.GetNoBZName(), player.GetNoBZDesc() );
        ScriptRPC rpc = new ScriptRPC();
        GetGame().RPCSingleParam( player, NOBUILDZONE.NOBZ_MESSAGE, NoBZVars, true, player.GetIdentity() ) ;
    }

    bool ShouldUseNotifications()
    {
        if ( UseNotifications )
        {
            #ifdef JM_COT
            return UseNotifications;
            #endif
            #ifdef VPPADMINTOOLS
            return UseNotifications;
            #endif
            return false;
        }
        return true;
    }

    vector NoBZLocationToVector( float x, float y )
    {
        string sPosition = "" + x + " " + GetGame().SurfaceY(x, y) + " " + y;
        return sPosition.ToVector();
    }

    void Load()
    {
        ref NoBuildZonesSettings settings = new NoBuildZonesSettings();

        if ( FileExist( NoBZ_CONFIG ) )
        {
            JsonFileLoader<NoBuildZonesSettings>.JsonLoadFile( NoBZ_CONFIG, this );
        } else {
            IgnoredItems.Insert( "Fireplace" );
            NoBuildZones.Insert( new ref NoBZ_Location( "No build zone 1 exmaple", "zone 1 example", 7500, 7500, 1000 ) );
            JsonFileLoader<NoBuildZonesSettings>.JsonSaveFile( NoBZ_CONFIG, this );
        }
    }
}

static ref NoBuildZonesSettings NoBZ()
{
    if (!m_NoBuildZonesSettings)
    {
        m_NoBuildZonesSettings = new NoBuildZonesSettings;
        m_NoBuildZonesSettings.Load();
    }
    return m_NoBuildZonesSettings;
};

При выполнении этого кода, в чат падает сообщение красного цвета (примерно такое " [NoBuild]: запрещено строиться тут, отойдите чуть дальше.

 

Кто нибудь, ткните носом куда копать. Хотелось было переделать  DisableBuildingStaticMisc.SelfChatMessage(#login")  под уведомления VPPAdminTools. 

Сильно тапками не кидайте...Только только пытаюсь раскурить что и к чему.

 

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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

×
×
  • 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.