Bendarr

Bendarr

Feb 3rd, 2011
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.93 KB | None | 0 0
  1. const
  2. PMColor = $FF0FA0C6;
  3. PMColor2 = $FF9C9F9F;
  4. ErrorColor = $FFBF7F7F;
  5.  
  6. var
  7. HighestID: byte;
  8. SlotIDPM, NameCountPM, NamePieceInt: integer;
  9. IgnorePM: array[1..32] of array[1..32] of boolean;
  10. NamePiecePM: string;
  11. Trigger: boolean;
  12.  
  13. function StrrPos(const Substr, S: string): integer;
  14. begin
  15.    for Result := Length(S) - Length(Substr) + 1 downto 1 do
  16.    if (Copy(S, Result, Length(Substr)) = Substr) then
  17.      exit;
  18.    Result := 0;
  19. end;
  20.  
  21. procedure Say(const Id: byte; const Text: string; const Color: longint);
  22. var
  23.    Pos: integer;
  24. begin
  25.    if (Length(Text) <= 72) then
  26.      WriteConsole(Id, Text, Color)
  27.    else begin
  28.    Pos := StrrPos(' ', Copy(Text, 1, 72));
  29.    if (Pos = 0) then begin
  30.      Pos := 72;
  31.    WriteConsole(Id, Copy(Text, 1, 72), Color);
  32. end else
  33. WriteConsole(Id, Copy(Text, 1, Pos - 1), Color);
  34. Say(Id, Copy(Text, Pos + 1, Length(Text)), Color);
  35. end;
  36. end;
  37.  
  38. Procedure SetHighestID();
  39. var
  40.    i: byte;
  41. begin
  42.    for i := 1 to 32 do
  43.    if (HighestID < i) then
  44.    if (GetPlayerStat(i, 'Active') = true) then
  45.    HighestID := i
  46. end;
  47.  
  48. procedure CountPM();
  49. var
  50.    i: byte;
  51. begin
  52.    for i := 1 to HighestID do
  53.      if (ContainsString(LowerCase(GetPlayerStat(i, 'Name')), LowerCase(NamePiecePM))) then begin
  54.      NameCountPM := NameCountPM + 1
  55.      SlotIDPM := i
  56. end;
  57. end;
  58.  
  59. function OnCommand(Id: byte; Text: string): boolean;
  60. begin
  61. if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') then begin
  62. Result := true;
  63. end else if (LowerCase(Text) = '/updateplayers') then begin
  64. SetHighestID();
  65. end
  66. end;
  67.  
  68. function OnPlayerCommand(Id: byte; Text: string): boolean;
  69. var
  70.    Team, i: byte;
  71. begin
  72.  
  73. if (LowerCase(GetPiece(Text, ' ', 0)) = '/pm') then begin
  74. if (ContainsString(Text, ' ')) then begin
  75. NamePiecePM := GetPiece(Text, ' ', 1)
  76. Text := Copy(Text, StrPos(NamePiecePM, Text) + Length(NamePiecePM) + 1, Length(Text))
  77.  
  78. try
  79. NamePieceInt := StrToInt(NamePiecePM);
  80. if GetPlayerStat(NamePieceInt, 'Active') = true then begin
  81. Trigger := true;
  82. NameCountPM := 1;  
  83. SlotIDPM := NamePieceInt;
  84. end;
  85. except
  86. Trigger := false
  87. end;
  88.  
  89. if Trigger = false then begin
  90. CountPM();
  91. end;
  92.  
  93. if NameCountPM = 1 then begin
  94. Say(SlotIDPM, '[PM] [' + GetPlayerStat(Id, 'Name') + ']' + ' ' + Text, PMColor)
  95. Say(Id, 'PM To: [' + GetPlayerStat(SlotIDPM, 'Name') + ']' + ' ' + Text, PMColor2)
  96. end;
  97. if NameCountPM = 0 then begin
  98. Say(Id, 'Phrase' + ' "' + NamePiecePM + '" ' + 'was not found, please be more specific or use the players slot number (1-32)', ErrorColor)
  99. end;
  100. if NameCountPM > 1 then begin
  101. Say(Id, 'Phrase' + ' "' + NamePiecePM + '" ' + 'returned too many different players, please be more specific or use the players slot number (1-32)', ErrorColor)
  102. end
  103. NameCountPM := 0
  104. SlotIDPM := 0
  105. end
  106. end;
  107. end;
  108.  
  109. procedure OnJoinGame(Id, Team: byte);
  110. begin
  111. HighestID := 1
  112. SetHighestID();
  113. end;
  114.  
  115. procedure OnLeaveGame(Id, Team: byte; Kicked: boolean);
  116. begin
  117. if Id = HighestID then begin
  118. HighestID := 1
  119. SetHighestID();
  120. end;
  121. end;
Add Comment
Please, Sign In to add comment