Author Topic: /kill and OnPlayerKill  (Read 826 times)

0 Members and 1 Guest are viewing this topic.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
/kill and OnPlayerKill
« on: January 08, 2009, 09:55:46 pm »
What happens in OnPlayerKill when someone suicides with /kill?

I ask this because this code
Code: [Select]
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);

begin
inc(PlayerInfo[Killer].Level, 1);
ForceWeapon(Killer, WeaponForLevel[PlayerInfo[Killer].Level], WeaponForLevel[PlayerInfo[Killer].Level], 0);
SetScore(Killer, PlayerInfo[Killer].Level);

if LevelDecreaseOnKill then begin
if PlayerInfo[victim].Level > 1 then begin
dec(PlayerInfo[Victim].Level, 1);
ForceWeapon(Victim, WeaponForLevel[PlayerInfo[Victim].Level], WeaponForLevel[PlayerInfo[Victim].Level], 0);
SetScore(Victim, PlayerInfo[Victim].Level);
end;
end;
end;
Gives me an out of range error for OnPlayerKill when I do /kill and I have no clue why.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: /kill and OnPlayerKill
« Reply #1 on: January 09, 2009, 01:55:32 am »
is playerinfo.level an integer or byte?

is LevelDecreaseOnKill boolean?

Show us the array WeaponForLevel
« Last Edit: January 09, 2009, 01:57:31 am by Hacktank »


Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: /kill and OnPlayerKill
« Reply #2 on: January 09, 2009, 02:48:02 am »
Make sure the Victim or Shooter numbers arent 0 or greater than 32, like 255 (server) etc.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: /kill and OnPlayerKill
« Reply #3 on: January 09, 2009, 04:25:26 pm »
@Hactank
PlayerInfo.Level is Integer
LevelDecreaseOnKill is Boolean
WeaponForLevel is an array from 1 to 14, in activateServer each index is assigned a weapon number.

@EnEsCe
Ok i'll add in some safe measures

EDIT: I think I know whats causing it now, just have to test it.
Also, what number do you use to forceweapon fists?, I got all the weapon numbers from Core.pas, but Fists aren't listed there.

EDIT2: Works yay. PlayerInfo.Level was going past 14.
« Last Edit: January 09, 2009, 05:01:12 pm by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: /kill and OnPlayerKill
« Reply #4 on: January 09, 2009, 04:58:20 pm »
Fists are 255.


Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: /kill and OnPlayerKill
« Reply #5 on: January 09, 2009, 05:02:12 pm »
Cool, thanks.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs