Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- PMColor = $FF0FA0C6;
- PMColor2 = $FF9C9F9F;
- ErrorColor = $FFBF7F7F;
- var
- HighestID: byte;
- SlotIDPM, NameCountPM, NamePieceInt: integer;
- IgnorePM: array[1..32] of array[1..32] of boolean;
- NamePiecePM: string;
- Trigger: boolean;
- function StrrPos(const Substr, S: string): integer;
- begin
- for Result := Length(S) - Length(Substr) + 1 downto 1 do
- if (Copy(S, Result, Length(Substr)) = Substr) then
- exit;
- Result := 0;
- end;
- procedure Say(const Id: byte; const Text: string; const Color: longint);
- var
- Pos: integer;
- begin
- if (Length(Text) <= 72) then
- WriteConsole(Id, Text, Color)
- else begin
- Pos := StrrPos(' ', Copy(Text, 1, 72));
- if (Pos = 0) then begin
- Pos := 72;
- WriteConsole(Id, Copy(Text, 1, 72), Color);
- end else
- WriteConsole(Id, Copy(Text, 1, Pos - 1), Color);
- Say(Id, Copy(Text, Pos + 1, Length(Text)), Color);
- end;
- end;
- Procedure SetHighestID();
- var
- i: byte;
- begin
- for i := 1 to 32 do
- if (HighestID < i) then
- if (GetPlayerStat(i, 'Active') = true) then
- HighestID := i
- end;
- procedure CountPM();
- var
- i: byte;
- begin
- for i := 1 to HighestID do
- if (ContainsString(LowerCase(GetPlayerStat(i, 'Name')), LowerCase(NamePiecePM))) then begin
- NameCountPM := NameCountPM + 1
- SlotIDPM := i
- end;
- end;
- function OnCommand(Id: byte; Text: string): boolean;
- begin
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') then begin
- Result := true;
- end else if (LowerCase(Text) = '/updateplayers') then begin
- SetHighestID();
- end
- end;
- function OnPlayerCommand(Id: byte; Text: string): boolean;
- var
- Team, i: byte;
- begin
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') then begin
- if (ContainsString(Text, ' ')) then begin
- NamePiecePM := GetPiece(Text, ' ', 1)
- Text := Copy(Text, StrPos(NamePiecePM, Text) + Length(NamePiecePM) + 1, Length(Text))
- try
- NamePieceInt := StrToInt(NamePiecePM);
- if GetPlayerStat(NamePieceInt, 'Active') = true then begin
- Trigger := true;
- NameCountPM := 1;
- SlotIDPM := NamePieceInt;
- end;
- except
- Trigger := false
- end;
- if Trigger = false then begin
- CountPM();
- end;
- if NameCountPM = 1 then begin
- Say(SlotIDPM, '[PM] [' + GetPlayerStat(Id, 'Name') + ']' + ' ' + Text, PMColor)
- Say(Id, 'PM To: [' + GetPlayerStat(SlotIDPM, 'Name') + ']' + ' ' + Text, PMColor2)
- end;
- if NameCountPM = 0 then begin
- Say(Id, 'Phrase' + ' "' + NamePiecePM + '" ' + 'was not found, please be more specific or use the players slot number (1-32)', ErrorColor)
- end;
- if NameCountPM > 1 then begin
- Say(Id, 'Phrase' + ' "' + NamePiecePM + '" ' + 'returned too many different players, please be more specific or use the players slot number (1-32)', ErrorColor)
- end
- NameCountPM := 0
- SlotIDPM := 0
- end
- end;
- end;
- procedure OnJoinGame(Id, Team: byte);
- begin
- HighestID := 1
- SetHighestID();
- end;
- procedure OnLeaveGame(Id, Team: byte; Kicked: boolean);
- begin
- if Id = HighestID then begin
- HighestID := 1
- SetHighestID();
- end;
- end;
Add Comment
Please, Sign In to add comment