Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on June 10, 2007, 05:37:25 pm

Title: DrawText Command
Post by: DorkeyDear on June 10, 2007, 05:37:25 pm
Script Name: DrawText Command
Script Description: When an admin does the /big command, the text following that will be drawn to everybody's screen. It also writes it to everybody's console in case the full message is unreadable (due to it falling off the screen) even with the auto scaler. If you type something lengthy with all caps, or a lot of wide characters, then it may fall off the screen.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.1
Code:
Code: [Select]
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:
Title: Re: DrawText Command
Post by: deguix on June 11, 2007, 01:29:51 am
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. :P)

That is the maximum amount of characters you can type in the game.
Title: Re: DrawText Command
Post by: DorkeyDear on June 11, 2007, 11:32:07 am
Modified the note. :)
Still there should be a fix so nobody can purposely bring up an error to annoy people or for whatever reason.
Title: Re: DrawText Command
Post by: mikembm on June 11, 2007, 11:40:07 am
Please follow the code format guidelines for 100% compatibility with my script combiner:
http://forums.soldat.pl/index.php?topic=15629

The result := false line should not be included because it is already a part of any code.
Title: Re: DrawText Command
Post by: urraka on June 11, 2007, 11:41:43 am
Please follow the code format guidelines for 100% compatibility with my script combiner:
http://forums.soldat.pl/index.php?topic=15629

The result := false line should not be included because it is already a part of any code.

It doesn't make any difference, does it?
Title: Re: DrawText Command
Post by: mikembm on June 11, 2007, 11:50:09 am
If people use the script combiner it will have that line twice after this script is added.
And besides, its not part of the script's code - shouldn't be included regardless.
Title: Re: DrawText Command
Post by: urraka on June 11, 2007, 12:17:38 pm
Yeah, i see your point, but what i mean is that it doesn't affect the behaviour of the script, so it's not really a big deal. The script combiner would work just fine with a script like this one.
Title: Re: DrawText Command
Post by: mikembm on June 11, 2007, 12:25:29 pm
It would work fine but if everyone puts that line in and someone combines a lot of scripts then they will have a lot of redundant lines.
Title: Re: DrawText Command
Post by: DorkeyDear on June 11, 2007, 01:49:14 pm
Edited.
It should check if there is a Result := not under an if and if there isn't, then it will add it at the beginning. (or if there are any elses outside all ifs (other than the if that the else is directed towards) and if there is no Result := under there, then add it too; that way if you have if Copy(Text,1,5) = '/say ' then Result := true else Result := false, you don't have to have the extra Result := false at the beginning. :P) (But thats too much to ask for)
Title: Re: DrawText Command
Post by: Avarax on July 06, 2007, 07:03:42 am
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole line
Code: [Select]
if ID = 255 then Name := 'Server' else Name := IDtoName(ID);into the following if condition to save up some resources ;Q
Title: Re: DrawText Command
Post by: zyxstand on July 06, 2007, 09:37:42 am
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole line
Code: [Select]
if ID = 255 then Name := 'Server' else Name := IDtoName(ID);into the following if condition to save up some resources ;Q

while you're at it make it:
Name := iif(ID=255,'Server',GetPlayerStat(ID,'Name'));
:P
Title: Re: DrawText Command
Post by: DorkeyDear on July 06, 2007, 12:51:24 pm
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole line
Code: [Select]
if ID = 255 then Name := 'Server' else Name := IDtoName(ID);into the following if condition to save up some resources ;Q
I 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 GetPlayerStat
while you're at it make it:
Name := iif(ID=255,'Server',GetPlayerStat(ID,'Name'));
:P
Title: Re: DrawText Command
Post by: Dizzy So 1337 on August 02, 2007, 03:25:48 am
Hi.  Is this a complete script, or just a command set that might be included in a complete script?

I gotta ask, because I am trying to learn script hosting, and I thought this would be a nice simple one to start with on my test server.  So far, she don't fly. 
Title: Re: DrawText Command
Post by: DorkeyDear on August 02, 2007, 07:26:14 pm
This is just a script that you plug in with whatever you have already. Or you can use it by itself if you have no other scripts.
(Please say something if it brings up an error message and what it is.)
Title: Re: DrawText Command
Post by: Dizzy So 1337 on August 02, 2007, 08:42:17 pm
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...
Title: Re: DrawText Command
Post by: DorkeyDear on August 03, 2007, 12:36:47 pm
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...
It is. Glad this can be used to help noobs out, lol.
Title: Re: DrawText Command
Post by: 1221995 on August 04, 2007, 06:11:55 am
I love this script. Thanks :)
Title: Re: DrawText Command
Post by: SneS on March 07, 2014, 08:41:48 am
why not show a big inscription? Shows only a small inscription on the top of the screen. :'(
Title: Re: DrawText Command
Post by: Akinaro on March 07, 2014, 09:28:39 am
use this:

its simpler version, so its just putt color message on screen when admin write: /big or /warning.
You can use any color, use this site for quick color pick:
www.asciiflow.com/#Draw
Code: [Select]
const
color1=$FFFA002A;   ////// red
color2=$FFFFA40F; ////// orange

function OnCommand(ID: Byte; Text: string): boolean;
var
Msg: 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;


Its part of my small color script that i wrote for my self, if you are using polish language you can use it(it have colors for admins and players):
Title: Re: DrawText Command
Post by: skrX on March 07, 2014, 10:25:15 am
Try this:

Code: [Select]
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;
Title: Re: DrawText Command
Post by: SneS on March 04, 2015, 08:36:27 am
Great script and thank you. ;D