Author Topic: [SOLVED] Accuracy counting script [SoldatServer265]  (Read 1428 times)

0 Members and 1 Guest are viewing this topic.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
[SOLVED] Accuracy counting script [SoldatServer265]
« on: June 17, 2010, 03:55:42 pm »
Hi

Im trying to make script that would count thrown knives, knives that did some dmg and then get accuracy out of this.
I have problems with getting some info from OnPlayerDamage.

AccHits should be counting hits (both stabbs and throws)

Code: [Select]
VAR
AccHits: array[1..16] of byte;

(...)

function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer;Weapon: Byte) : integer;
begin
  // weapon 14 - knife
  If (Weapon=14) then AccHits[Shooter] := AccHits[Shooter] + 1;
 
  result := Damage;
end;

It compiles correctly.
Then i join game and when i hit some1 with knife i see
[Error] default -> (OnPlayerDamage): Not enough parameters
on ARSSE.

What the heck? How can i make this work?

« Last Edit: June 18, 2010, 11:52:04 am by Mighty »
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #1 on: June 17, 2010, 07:54:55 pm »
The Weapon parameter of the OnPlayerDamage event only exists for Soldat Dedicated Server 2.7.0+ (Soldat 1.5.1). If it is required for your script (as it appears it is), you must use this version.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #2 on: June 17, 2010, 11:56:03 pm »
Ahh, thanks a lot.

Do you have any other idea how to count knives thrown?
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #3 on: June 18, 2010, 12:37:48 am »
It's not possible.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #4 on: June 18, 2010, 06:45:21 am »
It's not possible.
You can do it with OnWeaponChange()

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #5 on: June 18, 2010, 09:26:03 am »
Made a mistake in prev post

I meant how to count hits made with knives.

Quote
It's not possible
Already dealt with knives thrown (Im getting some bugs but gonna fix em)
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #6 on: June 18, 2010, 09:29:35 am »

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #7 on: June 18, 2010, 09:35:49 am »
I'm 100% sure it is possible as i know the server where the script works perfectly. Author doesnt wanna share his scripts tho.

83.243.81.52:39273
pass 555

Got an idea. As i have only 2 'weapons' unblocked (Knife & Punch) I can just see what's the Damage, but then it won't count slow throws. Better that than nothing, gonna try.
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #8 on: June 18, 2010, 10:24:12 am »
Set fist damage to 900000 :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #9 on: June 18, 2010, 11:20:01 am »
that's over 9000!

Wait till core v3 comes out, then OnPlayerDamage has a Weapon param.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Accuracy counting script -> Problem with OnPlayerDamage
« Reply #10 on: June 18, 2010, 11:50:58 am »
dealt with whole script ;)
too many global vars tho.

Code: [Select]
const
   Color = $EE30DDEE;

var
   AccKnives1, AccKnives2, AccHits, AccThrows: array[1..16] of byte;
   Acc: array[0..16] of double;
   AccBestID: byte;
   AccWorstID: byte;
   i: byte;
Code: [Select]
function IntToFloat(Num: integer): single;
begin
result := strtofloat(inttostr(num));
end;
Code: [Select]
procedure ActivateServer();
begin 
   AccBestID := 0;
   AccWorstID := 0;
end;
Code: [Select]
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if (Text='!stats') AND (GetPlayerStat(ID,'team')<>5) then
begin
if (AccThrows[ID] = 0) then WriteConsole(0,'Make some throws first',Color)
else
begin
Acc[ID] := RoundTo(inttofloat(AccHits[ID])/inttofloat(AccThrows[ID]),4) * 100;
WriteConsole(0,IDToName(ID)+', Your Accuracy is ' + floattostr(Acc[ID]) + '%   ('+inttostr(AccHits[ID])+'/'+inttostr(AccThrows[ID])+')',Color);
end;
end;
end;
Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin

If ((PrimaryNum=14) AND (SecondaryNum=255)) OR ((PrimaryNum=255) AND (SecondaryNum=14)) then AccKnives1[ID] := 1;
If (PrimaryNum=14) AND (SecondaryNum=14) then AccKnives1[ID]:=2;
If (PrimaryNum=255) AND (SecondaryNum=255) then AccKnives1[ID] := 0;

if (AccKnives2[ID]>AccKnives1[ID]) AND (GetPlayerStat(ID,'health')>0) then
begin
AccThrows[ID] := AccThrows[ID] + 1;
end;

If ((PrimaryNum=14) AND (SecondaryNum=255)) OR ((PrimaryNum=255) AND (SecondaryNum=14)) then AccKnives2[ID] := 1;
If (PrimaryNum=14) AND (SecondaryNum=14) then AccKnives2[ID]:=2;
If (PrimaryNum=255) AND (SecondaryNum=255) then AccKnives2[ID] := 0;

end;
Code: [Select]
function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
begin        {Damage dealt by fists is always (?) 29/33/37}
  IF (Damage<>29) AND (Damage<>33) AND (Damage<>37) AND (Shooter<>Victim) then AccHits[Shooter] := AccHits[Shooter] + 1;
  result := Damage;
end;
Code: [Select]
procedure OnPlayerRespawn(ID: byte);
begin
AccKnives1[ID] := 1;
end;
Code: [Select]
procedure OnFlagScore(ID, TeamFlag: byte);
begin
if (AlphaScore=ScoreLimit) OR (BravoScore=ScoreLimit) then
begin

for i:=1 to MaxPlayers do
begin
If AccThrows[i] <> 0 then
begin
Acc[i] := RoundTo(inttofloat(AccHits[i])/inttofloat(AccThrows[i]),4) * 100;
IF Acc[i] > Acc[AccBestID] then AccBestID := i;
IF Acc[i] < Acc[AccWorstID] then AccWorstID := i;
end;
end;

IF AccBestID <> 0 then WriteConsole(0,'Best Accuracy:   '+ floattostr(Acc[AccBestID]) +' % by   ' +IDToName(AccBestID)+'      ['+inttostr(AccHits[AccBestID])+'/'+inttostr(AccThrows[AccBestID])+']',Color);
IF AccWorstID <> 0 then WriteConsole(0,'Worst Accuracy: '+ floattostr(Acc[AccWorstID]) +' % by   ' +IDToName(AccWorstID)+'      ['+inttostr(AccHits[AccWorstID])+'/'+inttostr(AccThrows[AccWorstID])+']',Color);

for i:=1 to MaxPlayers do
begin
AccHits[i] := 0;
AccThrows[i] := 0;
Acc[i] := 0;
end;

AccBestID := 0;
AccWorstID := 0;

end;
end;
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
begin
AccHits[ID] := 0;
AccThrows[ID] := 0;
Acc[ID] := 0;
AccKnives1[ID] := 1;
AccKnives2[ID] := 1;
end;


« Last Edit: June 18, 2010, 12:11:18 pm by Mighty »
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID