{ _
___| | ___ ____ __
/ __| |/ / '__\ \/ /
\__ \ <| | > <
|___/_|\_\_| /_/\_\
by skrX
}
var
TypeArray: TStringarray;
function Explode(Source: string; const Delimiter: string): array of string;
var
Position, DelLength, ResLength: integer;
begin
DelLength := Length(Delimiter);
Source := Source + Delimiter;
repeat
Position := Pos(Delimiter, Source);
SetArrayLength(Result, ResLength + 1);
Result[ResLength] := Copy(Source, 1, Position - 1);
ResLength := ResLength + 1;
Delete(Source, 1, Position + DelLength - 1);
until (Position = 0);
SetArrayLength(Result, ResLength - 1);
end;
function OnCommand(ID: byte; Text: string): boolean;
var
randomtext: integer;
buffer: string;
i: integer;
begin
Result := false;
buffer := '';
TypeArray := Explode(Text, ' ');
case TypeArray[0] of
'/troll','/says','chat':
if ArrayHigh(TypeArray) >= 2 then begin
for i := 2 to ArrayHigh(TypeArray) - 1 do begin
buffer := buffer + TypeArray[i] + ' ';
end;
buffer := buffer + TypeArray[ArrayHigh(TypeArray)];
BotChat(strtoint(TypeArray[1]), buffer);
//to be able to use the commands
//OnPlayerSpeak(strtoint(TypeArray[1]), buffer);
end;
end;
end;
So it is not simpler?
if MaskCheck(LowerCase(Text),'/troll *') then begin
BotChat(strtoint(GetPiece(Text,' ',1)), Copy(Text,10,Length(Text)));
end;