0 Members and 2 Guests are viewing this topic.
const COLOR_PM_MSG = $FF8888FF; // color of private message COLOR_PM_OK = $FF88FF88; // color of "unmuted" and "msg sent" COLOR_PM_ERROR = $FFFF8888; // color of "muted", "not sent" and "player doesn't exist" COLOR_PM_SERVER = $FF8888FF; // color of PM from TCP Adminvar i, idpm: integer; playerpm: string; mutepm: array[1..32] of array[1..32] of boolean;procedure ActivateServer();begin for i := 1 to 32 do mutepm[i][i] := false;end;function OnCommand(ID: Byte; Text: string): boolean;begin if GetPiece(Text,' ',0) = '/pm' then begin Result := true; if ID = 255 then begin playerpm := 'SERVER'; idpm := strtoint(GetPiece(Text, ' ', 1)); if GetPlayerStat(idpm, 'Active') then begin WriteConsole(idpm, '[PM] [' + playerpm + ']' + Copy(Text, Length(GetPiece(Text, ' ', 1)) + 5, Length(Text)), COLOR_PM_SERVER); WriteLn('Private message sent to ' + IDToName(idpm)); end else WriteLn('Error: player #' + (GetPiece(Text, ' ', 1)) + ' doesn`t exist.'); end; end; end;function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if GetPiece(Text, ' ', 0) = '/mutepm' then begin idpm := strtoint(GetPiece(Text, ' ', 1)); if GetPlayerStat(idpm, 'Active') = true then begin mutepm[ID][idpm] := true; WriteConsole(ID, 'Private Meggages from ' + IDToName(idpm) + ' muted.', COLOR_PM_ERROR); end else WriteConsole(ID, 'Error: player #' + (GetPiece(Text, ' ', 1)) + ' doesn`t exist.', COLOR_PM_ERROR); end else if GetPiece(Text, ' ', 0) = '/unmutepm' then begin idpm := strtoint(GetPiece(Text, ' ', 1)); if GetPlayerStat(idpm, 'Active') = true then begin mutepm[ID][idpm] := false; WriteConsole(ID, 'Private Meggages from ' + IDToName(idpm) + ' unmuted.', COLOR_PM_OK); end else WriteConsole(ID, 'Error: player #' + (GetPiece(Text, ' ', 1)) + ' doesn`t exist.', COLOR_PM_ERROR); end; if GetPiece(Text, ' ', 0) = '/pm' then begin Result := true; playerpm := GetPlayerStat(ID, 'Name'); if GetPiece(Text, ' ', 1) = 'admin' then begin WriteLn('[PM] [' + playerpm + '] ' + Copy(Text, StrPos(GetPiece(Text, ' ', 1), Text) + 5, Length(Text))); WriteConsole(ID, 'Private message sent to TCP Admin', COLOR_PM_OK); end else begin idpm := strtoint(GetPiece(Text, ' ', 1)); if GetPlayerStat(idpm, 'Active') = true then begin if mutepm[idpm][ID] = true then begin WriteConsole(ID, 'Message NOT sent, ' + IDToName(idpm) + ' has muted your PMs.', COLOR_PM_ERROR); end else begin WriteConsole(idpm, '[PM] [' + playerpm + ']' + Copy(Text, Length(GetPiece(Text, ' ', 1)) + 5, Length(Text)), COLOR_PM_MSG); WriteConsole(ID, 'Private message sent to ' + IDToName(idpm), COLOR_PM_OK); end; end else WriteConsole(ID, 'Error: player #' + (GetPiece(Text, ' ', 1)) + ' doesn`t exist.', COLOR_PM_ERROR); end; end;end;procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);begin for i := 1 to 32 do begin mutepm[i][ID] := false; mutepm[ID][i] := false; end;end;
It's good practice to do that mikembm. It may not be necessary in pascal but it definitely is in vritually all other languages. What if an admin wants to recompile the script?
Quote from: zyxstand on August 14, 2007, 06:52:05 pmIt's good practice to do that mikembm. It may not be necessary in pascal but it definitely is in vritually all other languages. What if an admin wants to recompile the script?I'm pretty sure recompiling will also set them back to false.You may think it's good practice, but I think including code which does absolutely nothing isn't.And as far as other languages go, I'm pretty sure they all have default values as well...
It's good practice to do that mikembm. It may not be necessary in pascal but it definitely is in vritually all other languages. What if an admin wants to recompile the script?
Maybe you should use GetPiece(Text, ',', 1) function? Then players could use /PM,ID,Message and it ll send all message. And others suggestion: use lowercase(GetPiece(Text, ',', 0) = '/pm', then command will work even when player ll write '/PM'.