Author Topic: [Function] AddSpaces  (Read 2041 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 166
[Function] AddSpaces
« on: September 06, 2008, 03:55:05 am »
Script Name: AddSpaces
Script Description: This function allows you to add spaces to... meh, whatever, look at the attached screenshot
Original Author(s): Mr
Core Version: 2.2.X

Code: [Select]
{ Mr's AddSpaces }
function AddSpaces(Text: string; tlen: integer): string;
var
  i,Spacecount: integer;
  Spaces: string;
begin
  Spacecount := length(Text);
  for i := 0 to (tlen-Spacecount) do Spaces := Spaces+' ';
  Result := Spaces;
end;
If you don't always want to write the string that you want to use with my function twice, just change Result := Spaces; to Result := Text+Spaces;

Usage example:
Code: [Select]
WriteConsole(ID,GetPlayerStat(i,'Name')+AddSpaces(GetPlayerStat(i,'Name'),26)+iif(GodMode[i],'On','Off'),RGB(0,245,245));

- Mr
« Last Edit: September 06, 2008, 05:17:44 am by Mr »

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: [Function] AddSpaces
« Reply #1 on: September 06, 2008, 04:45:17 am »
whats the point? you can just press space to add spaces...

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: [Function] AddSpaces
« Reply #2 on: September 06, 2008, 04:48:51 am »
It will dynamically add the right amount of spaces. Nice work Mr, simple and effective ;)

Offline Mr

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 166
Re: [Function] AddSpaces
« Reply #3 on: September 06, 2008, 05:23:43 am »
I updated the first post... I don't think that someone wants to calculate the amount of spaces that are needen for another string xD

Btw, thanks EnEsCe :)

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Re: [Function] AddSpaces
« Reply #4 on: September 06, 2008, 09:02:27 am »
Wow. Nice Work Mr.

Great for organizing console writes.
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: [Function] AddSpaces
« Reply #5 on: September 08, 2008, 05:29:02 am »
I have a similar function created a while ago, called Table. If you want to take a look: http://forums.soldat.pl/index.php?topic=26687
Good job though, nice clean and simple.