Official Soldat Forums
Server Talk => Scripting Releases => Topic started 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: 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.
-
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.
-
Modified the note. :)
Still there should be a fix so nobody can purposely bring up an error to annoy people or for whatever reason.
-
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.
-
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?
-
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.
-
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.
-
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.
-
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)
-
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole line
if ID = 255 then Name := 'Server' else Name := IDtoName(ID);
into the following if condition to save up some resources ;Q
-
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole line
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
-
use GetPlayerStat(ID,'Name') instead of IDtoName (cleaner) and put that whole line
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
-
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.
-
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.)
-
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...
-
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.
-
I love this script. Thanks :)
-
why not show a big inscription? Shows only a small inscription on the top of the screen. :'(
-
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
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):
-
Try this:
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;
-
Great script and thank you. ;D