Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: 1221995 on October 14, 2007, 08:01:27 pm

Title: Whats wrong with this script?
Post by: 1221995 on October 14, 2007, 08:01:27 pm
What it does is make it so u dont kill urself, teh server kills u. Im making this cause i hav a no suicide script, but it make /kill not work. Tihs makes it so someone else kill u. Whats wrong with it? Does it do what it supposed to?

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

Plz respond ASAP.

Thanks,
1221995
Title: Re: Whats wrong with this script?
Post by: Kavukamari on October 15, 2007, 12:43:35 pm
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string):boolean;
var
  Temp: array[1..5] of string; //now you have an easy 5 "Temp" variables :)
begin
  Result:=false;
  Temp[1]:=GetPiece(LowerCase(Text), ' ', 0);
  if Temp[1] = '/kill' then begin
    Result:=true; //ignores command...
    DoDamage(ID,4444); //actually, 150 is a "Perfect kill" in DoDamage, but 4000 makes sure...
//-----Optional-----
    DrawText(ID,'  ',50,$ffff2020,.24,40,240);
    DrawText(ID,'Killed by The Guardians.',125,$ffff2020,.24,40,240);
//I think that's the right scale and position for "Killed By" drawtexts, I am not sure...
  end;
end;

I think that works, I can't test it now, I'm at school... I hope it helps...
Title: Re: Whats wrong with this script?
Post by: 1221995 on October 15, 2007, 04:27:38 pm
It makes it say "sytax error"... I like the guardians thing tho... Wat does that syntax error mean/ why does it happen? :P
Title: Re: Whats wrong with this script?
Post by: DorkeyDear on October 15, 2007, 05:19:31 pm
".24" should be "0.24"
Title: Re: Whats wrong with this script?
Post by: Kavukamari on October 15, 2007, 07:53:25 pm
oh, my bad :P sometimes you get used to forgetting the 0
Title: Re: Whats wrong with this script?
Post by: 1221995 on October 15, 2007, 08:42:36 pm
uh... Klled by the guardians is too big for screen, it shows killed by the gua....
I dont know y, but it doesnt actually kill him. it just says the guardians thing... :p?
Title: Re: Whats wrong with this script?
Post by: urraka on October 15, 2007, 09:41:46 pm
You have to retrieve the ID from Text, and you are using the ID of whoever sends the comand. So you should replace the DoDamage with
Code: [Select]
DoDamage(StrToInt(GetPiece(Text, ' ', 1)), 4444);
Title: Re: Whats wrong with this script?
Post by: Kavukamari on October 16, 2007, 12:07:13 am
yeah, I only did it for person killing self

for Admin killing person, you need OnCommand instead of OnPlayerCommand...
Title: Re: Whats wrong with this script?
Post by: BombSki on October 16, 2007, 10:09:34 am
I dont think it works because the trigger is /kill which is already a default command? looking at the first post it seems like that is exactly what he needs.
Title: Re: Whats wrong with this script?
Post by: 1221995 on October 19, 2007, 02:28:15 pm
alrite.. i am cofuzzled :P Can someone put the FINISHED SCRIPT on this thred please? thanks.
Title: Re: Whats wrong with this script?
Post by: spkka on October 20, 2007, 07:20:37 am
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string):boolean;
var
  Temp: array[1..5] of string; //now you have an easy 5 "Temp" variables :)
begin
  Result:=false;
  Temp[1]:=GetPiece(LowerCase(Text), ' ', 0);
  if Temp[1] = '/suicide' then begin
    Result:=true; //ignores command...
    DoDamage(ID,4444); //actually, 150 is a "Perfect kill" in DoDamage, but 4000 makes sure...
//-----Optional-----
    DrawText(0,IDToName(ID),50,$ffff2020,.24,40,240);
    DrawText(0,'Killed by The Guardians.',125,$ffff2020,.24,40,240);
//I think that's the right scale and position for "Killed By" drawtexts, I am not sure...
  end;
end;


sth like this should work i think. Drawtext(0 writes the text to all players that the player using /suicide was  killed by the gaurdians.


Title: Re: Whats wrong with this script?
Post by: 1221995 on October 20, 2007, 09:17:25 am
nice, but instead of .24 it should be 0.24 or it gives a syntax error ::)
Title: Re: Whats wrong with this script?
Post by: spkka on October 20, 2007, 12:16:10 pm
oh ye :P lol