InfinityX と呼ばれる Crysis Wars Server Side Modification の新しいバージョンを開始しました。管理を改善するために、見栄えが良く、関数をグループ化できるように関数をテーブル内に配置しました (Core.PlayerHandle:GetIp(player) のように) が、問題が発生しました。問題は、プレーヤーの名前を取得するために指定されたメソッドが、player:GetName()
実際には完全に有効であるにもかかわらず、無効なメソッドと見なされていることです。
以下の構造を使用すると問題が発生するかどうか、問題が発生する場合は修正方法を教えてください。この構造を関数に使用するのはこれが初めてですが、使用していた古い方法よりも簡単であることが既に証明されています。
コード:
Event =
{
PlayerConnect = function(player)
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
Event:Log("Connect", player);
end;
};
以下のコードは、関数をバイパスしてコードを必要な場所に直接配置すると機能します。
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
エラー:
[警告] [Lua エラー] infinityx/main/core.events.lua:23: メソッド 'GetName' を呼び出そうとしています (nil 値)
PlayerConnect、(infinityx/main/core.events.lua: 23) ConnectScript、(infinityx/main/core.main.lua: 52) OnClientEnteredGame、(scripts/gamerules/instantaction.lua: 511) (null) (scripts/gamerules /teaminstantaction.lua: 520)
明確化をいただければ幸いです。ありがとう :)