Author Topic: SCRIPT problem  (Read 950 times)

0 Members and 1 Guest are viewing this topic.

Offline corl45

  • Major
  • *
  • Posts: 51
  • PWNED!
    • www.freewebs.com/tylersmod
SCRIPT problem
« on: December 01, 2007, 01:07:14 pm »
ok, i found a link to the tutorial section of scripting.... (still want to know if there is a compiler out there or if i just have to write in notepad)

so, i started writing this in notepad:
Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
var
  pname: string;
begin
  pname := GetPlayerStat(ID,'pname');
  if Text = '/black' then begin
 WriteConsole(0,'[' + Name + ']' +?????,$000000);
    end;
    Result := false;
   
  end;
end;

im trying to make it like a new /say command, and im gona add alot of color's

so it would be like
/black hi
and it would write
  • ["name"] hi

in black color.
I DO NOT KNOW WHAT TO DO IN THE ??


yes i know... i am a n00b, i just want some help...
« Last Edit: December 01, 2007, 01:08:51 pm by corl45 »
BE AWESOME!

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: SCRIPT problem
« Reply #1 on: December 01, 2007, 04:08:55 pm »
You should do something like this:

Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
var
  pname: string;
begin
  pname := GetPlayerStat(ID, 'Name');

  if GetPiece(LowerCase(Text), ' ', 0) = '/black' then
  begin
    WriteConsole(0, '[' + pname + '] ' + Copy(Text, 8, Length(Text)), RGB(0, 0, 0));
  end;

  Result := false;
end;

Notice that used 'Name' as the parameter of GetPlayerStat instead of pname, and used pname inside WriteConsole instead of Name. I think you messed up a bit there.
Also, I used GetPiece(LowerCase(Text), ' ', 0) to check against '/black'. That function call will return the first part of the text (separated by spaces) in lower case.
Then, I used Copy(Text, 8, Length(Text)). That should copy the Text from the character 8 (which is right after '/black ') to the end.
And then I used RGB to make the black color. You can use the hex form too, but I think you need to specify the alpha channel too or it will be transparent. Like $FF000000.

I didn't test this, I just wrote it here, so my apologies if there's some mistake.
urraka

Offline corl45

  • Major
  • *
  • Posts: 51
  • PWNED!
    • www.freewebs.com/tylersmod
Re: SCRIPT problem
« Reply #2 on: December 01, 2007, 08:19:34 pm »
thx! i think its just a matter of memorizing the basic functions and all... cuz i understood every thing you said there

edit:
wait... there is one thing i never got to understand, now... or when i learned the lessened pascal, when the result=true or false i still dont know exatclyl what that dose
« Last Edit: December 01, 2007, 08:27:49 pm by corl45 »
BE AWESOME!

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: SCRIPT problem
« Reply #3 on: December 01, 2007, 09:33:46 pm »
thx! i think its just a matter of memorizing the basic functions and all... cuz i understood every thing you said there

edit:
wait... there is one thing i never got to understand, now... or when i learned the lessened pascal, when the result=true or false i still dont know exatclyl what that dose
for OnCommand or OnPlayerCommand events, when result is false, the command works, if its false then the command doesn't do anything.. like if an admin does /say BLARG! and you have it so oncommand result := true, then nothing will happen..

Offline corl45

  • Major
  • *
  • Posts: 51
  • PWNED!
    • www.freewebs.com/tylersmod
Re: SCRIPT problem
« Reply #4 on: December 02, 2007, 06:21:04 pm »
thx! i think its just a matter of memorizing the basic functions and all... cuz i understood every thing you said there

edit:
wait... there is one thing i never got to understand, now... or when i learned the lessened pascal, when the result=true or false i still dont know exatclyl what that dose
for OnCommand or OnPlayerCommand events, when result is false, the command works, if its false then the command doesn't do anything.. like if an admin does /say BLARG! and you have it so oncommand result := true, then nothing will happen..

so leme use the script up top as an example (parro's) if i changed the result:=false to result:=true, it wouldn't do anything?
BE AWESOME!

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: SCRIPT problem
« Reply #5 on: December 02, 2007, 08:47:25 pm »
The script would still work. It's for avoiding default soldat commands to be executed. For example, if the command is "/map lalal" and you return true, the map won't be changed to "lalal".
urraka

Offline corl45

  • Major
  • *
  • Posts: 51
  • PWNED!
    • www.freewebs.com/tylersmod
Re: SCRIPT problem
« Reply #6 on: December 02, 2007, 09:41:32 pm »
ohh, so i could use this to use /say like that command?
BE AWESOME!

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: SCRIPT problem
« Reply #7 on: December 02, 2007, 10:26:17 pm »
Yep, exactly for that kind of things.
urraka

Offline corl45

  • Major
  • *
  • Posts: 51
  • PWNED!
    • www.freewebs.com/tylersmod
Re: SCRIPT problem
« Reply #8 on: December 03, 2007, 06:09:21 pm »
ok, so dose it matter where i put the =true? could i put it at the start of the function or at the bottom?
BE AWESOME!