Author Topic: Anti Spawn Bug  (Read 1646 times)

0 Members and 1 Guest are viewing this topic.

Offline Nedi

  • Major(1)
  • Posts: 47
Anti Spawn Bug
« on: June 02, 2013, 08:20:03 am »
Script Name: Anti Spawn Bug
Script Description: Script kills every player not spawned near his spawn.
Original Author(s): Nedi
Core Version: 2.7.3
Code:
Code: [Select]
const
Color = $00EE76;
AllowedDistFromSpawn = 200;
MaxSpawnID = 254;

var
IDsToCheck: Array of Byte;
Size: integer;

function NearestSpawn(ID: Byte; var Distance: Single): Byte;
var
timer: integer;
pTeam: Byte;
NearestDist, CurrentDist: Single;
pX, pY, sX, sY: Single;
begin
NearestDist := 999999;
Result := 0;
pTeam := GetPlayerStat(ID, 'Team');
for timer := 1 to MaxSpawnID do begin
if (GetSpawnStat(timer, 'Active') = true) and (GetSpawnStat(timer, 'Style') = pTeam) then begin
GetPlayerXY(ID, pX, pY);
sX := GetSpawnStat(timer, 'X');
sY := GetSpawnStat(timer, 'Y');
sX := sX - pX;
sY := sY - pY;
CurrentDist := sX * sX + sY * sY;
CurrentDist := Iif(CurrentDist < 0, CurrentDist * (-1), CurrentDist);
//WriteConsole(0, 'SpawnID: ' + IntToStr(timer) + ' cDist: ' + IntToStr(Round(CurrentDist)), Color);
if CurrentDist < NearestDist then begin
NearestDist := CurrentDist;
Result := timer;
end;
end;
end;
Distance := NearestDist;
end;

procedure ActivateServer();
begin
Size := 0;
end;

procedure OnPlayerRespawn(ID: byte);
begin
Size := Size + 1;
SetArrayLength(IDsToCheck, Size);
IDsToCheck[Size - 1] := ID;
end;

procedure AppOnIdle(Ticks: integer);
var
timer: integer;
Dist: Single;
begin
if Ticks mod 60 = 0 then begin
for timer := 0 to Size - 1 do begin
if GetPlayerStat(IDsToCheck[timer], 'Alive') = true then begin
NearestSpawn(IDsToCheck[timer], Dist);
WriteConsole(0, IntToStr(Round(Dist)) + ' ' + IntToStr(AllowedDistFromSpawn*AllowedDistFromSpawn), Color);
if Round(Dist) > AllowedDistFromSpawn*AllowedDistFromSpawn then begin
DoDamage(IDsToCheck[timer],4000);
WriteConsole(IDsToCheck[timer], 'Possible spawnbug, player killed.',Color);
WriteLn('Possible spawnbug detected, player '+IDToName(IDsToCheck[timer])+' killed.');
end;
IDsToCheck[timer] := 0;
end;

end;
Size := 0;
SetArrayLength(IDsToCheck, Size);
end;
end;

Modified something..
 
« Last Edit: June 02, 2013, 12:23:02 pm by Nedi »

Offline Spotix

  • Major
  • *
  • Posts: 63
  • Shut up! I just give my sentimental side!
    • http://steamcommunity.com/id/Spotix
Re: Anti Spawn Bug
« Reply #1 on: June 02, 2013, 08:23:54 am »
Good script thanks Nedi, that I need  :)

I've been wondering when will publish it in Soldat forum.
took a little long time ;)
« Last Edit: June 02, 2013, 09:05:38 am by Spotix »

Offline Bonecrusher

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1397
  • High above
    • Zabijaka.pl
Re: Anti Spawn Bug
« Reply #2 on: June 02, 2013, 10:59:29 am »
Disabled downloading as I came across this bug:

Quote
13-06-02 16:16:51 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:52 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:53 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:54 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:55 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:56 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:57 [ale urwal] !stats
13-06-02 16:16:57 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:58 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:59 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:16:59 [ale urwal] !top
13-06-02 16:17:00 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:01 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:02 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:03 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:04 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:05 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:06 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:06 Possible spawnbug detected, player |*~RP~*| Szczepan killed.
13-06-02 16:17:07 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:07 Possible spawnbug detected, player |*~RP~*| Szczepan killed.
13-06-02 16:17:08 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:08 Possible spawnbug detected, player |*~RP~*| Szczepan killed.
13-06-02 16:17:09 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:09 Possible spawnbug detected, player |*~RP~*| Szczepan killed.
13-06-02 16:17:10 Possible spawnbug detected, player *Saint| Emrys killed.
13-06-02 16:17:10 Possible spawnbug detected, player |*~RP~*| Szczepan killed.
13-06-02 16:17:11 Possible spawnbug detected, player *Saint| Emrys killed.

Im chill like that

Offline Nedi

  • Major(1)
  • Posts: 47
Re: Anti Spawn Bug
« Reply #3 on: June 02, 2013, 11:27:31 am »
I have modified AppOnIdle event. So it needs tests.