PDA

Просмотр полной версии : L2ph v 3.6.0.120 crash!


charly911
16.06.2009, 03:09
Hi! im trying to work with plugins, but when i use the OnPacket procedure the application crashes :(

If i don use that procedure everyting goes ok.

Does anyone knows if this is a bug, or if im doing it wrong?

Here is the code:


library plugin_demoC;

{$define RELEASE} // äëÿ ñîâìåñòèìîñòè ñ ðåëèçîì ïàêåòõàêà, ïðè äåáóãå ìîæíî çàêîìåíòèðîâàòü

uses
FastMM4 in '..\fastmm\FastMM4.pas',
FastMM4Messages in '..\fastmm\FastMM4Messages.pas',
SysUtils,
Windows,
dialogs,
Classes,
usharedstructs in '..\units\usharedstructs.pas';

var {version} {revision}
min_ver_a: array[0..3] of Byte = ( 3,5,1, 98 );
min_ver: Integer absolute min_ver_a; // ìèíèìàëüíàÿ ïîääåðæèâàåìàÿ âåðñèÿ ïðîãðàììû
ps: TPluginStruct;
ppck: PPacket;
const
pause=15000;

var
ColvoHP, CharObjID, ItemObjHP: integer;
CurHP, MaxHP, lastHP, cntHP:integer;
TimerHP: Boolean;
StatusHP: Boolean;

function GetPluginInfo(const ver: Integer): PChar; stdcall;
begin
if ver<min_ver then
Result:='Äåìîíñòðàöèîííûé Plugin ê ïðîãðàììå l2phx'+sLineBreak+
'Äëÿ âåðñèé 3.5.1.98+'+sLineBreak+
'Ó âàñ ñòàðàÿ âåðñèÿ ïðîãðàììû! Ïëàãèí íå ñìîæåò êîððåêòíî ñ íåé ðàáîòàòü!'
else
Result:='Äåìîíñòðàöèîííûé Plugin ê ïðîãðàììå l2phx'+sLineBreak+
'Äëÿ âåðñèé 3.5.1.98+'+sLineBreak+
'Àâòîâûïèâàëêà ÍÐ áóòûëîê';
end;


procedure Say(msg:string);
var
buf: string;
begin
with ps do begin
buf:=HexToString('4A 00 00 00 00');
WriteD(buf,2);
WriteS(buf,'AutoHP');
WriteS(buf,msg);
SendPacketStr(buf,cntHP,False);
end;
end;


function SetStruct(const struct: PPluginStruct): Boolean; stdcall;

begin
ps := TPluginStruct(struct^);
Result:=True;
end;

procedure OnLoad; stdcall;
begin
statusHP:=false;
CharObjID:=0;
ItemObjHP:=0;
TimerHP:=false;
lastHP:=0;
cntHP := 0;
with ps do
begin

if GoFirstConnection then
//repeat
cntHP := ConnectInfo.ConnectID;
Say(' Opa!');
//until GoNextConnection;

end;
end;

procedure OnPacket(const cnt: Cardinal; const fromServer: Boolean; var pck: Tpacket); stdcall;
var
buf,s: string;
begin
end;

exports
GetPluginInfo,
OnPacket,
OnLoad,
SetStruct;

begin
end.


Charly.

QaK
16.06.2009, 09:06
alexteam,у него в описании OnPAcket правильно параметры вбиты? А то я не помню как в последних версиях выглядит.

alexteam
16.06.2009, 11:48
3.5
TOnPacket = procedure(const cnt: Cardinal; const fromServer: Boolean; var packet : tpacket); stdcall;
3.6
TOnPacket = procedure(const cnt: Cardinal; const fromServer: Boolean; const connectionname:string; var packet : tpacket); stdcall;

victor_rvm
16.06.2009, 12:38
а где взять эту версию 3.6.0.120 или 133 как на SVNе, или это тестовые версии пока в Архив http://l2phx.pp.ru/arhive/ не выкладываются?

alexteam
16.06.2009, 12:43
с свн.

victor_rvm
16.06.2009, 15:54
брать исходники и компилировать? а собраНных версий уже не будет?

alexteam
16.06.2009, 17:10
имхо не имеет смысла. ибо реализация скриптового движка получилась не очень.

charly911
16.06.2009, 19:45
Worked! :D
Ty.

I use that version because y had to modify the timer in Packets Sender for longer times (more than 10 seconds). Also i wanted to translate it to Spanish...

Charly.

alexteam
16.06.2009, 20:05
3.6 got not really good implementation of script engine.

charly911
16.06.2009, 23:38
I know they have some differences. One i have noticed is that scripts are in Units, and i can not make them work. Where should i save the Unit file so the uses statements can be recocnized???
I will take a look to both of then 3.5 and 3.6...
But i think both can be used without problem...

Charly.

alexteam
16.06.2009, 23:42
simple script ported to 3.6.
code of mainunit.

Unit TitulMain;
interface
uses forms, classes, extctrls, sysutils, stdctrls;
const
Full_Title = ' Wtf is going on 0_o !?';//Titul
Char_Name = 'alexteam'; //character name

type
TMain = class (tform)
Timer : TTimer;
Button : TButton;
Edit: TEdit;

procedure ButtonClick(Sender: TObject);
procedure TimerTimer(Sender: TObject);
private
Pos_i : Integer;
Start : Boolean;

public
Constructor create(Aowner:Tcomponent); override;
end;

var
main : TMain;


Procedure Init;
procedure Free;
Procedure OnPacket;

implementation

procedure TMain.ButtonClick(Sender: TObject);
begin
Start := Not (Start);
Timer.Enabled := Start;
If Start
then Button.Caption:='Stop'
else Button.Caption:='Start';
end;

//процедура смена титула
procedure ChangeTitle(CharName,Title:String);
begin buf:=#$55;
WriteS(CharName);
WriteS(Title);
SendToServerex(CharName);
end;



procedure TMain.TimerTimer(Sender: TObject);
var i:integer;
Title:string;
begin Title:='';
for i:=1 to 16 do
if ((i+Pos_i)mod(Length(Full_Title)+1))=0
then Title:=Title+' '
else Title:=Title+Full_Title[(i+Pos_i)mod(Length(Full_Title)+1)];

Pos_i:=(Pos_i+1)mod(Length(Full_Title)+1);

Edit.Text:=Title;
ChangeTitle(Char_Name,Title);
end;



Constructor TMain.create(Aowner:Tcomponent);
begin
inherited;
Pos_i := 1;
Start := False;

Caption := 'animate titul v 1.0';
BorderStyle := bsSizeable;
Position := poDesigned;
Left :=725;
Top :=0;
Width :=300;
Height :=150;

//пример титула будет выводиться сюда
Edit := TEdit.Create(self);
Edit.Parent := self;
Edit.Left := 100;
Edit.Top := 10;
Edit.Width := 102;

//таймер
Timer := TTimer.Create(self);
Timer.Interval := 500;
Timer.Enabled := False;
Timer.onTimer := TimerTimer;

Button := TButton.Create(self);
Button.Parent := self;
Button.Caption := 'Start';
Button.Left := 10;
Button.Top := 10;
Button.onClick := ButtonClick;
end;

procedure Init;
Begin
Main := tmain.create(nil);
main.show;
End;


procedure Free;
Begin
Main.Destroy;
End;


procedure OnPacket;
Begin

End;

end.

anyway i stoped dev of 3.6 .

charly911
17.06.2009, 00:26
What i dont understand is where do i have to save the script, because i get the error: "[Pascal] undeclared identifier forms"... in uses.


anyway i stoped dev of 3.6 .


Do you mean that there wont be any updates of this version?? o.O

Charly.

alexteam
17.06.2009, 00:35
undeclared identifier forms
you removed IMPORT_COMMON from uses when compile l2ph right ?...
that why you don't have in script engine namespace 'forms'.
look into Import folder of l2ph. in any unit. and you understand why.

Do you mean that there wont be any updates of this version?? o.O
yep.

charly911
17.06.2009, 00:48
Ok i will recompile it and try again.

Ty, Charly.

Ps: What are the diferences between 3.5 and 3.6 scripts? I mean extra utilities...

alexteam
17.06.2009, 01:30
3.5 fastscript
3.6 paxcompiler