Author Topic: Scripting problem  (Read 1022 times)

0 Members and 1 Guest are viewing this topic.

Offline R0xy

  • Major(1)
  • Posts: 2
Scripting problem
« on: July 11, 2007, 08:16:54 am »
Hey guys im new here

Here is my problem;
im trying to add this scp to my server
Code: [Select]
var
  Realistic: boolean;
  Hits: array[1..32] of array[1..32] of byte;
  Dmg: array[1..32] of array[1..32] of longint;

procedure AfterKill(Killer,Victim: byte; Weapon: string);
var
  i: byte;
begin
  Sleep(10);
  DrawText(Victim,IDtoName(Killer) + ' killed you with ' + Chr(13) + Chr(10) + iif(Hits[Victim][Killer] = 1,'1 hit using ',InttoStr(Hits[Victim][Killer]) + ' hits using ') + Weapon + Chr(13) + Chr(10) + 'You hurt him with ' + Chr(13) + Chr(10) + iif(Hits[Killer][Victim] = 1,'1 hit doing ',InttoStr(Hits[Killer][Victim]) + ' hits doing ') + iif(Realistic,InttoStr(1.54 * Dmg[Killer][Victim]),InttoStr(Dmg[Killer][Victim])) + '% damage',500,$FF000000,0.06,8,340);
  for i := 1 to 32 do begin
    Hits[Victim][i] := 0;
    Dmg[Victim][i] := 0;
  end;
end;

procedure ActivateServer();
begin
  if StrtoInt(ReadINI('Soldat.ini','GAME','Realistic_Mode','0')) = 1 then Realistic := true else Realistic := false;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
  if Killer <> Victim then ThreadFunc([Killer,Victim,Weapon],'AfterKill');
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Hits[Victim][Shooter] := Hits[Victim][Shooter] + 1;
  if Damage <= GetPlayerStat(Victim,'Health') then Dmg[Victim][Shooter] := Dmg[Victim][Shooter] + Damage else Dmg[Victim][Shooter] := Dmg[Victim][Shooter] + GetPlayerStat(Victim,'Health');
end;

procedure OnPlayerRespawn(ID: byte);
var
  i: byte;
begin
  for i:= 1 to 32 do begin
    Dmg[i][ID] := 0;
    Hits[i][ID] := 0;
  end;
end;

And here's the error



i have this problem with 1-2 scps too

Plx help me guys =)
Thnx

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Scripting problem
« Reply #1 on: July 11, 2007, 09:32:37 am »
It would be nice if you could label your script.  Also note that you have to subtract 1 from whatever line the error message gives (or at least that's the case for me using N++).  Without seeing the line numbers on your script it'll be really hard to identify the error...
Can't think of anything original to put here...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting problem
« Reply #2 on: July 12, 2007, 04:14:24 pm »
Error on my part...
I forgot to round the %, to make it an integer..
For the draw text line, replace what you have with:
Code: [Select]
  DrawText(Victim,GetPlayerStat(Killer,'Name') + ' killed you with ' + Chr(13) + Chr(10) + iif(Hits[Victim][Killer] = 1,'1 hit using ',InttoStr(Hits[Victim][Killer]) + ' hits using ') + Weapon + Chr(13) + Chr(10) + 'You hurt him with ' + Chr(13) + Chr(10) + iif(Hits[Killer][Victim] = 1,'1 hit doing ',InttoStr(Hits[Killer][Victim]) + ' hits doing ') + iif(Realistic,InttoStr(Round(1.54 * Dmg[Killer][Victim])),InttoStr(Dmg[Killer][Victim])) + '% damage',500,$FF000000,0.06,8,340);

Offline R0xy

  • Major(1)
  • Posts: 2
Re: Scripting problem
« Reply #3 on: July 20, 2007, 03:08:41 am »
Thnx for helping...
But...
i changed the code like u said, then server give a error like this




And here is my code...

Code: [Select]
var
  Realistic: boolean;
  Hits: array[1..32] of array[1..32] of byte;
  Dmg: array[1..32] of array[1..32] of longint;

procedure AfterKill(Killer,Victim: byte; Weapon: string);
var
  i: byte;
begin
  Sleep(10);
  DrawText(Victim,GetPlayerStat(Killer,'Name') + ' killed you with ' + Chr(13) + Chr(10) + iif(Hits[Victim][Killer] = 1,'1 hit using ',InttoStr(Hits[Victim][Killer]) + ' hits using ') + Weapon + Chr(13) + Chr(10) + 'You hurt him with ' + Chr(13) + Chr(10) + iif(Hits[Killer][Victim] = 1,'1 hit doing ',InttoStr(Hits[Killer][Victim]) + ' hits doing ') + iif(Realistic,InttoStr(Round(1.54 * Dmg[Killer][Victim])),InttoStr(Dmg[Killer][Victim])) + '% damage',500,$FF000000,0.06,8,340);
  for i := 1 to 32 do begin
    Hits[Victim][i] := 0;
    Dmg[Victim][i] := 0;
  end;
end;

procedure ActivateServer();
begin
  if StrtoInt(ReadINI('Soldat.ini','GAME','Realistic_Mode','0')) = 1 then Realistic := true else Realistic := false;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
  if Killer <> Victim then ThreadFunc([Killer,Victim,Weapon],'AfterKill');
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Hits[Victim][Shooter] := Hits[Victim][Shooter] + 1;
  if Damage <= GetPlayerStat(Victim,'Health') then Dmg[Victim][Shooter] := Dmg[Victim][Shooter] + Damage else Dmg[Victim][Shooter] := Dmg[Victim][Shooter] + GetPlayerStat(Victim,'Health');
end;

procedure OnPlayerRespawn(ID: byte);
var
  i: byte;
begin
  for i:= 1 to 32 do begin
    Dmg[i][ID] := 0;
    Hits[i][ID] := 0;
  end;
end;

i'm gonna cry  :-[

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Scripting problem
« Reply #4 on: July 20, 2007, 10:45:05 am »
ok, the 'result never used' hint is this:
a function is like a procedure.  The difference is that a function returns a value and a procedure does not.  To return something in a value you have to do Result := myValue.
for example:
Code: [Select]
function AddValue(x: integer): integer
begin
Result := x + 5;
end;

//Somewhere later in the script:

t := AddValue(20);  //makes t = 25
that's a function.
basically to return something in a function, you have to let Result = that something (and make sure that the function type is of what you want to return)

Your duplicate error most likely is caused by the following:
You have in another included .pas file the procedure ActivateServer.  Just Remove the one you don't need...

Hopefully that fixes your problems.....
Can't think of anything original to put here...

Offline Neotype

  • Major(1)
  • Posts: 2
Re: Scripting problem
« Reply #5 on: October 20, 2007, 11:34:00 am »
YOu have the
OnActivateServer action used more times.
Maby you should turn off the other .pas files.