Author Topic: OnPlayerFire or something like it?  (Read 1948 times)

0 Members and 1 Guest are viewing this topic.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
OnPlayerFire or something like it?
« on: August 27, 2007, 01:55:46 am »
Well... I want to make a script that tells the accuracy of a player, basically with shots hit / shots fired, but... It seems to me like there is no way to tell if a player fires their gun. I'm wondering 1) is it possible? Am I missing something? or 2) Can it be added?

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OnPlayerFire or something like it?
« Reply #1 on: August 27, 2007, 03:34:24 am »
Nope, isn't possible to do accurately. Nope, wont be added.

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: OnPlayerFire or something like it?
« Reply #2 on: August 27, 2007, 04:10:49 am »
EnEsCe  why was this never added? Not that i need it but just curious...

Offline ghg

  • Camper
  • ***
  • Posts: 411
  • Village Idiot
Re: OnPlayerFire or something like it?
« Reply #3 on: August 27, 2007, 04:15:45 am »
Lag I'll bet.
-=Gradius wuz you=-

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OnPlayerFire or something like it?
« Reply #4 on: August 27, 2007, 04:16:56 am »
It would be called too often, reduce performance of the server dramatically.

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: OnPlayerFire or something like it?
« Reply #5 on: August 27, 2007, 04:17:23 am »
oh idante. Can´t you do sth with onplayerdamage. And check how  much damage he has taken. Sth like that would be possible...

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: OnPlayerFire or something like it?
« Reply #6 on: August 27, 2007, 09:11:57 am »
Writing your own would be possible if ThreadFunce wasn't all that buggy. A threaded loop with sleep(5) or something that checks every players Ammo and compares with the previous ammo. Would drop the performance a lot though.
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: OnPlayerFire or something like it?
« Reply #7 on: August 27, 2007, 11:30:14 am »
Ummmm... I already made and posted an accuracy script like a week ago. lol
http://forums.soldat.pl/index.php?topic=19225.0

And no it doesn't use ThreadFunc but it still works.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: OnPlayerFire or something like it?
« Reply #8 on: August 27, 2007, 03:36:58 pm »
If you wanted a OnPlayerShoot event for anything else, i did make a semi-buggy one that is called most of the time a player shoots, although as said, it will probably lower performance on the server a lot.

Code: [Select]
procedure OnPlayerShoot(ID, Weapon: byte);
begin
  Command('/say ' + GetPlayerStat(ID,'Name') + ' has fired a ' + WeaponNamebyNum(Weapon) + '.');
end;

procedure ShootCheckLoop;
var
  i: byte;
  Ammo, Weap: array[1..32] of byte;
begin
  WriteLn('ShootCheckLoop Initialized')
  while true do begin
    for i := 1 to 32 do if (GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Ammo') <> Ammo[i]) then begin
      if (GetPlayerStat(i,'Primary') = Weap[i]) and (GetPlayerStat(i,'Ammo') <> 0) and (GetPlayerStat(i,'Ammo') < Ammo[i]) then OnPlayerShoot(i,GetPlayerStat(i,'Primary'));
      Weap[i] := GetPlayerStat(i,'Primary');
      Ammo[i] := GetPlayerStat(i,'Ammo');
    end;
  end;
end;

procedure ActivateServer();
begin
  ThreadFunc([],'ShootCheckLoop');
end;

Adding a sleep and making a thing that calls the OnPlayerShoot procedure multiple times after the sleep would probably make server performance a bit better, but will probably still be slow.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: OnPlayerFire or something like it?
« Reply #9 on: August 27, 2007, 09:53:38 pm »
Well... I can see the problem with this, but what about making GetPlayerStat have like... Fired, or Hit, or something like that to tell?

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OnPlayerFire or something like it?
« Reply #10 on: August 27, 2007, 10:15:29 pm »
Because such things are not saved in the server, and wont be.

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: OnPlayerFire or something like it?
« Reply #11 on: August 27, 2007, 11:19:00 pm »
Like I already posted... I made a script which calculates accuracy. It keeps track of the number of hits and shots fired.

Offline Flacid Assassin

  • Camper
  • ***
  • Posts: 450
  • Gorby The Grunt
Re: OnPlayerFire or something like it?
« Reply #12 on: August 28, 2007, 03:09:36 am »
but what if u wanted to know your weakness of weapons

Idea! can u like go around shoot and die and once u die tells u your current accuarcy from time of spawn till time of death

say liek someone spawns with deagles goes take 7 shots to kill guy then turns around and dies

says Your Accuracy was 6/7 88% or w.e it is

and still have the ability to see what ur overall accuracy is?  like a OnDeath Trigger