Jump to content

Recommended Posts

Posted (edited)

Ok now its fine but look, in this part: if (KeyCode = $7B) then begin i think this $7B is the key for stop script no? So i changed to $69 and dont work, script dont stop, i think this $69 is key 9 true?

Edited by Adri555
Posted

Ok now its fine but look, in this part: if (KeyCode = $7B) then begin i think this $7B is the key for stop script no? So i changed to $69 and dont work, script dont stop, i think this $69 is key 9 true?

http://delphi.about.com/od/objectpascalide/l/blvkc.htm

its numpad 9

Posted

 

Yes i know, but still dont work, holy fuck i dont want imagine if i want make script for autofarm ...

function keybd_event(bVk,bScan:byte;dwFlags,dwExtraInfo: integer): integer;  stdcall; external 'user32.dll';
function SetCursorPos(x, y : integer): boolean; stdcall; external 'user32.dll';
function mouse_event(dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll';

procedure SuspendScript;
var keycode,i:integer;
 begin
while true do begin
delay(150);
Engine.WaitAction([lakey], KeyCode, i);
  if (KeyCode = $69) then begin
  script.Suspend;
  end;
  end;
end;

procedure pressKey(hexCode: BYTE);
begin
  keybd_event(hexCode, 45, 1, 0 );
  delay(200);
end;

procedure mouseClick(x, y, _delay : integer); 
begin
SetCursorPos(x, y);
mouse_event($0002, 0, 0, 0, 0);
delay(_delay);
mouse_event($0004, 0, 0, 0, 0);
end;

procedure augments;
var obj: TL2Effect;
begin
while 
(SkillList.ByID(3124, obj)) or
(SkillList.ByID(3259, obj)) do delay(3000);
end;

begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(515,891,400);	///mouse click
SetCursorPos(504, 886);		///mouse move
delay(500);
augments;			///and check procedure augments for skill detect
end;
end.

I tryed 3000000000 changes and never

Posted

Yes i know, but still dont work, holy fuck i dont want imagine if i want make script for autofarm ...

function keybd_event(bVk,bScan:byte;dwFlags,dwExtraInfo: integer): integer;  stdcall; external 'user32.dll';
function SetCursorPos(x, y : integer): boolean; stdcall; external 'user32.dll';
function mouse_event(dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll';

procedure SuspendScript;
var keycode,i:integer;
 begin
while true do begin
delay(150);
Engine.WaitAction([lakey], KeyCode, i);
  if (KeyCode = $69) then begin
  script.Suspend;
  end;
  end;
end;

procedure pressKey(hexCode: BYTE);
begin
  keybd_event(hexCode, 45, 1, 0 );
  delay(200);
end;

procedure mouseClick(x, y, _delay : integer); 
begin
SetCursorPos(x, y);
mouse_event($0002, 0, 0, 0, 0);
delay(_delay);
mouse_event($0004, 0, 0, 0, 0);
end;

procedure augments;
var obj: TL2Effect;
begin
while 
(SkillList.ByID(3124, obj)) or
(SkillList.ByID(3259, obj)) do delay(3000);
end;

begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(515,891,400);	///mouse click
SetCursorPos(504, 886);		///mouse move
delay(500);
augments;			///and check procedure augments for skill detect
end;
end.

I tryed 3000000000 changes and never

 

 

 

put var keycode,i:integer;

also this not work becouse you dont "link" to run that procedure, you need add last step in to procedure example

 

 

procedure AugmentScriptMain;
begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(403,726,400);	///mouse click
SetCursorPos(133, 339);		///mouse move
pressKey($62);			///press key 2
pressKey($65);			///press key 5 for add gemstone count
delay(500);
augments;			///and check procedure augments for skill detect
end;
end;

and then in last link run that augment script and that suspend scripts example

begin
Script.NewThread(@SuspendScript);
Script.NewThread(@AugmentScriptMain);
end.
Posted (edited)

Ye man sorry but me english is limited and im not good in scripts xd

 

I understand i need add this you code

begin
Script.NewThread(@SuspendScript);
Script.NewThread(@AugmentScriptMain);
end.

But where? Cause this full script we end in end.

And maybe we need add: SuspendScript; in procedure AugmentScriptMain; like this or something:

procedure AugmentScriptMain;
begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(403,726,400);	///mouse click
SetCursorPos(133, 339);		///mouse move
pressKey($62);			///press key 2
pressKey($65);			///press key 5 for add gemstone count
delay(500);
augments;			///and check procedure augments for skill detect
SuspendScript;
end;
end;

For call this suspendscript action? I tryed but still dont work and script do nothing.

Thanks for patience adr.bot with noob newbies xD

Edited by Adri555
Posted (edited)

Ye man sorry but me english is limited and im not good in scripts xd

 

I understand i need add this you code

begin
Script.NewThread(@SuspendScript);
Script.NewThread(@AugmentScriptMain);
end.

But where? Cause this full script we end in end.

And maybe we need add: SuspendScript; in procedure AugmentScriptMain; like this or something:

procedure AugmentScriptMain;
begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(403,726,400);	///mouse click
SetCursorPos(133, 339);		///mouse move
pressKey($62);			///press key 2
pressKey($65);			///press key 5 for add gemstone count
delay(500);
augments;			///and check procedure augments for skill detect
SuspendScript;
end;
end;

For call this suspendscript action? I tryed but still dont work and script do nothing.

Thanks for patience adr.bot with noob newbies xD

function keybd_event(bVk,bScan:byte;dwFlags,dwExtraInfo: integer): integer;  stdcall; external 'user32.dll';
function SetCursorPos(x, y : integer): boolean; stdcall; external 'user32.dll';
function mouse_event(dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll';

procedure pressKey(hexCode: BYTE);
begin
  keybd_event(hexCode, 45, 1, 0 );
  delay(200);
end;

procedure mouseClick(x, y, _delay : integer); 
begin
SetCursorPos(x, y);
mouse_event($0002, 0, 0, 0, 0);
delay(_delay);
mouse_event($0004, 0, 0, 0, 0);
end;

procedure augments;
var obj: TL2Effect;
begin
while 
(SkillList.ByID(3124, obj)) or
(SkillList.ByID(3259, obj)) do delay(3000);
end;

procedure SuspendScript;
var keycode,i:integer;
 begin
while true do begin
delay(150);
Engine.WaitAction([lakey], KeyCode, i);
  if (KeyCode = $69) then begin
  script.Suspend;
  end;
  end;
end;

procedure AugmentScriptMain;
begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(403,726,400);	///mouse click
SetCursorPos(133, 339);		///mouse move
pressKey($62);			///press key 2
pressKey($65);			///press key 5 for add gemstone count
delay(500);
augments;			///and check procedure augments for skill detect
end;
end;
{its like run both procedures at same time, its like merge scripts i dont know how better explain xd
hope you understand what i whant to say xd}
begin
Script.NewThread(@SuspendScript);
Script.NewThread(@AugmentScriptMain);
end.

its example how it looks like, i dont know how better explain xd

Edited by adr.bot
Posted (edited)

YE no problem, you explain good just im noob and dont understand xd

______

 

Any scripter can share argument script with this script for stop that with key? If is for free better, but maybe we can negociate a small price

Edited by Adri555
Posted (edited)

What script is better this:

 

 

An example should look like, i think be shorter way to detect skills but i know only this xd
i think with this example be easier understand :D gl hf

function keybd_event(bVk,bScan:byte;dwFlags,dwExtraInfo: integer): integer;  stdcall; external 'user32.dll';
function SetCursorPos(x, y : integer): boolean; stdcall; external 'user32.dll';
function mouse_event(dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll';

procedure pressKey(hexCode: BYTE);
begin
  keybd_event(hexCode, 45, 1, 0 );
  delay(200);
end;

procedure mouseClick(x, y, _delay : integer); 
begin
SetCursorPos(x, y);
mouse_event($0002, 0, 0, 0, 0);
delay(_delay);
mouse_event($0004, 0, 0, 0, 0);
end;

procedure augments;
var obj: TL2Effect;
begin
while 
(SkillList.ByID(3124, obj)) or
(SkillList.ByID(3259, obj)) do delay(3000);
end;

begin
while Engine.Status = lsOnline do begin
delay(100);
mouseClick(403,726,400);	///mouse click
SetCursorPos(133, 339);		///mouse move
pressKey($62);			///press key 2
pressKey($65);			///press key 5 for add gemstone count
delay(500);
augments;			///and check procedure augments for skill detect
end;
end.

 

Or this: (Problem i think this second script is hard as fuck for edit xD)

var 
L2Skill: TL2Skill; 
skill1: TL2Skill; 
skill2: TL2Skill; 
skill3: TL2Skill; 
skill4: TL2Skill; 
NovObj: TL2Skill; 
NovEngine: TL2Control; 
buff: TL2Buff; function keybd_event (bVk, bScan: byte; dwFlags, dwExtraInfo: integer): integer ; stdcall; external 'user32.dll'; function SetCursorPos (x, y: integer): boolean; stdcall; external 'user32.dll'; function mouse_event (dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll'; function GetSkill (const Control: String; const ID: Cardinal): TL2Skill; begin NovEngine: = GetControl (control); if Assigned (NovEngine) and NovEngine.GetSkillList.ByID (ID, NovObj) then Result : = NovObj; delay (10000) end; procedure pressKey (hexCode: BYTE); begin   keybd_event (hexCode, 45, 1, 0);   delay (200); end; procedure mouseClick (x, y, _delay: integer); begin   SetCursorPos (x, y);   mouse_event ($ 2, 0, 0, 0, 0);   delay (_delay);   mouse_event ($ 4, 0, 0, 0, 0); end; procedure mouseDown (x, y, _delay: integer ); begin   SetCursorPos (x, y);   mouse_event ($ 2, 0, 0, 0, 0);   // delay (_delay);   // mouse_event ($ 4, 0, 0, 0, 0); end; procedure mouseUp ( x, y, _delay: integer); begin   SetCursorPos (x, y);   // mouse_event ($ 2, 0, 0, 0, 0);   // delay (_delay);   mouse_event ($ 4, 0, 0, 0, 0 ); end; // coordinate of the higher edge of the box augmentation \\ \\ 486 144 // coordinate of the higher edge of the box cancel \\ \\ 485 413 // coordinate of the higher edge of the box inventory \\ 203 \\ 1072 // active REFRESH 3199 // Reflect active 3204 // virgin 3158 // active PvP Mait 3134 // Passive Reflect 3259 // active refresh2 3202 // weight limit 3251 // Passive pvp Mait 3243 begin delay (10,000); while 1 <> 2 do begin if (not SkillList.ByID (3243, skill1)) then begin // remove augment      mouseDown (884, 1010, 1000); // click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      delay (300);      mouseUp (486, 700, 1000); // Fluff drag the window aukmenta cancellation and release      delay (300);      mouseClick (445, 829, 200); // Confirm cancellation augment (augment cancel confirmation button)      delay (3000); // Waiting for the augmentation      mouseClick (445, 829, 200); // Push for the next augmentation (after HP pulled out)      delay (300); // insert the new augment      mouseDown (884, 1010, 1000); // click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      delay (300);      mouseUp (446, 390, 1000); // Aukmenta drag the window and release      delay (300);      mouseDown (1156 897 1000); // click on the LAN      delay (300);      mouseUp (526, 392, 1000); // Aukmenta drag the window and release      delay (300);      mouseDown (1197, 897, 1000); // click on gemston      delay (300);      mouseUp (485, 432, 1000); // Aukmenta drag the window and release      delay (300);      mouseClick (440, 562, 200); // Confirm augment      delay (4300); // Waiting for the augmentation      mouseClick (440, 562, 200); // Push for the next augmentation      delay (100);      end; if (SkillList.ByID (3243, skill2)) then begin PlaySound (exepath + '\ sounds \' + 'dc' + '.wav', False); delay ( 5000); end; end; end.     

Not sure what script try use

Edited by CristianPascual
Posted

What script is better this:

 

 

Or this: (Problem i think this second script is hard as fuck for edit xD)

var 
L2Skill: TL2Skill; 
skill1: TL2Skill; 
skill2: TL2Skill; 
skill3: TL2Skill; 
skill4: TL2Skill; 
NovObj: TL2Skill; 
NovEngine: TL2Control; 
buff: TL2Buff; function keybd_event (bVk, bScan: byte; dwFlags, dwExtraInfo: integer): integer ; stdcall; external 'user32.dll'; function SetCursorPos (x, y: integer): boolean; stdcall; external 'user32.dll'; function mouse_event (dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll'; function GetSkill (const Control: String; const ID: Cardinal): TL2Skill; begin NovEngine: = GetControl (control); if Assigned (NovEngine) and NovEngine.GetSkillList.ByID (ID, NovObj) then Result : = NovObj; delay (10000) end; procedure pressKey (hexCode: BYTE); begin   keybd_event (hexCode, 45, 1, 0);   delay (200); end; procedure mouseClick (x, y, _delay: integer); begin   SetCursorPos (x, y);   mouse_event ($ 2, 0, 0, 0, 0);   delay (_delay);   mouse_event ($ 4, 0, 0, 0, 0); end; procedure mouseDown (x, y, _delay: integer ); begin   SetCursorPos (x, y);   mouse_event ($ 2, 0, 0, 0, 0);   // delay (_delay);   // mouse_event ($ 4, 0, 0, 0, 0); end; procedure mouseUp ( x, y, _delay: integer); begin   SetCursorPos (x, y);   // mouse_event ($ 2, 0, 0, 0, 0);   // delay (_delay);   mouse_event ($ 4, 0, 0, 0, 0 ); end; // coordinate of the higher edge of the box augmentation \\ \\ 486 144 // coordinate of the higher edge of the box cancel \\ \\ 485 413 // coordinate of the higher edge of the box inventory \\ 203 \\ 1072 // active REFRESH 3199 // Reflect active 3204 // virgin 3158 // active PvP Mait 3134 // Passive Reflect 3259 // active refresh2 3202 // weight limit 3251 // Passive pvp Mait 3243 begin delay (10,000); while 1 <> 2 do begin if (not SkillList.ByID (3243, skill1)) then begin // remove augment      mouseDown (884, 1010, 1000); // click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      delay (300);      mouseUp (486, 700, 1000); // Fluff drag the window aukmenta cancellation and release      delay (300);      mouseClick (445, 829, 200); // Confirm cancellation augment (augment cancel confirmation button)      delay (3000); // Waiting for the augmentation      mouseClick (445, 829, 200); // Push for the next augmentation (after HP pulled out)      delay (300); // insert the new augment      mouseDown (884, 1010, 1000); // click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      delay (300);      mouseUp (446, 390, 1000); // Aukmenta drag the window and release      delay (300);      mouseDown (1156 897 1000); // click on the LAN      delay (300);      mouseUp (526, 392, 1000); // Aukmenta drag the window and release      delay (300);      mouseDown (1197, 897, 1000); // click on gemston      delay (300);      mouseUp (485, 432, 1000); // Aukmenta drag the window and release      delay (300);      mouseClick (440, 562, 200); // Confirm augment      delay (4300); // Waiting for the augmentation      mouseClick (440, 562, 200); // Push for the next augmentation      delay (100);      end; if (SkillList.ByID (3243, skill2)) then begin PlaySound (exepath + '\ sounds \' + 'dc' + '.wav', False); delay ( 5000); end; end; end.     

Not sure what script try use

i think second is better, second script hard edit? not hard , if that guy who posted that paste script normally not in one line xd

Posted

i think second is better, second script hard edit? not hard , if that guy who posted that paste script normally not in one line xd

 

Ye, is in 1 line all: http://www.maxcheaters.com/topic/195002-adrenaline-scripts-free/ For this i think is really hardxd I will be try, let me gl xd

Posted

Ey bro, script for autobuff-teleport is more easy than this xD

What i need edit, for example i think its only editable this part:

procedure pressKey (hexCode: BYTE); begin   keybd_event (hexCode, 45, 1, 0);   delay (200); end; 
procedure mouseClick (x, y, _delay: integer); begin   SetCursorPos (x, y);   mouse_event ($ 2, 0, 0, 0, 0);   delay (_delay);   mouse_event ($ 4, 0, 0, 0, 0); end; 
procedure mouseDown (x, y, _delay: integer ); begin   SetCursorPos (x, y);   mouse_event ($ 2, 0, 0, 0, 0);   // delay (_delay);   // mouse_event ($ 4, 0, 0, 0, 0); end; 
procedure mouseUp ( x, y, _delay: integer); begin   SetCursorPos (x, y);   // mouse_event ($ 2, 0, 0, 0, 0);   // delay (_delay);   mouse_event ($ 4, 0, 0, 0, 0 ); end; // coordinate of the higher edge of the box augmentation \\ \\ 486 144 // coordinate of the higher edge of the box cancel \\ \\ 485 413 // coordinate of the higher edge of the box inventory \\ 203 \\ 1072 // active REFRESH 3199 // Reflect active 3204 // virgin 3158 // active PvP Mait 3134 // Passive Reflect 3259 // active refresh2 3202 // weight limit 3251 // Passive pvp Mait 3243 begin delay (10,000); while 1 <> 2 do begin if (not SkillList.ByID (3243, skill1)) then begin // remove augment      mouseDown (884, 1010, 1000); // click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      delay (300);      mouseUp (486, 700, 1000); // Fluff drag the window aukmenta cancellation and release      delay (300);      mouseClick (445, 829, 200); // Confirm cancellation augment (augment cancel confirmation button)      delay (3000); // Waiting for the augmentation      mouseClick (445, 829, 200); // Push for the next augmentation (after HP pulled out)      delay (300); // insert the new augment      mouseDown (884, 1010, 1000); // click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      delay (300);      mouseUp (446, 390, 1000); // Aukmenta drag the window and release      delay (300);      mouseDown (1156 897 1000); // click on the LAN      delay (300);      mouseUp (526, 392, 1000); // Aukmenta drag the window and release      delay (300);      mouseDown (1197, 897, 1000); // click on gemston      delay (300);      mouseUp (485, 432, 1000); // Aukmenta drag the window and release      delay (300);      mouseClick (440, 562, 200); // Confirm augment      delay (4300); // Waiting for the augmentation      mouseClick (440, 562, 200); // Push for the next augmentation      delay (100);      end; if (SkillList.ByID (3243, skill2)) then begin PlaySound (exepath + '\ sounds \' + 'dc' + '.wav', False); delay ( 5000); end; end; end.     

We just need edit this SetCursorPos (x, y); yes?

procedure mouseClick (x, y, _delay: integer); begin   SetCursorPos (x, y);
procedure mouseDown (x, y, _delay: integer ); begin   SetCursorPos (x, y);
procedure mouseUp ( x, y, _delay: integer); begin   SetCursorPos (x, y);
Posted

i just added that script not in one line, and fixed all red lines

var 
L2Skill: TL2Skill; 
skill1: TL2Skill; 
skill2: TL2Skill; 
skill3: TL2Skill; 
skill4: TL2Skill; 
NovObj: TL2Skill; 
NovEngine: TL2Control; 
buff: TL2Buff; 

function keybd_event (bVk, bScan: byte; dwFlags, dwExtraInfo: integer): integer ; stdcall; external 'user32.dll'; 
function SetCursorPos (x, y: integer): boolean; stdcall; external 'user32.dll'; 
function mouse_event (dwFlags, dx, dy, dwData: byte; dwExtraInfo: integer): void; stdcall; external 'user32.dll'; 

function GetSkill (const Control: String; const ID: Cardinal): TL2Skill; 
begin 
NovEngine:= GetControl(control); 
if Assigned (NovEngine) and NovEngine.GetSkillList.ByID (ID, NovObj) 
then Result := NovObj; 
delay (10000) 
end; 

procedure pressKey (hexCode: BYTE);
begin   
keybd_event (hexCode, 45, 1, 0);   
delay (200); 
end; 

procedure mouseClick (x, y, _delay: integer); 
begin   
SetCursorPos (x, y);   
mouse_event($2, 0, 0, 0, 0);   
delay (_delay);   
mouse_event($4, 0, 0, 0, 0); 
end; 

procedure mouseDown (x, y, _delay: integer ); 
begin   
SetCursorPos (x, y);   
mouse_event ($2, 0, 0, 0, 0);   
// delay (_delay);   
// mouse_event ($ 4, 0, 0, 0, 0); 
end; 

procedure mouseUp ( x, y, _delay: integer); 
begin   
SetCursorPos (x, y);   
// mouse_event ($ 2, 0, 0, 0, 0);   
// delay (_delay);   
mouse_event ($4, 0, 0, 0, 0 ); 
end; // coordinate of the higher edge of the box augmentation \\ \\ 486 144 // coordinate of the higher edge of the box cancel \\ \\ 485 413 // coordinate of the higher edge of the box inventory \\ 203 \\ 1072 // active REFRESH 3199 // Reflect active 3204 // virgin 3158 // active PvP Mait 3134 // Passive Reflect 3259 // active refresh2 3202 // weight limit 3251 // Passive pvp Mait 3243 

begin 
delay(10000); 
while 1 <> 2 do begin 
if (not SkillList.ByID (3243, skill1)) then begin 
// remove augment      
mouseDown (884, 1010, 1000); 
// click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      
delay (300);      
mouseUp (486, 700, 1000); 
// Fluff drag the window aukmenta cancellation and release      
delay (300);      
mouseClick (445, 829, 200); 
// Confirm cancellation augment (augment cancel confirmation button)      
delay (3000); // Waiting for the augmentation      
mouseClick (445, 829, 200); 
// Push for the next augmentation (after HP pulled out)      
delay (300); 
// insert the new augment      
mouseDown (884, 1010, 1000); 
// click on the feathers (coordinate location puhi. it must necessarily be in the hands of)      
delay (300);      
mouseUp (446, 390, 1000); // Aukmenta drag the window and release      
delay (300);      
mouseDown (1156, 897, 1000); // click on the LAN      
delay (300);      
mouseUp (526, 392, 1000); // Aukmenta drag the window and release      
delay (300);      
mouseDown (1197, 897, 1000); // click on gemston      
delay (300);      
mouseUp (485, 432, 1000); // Aukmenta drag the window and release      
delay (300);      
mouseClick (440, 562, 200); // Confirm augment      
delay (4300); // Waiting for the augmentation      
mouseClick (440, 562, 200); // Push for the next augmentation      
delay (100);      
end; 
if (SkillList.ByID (3243, skill2)) then begin 
PlaySound (exepath + '\ sounds \' + 'dc' + '.wav', False); 
delay ( 5000); 
end; 
end; 
end.   

about what need edit, that procedures MouseClick and etc its same, that procedures use in main body script, so you need edit only main script part example 

mouseDown (1156, 897, 1000); // click on the LAN 

change only coordinates

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



  • Posts

    • im using l2jmobius
    • what pack you use  send me on discord for it
    • package custom.events.RandomZoneEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.ScheduledFuture; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.commons.time.SchedulingPattern; import org.l2jmobius.commons.time.TimeUtil; import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.gameserver.managers.ZoneManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.quest.Event; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.RandomZone; import org.l2jmobius.gameserver.util.Broadcast; /** * Random Zone Event - Activates one random PvP zone temporarily. No modifica la clase de la zona: usa flags PvP en runtime. * @author Juan */ public class RandomZoneEvent extends Event { private static final String CONFIG_FILE = "data/scripts/custom/events/RandomZoneEvent/config.xml"; private static int EVENT_DURATION_MINUTES = 15; private static boolean _isActive = false; private ScheduledFuture<?> _eventTask = null; private final List<ZoneType> _availableZones = new ArrayList<>(); private ZoneType _activeZone = null; public RandomZoneEvent() { loadConfig(); loadZones(); registerZoneListeners(); } /** * Registra listeners a TODAS LAS ZONAS random */ private void registerZoneListeners() { for (ZoneType zone : _availableZones) { addEnterZoneId(zone.getId()); addExitZoneId(zone.getId()); LOGGER.info("[RandomZoneEvent] Registered listener for zone: " + zone.getName()); } } private void loadConfig() { new IXmlReader() { @Override public void load() { parseDatapackFile(CONFIG_FILE); } @Override public void parseDocument(Document doc, File file) { forEach(doc, "event", eventNode -> { final StatSet att = new StatSet(parseAttributes(eventNode)); final String name = att.getString("name"); for (Node node = eventNode.getFirstChild(); node != null; node = node.getNextSibling()) { if ("schedule".equals(node.getNodeName())) { final StatSet attributes = new StatSet(parseAttributes(node)); final String pattern = attributes.getString("pattern"); final SchedulingPattern schedulingPattern = new SchedulingPattern(pattern); final StatSet params = new StatSet(); params.set("Name", name); params.set("SchedulingPattern", pattern); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer("Schedule_" + name, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Event " + name + " scheduled at " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } }); } }.load(); } private void loadZones() { for (ZoneType zone : ZoneManager.getInstance().getAllZones(RandomZone.class)) { if ((zone.getName() != null) && zone.getName().toLowerCase().startsWith("random_zone")) { _availableZones.add(zone); LOGGER.info("[RandomZoneEvent] Loaded zone: " + zone.getName() + " (id=" + zone.getId() + ")"); } } LOGGER.info("[RandomZoneEvent] Total random zones loaded: " + _availableZones.size()); } @Override public void onTimerEvent(String event, StatSet params, Npc npc, Player player) { if (event.startsWith("Schedule_")) { eventStart(null); final SchedulingPattern schedulingPattern = new SchedulingPattern(params.getString("SchedulingPattern")); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer(event, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Rescheduled for " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } @Override public boolean eventStart(Player eventMaker) { if (_isActive) { if (eventMaker != null) { eventMaker.sendMessage("RandomZoneEvent already active."); } return false; } if (_availableZones.isEmpty()) { Broadcast.toAllOnlinePlayers("[RandomZoneEvent] No zones configured."); return false; } _isActive = true; Broadcast.toAllOnlinePlayers("⚔️ Random Zone Event has started!"); _eventTask = ThreadPool.schedule(this::activateRandomZone, 5_000); return true; } private void activateRandomZone() { _activeZone = _availableZones.get(new Random().nextInt(_availableZones.size())); _activeZone.setEnabled(true); Broadcast.toAllOnlinePlayers("🔥 Random Zone Event: " + _activeZone.getName() + " is now PvP for " + EVENT_DURATION_MINUTES + " minutes!"); _eventTask = ThreadPool.schedule(this::eventStop, EVENT_DURATION_MINUTES * 60 * 1000L); } @Override public boolean eventStop() { if (!_isActive) { return false; } _isActive = false; if (_eventTask != null) { _eventTask.cancel(true); _eventTask = null; } if (_activeZone != null) { _activeZone.setEnabled(false); Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended. " + _activeZone.getName() + " is back to normal."); _activeZone = null; } else { Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended."); } return true; } @Override public void onEnterZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, true); if (creature.isPlayer()) { creature.sendMessage("Esta zona está en modo PvP temporalmente."); } } } @Override public void onExitZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, false); if (creature.isPlayer()) { creature.sendMessage("Abandonaste la zona PvP temporal."); } } } @Override public boolean eventBypass(Player player, String bypass) { return true; } @Override public String onEvent(String event, Npc npc, Player player) { return super.onEvent(event, npc, player); } @Override public String onFirstTalk(Npc npc, Player player) { return null; } public static void main(String[] args) { new RandomZoneEvent(); } } i have this but its not working
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock