Author Topic: Question Thread  (Read 31783 times)

0 Members and 4 Guests are viewing this topic.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #200 on: May 02, 2010, 10:28:59 am »
You fail Squiddy, besides that you forgot to check if the players are active the loop is really useless, wherefore is case and these TeamScore variables  ::)

If you check Teams, means the player is already Active.

At least, that's what I think. I bearly have time to test my own Scripts, even less to test other people's ones :\

In regards to the "= True/= False" stuff, I don't really care. I learned that way, and don't expect me to change it that soon. :)

About the Case() Stuff..

Why would you use it, since you can do GetTeamScore(1) and it returns Alpha's Score ?

Well, I don't think you got my point. Kinda hard to explain. I just believe you don't need any variables.

Oh well.
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #201 on: May 02, 2010, 11:02:55 am »
The player at the start may be active, but if you check all 32 IDs with a loop you should at least check whether he's active or not, am I right?

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #202 on: May 02, 2010, 11:19:03 am »
The player at the start may be active, but if you check all 32 IDs with a loop you should at least check whether he's active or not, am I right?

Check it if you want, I just thought that checking teams, player would be automatically active.
www.soldatx.com.br - The brazilian Soldat community.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #203 on: May 02, 2010, 12:26:22 pm »
Well, but what team would a player be in when he is not active? :/

As for case and the variables again:
It is much faster a loop from 1 to 32 which checks if he's in the right team, then gets his flag scores, and adds it to the result (which you actually didn't do, I just noticed that).

Anyway, I think you need to know that I like to say people how they could to improve their script much more, ask DC if you don't trust me xD.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #204 on: May 02, 2010, 12:34:34 pm »
Swompie, I think I got it now.

"AlphaScore, BravoScore" etc. Are Already-Existing-Values ?

I thought you were creating them, so it would be much more complex.

Indeed, it is quite better to use Case Of on that case.

Oh well, I know how you say people how they could improve their Scripts, and I understand that, it's very good when you do that :)

Thanks us for the lesson :P
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #205 on: May 03, 2010, 01:00:56 pm »
Please don't blame me for the shitty indentations. The forum is doing something really weird with them ... No idea. I'm struggling with this piece of code a little and cannot help myself with it.
I have 4 different teams, every team has different weapons and abilitys, the last team (Delta) is a bot team which shouldm't get any points for killing, hence the last lines. My problem is, that whatever I try to check the kills with, it doesn't work. There is a mapchange feature to avoid color bugged and not kicked bots and additional weapons for teams that reached a certain score. Alpha,Bravo,Charlie and DeltaScore are built-in variables that should be accessable all time ...

Code: [Select]
const
  MapGap = 100;
  WepGap = 50;

var
  WepTemp,Wave,Msg: Byte;
  W1,W2,W3,MapChange: Boolean;

Procedure KickBots();
var BotID: Integer; 
  begin
    for BotID := 1 to 32 do
  if GetPlayerStat(BotID,'Human') = false then begin
    Command('/kick ' + inttostr(BotID));
  end;
    end; 
 
// Additional weapons for teams with more than 50 points
Procedure AllowWeapon();
var ID: Byte; 
  begin
for ID := 1 to 32 do
  if GetPlayerStat(ID,'Active') then
case WepTemp of
      1: begin
    SetWeaponActive(ID,8,true);
    DrawText(ID,'Your team got a new weapon!',180,White,0.06,160,200);
  end;  
  2: begin
    SetWeaponActive(ID,5,true);
    DrawText(ID,'Your team got a new weapon!',180,White,0.06,160,200);
  end;
  3: begin
    SetWeaponActive(ID,7,true);
        DrawText(ID,'Your team got a new weapon!',180,White,0.06,160,200);
  end;
end;  
  end;  

Procedure OnPlayerKill(Killer, Victim: Byte; Weapon: String);
  begin  
    // MapChange + additional weapons
case AlphaScore of
  AlphaScore > (WepGap - 1): begin
    if W1 then begin
  W1 := false;
  WepTemp := 1;
  AllowWeapon();
end; 
  end;
      Alphascore > (MapGap - 1): begin
        if MapChange then begin
  KickBots();
          Command('/nextmap');
          DrawText(0,'The Garmons have won the match! Congratulations!',3,White,0.15,160,200);
          Wave := 1;
          Msg := 1;
  MapChange := false;
end; 
      end;
    end;
    case BravoScore of
  BravoScore > (WepGap - 1): begin
    if W2 then begin
  W2 := false;
  WepTemp := 2;
  AllowWeapon();
end;
  end;
      Bravoscore > (MapGap - 1): begin
        if MapChange then begin
  KickBots();
          Command('/nextmap');
          DrawText(0,'The Verrights have won the match! Congratulations!',3,White,0.15,160,200);
          Wave := 1;
          Msg := 1;
  MapChange := false;
end; 
      end;
    end;
    case CharlieScore of
  CharlieScore > (WepGap - 1): begin
    if W3 then begin
  W3 := false;
  WepTemp := 3;
  AllowWeapon();
end;
  end;
      CharlieScore > (MapGap - 1): begin
        if MapChange then begin
  KickBots();
          Command('/nextmap');
          DrawText(0,'The Magi have won the match! Congratulations!',3,White,0.15,160,200);
          Wave := 1;
          Msg := 1;
  MapChange := false;
end; 
      end;
    end;
    if DeltaScore <> 0 then
      SetScore(4,0); 

  end;

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Question Thread
« Reply #206 on: May 03, 2010, 05:05:31 pm »
Code: [Select]
function GetTeamKills(Team: byte): integer;
var i: byte;
begin
result := 0;
for i := 1 to 32 do if getplayerstat(i,'active') then if getplayerstat(i,'team') = team then result := result + getplayerstat(i,'kills');
end;

Crude but it should work, remember, the kills tallied for a player doesnt increase until after the onplayerkill() procedure exits, so you will need to add 1 to the result of the function above.


Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Question Thread
« Reply #207 on: May 04, 2010, 02:51:33 am »
@hacktank: getplayerstat(i,'active') = true

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #208 on: May 04, 2010, 04:38:39 am »
@hacktank: getplayerstat(i,'active') = true

Why would you compare a True boolean to = True again ?
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #209 on: May 04, 2010, 05:43:07 am »
Because you need to compare them when using GetPlayerStat afaik.

Thanks, I already changed my script but didn't test it yet.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Question Thread
« Reply #210 on: May 04, 2010, 06:46:38 am »
You don't afaik, works without it.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #211 on: May 04, 2010, 08:52:08 am »
You don't afaik, works without it.
Since when? I thought it's bugging ;/

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Question Thread
« Reply #212 on: May 04, 2010, 10:15:23 am »
I'll test it, as an almost scientist I can't leave stuff that way.

edit: tk is right, there's no need for = true. Someone needs to be burnt in my opinion.
« Last Edit: May 04, 2010, 10:35:23 am by Gizd »

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #213 on: May 04, 2010, 10:57:07 am »
Someone needs to be burnt in my opinion.
@hacktank: getplayerstat(i,'active') = true

Have fun burning >;D
Anyway, I want to see what code you used to test it ;P

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Question Thread
« Reply #214 on: May 04, 2010, 11:13:42 am »
I'll test it, as an almost scientist I can't leave stuff that way.

edit: tk is right, there's no need for = true. Someone needs to be burnt in my opinion.
it starts throwing random errors after some time on some systems if you dont do it with "= true".
Spkka or saiĀ“ke posted about this some years ago i think. NSC did too (more recently) - said it was because getplayerstat returns a variant, not a boolean, so it might act weird sometimes. That's a pascal/delphi "feature" apparently

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Question Thread
« Reply #215 on: May 04, 2010, 01:16:55 pm »
NEVER, NEVER USE = true OR = false AGAIN EXCEPT FOR GetPlayerStat() STUFF.
Its more appropriate to say whenever dealing with a variant, which includes GetPlayerStat, but necessarily only that.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #216 on: May 13, 2010, 11:49:38 pm »
I removed Drain and added Vanish instead. Nextmap will be called when TimeLeft is under a certain amount. You get the new weapons after an amount of time either.

How can I check a text for certain characters?

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #217 on: May 14, 2010, 04:05:41 am »
I removed Drain and added Vanish instead. Nextmap will be called when TimeLeft is under a certain amount. You get the new weapons after an amount of time either.

How can I check a text for certain characters?

You mean this?

http://www.enesce.com/help/html/Functions/ContainsString.html

It cheecks on Haystack for Needle. Returns True or False if Matched/Not matched.
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #218 on: May 29, 2010, 07:15:45 am »
I want to change one value in an index of an array in a record and tried this (weapon is an array of booleans):

Player[ID].Weapon[ID2] := true;

But I get this error:

13:15:13 
  • Zombie MADNESS -> [Error] (219:25): Semicolon (';') expected


Line 218 is the line I've pasted here, char 25 is the dot after [ID]

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Question Thread
« Reply #219 on: May 29, 2010, 07:44:00 am »
This line is correct, the error must be somewhere else.