Author Topic: DrawText Command  (Read 11176 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
DrawText Command
« 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:
  • The limit of 72 characters is due to Soldat limitations.
  • Fits well with the colored '/say' script, sense this writes to the console with the style that the '/say' color script does.
« Last Edit: July 06, 2007, 12:52:53 pm by DorkeyDear »

Offline deguix

  • Major
  • *
  • Posts: 79
Re: DrawText Command
« Reply #1 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.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: DrawText Command
« Reply #2 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.

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: DrawText Command
« Reply #3 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.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: DrawText Command
« Reply #4 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?
urraka

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: DrawText Command
« Reply #5 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.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: DrawText Command
« Reply #6 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.
urraka

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: DrawText Command
« Reply #7 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.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: DrawText Command
« Reply #8 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)
« Last Edit: June 11, 2007, 01:57:33 pm by DorkeyDear »

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: DrawText Command
« Reply #9 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
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: DrawText Command
« Reply #10 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
Can't think of anything original to put here...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: DrawText Command
« Reply #11 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

Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
Re: DrawText Command
« Reply #12 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. 
xfire - todhostetler
"There's nothing I wouldn't do to win. But I never hurt anyone except to stick a dogskull on a stake."

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: DrawText Command
« Reply #13 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.)

Offline Dizzy So 1337

  • Soldier
  • **
  • Posts: 246
Re: DrawText Command
« Reply #14 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...
xfire - todhostetler
"There's nothing I wouldn't do to win. But I never hurt anyone except to stick a dogskull on a stake."

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: DrawText Command
« Reply #15 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.

Offline 1221995

  • Soldier
  • **
  • Posts: 206
Re: DrawText Command
« Reply #16 on: August 04, 2007, 06:11:55 am »
I love this script. Thanks :)

Offline SneS

  • Soldier
  • **
  • Posts: 110
Re: DrawText Command
« Reply #17 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. :'(

Offline Akinaro

  • Flagrunner
  • ****
  • Posts: 749
Re: DrawText Command
« Reply #18 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):
« Last Edit: March 07, 2014, 09:37:10 am by Akinaro »

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: DrawText Command
« Reply #19 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;
« Last Edit: March 07, 2014, 10:27:50 am by skrX »

Offline SneS

  • Soldier
  • **
  • Posts: 110
Re: DrawText Command
« Reply #20 on: March 04, 2015, 08:36:27 am »
Great script and thank you. ;D