Author Topic: How to kill everyone  (Read 698 times)

0 Members and 1 Guest are viewing this topic.

Offline Norbo

  • Camper
  • ***
  • Posts: 338
How to kill everyone
« on: July 28, 2008, 05:50:31 am »
I started scripting 3 days ago... and i dont know how to kill everyone.
Can someone help me? How should I make a loop that does that?
I know, imma noob ;/

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: How to kill everyone
« Reply #1 on: July 28, 2008, 06:02:27 am »
You'd need a way of getting a list of all players connected to the server and their ID's

Something like this might work:

Code: [Select]
//kill everyone when someone does /killall

//run this every time someone uses a command
procedure OnPlayerCommand(ID: Byte; Text: string): boolean;
var i: Integer;
begin
//make sure their comand was /killall
if Text = '/killall' then
begin
//go through each of the possible player id's
for i := 1 to 32 do
begin
//make sure this id in question is a real one, if so kill the player
if IDToName(i) <> '' then
DoDamage(i,4000);
end;
end;
end;

I hope that helps.
There are other worlds than these

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: How to kill everyone
« Reply #2 on: July 28, 2008, 06:42:50 am »
thanks, but i don't want it on command, i just want it in script, like if something happends u kill everyone
ill just copy the script from the //go through each of the possible player id's

thanks for help

Offline Irlandec

  • Soldier
  • **
  • Posts: 176
Re: How to kill everyone
« Reply #3 on: July 28, 2008, 06:48:53 am »
Quote
but i don't want it on command, i just want it in script, like if something happends u kill everyone

in line "if Text = '/killall' then " you can edit it as you wish. See here for events or functions.
Example:
Code: [Select]
//Example

//starts when flag is picked
procedure OnFlagGrab(ID, TeamFlag: byte;GrabbedInBase: boolean)
var i: Integer;
begin
//go through each of the possible player id's
for i := 1 to 32 do
begin

if GetPlayerStat(i, 'Active')  then
DoDamage(i,4000);
end;

end;

Not tested, i am a beginner scripter too



« Last Edit: July 28, 2008, 06:55:06 am by Irlandec »

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: How to kill everyone
« Reply #4 on: July 28, 2008, 06:49:38 am »
You should really use if GetPlayerStat(i, 'active') then instead of IDToName (possibly with a check for team <> 5, too).

(Also note that Irlandec's code really makes no sense; for flag grabs, use OnFlagGrab.)
« Last Edit: July 28, 2008, 06:51:27 am by Toumaz »