Author Topic: WriteConsole help!  (Read 1334 times)

0 Members and 1 Guest are viewing this topic.

Offline |_ancer

  • Soldier
  • **
  • Posts: 153
  • again and again.
WriteConsole help!
« on: September 12, 2009, 08:53:37 am »
OK, I'm wondering basically how do you make a script like this. I'm really frustrated and please help.

If you type /fjoin x, it'll say x has joined the game? (The color doesn't matter).

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: WriteConsole help!
« Reply #1 on: September 12, 2009, 09:00:10 am »
Code: [Select]
function OnPlayerCommand(ID: byte; Text: string): boolean;
begin
  if GetPiece(text,' ',0) = '/fjoin' then WriteConsole(0,GetPiece(text,' ',1) + ' has joined the game', $AA4444);
end;

Offline |_ancer

  • Soldier
  • **
  • Posts: 153
  • again and again.
Re: WriteConsole help!
« Reply #2 on: September 12, 2009, 08:14:08 pm »
Thanks. Can I ask something, I don't get the GetPiece(Text,' ',1) or the GetPiece(Text,' ',0). What does it mean by 1 or 0.
« Last Edit: September 12, 2009, 08:44:24 pm by |_ancer »

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: WriteConsole help!
« Reply #3 on: September 12, 2009, 10:00:21 pm »
Thanks. Can I ask something, I don't get the GetPiece(Text,' ',1) or the GetPiece(Text,' ',0). What does it mean by 1 or 0.
GetPiece basically splits the string up into sections and then returns one of those sections. The first parameter of GetPiece is the string. The second is what to split it by, and the third is which part of it to return.

So if your string is "hi there what's up" then GetPiece(string, ' ', 0) would return "hi", 1 would return "there", etc.

Offline TmTgr

  • Retired Soldat Developer
  • Major
  • ******
  • Posts: 55
Re: WriteConsole help!
« Reply #4 on: September 13, 2009, 02:31:25 am »
Does the splitting only use spaces, or does all whitespace count?

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: WriteConsole help!
« Reply #5 on: September 13, 2009, 05:05:45 am »
Does the splitting only use spaces, or does all whitespace count?
whatever string you specify as the 2nd argument
http://enesce.com/help/html/Functions/GetPiece.html

Offline TmTgr

  • Retired Soldat Developer
  • Major
  • ******
  • Posts: 55
Re: WriteConsole help!
« Reply #6 on: September 14, 2009, 01:10:41 am »
Ok, I should have read it a little more closely.

Offline Uncle_FuXX0r

  • Major(1)
  • Posts: 16
Re: WriteConsole help!
« Reply #7 on: September 25, 2009, 12:24:25 pm »
Just a thought to keep in mind. Arrays, lists, etc., in practically all languages are zero-index based. That means the first element will be at index '0', not '1'.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: WriteConsole help!
« Reply #8 on: September 27, 2009, 03:04:35 am »
In pascal you can specify the range of array:
Code: [Select]
var
 omgarray: array[46..777] of boolean;

But if you mean GetPiece then yes, first element will be 0.