【传奇服务器爱好者】-IGE引擎M2-Plug-In-zPlugOfEngine

本文档介绍了传奇服务器插件zPlugOfEngine的开发,包括插件初始化、配置、用户命令管理和消息过滤等功能。通过示例代码展示了如何添加、删除和修改用户自定义命令,以及实现消息过滤和物品操作限制。
摘要由CSDN通过智能技术生成

插件开发-zPlugOfEngine

提示:初始化DLL
const
PlugName = ‘网络引擎功能插件 (2016/8/18)’;
LoadPlus = ‘正在加载网络引擎功能插件’;
nFindObj = 5;
nPlugHandle = 6;
type
TMsgProc = procedure(Msg: PChar; nMsgLen: Integer; nMode: Integer); stdcall;
TFindProc = function(sProcName: PChar; nNameLen: Integer): Pointer; stdcall;
TFindObj = function(sObjName: PChar; nNameLen: Integer): TObject; stdcall;
TSetProc = function(ProcAddr: Pointer; ProcName: PChar; nNameLen: Integer): Boolean; stdcall;
TGetFunAddr = function(nIndex: Integer): Pointer; stdcall;
function Init(AppHandle: HWnd; MsgProc: TMsgProc; FindProc: TFindProc; SetProc: TSetProc; GetFunAddr: TGetFunAddr): PChar; stdcall;
//var
//FindObj: TFindObj;
begin
PlugHandle := 0;
MsgProc(LoadPlus, length(LoadPlus), 0);
//FindObj := TFindObj(GetFunAddr(nFindObj));
PlugHandle := PInteger(GetFunAddr(nPlugHandle))^;
InitPlug();
Result := PlugName;
end;

procedure UnInit();
begin
UnInitPlug();
end;

procedure Config(); stdcall;
begin
FrmFunctionConfig := TFrmFunctionConfig.Create(nil);
FrmFunctionConfig.Open();
FrmFunctionConfig.Free;
end;

exports
Init, UnInit, Config;

提示:包含引擎的开发API包
在这里插入图片描述
提示:插件设置界面
在这里插入图片描述procedure TFrmFunctionConfig.Open();
var
I: Integer;
StdItem: _LPTOSTDITEM;
List: Classes.TList;
begin
boOpened := False;
boModValued := False;
ButtonUserCommandDel.Enabled := False;
ButtonUserCommandChg.Enabled := False;
ButtonDisallowDel.Enabled := False;
ButtonMsgFilterDel.Enabled := False;
ButtonMsgFilterChg.Enabled := False;
ListBoxitemList.Items.Clear;
ListBoxUserCommand.Items.Clear;
List := Classes.TList(TUserEngine_GetStdItemList);
for I := 0 to List.Count - 1 do begin
StdItem := List.Items[I];
ListBoxitemList.Items.AddObject(StdItem.szName, TObject(StdItem));
end;
RefLoadMsgFilterList();
RefLoadDisallowStdItems();
ListBoxUserCommand.Items.Clear;
ListBoxUserCommand.Items.AddStrings(g_UserCmdList);
boOpened := True;
FunctionConfigControl.ActivePageIndex := 0;
ShowModal;
end;

procedure TFrmFunctionConfig.ListBoxUserCommandClick(Sender: TObject);
var
nItemIndex: Integer;
begin
try
nItemIndex := ListBoxUserCommand.ItemIndex;
EditCommandName.Text := ListBoxUserCommand.Items.Strings[nItemIndex];
SpinEditCommandIdx.Value := Integer(ListBoxUserCommand.Items.Objects[nItemIndex]);
ButtonUserCommandDel.Enabled := True;
ButtonUserCommandChg.Enabled := True;
except
EditCommandName.Text := ‘’;
SpinEditCommandIdx.Value := 0;
ButtonUserCommandDel.Enabled := False;
ButtonUserCommandChg.Enabled := False;
end;
end;

function TFrmFunctionConfig.InCommandListOfIndex(nIndex: Integer): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to ListBoxUserCommand.Items.Count - 1 do begin
if nIndex = Integer(ListBoxUserCommand.Items.Objects[I]) then begin
Result := True;
Break;
end;
end;
end;

function TFrmFunctionConfig.InCommandListOfName(sCommandName: string): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to ListBoxUserCommand.Items.Count - 1 do begin
if CompareText(sCommandName, ListBoxUserCommand.Items.Strings[I]) = 0 then begin
Result := True;
Break;
end;
end;
end;

procedure TFrmFunctionConfig.ButtonUserCommandAddClick(Sender: TObject);
var
sCommandName: string;
nCommandIndex: Integer;
begin
sCommandName := Trim(EditCommandName.Text);
nCommandIndex := SpinEditCommandIdx.Value;
if sCommandName = ‘’ then begin
Application.MessageBox(‘请输入命令!!!’, ‘提示信息’, MB_ICONQUESTION);
Exit;
end;
if InCommandListOfName(sCommandName) then begin
Application.MessageBox(‘输入的命令已经存在,请选择其他命令!!!’, ‘提示信息’, MB_ICONQUESTION);
Exit;
end;
if InCommandListOfIndex(nCommandIndex) then begin
Application.MessageBox(‘输入的命令编号已经存在,请选择其他命令编号!!!’, ‘提示信息’, MB_ICONQUESTION);
Exit;
end;
ListBoxUserCommand.Items.AddObject(sCommandName, TObject(nCommandIndex));
end;

procedure TFrmFunctionConfig.ButtonUserCommandDelClick(Sender: TObject);
begin
if Application.MessageBox(‘是否确认删除此命令?’, ‘确认信息’, MB_YESNO + MB_ICONQUESTION) = mrYes then begin
try
ListBoxUserCommand.DeleteSelected;
except
end;
end;
end;

procedure TFrmFunctionConfig.ButtonUserCommandChgClick(Sender: TObject);
var
sCommandName: string;
nCommandIndex: Integer;
I, nItemIndex: Integer;
begin
sCommandName := Trim(EditCommandName.Text);
nCommandIndex := SpinEditCommandIdx.Value;
if sCommandName = ‘’ then begin
Application.MessageBox(‘请输入命令!!!’, ‘提示信息’, MB_ICONQUESTION);
Exit;
end;
if InCommandListOfName(sCommandName) then begin
Application.MessageBox(‘你要修改的命令已经存在,请选择其他命令!!!’, ‘提示信息’, MB_ICONQUESTION);
Exit;
end;
if InCommandListOfIndex(nCommandIndex) then begin
Application.MessageBox(‘你要修改的命令编号已经存在,请选择其他命令编号!!!’, ‘提示信息’, MB_ICONQUESTION);
Exit;
end;
nItemIndex := ListBoxUserCommand.ItemIndex;
try
ListBoxUserCommand.Items.Strings[nItemIndex] := sCommandName;
ListBoxUserCommand.Items.Objects[nItemIndex] := TObject(nCommandIndex);
Application.MessageBox(‘修改完成!!!’, ‘提示信息’, MB_ICONQUESTION);
except
Application.MessageBox(‘修改失败!!!’, ‘提示信息’, MB_ICONQUESTION);
end;
end;

procedure TFrmFunctionConfig.ButtonUserCommandSaveClick(Sender: TObject);
var
sFileName: string;
I: Integer;
sCommandName: string;
nCommandIndex: Integer;
SaveList: Classes.TStringList;
begin
ButtonUserCommandSave.Enabled := False;
sFileName := ‘.\UserCmd.txt’;
SaveList := Classes.TStringList.Create;
SaveList.Add(‘;引擎插件配置文件’);
SaveList.Add(‘;命令名称’#9’对应编号’);
for I := 0 to ListBoxUserCommand.Items.Count - 1 do begin
sCommandName := ListBoxUserCommand.Items.Strings[I];
nCommandIndex := Integer(ListBoxUserCommand.Items.Objects[I]);
SaveList.Add(sCommandName + #9 + IntToStr(nCommandIndex));
end;
SaveList.SaveToFile(sFileName);
SaveList.Free;
Application.MessageBox(‘保存完成!!!’, ‘提示信息’, MB_ICONQUESTION);
ButtonUserCommandSave.Enabled := True;
end;

procedure TFrmFunctionConfig.ButtonLoadUserCommandListClick(
Sender: TObject);
begin
ButtonLoadUserCommandList.Enabled := False;
LoadUserCmdList();
ListBoxUserCommand.Items.Clear;
ListBoxUserCommand.Items.AddStrings(g_UserCmdList);
Application.MessageBox(‘重新加载自定义命令列表完成!!!’, ‘提示信息’, MB_ICONQUESTION);
ButtonLoadUserCommandList.Enabled := True;
end;

function TFrmFunctionConfig.InListBoxitemList(sItemName: string): Boolean;
var
I: Integer;
ListItem: TListItem;
begin
Result := False;
ListViewDisallow.Items.BeginUpdate;
try
for I := 0 to L

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大龙软件研发

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值