Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: 1221995 on September 09, 2007, 08:27:23 am

Title: ID Kills
Post by: 1221995 on September 09, 2007, 08:27:23 am
Alright. Im Making a script. I want to be able to write "kill 3" and number 3 dies or "kill 1" number 1 dies, etc. (1-999 able to kill). How do I make it so you can kill any number (what function would i use to pull this off)?

Thanks
1221995

P.S.
Respond ASAP ;D
Title: Re: ID Kills
Post by: DorkeyDear on September 09, 2007, 08:38:54 am
Using OnPlayerSpeak, and having DoDamage(##,4000) or Command('/kill ' + InttoStr(##))
Remember you have to have StrtoInt to change the part of the string to an integer..
To get part of a string, theres 2 ways..
Copy and GetPiece
Copy juts gets part of a string starting at the 2nd argument and ending at the 3rd argument, so Copy('this is a test',6,9) = 'is a'
GetPiece is kind of like Split, except you don't have to store it into a variable and get part of it.. 2nd argument is the separator, and 3rd is the array # thingy (i don't know what to call it), example: GetPiece('this is a test',' ',2) = 'a'
Title: Re: ID Kills
Post by: 1221995 on September 09, 2007, 08:42:16 am
Hi DorkeyDear. I Just Found out on Enesce.com/help, but thanks for responding :) ;D .  I found that i could do it differently. Take a look.
Code: [Select]
var

procedure DoDamage(ID: Byte; Damage: Integer)
begin
If Text'/kill (ID)' then begin
DoDamage((ID), 16000);
end;
end;

You know what that means? I CANM CHOOSE HOW MUCH DAMAGE IT DOES WHILE PLAYING!!! ILL post how in a minute...
Title: Re: ID Kills
Post by: EnEsCe on September 09, 2007, 09:17:58 am
Uh no, that code does not work. I really wish you would stop writing random code on the forum that you clearly haven't even tested, its extremely moronic.
Title: Re: ID Kills
Post by: 1221995 on September 09, 2007, 10:06:02 am
Actually, it did work, but it WASNT because of the script...  [retard] :-X
Title: Re: ID Kills
Post by: Kavukamari on September 09, 2007, 05:13:48 pm
How about my dodamage controller script (I make a lot of scripts to control all of these wonderful functions EnEsCe has supplied to us)

Code: [Select]
function OnCommand(ID:Byte;Text:string):boolean;
var
  DPlr: Byte;
  DmgI: integer;
begin
//-----DoDamage-----
  if GetPiece(LowerCase(Text), ' ', 0) = '/dodamage' then begin
    DPlr:=strtoint(GetPiece(Text, ' ', 1));
    DmgI:=strtoint(GetPiece(Text, ' ', 2));
    if GetPlayerStat(DPlr,'Active') = true then begin
      DoDamage(DPlr,DmgI);
    end;
    if GetPlayerStat(DPlr,'Active') = false then begin
      SayToPlayer(ID,'Player number to damage is inactive.');
    end;
    if (DmgI = 150) then begin
      SayToPlayer(ID,'Perfect Kill!');
    end;
  end;
end;

Example:
'/dodamage 1 150' kills player one (150 gets "perfect kill")

(the "//-----DoDamage-----" line is the title of the script)

Date Posted: September 09, 2007, 06:04:43 PM
......
Code: [Select]
procedure DoDamage(ID: Byte; Damage: Integer)
begin
If Text'/kill (ID)' then begin
DoDamage((ID), 16000);
end;
end;
......

the correct way to do this would be:

Code: [Select]
function OnCommand(ID:Byte;Text:string):boolean;
begin
  Result:=false;
  if GetPiece(LowerCase(Text), ' ', 0) = '/kill' then begin
    DoDamage(GetPiece((Text), ' ', 1),4000);
  end;
end;

but what you are trying to do is already possible if you are an admin

(/kill *) (* = player number)
Title: Re: ID Kills
Post by: 1221995 on October 14, 2007, 02:29:29 pm
ok thx
Title: Re: ID Kills
Post by: DorkeyDear on October 14, 2007, 04:16:24 pm
'/dodamage 1 150' kills player one (150 gets "perfect kill")
unless he has a vest on; if i remember correctly, the damage acts like a bullet, and effects ~half and half onto vest and person's health (not sure exactly how much goes to what and when, but wahtever)
Title: Re: ID Kills
Post by: Kavukamari on October 15, 2007, 12:55:24 pm
oh, never thought of that...

I've simplified the "correct way" script I made...

Code: [Select]
function OnCommand(ID:Byte;Text:string):boolean;
begin
  Result:=false;
  if GetPiece(LowerCase(Text), ' ', 0) = '/kill' then DoDamage(GetPiece((Text), ' ', 1),4000);
end;

a small change, made code cleaner and smaller and took out a begin and end;