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
LUGU

Как определять написал ли игрок чат?

Собрался написать скрипт, который телепортировал бы игрока на определенные координаты, при написании в чат !base. Однако не смог найти обработчик событий чата. Как проверить написал ли игрок что-то в чат, что именно и что за игрок это сделал?

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1

тут 2 варианта:
1. через событие миссии в init.c 

class CustomMission: MissionServer
{
    // ...
    // тут всякий инициализационный код

	override void OnEvent(EventType eventTypeId, Param params) {
		super.OnEvent(eventTypeId,params);
		switch(eventTypeId) {
			case ChatMessageEventTypeID:
			ChatMessageEventParams chat_params = ChatMessageEventParams.Cast(params);
			if (chat_params.param2 != "" && chat_params.param3 != "" && chat_params.param3.Substring(0,1) == "/") {
                array<Man> players = new array<Man>;
				GetGame().GetPlayers( players );
				PlayerBase pb;
				for (int i = 0; i < players.Count(); i++)
				{
					if (Class.CastTo(pb, players.Get(i)) && pb.GetIdentity() && pb.GetIdentity().GetName() == param2)
					{
						// вот тут обрабатываешь конанду
                        // то что в chat_params.param3 это то что ввел игрок
						return;
					}
				}
			}
			break;
		}
	} 
}

но есть баг, что если игрок не имеет имени или быстро перезаходил и имеет имя вроде User 1, где 1 добавлена системой входа, то этот игрок не сможет пользоваться командами

2. ловить на игроке RPC, муторно описывать, но работоспособно и не имеет бага как в первом случае
а как быстрый способ сойдет первый

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

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