PDA

Просмотр полной версии : [Помогите!] С скриптом


Bacek
19.07.2010, 22:25
Помогите сделать скрипт для l2phx

При нажатии соц действия
13 0D 00 00 00 00 00 00 00 00
должен включатся таймер с циклом (бесконечным)
Посылать 2 пакета с задержкой 10 мс
A7 3E 84 06 10 00 00 00 00
7C 33 00 52 4A 06 10
Потом через 6 сек
9C 53 4A 06 10 00 00 00 00
и снова в начало

Выключение цикла
13 0C 00 00 00 00 00 00 00 00

Вот есть набросок в 2 кнопки но я не знаю как вставить таймеры и проверки

begin
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then begin
buf:=HStr('A7 3E 84 06 10 00 00 00 00');
SendToServer;
end;
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then begin
buf:=HStr('7C 33 00 52 4A 06 10');
SendToServer;
end;
if FromClient and (pck=HStr('13 0C 00 00 00 00 00 00 00 00')) then begin
buf:=HStr('9C 53 4A 06 10 00 00 00 00');
SendToServer;
end;
end.

dyh9l
20.07.2010, 01:49
Мне чтото подобное нужно тоже:
Если персоонаж похлопает в ладоши то юзается пакет "а"
через секунду юзается пакет "б"
через секунду юзается пакет "в"

Добавлено через 1 час 1 минуту
begin
if (buf:=hstr('17 01 00 00 00'))then begin buf:=HStr('09');
SendToServer;
end.
Вот чтото подобное надо, но не получается почему то

Fer123
20.07.2010, 02:04
var
TimerCycle:integer;
timer:TTimer;

procedure Init;
begin
timer:=TTimer.Create(nil);
timer.interval:=10;
timer.OnTimer:=@OnTimer;
timer.enabled:=false;
TimerCycle:=1;
end;

procedure OnTimer(Sender: TObject);
begin
case TimerCycle of
1:begin
buf:=packet1;
sendtoserver;
Inc(TimerCycle);
end;
2:begin
buf:=packet2;
sendtoserver;
Inc(TimerCycle);
timer.interval:=6000;
end;
3:begin
buf:=packet3;
sendtoserver;
TimerCycle:=1;
timer.interval:=10;
end;
end;
end;

procedure Free;
begin
timer.free;
end;

begin
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then timer.enabled:=true;
if FromClient and (pck=HStr('13 0C 00 00 00 00 00 00 00 00')) then timer.enabled:=false;
end.

Bacek
20.07.2010, 12:03
var
TimerCycle:integer;
timer:TTimer;

procedure Init;
begin
timer:=TTimer.Create(nil);
timer.interval:=10;
timer.OnTimer:=@OnTimer;
timer.enabled:=false;
TimerCycle:=1;
end;

procedure OnTimer(Sender: TObject);
begin
case TimerCycle of
1:begin
buf:=packet1;
sendtoserver;
Inc(TimerCycle);
end;
2:begin
buf:=packet2;
sendtoserver;
Inc(TimerCycle);
timer.interval:=6000;
end;
3:begin
buf:=packet3;
sendtoserver;
TimerCycle:=1;
timer.interval:=10;
end;
end;
end;

procedure Free;
begin
timer.free;
end;

begin
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then timer.enabled:=true;
if FromClient and (pck=HStr('13 0C 00 00 00 00 00 00 00 00')) then timer.enabled:=false;
end.


Не работает (

var
TimerCycle:integer;
timer:TTimer;

procedure Init;
begin
timer:=TTimer.Create(nil);
timer.interval:=10;
timer.OnTimer:=@OnTimer;
timer.enabled:=false;
TimerCycle:=1;
end;

procedure OnTimer(Sender: TObject);
begin
case TimerCycle of
1:begin
buf:=HStr('3E 3E 84 06 10 00 00 00 00');
sendtoserver;
Inc(TimerCycle);
end;
2:begin
buf:=HStr('BD 12 00 A1 C5 01 10');
sendtoserver;
Inc(TimerCycle);
timer.interval:=6000;
end;
3:begin
buf:=HStr('86 A0 C5 01 10 00 00 00 00');
sendtoserver;
TimerCycle:=1;
timer.interval:=10;
end;
end;
end;

procedure Free;
begin
timer.free;
end;

begin
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then timer.enabled:=true;
if FromClient and (pck=HStr('13 0C 00 00 00 00 00 00 00 00')) then timer.enabled:=false;
end.

Таймер не включается (
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then
срабатывает но дальше 0 эмоций

alexteam
20.07.2010, 12:12
useforconnectname := 'имя чара';
в инит вставь.

Bacek
20.07.2010, 12:21
useforconnectname := 'имя чара';
в инит вставь.
Проблема в том что стоит шифрация первых 2 байтов и ник отображается криво

alexteam
20.07.2010, 12:34
begin
useforconnectid := ConnectID;
if FromClient and (pck=HStr('13 0D 00 00 00 00 00 00 00 00')) then timer.enabled:=true;
......

Bacek
20.07.2010, 13:15
Всем спасибо за помощь все работает
Вот скрипт если каму то понадобится


var
TimerCycle:integer;
timer:TTimer;

procedure Init;
begin
timer:=TTimer.Create(nil);
timer.interval:=10;
timer.OnTimer:=@OnTimer;
timer.enabled:=false;
TimerCycle:=1;
end;

procedure OnTimer(Sender: TObject);
begin
case TimerCycle of
1:begin
buf:=HStr('A6 3E 84 06 10 00 00 00 00'); //1 пакет
sendtoserver;
Inc(TimerCycle);
timer.interval:=200;
end;
2:begin
buf:=HStr('7B 36 00 A1 C5 01 10'); //2 пакет
sendtoserver;
Inc(TimerCycle);
timer.interval:=2500;
end;
3:begin
buf:=HStr('93 A0 C5 01 10 00 00 00 00'); //3 пакет
sendtoserver;
TimerCycle:=1;
timer.interval:=600;
end;
end;
end;

procedure Free;
begin
timer.free;
end;


begin
useforconnectid := ConnectID;
if FromClient and (pck=HStr('5D 0D 00 00 00 00 00 00 00 00')) then timer.enabled:=true;
if FromClient and (pck=HStr('5D 0C 00 00 00 00 00 00 00 00')) then timer.enabled:=false;
end.

Fer123
20.07.2010, 13:21
useforconnectid := ConnectID;
это надо было в Init пихнуть, например useforconnectid := 1; в зависимости от соединения которому нужно отправлять.
А так получается, если запущено более 1 соединения то useforconnectid постоянно будет меняться, и не известно кому отправятся эти пакеты.

alexteam
20.07.2010, 16:54
useforconnectid := 1;
connectid равен номеру сокета инициализировавшего соединение с сервером. а не какомуто константному порядковому номеру.

Добавлено через 1 минуту
если запущено более 1 соединения то useforconnectid постоянно будет меняться
не будет. единственное в чем ты технически прав (хоть об этом и не писал) - довольно тяжело будет запустить скрипт для 2х соединений.
новый активированный скрипт будет привязываться к тому соединению которое первым пришлет пакет на обработку.