Author Topic: Score OnFlagGrab  (Read 1034 times)

0 Members and 1 Guest are viewing this topic.

Offline Moa124

  • Major(1)
  • Posts: 6
  • And they shall know no fear...
Score OnFlagGrab
« on: May 27, 2008, 11:42:10 am »
I need help with a script!
: You score after 5 or 10 Secs onflaggrab

Code: [Select]
procedure OnFlagGrab(ID, TeamFlag: Byte;GrabbedInBase: boolean);
if Ticks mod (60 * 5) = 0 then begin
    SetTeamScore(2, 1);
end;

and

Code: [Select]
procedure OnFlagGrab(ID, TeamFlag: byte;GrabbedInBase: boolean);
if Ticks mod (60 * 5) = 0 then begin
    SetTeamScore(1, 1);
end;

These are two different scripts. My Problem is: Both Teams score OnFlagGrab. I tried to write the ID of the team in "TeamFlag: byte" but it didnt work...

There must be another way to achieve it with only one script....


Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Score OnFlagGrab
« Reply #1 on: May 27, 2008, 02:31:40 pm »
Well, you need to begin and end; your procedures and set which team (using TeamFlag) gets the points. Also, OnFlagGrab will run only once, so you can't wait 5 (or 10) seconds there. Also, Ticks isn't defined, so it won't work. Use AppOnIdle (runs once every second) for this.

Code: [Select]
const
  Timer = 6; // Seconds after grab the point is given (+1, so 6 means 5)

var
  AlphaTimer, BravoTimer: Byte;

procedure AppOnIdle(Ticks: Integer);
begin

  // Count down
  if AlphaTimer > 0 then AlphaTimer := AlphaTimer - 1;
  if BravoTimer > 0 then BravoTimer := BravoTimer - 1;

  // Add points
  if AlphaTimer = 1 then SetTeamScore(1, AlphaScore + 1);
  if BravoTimer = 1 then SetTeamScore(2, BravoScore + 1);

end;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
  if TeamFlag = 1 then
    BravoTimer := Timer
  else
    AlphaTimer := Timer;
end;

procedure OnFlagReturn(ID, TeamFlag: byte);
begin
  if TeamFlag = 1 then
    BravoTimer := 0
  else
    AlphaTimer := 0;
end;

I haven't tested this, so it might not work... But it should.

Offline Moa124

  • Major(1)
  • Posts: 6
  • And they shall know no fear...
Re: Score OnFlagGrab
« Reply #2 on: May 27, 2008, 02:59:51 pm »
thank you for spending time to help me :)

Edit: Sorry that i keep bothering you but i just dont get why this wont work!

Code: [Select]
procedure OnJoinTeam(ID, Team: byte);
begin
    SetWeaponActive(1,1,false);
    SetWeaponActive(1,2,false);
    SetWeaponActive(1,3,false);
    SetWeaponActive(1,4,false);
    SetWeaponActive(1,5,false);
    SetWeaponActive(1,6,false);
    SetWeaponActive(1,7,false);
    SetWeaponActive(1,8,false);
    SetWeaponActive(1,9,false);
    SetWeaponActive(1,10,false);
end;

procedure OnPlayerRespawn(ID: Byte);
begin
    SetWeaponActive(1,1,false);
    SetWeaponActive(1,2,false);
    SetWeaponActive(1,3,false);
    SetWeaponActive(1,4,false);
    SetWeaponActive(1,5,false);
    SetWeaponActive(1,6,false);
    SetWeaponActive(1,7,false);
    SetWeaponActive(1,8,false);
    SetWeaponActive(1,9,false);
    SetWeaponActive(1,10,false);
end;

function OnPlayerCommand(ID: byte; Text: string): boolean;
begin
  if Text = '/Bomb' and if GetPlayerStat(1, team) = 1 then begin //this is where you pick the class Bomber by typing /bomb
    WriteLn('Test')
    SetWeaponActive(1,1,false);
    SetWeaponActive(1,2,false);
    SetWeaponActive(1,3,false);
    SetWeaponActive(1,4,false);
    SetWeaponActive(1,5,true);
    SetWeaponActive(1,6,false);
    SetWeaponActive(1,7,true);
    SetWeaponActive(1,8,false);
    SetWeaponActive(1,9,false);
    SetWeaponActive(1,10,false);
  end;
  Result := false;
end;

It appears to be a script to choose kinda classes like in Battlefield2 and activate specialized weapons...this is one of the classes

Thanks
   

EDIT: does nobody wanna help me? :(
« Last Edit: May 29, 2008, 11:57:34 am by Moa124 »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Score OnFlagGrab
« Reply #3 on: May 29, 2008, 12:14:02 pm »
try using ID istead on 1 as the first parameter in SetWeaponActive

Offline Moa124

  • Major(1)
  • Posts: 6
  • And they shall know no fear...
Re: Score OnFlagGrab
« Reply #4 on: May 29, 2008, 12:34:47 pm »
nah the problem is that the weapons arent activated when you type "/bomb"...there's no error. "Test" doesnt appear as well...

Edit: Yeah i f*cking works!! i dont know how i did it but yeah! im happy;)

YEAH YEAH YEAH YEAH !!!

But when i try to add other classes, they dont work:
Code: [Select]
function OnPlayerCommand(ID: byte; Text: string): boolean;
begin
 if Text = '/bomb' then
  begin
    WriteConsole(1,'Du hast Bombenbastler gewählt',$EE81FAA1)
    SetWeaponActive(ID,1,false);
    SetWeaponActive(ID,2,false);
    SetWeaponActive(ID,3,false);
    SetWeaponActive(ID,4,false);
    SetWeaponActive(ID,5,true);
    SetWeaponActive(ID,6,false);
    SetWeaponActive(ID,7,true);
    SetWeaponActive(ID,8,false);
    SetWeaponActive(ID,9,false);
    SetWeaponActive(ID,10,false);
    SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),17);
  end;
 if Text = '/schütze' then
  begin
    WriteConsole(ID,'Du hast Scharfschütze gewählt',$EE81FAA1)
    SetWeaponActive(ID,1,false);
    SetWeaponActive(ID,2,false);
    SetWeaponActive(ID,3,false);
    SetWeaponActive(ID,4,false);
    SetWeaponActive(ID,5,false);
    SetWeaponActive(ID,6,true);
    SetWeaponActive(ID,7,false);
    SetWeaponActive(ID,8,true);
    SetWeaponActive(ID,9,false);
    SetWeaponActive(ID,10,false);
   end;
  Result := false
end;
« Last Edit: May 29, 2008, 02:00:40 pm by Moa124 »

Offline amb2010

  • Camper
  • ***
  • Posts: 264
  • Fear the dot ...
Re: Score OnFlagGrab
« Reply #5 on: May 29, 2008, 06:51:13 pm »
Function OnPlayerCommand(ID: byte; Text: string): boolean;
begin
if Text = '/bomb' then
  begin
    WriteConsole(1,'Du hast Bombenbastler gewählt',$EE81FAA1);
    SetWeaponActive(ID,1,false);
    SetWeaponActive(ID,2,false);
    SetWeaponActive(ID,3,false);
    SetWeaponActive(ID,4,false);
    SetWeaponActive(ID,5,true);
    SetWeaponActive(ID,6,false);
    SetWeaponActive(ID,7,true);
    SetWeaponActive(ID,8,false);
    SetWeaponActive(ID,9,false);
    SetWeaponActive(ID,10,false);
    SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),17);
  end;
if Text = '/schütze' then
  begin
    WriteConsole(ID,'Du hast Scharfschütze gewählt',$EE81FAA1);
    SetWeaponActive(ID,1,false);
    SetWeaponActive(ID,2,false);
    SetWeaponActive(ID,3,false);
    SetWeaponActive(ID,4,false);
    SetWeaponActive(ID,5,false);
    SetWeaponActive(ID,6,true);
    SetWeaponActive(ID,7,false);
    SetWeaponActive(ID,8,true);
    SetWeaponActive(ID,9,false);
    SetWeaponActive(ID,10,false);
   end;
  Result := false
end;

Try adding in the bold ;

*code doesnt work with and stuff...*
And as the lyrics go in the United State's national anthem: "America, f**k YEAH!".

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Score OnFlagGrab
« Reply #6 on: May 29, 2008, 07:20:06 pm »
The first WriteConsole and the two GetPlayerStats should have ID instead of 1...