0 Members and 2 Guests are viewing this topic.
function OnCommand(ID: Byte; Text: string): boolean;var Name: string;begin if ID = 255 then Name := 'Server' else Name := GetPlayerStat(ID,'Name'); if Copy(Text,1,5) = '/big ' then begin if Length(Text) <= 72 then DrawText(0,Copy(Text,6,Length(Text)),Length(Text) * 10 + 100,$FFDF3CA8,4 / Length(Text),8,240 + Length(Text)) else WriteConsole(ID,'Your message was greater than 72 charactes. It was unable to be drawn.',$FFDF3CA8); WriteConsole(0,'[' + Name + '] ' + Copy(Text,6,Length(Text)),$FFDF3CA8); end;end;
Note: The limit of 72 characters is because of a bug with the DrawText procedure. (As I believe, sorry if I'm incorrect there, but I know something happened on that 72nd character that nobody would normally like. )
Please follow the code format guidelines for 100% compatibility with my script combiner:http://forums.soldat.pl/index.php?topic=15629The result := false line should not be included because it is already a part of any code.
if ID = 255 then Name := 'Server' else Name := IDtoName(ID);
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole lineCode: [Select]if ID = 255 then Name := 'Server' else Name := IDtoName(ID);into the following if condition to save up some resources ;Q
Quote from: Avarax on July 06, 2007, 07:03:42 amuse GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole lineCode: [Select]if ID = 255 then Name := 'Server' else Name := IDtoName(ID);into the following if condition to save up some resources ;QI like to use iifs only when it would require many many lines if I do not (many many iffs in 1 statement), but in cases where there is only 1 line either way, I like to stick with normal ifs. I'll modify the IDtoName to the GetPlayerStatwhile you're at it make it:Name := iif(ID=255,'Server',GetPlayerStat(ID,'Name'));
Oh hey... actually i got it figured out. In fact I wrote a tutorial for noobs and used this script as an example, hope that's OK...
constcolor1=$FFFA002A; ////// redcolor2=$FFFFA40F; ////// orangefunction OnCommand(ID: Byte; Text: string): boolean;varMsg: string;begin if(lowercase(Copy(Text,1,5))='/big ')then begin Result:=true; delete(Text,1,4); Msg:=Text; if(Msg<>'') then DrawText(0,''+Msg,330,color2,0.20,40,240); end; if(lowercase(Copy(Text,1,9))='/warning ')then begin Result:=true; delete(Text,1,8); Msg:=Text; if(Msg<>'') then DrawText(0,''+Msg,330,color1,0.20,40,240); end;end;
function OnCommand(ID: Byte; Text: string): boolean;var Name: string;begin if ID = 255 then Name := 'Server' else Name := GetPlayerStat(ID,'Name'); if (LowerCase(Copy(Text,1,5)) = '/big ') then begin if Length(Text) <= 72 then DrawText(0,Copy(Text,6,Length(Text)),Length(Text) * 10 + 100,$FFDF3CA8, 4.0 / Length(Text),8,240 + Length(Text)) else WriteConsole(ID,'Your message was greater than 72 charactes. It was unable to be drawn.',$FFDF3CA8); WriteConsole(0,'[' + Name + '] ' + Copy(Text,6,Length(Text)),$FFDF3CA8); end; Result := false;end;