Advertisement
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, PhrasePM: 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;
- StoreText: string;
- begin
- for i := 1 to HighestID do begin
- if LowerCase(GetPlayerStat(i, 'Name')) = LowerCase(NamePiecePM) then begin
- NameCountPM := 1
- SlotIDPM := i
- exit;
- end;
- if ContainsString(LowerCase(NamePiecePM) + ' ' + LowerCase(PhrasePM), LowerCase(GetPlayerStat(i, 'Name'))) then begin
- NameCountPM := 1
- SlotIDPM := i
- StoreText := NamePiecePM + ' ' + PhrasePM
- NamePiecePM := Copy(StoreText, 1, Length(GetPlayerStat(i, 'Name')))
- PhrasePM := Copy(StoreText, Length(GetPlayerStat(i, 'Name')) + 2, Length(StoreText))
- exit;
- end;
- if (ContainsString(LowerCase(GetPlayerStat(i, 'Name')), LowerCase(NamePiecePM))) then begin
- NameCountPM := NameCountPM + 1
- SlotIDPM := i
- end;
- end;
- end;
- function OnCommand(Id: byte; Text: string): boolean;
- begin
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') then begin
- Result := true;
- if Id = 255 then begin
- if (ContainsString(Text, ' ')) then begin
- NamePiecePM := GetPiece(Text, ' ', 1)
- PhrasePM := Copy(Text, StrPos(NamePiecePM, Text) + Length(NamePiecePM) + 1, Length(Text))
- NameCountPM := 0
- SlotIDPM := 0
- Trigger := false
- 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, '[SERVER PM]' + ' ' + PhrasePM, PMColor)
- WriteLn('PM To: [' + GetPlayerStat(SlotIDPM, 'Name') + ']' + ' ' + PhrasePM);
- end;
- if NameCountPM = 0 then begin
- WriteLn('Phrase' + ' "' + NamePiecePM + '" ' + 'was not found, please be more specific or use the players slot number (1-32)');
- end;
- if NameCountPM > 1 then begin
- WriteLn('Phrase' + ' "' + NamePiecePM + '" ' + 'returned too many different players, please be more specific or use the players slot number (1-32)');
- end
- end
- end
- end
- end;
- function OnPlayerCommand(Id: byte; Text: string): boolean;
- var
- i: byte;
- begin
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') or (LowerCase(GetPiece(Text, ' ', 0)) = '/ignore') or (LowerCase(GetPiece(Text, ' ', 0)) = '/unignore') then begin
- if (ContainsString(Text, ' ')) then begin
- NamePiecePM := GetPiece(Text, ' ', 1)
- PhrasePM := Copy(Text, StrPos(NamePiecePM, Text) + Length(NamePiecePM) + 1, Length(Text))
- NameCountPM := 0
- SlotIDPM := 0
- Trigger := false
- try
- NamePieceInt := StrToInt(NamePiecePM);
- if GetPlayerStat(NamePieceInt, 'Active') = true then begin
- Trigger := true;
- NameCountPM := 1;
- SlotIDPM := NamePieceInt;
- end;
- except
- Trigger := false
- end;
- if (LowerCase(NamePiecePM) = 'server') or (LowerCase(NamePiecePM) = 'admin') then begin
- Trigger := true
- NameCountPM := 69;
- end;
- if (Trigger = false) then begin
- CountPM();
- end;
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') then begin
- 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)
- exit;
- end;
- if (NameCountPM > 1) and (NameCountPM < 69) then begin
- Say(Id, 'Phrase' + ' "' + NamePiecePM + '" ' + 'returned too many different players, please be more specific or use the players slot number (1-32)', ErrorColor)
- exit;
- end;
- if NameCountPM = 69 then begin
- Say(Id, 'PM Sent To Admin:' + ' ' + PhrasePM, PMColor2)
- WriteLn('!admin')
- WriteLn('PM' + ' ' + 'From:' + ' [' + GetPlayerStat(Id, 'Name') + '] ' + 'To: [SERVER ADMIN]' + ' ' + PhrasePM);
- exit;
- end;
- if (NameCountPM = 1) and (IgnorePM[SlotIDPM][Id] = true) then begin
- NameCountPM := 70;
- end;
- if NameCountPM = 1 then begin
- Say(SlotIDPM, '[PM] [' + GetPlayerStat(Id, 'Name') + ']' + ' ' + PhrasePM, PMColor)
- Say(Id, 'PM To: [' + GetPlayerStat(SlotIDPM, 'Name') + ']' + ' ' + PhrasePM, PMColor2)
- WriteLn('PM' + ' ' + 'From' + ' [' + GetPlayerStat(Id, 'Name') + '] ' + 'To: [' + GetPlayerStat(SlotIDPM, 'Name') + ']' + ' ' + PhrasePM);
- exit;
- end;
- if NameCountPM = 70 then begin
- WriteConsole(Id, GetPlayerStat(SlotIDPM, 'Name') + ' ' + 'has muted your Private Messages', ErrorColor)
- exit;
- end
- end;
- end;
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/ignore') then begin
- if NameCountPM = 1 then begin
- IgnorePM[Id][SlotIDPM] := true;
- WriteConsole(SlotIDPM, GetPlayerStat(Id, 'Name') + ' ' + 'has muted your Private Messages', ErrorColor);
- Say(Id, 'You have muted Private Messages from' + ' ' + GetPlayerStat(SlotIDPM, 'Name') + ' ' + '(to get private messages again from this player use /unignore)', ErrorColor)
- WriteLn(GetPlayerStat(Id, 'Name') + ' ' + 'has muted Private Messages from' + ' ' + GetPlayerStat(SlotIDPM, 'Name'));
- exit;
- 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)
- exit;
- 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)
- exit;
- end;
- end;
- if (LowerCase(GetPiece(Text, ' ', 0)) = '/unignore') then begin
- if NameCountPM = 1 then begin
- IgnorePM[Id][SlotIDPM] := false;
- WriteConsole(SlotIDPM, GetPlayerStat(Id, 'Name') + ' ' + 'has unmuted your Private Messages', ErrorColor)
- Say(Id, 'You have unmuted Private Messages from' + ' ' + GetPlayerStat(SlotIDPM, 'Name'), ErrorColor)
- WriteLn(GetPlayerStat(Id, 'Name') + ' ' + 'has unmuted Private Messages from' + ' ' + GetPlayerStat(SlotIDPM, 'Name'));
- exit;
- 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)
- exit;
- 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)
- exit;
- end
- end
- end;
- //
- if (LowerCase(Text) = '/ignoreall') then begin
- for i := 1 to 32 do IgnorePM[Id][i] := true;
- WriteConsole(Id, 'You have muted all Private Messages, to undo this type /unignoreall', ErrorColor);
- end;
- if (LowerCase(Text) = '/unignoreall') then begin
- for i := 1 to 32 do IgnorePM[Id][i] := false;
- WriteConsole(Id, 'You have unmuted all Private Messages', ErrorColor);
- end;
- //
- end;
- procedure OnJoinGame(Id, Team: byte);
- begin
- HighestID := 1
- SetHighestID();
- end;
- procedure OnLeaveGame(Id, Team: byte; Kicked: boolean);
- var i: byte;
- begin
- for i := 1 to 32 do begin
- IgnorePM[i][Id] := false;
- IgnorePM[Id][i] := false;
- end;
- if Id = HighestID then begin
- HighestID := 1
- SetHighestID();
- end;
- end;
- procedure ActivateServer();
- var i, j: byte;
- begin
- SetHighestID();
- for i := 1 to 32 do for j := 1 to 32 do IgnorePM[i][j] := false;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement