Author Topic: Question Thread  (Read 31774 times)

0 Members and 3 Guests are viewing this topic.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Question Thread
« Reply #180 on: April 17, 2010, 02:47:24 pm »
- PunishBot (kicks spammers and bans them for x minutes (nearly finished)
You know there's a built-in anti-flood?

DarkCrusade

  • Guest
Re: Question Thread
« Reply #181 on: April 18, 2010, 08:13:40 am »
Yeah, you´d have a hang of what it will be like if I´d post what I´ve got until now. It´s WAY different.

From: April 18, 2010, 08:13:16 am
This is so basic that I am confused that it´s not working like this, because it should work to 100% ...

Code: [Select]
procedure OnJoinTeam(ID,Team:Byte); 
  begin
    if Team = 4 then begin
    Command('/setteam5 ' + ID);    <<<- THIS LINE RETURNS THE ERROR
    WriteConsole(ID,'Do not try to join the mutants. Please choose an other faction!', Red);
    WriteConsole(ID,'To see which factions are available and other commands type !help', Red);
  end;
end; 


As soon as I remove ID it´s working. I used Command like this before and it worked. Is it not working with this specific procedure? (Error = Type Mismatch)

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped

DarkCrusade

  • Guest
Re: Question Thread
« Reply #183 on: April 18, 2010, 09:35:44 am »
Next question: Why do I blame myself? ;D

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Question Thread
« Reply #184 on: April 18, 2010, 11:32:38 am »
Next question: Why do I blame myself? ;D
because you should

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #185 on: April 18, 2010, 12:09:41 pm »
Dnmr is correct, DC.

Type Mismatches are errors that result when you have an integer value inside a string local, and vice-versa.

Also happens with float, and stuff.

Oh, well. Learn that. :P

Any more questions, feel free to ask :]
www.soldatx.com.br - The brazilian Soldat community.

Offline Runny

  • Major(1)
  • Posts: 11
Re: Question Thread
« Reply #186 on: April 18, 2010, 12:13:26 pm »
There's something weird with GiveBonus

I'm using GiveBonus with OnPlayerRespawn procedure. I can't say it doesn't work - as the result I can see 'Berserker Mode', 'Cluster nades', 'Predator mode', but I don't get these bonuses actually...

wtf?

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Question Thread
« Reply #187 on: April 18, 2010, 12:19:25 pm »
There's something weird with GiveBonus

I'm using GiveBonus with OnPlayerRespawn procedure. I can't say it doesn't work - as the result I can see 'Berserker Mode', 'Cluster nades', 'Predator mode', but I don't get these bonuses actually...

wtf?
onplayerrespawn is called before the player actually respawns. You'll need to set a flag var and give the bonus in AppOnIdle right after the player respawns

Offline Runny

  • Major(1)
  • Posts: 11
Re: Question Thread
« Reply #188 on: April 18, 2010, 12:24:13 pm »
Thanks!

DarkCrusade

  • Guest
Re: Question Thread
« Reply #189 on: April 19, 2010, 11:28:16 am »
Is OnJoinGame called before OnJoinTeam?

And is there any possible way to disable more than one weapon with one line?


Solved (figured it out myself).
« Last Edit: April 19, 2010, 12:17:22 pm by DarkCrusade »

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #190 on: April 19, 2010, 12:18:26 pm »
Is OnJoinGame called before OnJoinTeam?
Try it yourself, put in these two proc, then write a msg which says which proc. was called, the first text appearing is the faster one. :P

DarkCrusade

  • Guest
Re: Question Thread
« Reply #191 on: April 21, 2010, 08:55:34 am »
Compiles, but there is an OutOfRange error OnMapChange and I don't know what could have caused it, any thoughts?

Code: [Select]
Procedure OnMapChange(NewMap: String);
var PlaID: Integer;
  begin
    for PlaID := 1 to 32 do
      Spamming[PlaID] := 0;
        if Warning[PlaID] > 0 then begin
          Warning[PlaID] := 0;
          WriteConsole(PlaID,'Your warning level was reset', Green);
     end;
  end;



Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #192 on: April 21, 2010, 09:33:45 am »
Out of range -> You are trying to access an index of an array which doesn't exists.

Offline croat1gamer

  • Veteran
  • *****
  • Posts: 1327
  • OMG CHANGING AVATAR!!! ^ω^
Re: Question Thread
« Reply #193 on: April 22, 2010, 06:57:12 am »
PlaID has to be an array of integers or sth like that. Not just an integer.
You didnt define Warning and Spamming.
« Last Edit: April 22, 2010, 06:58:48 am by croat1gamer »
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #194 on: April 22, 2010, 07:13:58 am »
PlaID has to be an array of integers or sth like that. Not just an integer.
You didnt define Warning and Spamming.
Then it'll say it's missing vars.

He just forgot to put an begin in the loop.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #195 on: April 23, 2010, 09:40:59 pm »
He just forgot to put an begin in the loop.

Not really, he just forgot to check is PlaID is on server.

Code: (pascal) [Select]
OnMapChange();
For PlaID := 1 To 32 Do if GetPlayerStat(PlaID,'Active') = True Then
{ Statements }
End;
« Last Edit: April 27, 2010, 12:55:24 pm by squiddy »
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #196 on: May 02, 2010, 09:35:00 am »
What is the best way to check a teams score? Because I've already tried different things with no real result other than that it failed. Also one of my admin commands worked before I summarized a procedure (pretty basic command, should work that way).

Necessary parts:

Code: [Select]
var
  ShowDmg: Boolean;

Code: [Select]
Function OnPlayerDamage(Shooter,Victim:Byte; Damage:Integer): Integer;
begin
  case GetPlayerStat(Shooter,'Human') of
    true: [...]
    false: [...]
  end;

  case GetPlayerStat(Victim,'Human') of
    true: [...]
    false: [...]
  end;

  if Player[Shooter].ShowDmg = true then
    WriteConsole(Shooter,'Output: ' + inttostr(Result), Red);
  if Player[Victim].ShowDmg = true then
    WriteConsole(Shooter,'Input: ' + inttostr(Result), Red);
end;
And:

Code: [Select]
Function OnCommand(ID:Byte; Text:String):boolean;
var Piece1,Piece2,Piece3: String;
     Temp2,Temp3: Integer;
  begin
    Piece1 := GetPiece(Text,' ', 0);
    Piece2 := GetPiece(Text,' ', 1);
    Piece3 := GetPiece(Text,' ', 2);
    Temp2 := strtoint(Piece2);
    Temp3 := strtoint(Piece3);
  case Piece1 of
    '/showdmg': begin
      Player[ID].ShowDmg := not Player[ID].ShowDmg;
      WriteConsole(ID,'I/O messages got '+iif(Player[ID].ShowDmg=true,'enabled','disabled'),Black);
     end;
    [...]
  end;

The script has a size of ~1350 lines right now.
« Last Edit: May 02, 2010, 09:37:35 am by DarkCrusade »

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #197 on: May 02, 2010, 09:59:02 am »
Code: (pascal) [Select]
Var ShowDmg: Boolean;

Player[Shooter].ShowDmg; //This shouldn't work, because ShowDmg is a Global Variant, not an Array.

//~~~~~~~~~~~~~~~~~~~~~~
//To make that work, do this:

Type DC = Record
 ShowDmg: Boolean;
end;

Var
 Player: Array[1..32] of DC;

{ Statements }
 if Player[Shooter].ShowDmg = True; //Now we're talking about it!

//~~~~~~~~~~~~~~~~~~~~~~~~
//Although, if you are going to make only that Array, this should be faster and easier:

Var
 ShowDmg: Array[1..32] of Boolean;

{ Statements }

if ShowDmg[Shooter] = True; //Faster, if you only have one Array.

//Is a waste of time to create a Type Function for one Array.

Aaanyway....

@Topic:

This should work:

Code: (pascal) [Select]
Function GetTeamScore(Team: Byte): Integer;
 Var DC: Byte;
  Begin
   For DC := 1 To 32 Do if GetPlayerStat(DC,'Team') = Team Then Begin
  Result := GetPlayerStat(DC,'Flags');
 end;
end;

//I'm sure you can come up with some Command that activates GetTeamScore() Function. :)
//Good luck :D
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #198 on: May 02, 2010, 10:15:43 am »
@boolean issue: Sorry, I already did it like that. I have a big type for that stuff ...

Uhm ... could you explain me what 'GetPlayerStat(DC,'Flags');' returns? Because I looked it up at devs.soldat and didn't find it..

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #199 on: May 02, 2010, 10:21:00 am »
NEVER, NEVER USE = true OR = false AGAIN EXCEPT FOR GetPlayerStat() STUFF.
When will people finally learn it ::)

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  ::)
Code: [Select]
function GetTeamScore(Team: byte): integer;
begin
  case Team of
    1: Result := AlphaScore;
    2: Result := BravoScore;
    3: Result := CharlieScore;
    4: Result := DeltaScore;
  end;
end;

As for the command:
Code: [Select]
  case LowerCase(Piece1) of
    '/showdmg': begin
      Player[ID].ShowDmg := not Player[ID].ShowDmg;
      WriteConsole(ID, 'Damage displaying is now ' + iif(Player[ID].ShowDmg, 'enabled', 'disabled'), $FFFFFF);
    end;
  end;
This is the shortest and best way.

OnPlayerDamage():
Code: [Select]
  if Player[Shooter].ShowDmg then WriteConsole(Shooter, 'Base Dmg: ' + inttostr(Damage) + ' Out: ' + inttostr(Result) + ' dmg.' Red);
  if Player[Victim].ShowDmg then WriteConsole(Victim, 'Base Dmg: ' + inttostr(Damage) + ' In: ' + inttostr(Result) + ' dmg.' Red);

Regards Swompie.