PDA

View Full Version : SRL Snippets Section



Coh3n
12-13-2011, 07:01 PM
This section is quite simple. It's for any useful code you've made in your scripts that you wish to share with the community. Not all suggestions can be added to SRL, so whatever isn't fit for the include can be placed in here. :) If you find a thread that should be in this section, please report it, and a staff member will move it as soon as possible.

Enjoy,
The SRL Team

Flight
12-13-2011, 11:52 PM
Yay! I've been waiting for this.

Kyle Undefined
12-14-2011, 03:49 AM
Awesome, I'll have to go through my code and post some here :)

cosmasjdz
08-09-2014, 07:15 PM
///////////////////////////////////////////////////////////////////
// function Minimap.RotateToPoint( DotType: integer; MainscreenLocation: integer): boolean;
//
// Rotates the mainscreen to the closest of the selected type minimap point at the selected angle
//
// top is 0 right 90 bottom 180 left 270
//
// by cosmasjdz 2014-08-09
//
// example: Minimap.RotateToPoint(MM_DOT_NPC,0); this rotates screen so the closest yellow dot on the minimap becomes north of the screen
//
////////////////////////////////////////////////////////////////////
function TRSMinimap.RotateToPoint( DotType: integer; MainscreenLocation: integer): boolean;
var
TPA: TPointArray;
t: tpoint;
k,m: extended;
xv,yv,i,ml: integer;
begin
ml:=mainscreenlocation;
t:=self.getCenterPoint();
TPA:=self.getdots(DotType,self.getbounds());
if high(tpa)=-1 then
begin
writeln('No such type dots found on the minimap, quiting procedure');
result:=false;
exit;
end;
SortTPAFrom(TPA, t);
writeln('Trying to rotate to the closest '+tostring(dottype)+' dot '+'at angle of mainscreen of '+tostring(Mainscreenlocation));
xv:=tpa[0].x-t.x;
yv:=t.y-tpa[0].y;
k:=degrees(ArcTan2(yv,xv));
m:=(self.getangledegrees());
self.setangle(trunc(k+m-90+ml));
result:=true;
writeln('Succesfully rotated');
end;

Wetish
08-09-2014, 07:36 PM
cosmasjdz;
You should make a new thread in this section instead of replying to this post.