Author Topic: Help with the "/big" taunt in Firstblood script  (Read 893 times)

0 Members and 1 Guest are viewing this topic.

Offline Bydlak

  • Major(1)
  • Posts: 34
Help with the "/big" taunt in Firstblood script
« on: August 08, 2013, 08:40:30 am »
Hi

I have a problem with the Firstblood script. After a firstblood there should be a big red sign "FIRST BLOOD" on the screen, but its not working when the soldat version changed. What should I do to fix it?

The firstblood scriptcode:

Code: [Select]
var
firstBlood: integer;
GOOD, BAD: longint;
 
procedure ActivateServer();
begin
//color of writeconsole messages
GOOD := $EE00FF00;
BAD := $FFFF4444;
//reset firstblood
firstBlood := 1;
end;
 
procedure OnMapChange(NewMap: string);
begin
//reset firstblood
firstBlood := 1;
end;
 
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
//check for firstblood and award 10 points
if (firstBlood > 0) and (Killer <> Victim) then
begin
firstBlood := 0;
WriteConsole(0, 'FIRST BLOOD: '+IDToName(Killer) + ' killed '+IDToName(Victim),GOOD);
WriteConsole(0, '3 Points Awarded!',GOOD);
SetScore(Killer,GetPlayerStat(1, 'Kills' ) + 3 );
end
 
//if killer suicide then there is no firstblood
if (firstblood > 0) and (Killer = Victim) then
begin
firstBlood := 1;
end
end;

EDIT (Falcon): use code blocks next time.
« Last Edit: August 08, 2013, 09:25:43 am by FalconPL »

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Help with the "/big" taunt in Firstblood script
« Reply #1 on: August 08, 2013, 09:36:38 am »
1. No wonder it doesn't show any big messages, the code is not even there
2. If you want to save colors like that, declare them as const, not var.
3. "award 10 points", "3 Points Awarded!". Decide. TO prevent things like this, set reward as a const as well.

I wrote the simplest SC3 First Blood script, for the sake of practise. Attached whole script folder.
Code below. Sadly, OnKill is called before the "You killed XYZ" is being shown, so I had to use OnClockTick.
Code: [Select]
const
GREEN = $00FF00;
RED = $FF0000;
REWARD = 10;

var
   firstBlood: boolean;
   firstMessage: boolean;
   i: integer;
 
procedure OnMapChange(NewMap: string); begin
   firstBlood := TRUE;
   firstMessage := TRUE;
end;
 
procedure MyOnKill(Killer, Victim: TActivePlayer; WeaponType: Byte); begin
   if (firstBlood) and (Killer <> Victim) then
   begin
      firstBlood := FALSE;
      Players.WriteConsole('FIRST BLOOD: '+ Killer.Name + ' killed '+ Victim.Name,GREEN);
      Players.WriteConsole(inttostr(REWARD)+' Points Awarded!',GREEN);
      Killer.Kills := Killer.Kills + REWARD;
   end;
end;

procedure OnClock(t: integer);
begin
if (not firstBlood) and firstMessage then
begin
Players.BigText(1,'FIRST BLOOD',250,RED,0.10,200,400);
firstMessage := FALSE;
Game.TickThreshold := 60;
end;
end;

begin
for i:=1 to 32 do
Players[i].OnKill := @MyOnKill;
Map.OnAfterMapChange := @OnMapChange;
Game.TickThreshold := 10;
Game.OnClockTick := @OnClock;
end.
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID