Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started 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
-
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'
-
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.
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...
-
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.
-
Actually, it did work, but it WASNT because of the script... [retard] :-X
-
How about my dodamage controller script (I make a lot of scripts to control all of these wonderful functions EnEsCe has supplied to us)
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
......
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:
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)
-
ok thx
-
'/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)
-
oh, never thought of that...
I've simplified the "correct way" script I made...
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;