Author Topic: Whats wrong with this script?  (Read 2327 times)

0 Members and 2 Guests are viewing this topic.

Offline 1221995

  • Soldier
  • **
  • Posts: 206
Whats wrong with this script?
« 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

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Whats wrong with this script?
« Reply #1 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...
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline 1221995

  • Soldier
  • **
  • Posts: 206
Re: Whats wrong with this script?
« Reply #2 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

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Whats wrong with this script?
« Reply #3 on: October 15, 2007, 05:19:31 pm »
".24" should be "0.24"

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Whats wrong with this script?
« Reply #4 on: October 15, 2007, 07:53:25 pm »
oh, my bad :P sometimes you get used to forgetting the 0
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline 1221995

  • Soldier
  • **
  • Posts: 206
Re: Whats wrong with this script?
« Reply #5 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?

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Whats wrong with this script?
« Reply #6 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);
urraka

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Whats wrong with this script?
« Reply #7 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...
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline BombSki

  • Flagrunner
  • ****
  • Posts: 927
    • Climbing-soldiers.net
Re: Whats wrong with this script?
« Reply #8 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.

Offline 1221995

  • Soldier
  • **
  • Posts: 206
Re: Whats wrong with this script?
« Reply #9 on: October 19, 2007, 02:28:15 pm »
alrite.. i am cofuzzled :P Can someone put the FINISHED SCRIPT on this thred please? thanks.

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Whats wrong with this script?
« Reply #10 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.



Offline 1221995

  • Soldier
  • **
  • Posts: 206
Re: Whats wrong with this script?
« Reply #11 on: October 20, 2007, 09:17:25 am »
nice, but instead of .24 it should be 0.24 or it gives a syntax error ::)

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Whats wrong with this script?
« Reply #12 on: October 20, 2007, 12:16:10 pm »
oh ye :P lol