Author Topic: Idea for a script, is it feasible?  (Read 7576 times)

0 Members and 2 Guests are viewing this topic.

Offline Londonbrig0

  • Major(1)
  • Posts: 38
  • despite my experience, I'm a noob, deal with it
Re: Idea for a script, is it feasible?
« Reply #40 on: May 15, 2010, 09:09:52 pm »
Go "if Winner Then", instead of "if Winner = True". Same thing for "Leader[Victim] = True". Go "if Leader[Victim] Then"..

Ah yes, good advice, thank you.

Quote
About the Script, I don't understand quite what you're asking.

1. Basically, I'm not sure when I shouldn't have semicolons in the middle of if then else statements.
2. I want to know how to combine some text and a string variable into one string, for example the variable VTeam[Killer] and the text 'wins!'
3. Can I end the game by setting TimeLeft to 0?
« Last Edit: May 15, 2010, 09:14:10 pm by Londonbrig0 »
I could have sworn I had something witty to put here...

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Idea for a script, is it feasible?
« Reply #41 on: May 15, 2010, 09:30:47 pm »
[...]

1. Basically, I'm not sure when I shouldn't have semicolons in the middle of if then else statements.
2. I want to know how to combine some text and a string variable into one string, for example the variable VTeam[Killer] and the text 'wins!'
3. Can I end the game by setting TimeLeft to 0?

1 - You just don't use ";" after:

If,Else,Begin,Then,Try,Except,Const,Type,Var.

You DO use ";" after ")", and everything else.

//~~~

2 - You mean like..

Code: (pascal) [Select]

[...]

 if VTeam[Killer] = 'Blablabla' Then WriteConsole(Killer,'Wins!',$FFFFFF);

Like that? I still don't got it :P

//~~~

3 - To end the game, just go "Command('/nextmap'); :P
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Idea for a script, is it feasible?
« Reply #42 on: May 16, 2010, 12:43:15 am »
Just go for

Code: (pascal) [Select]
const
  White = $FFFFFF;

Procedure OnPlayerSpeak(ID:Byte; Text:String);
var Disable:Boolean; 
  begin
    WriteConsole(ID,'Text1' + ' Text2', White);      // Will display the text "Text1 Text2"
    WriteConsole(ID,IDToName(ID) + '''s name is cool!', White); // Displays "<XXX>'s name is cool!" ('' = ' in text')
    if LowerCase(Text) = '!disable' then begin
      Disable := not Disable;
      WriteConsole(ID,'Script got ' + iif(Disable=true,'enabled','disabled') + '.', White);
    end;
  end;

Last text will display "Script got enabled." if Disable is true and "Script got disabled." when it's false.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Idea for a script, is it feasible?
« Reply #43 on: May 16, 2010, 09:11:37 am »
Just go for

[...]

You forgot a "+" in the "IDToName()" Stuff.

And, iif(Disable,'en','dis')+'abled' should be better.

Despite that, everything's good.
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Idea for a script, is it feasible?
« Reply #44 on: May 16, 2010, 09:14:59 am »
The '+' is there for ages, Squiddy ... or I don't get what you are trying to state.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Idea for a script, is it feasible?
« Reply #45 on: May 16, 2010, 09:18:34 am »
Code: (pascal) [Select]
    WriteConsole(ID,IDToName(ID) +'''s name is cool!', White);

Should be:

WriteConsole(ID,IDToName(ID)+'''+'s name is cool!',White);

See?
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Idea for a script, is it feasible?
« Reply #46 on: May 16, 2010, 09:32:12 am »
Yeah I see your mistake. You don't need to seperate it.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Idea for a script, is it feasible?
« Reply #47 on: May 16, 2010, 09:43:21 am »
Wow, just noticed what I did. :P

Thanks DC.

Although, I'm still curious.

Why do you have '''s name ...', instead of 's name ...' ?

:O
www.soldatx.com.br - The brazilian Soldat community.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Idea for a script, is it feasible?
« Reply #48 on: May 16, 2010, 09:57:34 am »
Wow, just noticed what I did. :P

Thanks DC.

Although, I'm still curious.

Why do you have '''s name ...', instead of 's name ...' ?

:O
http://en.wikipedia.org/wiki/Apostrophe#General_principles_for_the_possessive_apostrophe


and if you guys want to be really anal about the code,
Code: (pascal) [Select]
WriteConsole(ID,'Script got ' + iif(Disable,'dis','en') + 'abled.', White);and from the looks of it, disabled should be a global var ._.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Idea for a script, is it feasible?
« Reply #49 on: May 16, 2010, 10:00:30 am »
I agree.

Usually, all my scripts has a "TurnedON" Boolean.

I'm far too busy to make some other person's scritps perfect :P

Good luck with the script, though. :)
www.soldatx.com.br - The brazilian Soldat community.

Offline Londonbrig0

  • Major(1)
  • Posts: 38
  • despite my experience, I'm a noob, deal with it
Re: Idea for a script, is it feasible?
« Reply #50 on: May 16, 2010, 10:16:58 am »
Quote
1 - You just don't use ";" after:

If,Else,Begin,Then,Try,Except,Const,Type,Var.

You DO use ";" after ")", and everything else.

Makes sense to me, thanks.

Quote
3 - To end the game, just go "Command('/nextmap'); :P

Oh right, duh, thanks  :P

Just go for

[...]

Last text will display "Script got enabled." if Disable is true and "Script got disabled." when it's false.

Thanks a ton, now I know how it's supposed to look.
I could have sworn I had something witty to put here...

DarkCrusade

  • Guest
Re: Idea for a script, is it feasible?
« Reply #51 on: May 16, 2010, 12:14:55 pm »
-A way to tell who is on your team (have your clothes change to look the same as your leader? have people on your team emit flames?)

You can create an interface that shows you the people on your team. I attached something you can work with.


Offline Londonbrig0

  • Major(1)
  • Posts: 38
  • despite my experience, I'm a noob, deal with it
Re: Idea for a script, is it feasible?
« Reply #52 on: May 16, 2010, 10:33:08 pm »
You can create an interface that shows you the people on your team. I attached something you can work with.

Thank you, could you explain what it does basically?
I could have sworn I had something witty to put here...

DarkCrusade

  • Guest
Re: Idea for a script, is it feasible?
« Reply #53 on: May 17, 2010, 02:25:51 am »
Basically it's an inferface that will show up for everyone on the server. Everything in the procedure AppOnIdle gets called every second. If we want to work with everyones ID on the server we use a for loop:

I is a variable of type byte that you need to declare before, just look at my script.
Code: (pascal) [Select]
for I := 1 to 32 do [...]
But the problem is, that there are probably not 32 slots in use and it'd return us an error when we try to draw a text for a player who is not even there. We check now whether he's online or not:

Code: (pascal) [Select]
for I := 1 to 32 do              // Start the loop
  if GetPlayerStat(I,'Active') = true then     // Check ID
    AllDraw(I)
                                // Draw the text

The following will be a little bit more diificult. You will have 12 players at the maximum on your server, right? So I called one string for every possible ID. Now I loop through all IDs again and check whether they are in the same 'team' as the of the ID we checked in AppOnIdle. If that's so the next string will contain his name and will be drawn. Don't think much about '+ #13 + #10', it's just a nice thing that'll place one line above another instead of having one big line.

But a very important thing at least:

Code: (pascal) [Select]
Type XXX = Record
  Team: Byte;
end;

var
  Player: Array[1..32] of XXX;

It is very similiar to classes in Java, I hope you get the point. You can put more variables you want to use into the type XXX and to use it use

Code: (pascal) [Select]
<ArrayName>[<ID>].<Variable>   // Note the dot!

Now what you need to do with the script I gave you.

-You need to save the original teams of each player in an array
-You need to save ones team in an array when being killed
-You need to modify my script so it'll show up the leader of the team, too
-You need to find a solution for changing the map after one team contains all IDs that are connected to the server at that moment.

Offline Londonbrig0

  • Major(1)
  • Posts: 38
  • despite my experience, I'm a noob, deal with it
Re: Idea for a script, is it feasible?
« Reply #54 on: May 18, 2010, 12:31:57 pm »
Thanks a ton, I'll see what I can do to work it in.
I could have sworn I had something witty to put here...