Author Topic: Anti-spawnbug not working properly  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Anti-spawnbug not working properly
« on: December 28, 2010, 06:22:30 am »
What I wanted to get was anti spawnbug (when a player spawns in a wrong place). First of all, we need to get spawns x,y. So, on map change:

Code: [Select]
amount1 := 0;
amount1 := 0;
  for k:= 1 to 254 do if GetSpawnStat(k,'Style') = 1 then begin
amount1 := amount1 + 1;
alphaspawnstyle[amount1] := k;
  end;
  for k:= 1 to 254 do if GetSpawnStat(k,'Style') = 2 then begin
amount2 := amount2 + 1;
bravospawnstyle[amount2] := k;
  end;

(creates an array of spawns for both teams)

Code: [Select]
if numplayers > 0 then begin
  for i := 1 to 32 do begin
kill[i] := true;
  end
  letskill := true;
end

(marks all the players to be checked in a second)

Checking and killing spawnbugged players:
Code: [Select]
if letskill then begin
for i := 1 to 32 do if kill[i] and (GetPlayerStat(i,'Active') = true) then begin
kill[i] := false;
if GetPlayerStat(i,'Team') = 1 then begin
for j := 1 to amount1 do begin
if Distance(GetPlayerStat(i,'x'),GetPlayerStat(i,'y'),GetSpawnStat(alphaspawnstyle[j],'x'),GetSpawnStat(alphaspawnstyle[j],'y')) > 500 then begin
DoDamage(i,4000);
WriteConsole(i, 'Possible spawnbug, player killed.', $00EE76);
WriteLn('Possible spawnbug detected, player '+IDToName(i)+' killed.');
break;
end
end
end
else if GetPlayerStat(i,'Team') = 2 then begin
for j := 1 to amount2 do begin
if Distance(GetPlayerStat(i,'x'),GetPlayerStat(i,'y'),GetSpawnStat(bravospawnstyle[j],'x'),GetSpawnStat(bravospawnstyle[j],'y')) > 500 then begin
DoDamage(i,4000);
WriteConsole(i, 'Possible spawnbug, player killed.', $00EE76);
WriteLn('Possible spawnbug detected, player '+IDToName(i)+' killed.');
break;
end
end
end
end
letskill := false;
end

But the problem is it does not work properly. On most maps it just kills all the players. So my thought is I'm getting wrong spawns coordinates so the distance is not measured beetween right places. Any idea what I am doing worng?
« Last Edit: December 28, 2010, 06:25:36 am by Silnikos »

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Anti-spawnbug not working properly
« Reply #1 on: December 28, 2010, 08:47:57 am »
I believe here lies the problem:
Code: [Select]
if Distance(GetPlayerStat(i,'x'),GetPlayerStat(i,'y'),GetSpawnStat(alphaspawnstyle[j],'x'),GetSpawnStat(alphaspawnstyle[j],'y')) > 500 then beginDistance greater than 500?
Shouldn't it me less than it?

And aren't you missing semicolons here? Shouldn't blocks end with it?

Code: [Select]
if numplayers > 0 then begin
  for i := 1 to 32 do begin
   kill[i] := true;
  end
  letskill := true;
end

EDIT: Oh, your script is preventing the spawning in the middle of the map...So you should write it in another way I guess... but wait a second...spawns are almost always far away from eachother thus >500 will always execute. Anyway, those setting are kinda maps specific.
« Last Edit: December 28, 2010, 08:59:47 am by Wookash »
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Re: Anti-spawnbug not working properly
« Reply #2 on: December 28, 2010, 08:52:30 am »
Silnikos, I have the same problem, I guess its soldat-fail-core.
The truth is out there? Does anyone know the URL?
The URL is here

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Anti-spawnbug not working properly
« Reply #3 on: December 28, 2010, 10:40:10 am »
You check player's distance from every spawn, i'm quite sure that on most maps there is spawn farer than 500 pixels. Remake it to check only the lowest value.

And nice idea by the way

EDIT: Also, mind using GetPlayerXY() instead of GetPlayerStats, as it's faster and more stable
« Last Edit: December 28, 2010, 10:42:26 am by FalconPL »
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Anti-spawnbug not working properly
« Reply #4 on: December 28, 2010, 12:05:40 pm »
Quote
And aren't you missing semicolons here? Shouldn't blocks end with it?
They're not required. They are when you end a procedure/function/event.

Quote
You check player's distance from every spawn, i'm quite sure that on most maps there is spawn farer than 500 pixels. Remake it to check only the lowest value.
Oh true, that's where the problem is. That should solve it. Thanks!

Quote
EDIT: Also, mind using GetPlayerXY() instead of GetPlayerStats, as it's faster and more stable
Is it? Didn't know that, thanks.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Anti-spawnbug not working properly
« Reply #5 on: December 28, 2010, 12:14:31 pm »
Quote
Quote
EDIT: Also, mind using GetPlayerXY() instead of GetPlayerStats, as it's faster and more stable
Is it? Didn't know that, thanks.

It's good to avoid use of GetPlayerStat as much as possible