Shuttleu
2008-06-01 02:48:01
i have got all the functions and procedures in Friends.scar to work
Note i didnt edit all of the functions i just cant remember what ones i edited to get it to work
when scar gets updated to scar 3.16 then just take out all of these
~shut
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Friends Routines --//
//-----------------------------------------------------------------//
// * Function NumberOfOnlineFriends: Integer; // * by Wizzup?
// * Procedure AddFriend(Friend: String); // * by Wizzup?
// * Procedure DeleteFriend(Friend: String); // * by Wizzup?
// * Procedure AddIgnore(Friend: String); // * by Wizzup?
// * Procedure DeleteIgnore(Friend: String); // * by Wizzup?
// * Function GetFriendTexts: TStringArray; // * by n3ss3s
// * Function FromFriend(Friend: String): String; // * by n3ss3s
// * Function FromFriendMulti(Friend: String): TStringArray; // * by n3ss3s
// * Function GetChatterOfLine(Line: String): String; // * by n3ss3s
// * Function RespondToWith(rTo, rWith: String): Boolean; // * by n3ss3s
// * Function HasResponded(Friend: String): Boolean; // * by n3ss3s
type
TFriends = Record
Name: String;
World: String;
IsOnline: Boolean;
YourWorld: Boolean;
End;
Var
Friends : Array[0..12] Of TFriends;
FriendChars : integer;
{*******************************************************************************
function FriendName(PlayerNumber: Integer): String;
By: Wizzup?
Description: Gets FriendsName and saves it to a string.
*******************************************************************************}
Function FriendName(PlayerNumber: Integer): String;
Begin
FriendChars:=(LoadChars2(AppPath+'Fonts\FriendChars\'));
Result := Trim(GetTextAtEx(562, 233 + (PlayerNumber * 15), 45, FriendChars, True, False, 0,
2, 16777215, 20, False, tr_NormalChars));
End;
{*******************************************************************************
function FriendWorld(PlayerNumber: Integer; SameWorld: Boolean) : String;
By: Wizzup?
Description: Returns current world of a friend.
First Friend = 0
Last Friend = 11
*******************************************************************************}
function FriendWorld(PlayerNumber: Integer; SameWorld: Boolean) : String;
Var
I : Integer;
Begin
FriendChars:=(LoadChars2(AppPath+'Fonts\FriendChars\'));
If SameWorld Then
Result := Trim(GetTextAtEx(665, 233 + (PlayerNumber * 15), 45, FriendChars, True, False, 0,
2, 65280, 20, False, tr_NormalChars))
Else
Result := Trim(GetTextAtEx(665, 233 + (PlayerNumber * 15), 45, FriendChars, True, False, 0,
2, 65535, 20, False, tr_NormalChars));
I := Pos('orld', Result);
If I <> 0 Then
Begin
Delete(Result, 1, 5);
End
Else Result := '';
End;
{*******************************************************************************
procedure GetFriends;
By: Wizzup?
Description: Returns first 12 friends World/Status/Name into the Friends Record.
TFriends = Record
Name: String;
World: String;
IsOnline: Boolean;
YourWorld: Boolean;
*******************************************************************************}
Procedure GetFriends;
Var
I, iX, iY: Integer;
Begin
GameTab(8);
Wait(500);
For I := 0 To 11 Do
Begin
Friends[i].Name := FriendName(I);
If FindColor(iX, iY, 65280, 665, 233 + (I * 15), 718, 244 + (I * 15)) Then
Begin
Friends[i].IsOnline := True;
Friends[i].YourWorld := True;
Friends[i].World := FriendWorld(I, True);
End
Else If FindColor(iX, iY, 65535, 665, 233 + (I * 15), 718, 244 + (I * 15)) Then
Begin
Friends[i].IsOnline := True;
Friends[i].YourWorld := False;
Friends[i].World := FriendWorld(I, False);
End;
End;
End;
{*******************************************************************************
function FriendIsOnline(Var iX, iY: Integer; Friend: String): Boolean;
By: Wizzup?
Description: Returns coordinate of Online friend, if Online.
"Friend:String" May also be a part of the whole name, like Players[].Nick.
*******************************************************************************}
Function FriendIsOnline(Var iX, iY: Integer; Friend: String): Boolean;
Var
I : Integer;
Begin
GetFriends;
Begin
If IsTextInAreaEx(MIX1, MIY1, MIX2, MIY2, iX, iY, Capitalize(Friend), 5, FriendChars, false, false, 0, 0, 16777215) Then
Begin
Result := True;
iX := 562 + Random(130);
iY := 233 + (15 * I)+ Random(13);
End;
End;
End;
{*******************************************************************************
function MessageFriendEx(Friend, TheMessage: String): Boolean;
By: Wizzup?
Description: If a certain friend is online, sends them a message.
"Friend:String" May also be a part of the whole name, like Players[].Nick.
*******************************************************************************}
Function MessageFriendEx(Friend, TheMessage: String): Boolean;
Var
iX, iY : Integer;
Begin
If FriendIsOnline(iX, iY, LowerCase(Friend)) Then
Begin
Result := True;
Mouse(iX, iY, 0, 0, True);
Wait(100 + Random(100))
TypeSend(TheMessage);
End
Else WriteLn('The friend is not online.');
End;
{*******************************************************************************
function NumberOfOnlineFriends: Integer;
By: Wizzup?
Description: Returns # of friends online from 0-11.
Is actually 1-12, but the array only goes from 0 to 11 at the moment.
*******************************************************************************}
Function NumberOfOnlineFriends: Integer;
Var
I: Integer;
Begin
GetFriends;
For I := 0 To 11 Do
If Friends[i].IsOnline Then
Result := Result + 1;
End;
{*******************************************************************************
procedure AddFriend(Friend: String);
By: Wizzup?
Description: Add's 'Friend' to your friends list.
*******************************************************************************}
Procedure AddFriend(Friend: String);
Begin
GetFriends;
Mouse(575 + Random(45), 435 + Random(20), 0, 0, True);
Wait(100 + Random(100));
TypeSend(Friend);
Wait(1000 + Random(500));
End;
{*******************************************************************************
procedure DeleteFriend(Friend: String);
By: Wizzup?
Description: Delete's 'Friend' from your friends list.
*******************************************************************************}
Procedure DeleteFriend(Friend: String);
Begin
GetFriends;
Mouse(656 + Random(45), 435 + Random(20), 0, 0, True);
Wait(100 + Random(100));
TypeSend(Friend);
Wait(1000 + Random(500));
End;
{*******************************************************************************
procedure AddIgnore(Friend: String);
By: Wizzup?
Description: Add's 'Friend' to your ignore list.
*******************************************************************************}
Procedure AddIgnore(Friend: String);
Begin
GameTab(9);
Mouse(575 + Random(45), 435 + Random(20), 0, 0, True);
Wait(100 + Random(100));
TypeSend(Friend);
Wait(1000 + Random(500));
End;
{*******************************************************************************
procedure DeleteIgnore(Friend: String);
By: Wizzup?
Description: Deletes 'Friend' from Ignore list.
*******************************************************************************}
Procedure DeleteIgnore(Friend: String);
Begin
GameTab(9);
Mouse(656 + Random(45), 435 + Random(20), 0, 0, True);
Wait(100 + Random(100));
TypeSend(Friend);
Wait(1000 + Random(500));
End;
{*******************************************************************************
Function GetFriendTexts: TStringArray;
By: n3ss3s
Description: Returns all the friend chats, even the empty lines.
*******************************************************************************}
Function GetFriendTexts: TStringArray;
//* Result[0] is the first PM chatline counting from up to down.
//* Closest one to chatbox is Result[4]
//* There are total 5 PM chatlines visible once.
Var
Sx, Sy, I: Integer;
Begin
FriendChars:=(LoadChars2(AppPath+'Fonts\FriendChars\'));
sx := 4;
sy := 269;
SetArrayLength(Result, 5);
For I := 0 To 4 Do
Begin
Result[i] := GetTextAtEx(sx, sy + 13 * i, 0, FriendChars, false, false, 0, 0, 16776960, 70, false, tr_allchars);
Writeln(Result[i]);
End;
End;
Function GetChatterOfLine(Line: String): String; forward;
{*******************************************************************************
Function FromFriend(Friend: String): String;
By: n3ss3s
Description: Returns the first occurence of text sent by friend Friend.
*******************************************************************************}
Function FromFriend(Friend: String): String;
Var
GFT: TStringArray;
I: Integer;
Begin
GFT := GetFriendTexts;
For I := 0 To High(GFT) Do
Begin
If GetChatterOfLine(GFT[i]) = Friend Then
Begin
Result := GFT[i];
Result := Copy(Result, Pos(':', Result), Length(Result));
Exit;
End;
End;
End;
{*******************************************************************************
Function FromFriendMulti(Friend: String): TStringArray;
By: n3ss3s
Description: Returns all the occurences of text sent by friend Friend.
*******************************************************************************}
Function FromFriendMulti(Friend: String): TStringArray;
Var
GFT: TStringArray;
I: Integer;
Begin
GFT := GetFriendTexts;
For I := 0 To High(GFT) Do
Begin
If GetChatterOfLine(GFT[i]) = Friend Then
Begin
Result[i] := GFT[i];
Result[i] := Copy(Result[i], Pos(':', Result[i]), Length(Result[i]));
End;
End;
End;
{*******************************************************************************
Function GetChatterOfLine(Line: String): String;
By: n3ss3s
Description: Returns the friend who sent the text Line.
*******************************************************************************}
Function GetChatterOfLine(Line: String): String;
Var
A, B: String;
Begin
A := Copy(Line, 1, Pos(':', Line));
B := Copy(Line, 1, Pos(' ', A));
Result := Replace(A, B, '');
Result := Replace(Result, ':', '');
End;
{*******************************************************************************
Function RespondToWith(rTo, rWith: String): Boolean;
By: n3ss3s
Description: Returns true if could respond to message rTo with rWith.
*******************************************************************************}
Function RespondToWith(rTo, rWith: String): Boolean;
Var
GFT: TStringArray;
I: Integer;
Begin
GFT := GetFriendTexts;
For I := 0 To High(GFT) Do
If Pos(rTo, GFT[i]) > 0 Then
Result := MessageFriendEx(GetChatterOfLine(GFT[i]), rWith);
End;
{*******************************************************************************
Function HasResponded(Friend: String): Boolean;
By: n3ss3s
Description: Returns true if friend Friend has responded to you.
*******************************************************************************}
Function HasResponded(Friend: String): Boolean;
Var
GFT: TStringArray;
I: Integer;
Begin
GFT := GetFriendTexts;
Result := True;
For I := 0 To High(GFT) Do
If Pos('From '+Friend, GFT[i]) > 0 Then
Exit;
Result := False;
End;
but you will need these chars and you will need to place them into the folder called fonts in the scar folderNote i didnt edit all of the functions i just cant remember what ones i edited to get it to work
when scar gets updated to scar 3.16 then just take out all of these
FriendChars:=(LoadChars2(AppPath+'Fonts\FriendChars\'));~shut