Author Topic: Question Thread  (Read 28218 times)

0 Members and 1 Guest are viewing this topic.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Question Thread
« Reply #40 on: April 05, 2010, 03:18:37 am »
COMMA IN BETWEEN PARAMETERS, NOT A SEMICOLON

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Question Thread
« Reply #41 on: April 05, 2010, 03:52:52 am »
Code: [Select]
procedure OnJoinGame(ID,Team:byte);
begin
  procedure WriteConsole(ID:Byte;Text:String;Colour:Longint);
    then begin
      WriteConsole(ID,'Hello, this server is scripted.'; $FFFFFFFF);
      WriteConsole(ID,'You can choose out of 4 classes.'; $FFFFFFFF);
      WriteConsole(ID,'For further information type !help.'; $FFFFFFFF);
end; 
end;
What's that "then begin" for?

DarkCrusade

  • Guest
Re: Question Thread
« Reply #42 on: April 05, 2010, 04:43:54 am »
My logs work again. Right now ...

Code: [Select]
procedure OnJoinGame(ID,Team:byte);
begin
  procedure WriteConsole(ID:Byte;Text:String;Colour:Longint);   
    begin     
  WriteConsole(ID,'Hello, this server is scripted.', $FFFFFFFF);
      WriteConsole(ID,'You can choose out of 4 classes.', $FFFFFFFF);
      WriteConsole(ID,'For further information type !help.', $FFFFFFFF);
end; 
end;

I ... don´t quit understand what my failure is ... maybe you could simply correct it and I will see what I´m doing wrong?

Offline ShadowDancer

  • Major(1)
  • Posts: 22
Re: Question Thread
« Reply #43 on: April 05, 2010, 05:13:33 am »
Why you have function declaration in another function?
Sorry, I'm not native English speaker...

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #44 on: April 05, 2010, 05:20:09 am »
Code: [Select]
procedure OnJoinGame(ID,Team:byte);
begin
  procedure WriteConsole(ID:Byte;Text:String;Colour:Longint);   
    begin     
  WriteConsole(ID,'Hello, this server is scripted.', $FFFFFFFF);
      WriteConsole(ID,'You can choose out of 4 classes.', $FFFFFFFF);
      WriteConsole(ID,'For further information type !help.', $FFFFFFFF);
end; 
end;

You do not have to declare the WriteConsole() procedure since its build-in.
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
begin
  WriteConsole(ID, 'Hello, this server is scripted.', $FFFFFFFF);
  WriteConsole(ID, 'You can choose out of 4 classes.', $FFFFFFFF);
  WriteConsole(ID, 'For further information type !help.', $FFFFFFFF);
end;

DarkCrusade

  • Guest
Re: Question Thread
« Reply #45 on: April 05, 2010, 06:04:48 am »
My script works now, but that´s the one I had before (not posted) so I am confused now (that is why I tried everything, too ...), seems like it was caused by the same error that destroyed my logs but it is fine now :)

Since the script works now I worked on it further and added the commands !help and the commands !classes, !credits and !rules but I have no idea yet how I can implement the different classes ...


Can I use more than one script or can I use only one big mainscript? It would be hellalot easier ...


I just compiled my script again and tried it online. Nothing happens ... I tried the different commands but really nothing happened ... /info told me scripts are compiled and that scripting is enabled. Since I don´t want to copy 75 lines I just attached it.
« Last Edit: April 05, 2010, 07:53:46 am by DarkCrusade »

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #46 on: April 05, 2010, 07:57:56 am »
[EDIT]
Here is your problem, you used WriteLn insteaf of WriteConsole which is displaying text to a player ingame. (WriteLn displays it to admins, in ARSSE for example)



You could split it off in different scripts, but I'd highly recommend having one big script for a mod.
Even though that class thing will be a harder part.
You should now get used to type:
Code: [Select]
// Declare the type
type
   TPlayer = Record
     Task: byte; // I used task instead of Class because Class is a reserved word :/
   end;

// Now create an array, one index slot for each player
var
   Player: Array [1..32] of TPlayer;

// Looks like that when you use it:
procedure SetTask(ID, Task: byte);
begin
  Player[ID].Task := Task;
end;
When you understand that you should think about the variables the players will need in your script and add them to that. If your going to make this Knife Only Mod you mentoined in Adverts you should add for example an timer how long it needs till he gets a new knife.
« Last Edit: April 05, 2010, 08:00:44 am by Swompie »

DarkCrusade

  • Guest
Re: Question Thread
« Reply #47 on: April 05, 2010, 01:21:58 pm »
So I got some more time and got the first part working.

Code: [Select]
procedure OnJoinGame(ID,Team:byte);
begin
   SayToPlayer(ID,' Text');
   SayToPlayer(ID,'Text');
end;

But this part is returning an error I cannot fix with my current knowledge: (Invalid number of parameters again)

Code: [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
begin
  if(Text='!help')
     then begin
          WriteConsole('/say  ', $FFFFFFF);
          WriteConsole('/say  ', $FFFFFFF);
     end;

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #48 on: April 05, 2010, 01:36:22 pm »
only need to do
Code: [Select]
procedure OnJoinGame(ID,Team:byte);
begin
  WriteConsole(ID,'Welcome to my server',$EE81FAA1);
  WriteConsole(ID,'Welcome text here !!!!!!,$EE81FAA1);
end;

ID, will say only to the guys who have joined the game the thing !

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #49 on: April 05, 2010, 01:37:31 pm »
Code: [Select]
WriteConsole(ID: byte; Text: string; Color: longint);That are the parameters, I think I don't need to explain which one is for what  ;)
You need to set each of it to a value otherwise it will throw errors.

However if you want to use /say you need to use Command
Code: [Select]
Command('/say Hello World');
But I'd highly recommend using WriteConsole since you can make that text colored and there won't be a *SERVER* infront of your text.

For the joining palyers you should use that how you've done it already instead of using SayToPlayer;
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
begin
  WriteConsole(ID, 'Hello, this server is scripted.', $FFFFFFFF);
  WriteConsole(ID, 'You can choose out of 4 classes.', $FFFFFFFF);
  WriteConsole(ID, 'For further information type !help.', $FFFFFFFF);
end;


In your second code, you are missing and end; aswell the first parameter of WriteConsole, try fixing it yourself, look at the latest working examples to find out what went wrong.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #50 on: April 05, 2010, 01:38:51 pm »
And that
Code: [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
begin
  if(Text='!help')
     then begin
          WriteConsole(ID,'Hmmm sorry but...',$EE81FAA1);
          WriteConsole(ID,'THERE IS NO HELP FOR THIS SERVER',$EE81FAA1);
     end;

DarkCrusade

  • Guest
Re: Question Thread
« Reply #51 on: April 05, 2010, 02:11:59 pm »
Damnit ...

Code: [Select]
10-04-05 21:09:48  [*] Compiling Knife Server -> KnifeServer.pas...
10-04-05 21:09:48  [*] Knife Server -> [Error] (33:10): Identifier expected
10-04-05 21:09:48  [*] Compilation Failed.
10-04-05 21:09:48 Shutting down server...

After I added ...

Code: [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
begin
  if(Text='!help')
     then begin
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
     end;

Am I really that dumb?

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #52 on: April 05, 2010, 02:26:34 pm »
this is not good
Code: [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
begin
  if(Text='!help')
     then begin
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
     end;
You cannot tell command with WriteConsole
if you want to tell a command do
Code: [Select]
Command('/say TEXT HERE');If you dont want the *SERVER* in front of your message do
Code: [Select]
WriteConsole(ID,'TEXT HERE',$EE81FAA1);i hope that will help u :P

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Question Thread
« Reply #53 on: April 05, 2010, 02:57:22 pm »
Code: [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
begin
  if(Text='!help')
     then begin
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
          WriteConsole(0,'/say ', $FFFFFFF);
     end;
Use the power of logic:
- how many begins are there? - 2
- how many ends are there? - 1

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Question Thread
« Reply #54 on: April 05, 2010, 03:22:08 pm »
Am I really that dumb?
im afraid so, if you cant count to TWO :/

DarkCrusade

  • Guest
Re: Question Thread
« Reply #55 on: April 06, 2010, 01:36:39 am »
Well, I already came to that conclusion. I just wasn´t sure :P Currently I am using ...

Code: [Select]
procedure OnPlayerSpeak(ID: Byte,Text: String);
if(Text=' ')
  then
  WriteConsole(ID,' ', $FFFFFFFF);
  WriteConsole(ID,' ', $FFFFFFFF);
  [...]
if(Text=' ')
  then
  WriteConsole(ID,' ', $FFFFFFFF);
  WriteConsole(ID,' ', $FFFFFFFF);
[...]
end;

... so I have different conditions for the different WriteConsols, but if I type !help it will show all lines of my script ... again I tried different things but came to no conclusion.

Is there an offline scripting manual? I tried downloading EnEsCes Manuals first site and hoped it would work but it didn´t.

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Question Thread
« Reply #56 on: April 06, 2010, 02:03:40 am »
if you have 'then', without begin and end on a condition, it will work only on ONE line.

For example, let's say boolean 'execute' is set to false:
Code: [Select]
(...)
WriteConsole(0,'Hello Players1', $FFFFFFFF);
if execute then  WriteConsole(0,'Hello Players2', $FFFFFFFF);
WriteConsole(0,'Hello Players3', $FFFFFFFF);
WriteConsole(0,'Hello Players4', $FFFFFFFF);
(...)

The script will display lines 1, 3, 4.

If you want it to display the lines 2 AND 3 depending on 'execute''s state:

Code: [Select]
(...)
WriteConsole(0,'Hello Players1', $FFFFFFFF);
if execute then begin
  WriteConsole(0,'Hello Players2', $FFFFFFFF);
  WriteConsole(0,'Hello Players3', $FFFFFFFF);
end
WriteConsole(0,'Hello Players4', $FFFFFFFF);
(...)

If 'execute' is false, lines 1 and 4 will be the output.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #57 on: April 09, 2010, 01:51:21 pm »
Just came back from Antwerpen and got some free time now to learn some more scripting stuff. I went further and tested my currently compiling script. Right now I use something like ...

Code: (Pascal) [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
     begin
  if(Text='!help')
     then
          WriteConsole(0,' ###################Commands#####################', $FFFFFFF);
          WriteConsole(0,'##!Classes: Will show you the different classes ##', $FFFFFFF);
          WriteConsole(0,'##          that you are able to choose.        ##', $FFFFFFF);
          WriteConsole(0,'##!Rules:   Will show you the rules.            ##', $FFFFFFF);
          WriteConsole(0,'##!Credits: Will show you the credits.          ##', $FFFFFFF);
          WriteConsole(0,' ################################################', $FFFFFFF);
end;

But for some unknown reason it displays the text everytime I type anything. Be it a taunt or the command ... I don´t know what´s going wrong. It´s really bugging the shit out of me :S

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #58 on: April 09, 2010, 02:13:08 pm »
wb DC.

Code: [Select]
procedure OnPlayerSpeak(ID:Byte;Text:String);
begin
  if Text = '!help' then begin // You need a begin here so it displays all that text when a player types !help
    WriteConsole(0,' ###################Commands#####################', $FFFFFFF);
    WriteConsole(0,'##!Classes: Will show you the different classes ##', $FFFFFFF);
    WriteConsole(0,'##          that you are able to choose.        ##', $FFFFFFF);
    WriteConsole(0,'##!Rules:   Will show you the rules.            ##', $FFFFFFF);
    WriteConsole(0,'##!Credits: Will show you the credits.          ##', $FFFFFFF);
    WriteConsole(0,' ################################################', $FFFFFFF);
  end;

  // If you want to add more "! commands" add one more
  // if Text = '!cmd' then begin
  //   ... things shall be executed when someone typed !cmd
  // end;

end;
Hope you get it ;)

DarkCrusade

  • Guest
Re: Question Thread
« Reply #59 on: April 09, 2010, 02:27:29 pm »
Ah, my problem was that I have put the condition into brackets. 

_________________________________________________ _____________

Now I wanted my script to display text when one condition is true. So I tried something like ...

Code: [Select]
if Text='!Help' OR  Text='!help' then begin
[...]
end;

But ...

Code: [Select]
10-04-09 21:37:51  [*] Compiling Knife Server -> KnifeServer.pas...
10-04-09 21:37:51  [*] Knife Server -> [Error] (19:28): Type mismatch
10-04-09 21:37:51  [*] Compilation Failed.
10-04-09 21:37:51 Shutting down server...
« Last Edit: April 09, 2010, 02:38:41 pm by DarkCrusade »