Author Topic: Help needed w/ script!  (Read 791 times)

0 Members and 1 Guest are viewing this topic.

Offline Lt. Sprizz

  • Major
  • *
  • Posts: 79
  • I'm sorry if I offended you.
Help needed w/ script!
« on: April 13, 2009, 08:07:10 pm »
Okay, so far I have all this...

var
   Timer: integer;
procedure AppOnIdle(Ticks: integer);
var i: integer;
begin
   if Timer = 6 then
      WriteConsole(0, 'Admin has chosen you to die in 5...', $DFDF39)
   if Timer = 5 then
      WriteConsole(0, '4...', $DFDF39)
   if Timer = 4 then
      WriteConsole(0, '3...', $DFDF39)
   if Timer = 3 then
      WriteConsole(0, '2...', $DFDF39)
   if Timer = 2 then
      WriteConsole(0, '1...', $DFDF39)
   if Timer > 0 then
      Timer := Timer - 1
   if Timer = 0 then begin
      for i := 1 to 32 do
         if GetPlayerStat(i, 'active') then Command('/kill '+inttostr(i));
      Timer := -1;
   if Timer = -1 then
      WriteConsole(0, 'That was a warning...', $DFDF39)
      Timer := -2
   end;
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
   if Text = '/pwnage time' then begin
      Timer := 6;
   end;
end;



Now, as you can see, when a player types in "pwnage time" a timer begins and eventually kills everyone. This is only the beginning of what I want to happen.

What I would like to make it so that I could type in something like "pwn (Player's name)" and it would specifically kill that one person, with the countdown still being said to everyone(although I would also like to see the beginning message of 'Admin has chosen you to die..." to something like 'Admin has chosen (player's name) to die...'

Now where i put (Player's name) I want it to read the player's name you type in, figure out the ID, and then kill him and ONLY HIM. Also, It will help to put a password on it, which I think i can figure out (something like after you type "/pwn (Player's name)" I will happen it Write Console "Password" followed by only starting the countdown when you type in the specifed password.

Sry for the long post but I want this script to work. It will be like a warning system to players instead of going ahead and kicking them for 15 min., or however long.

plz help
"I am Jack's lack of surprise..." ~(Tyler Durden)
-=::SPOILER::=-
Edward Norton and Brad Pitt are the same person...:)
In-game: \Biz|Niz/

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Help needed w/ script!
« Reply #1 on: April 14, 2009, 12:44:29 am »
Use [ code ] and [ /code ] (minus the spaces) for code.
About your question, look up the GetPiece function in the scripting manual.
Just make another global variable (I'd suggest an int, string is OK too though). Now when the person types /pwn or whatever use GetPiece to get the 2nd part (GetPiece(str, ' ', 1)) of what the say and store that.

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: Help needed w/ script!
« Reply #2 on: April 14, 2009, 10:45:52 am »
Code: [Select]
var
 Timer, ChosenPlayer: integer;

procedure AppOnIdle(Ticks: integer);
var
  i: integer;
begin
  if (Timer > 0) then
  begin
    if (GetPlayerStat(ChosenPlayer, 'Active') = true) then
    begin
      case Timer of
        7: WriteConsole(ChosenPlayer, 'Admin has chosen you to die in 5...', $DFDF39);
        6: WriteConsole(ChosenPlayer, '4...', $DFDF39);
        5: WriteConsole(ChosenPlayer, '3...', $DFDF39)
        4: WriteConsole(ChosenPlayer, '2...', $DFDF39)
        3: WriteConsole(ChosenPlayer, '1...', $DFDF39)
        2: Command('/kill ' + IntToStr(ChosenPlayer));
        1: WriteConsole(ChosenPlayer, 'That was a warning...', $DFDF39)
      end;
      Dec(Timer, 1);
    end;
  end;
end;

function OnCommand(ID: Byte; Text: string): boolean;
var
  i: integer;
begin
  if (GetPiece(Text, ' ', 0) = '/pwnagetime') then
  begin
    delete(Text, 1, length(GetPiece(Text, ' ', 0)) + 1);
    for i:= 1 to 32 do
    begin
      if (IDToName(i) = Text) then
      begin
        ChosenPlayer:= i;
        WriteConsole(ID, 'Player found - ID: ' + IntToStr(ChosenPlayer), $DFDF39);
        Timer:= 7;
        break;
      end;
    end;
  end;
  Result:= false;
end;

Code not tested.
Soldat Global Account System: #soldat.sgas @ quakenet

Offline Lt. Sprizz

  • Major
  • *
  • Posts: 79
  • I'm sorry if I offended you.
Re: Help needed w/ script!
« Reply #3 on: April 14, 2009, 07:43:29 pm »
...wow that would have taken me forever to figure out...

But CurryWurst, I'm having a hard time figuring out to make your code work. What does the admin need to type to start the whole order of things? Because all "/pwnagetime" does is say that there's a player found and his ID is 1.(I realize that was me, I was testing it on my own server by myself with bots.) What do u need to input after that so the timer and countdown begin? or is there just some trick to typing in "/pwnagetime" that I'm not getting :-[?

I'm a total noob at scripts, and I thought this project woul dbe easier when i started....I think i need a very simple script idea to get started(I've already done all the scripts in the tutorial)

Ty very much tho
"I am Jack's lack of surprise..." ~(Tyler Durden)
-=::SPOILER::=-
Edward Norton and Brad Pitt are the same person...:)
In-game: \Biz|Niz/

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: Help needed w/ script!
« Reply #4 on: April 15, 2009, 05:56:57 am »
You can pick a player by entering "/pwnagetime playersnamegoeshere".
Soldat Global Account System: #soldat.sgas @ quakenet

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Help needed w/ script!
« Reply #5 on: April 15, 2009, 06:25:06 am »
I wouldn't input (just) names. They are sometimes a bitch to spell correctly. Instead I would input ID or slot number. You can see all players' number by pressing / and then F1.
Come join: EliteCTF
Listen to: My Music

Offline Lt. Sprizz

  • Major
  • *
  • Posts: 79
  • I'm sorry if I offended you.
Re: Help needed w/ script!
« Reply #6 on: April 15, 2009, 08:08:39 pm »
Ty Currywurst :)

@JFK that sounds like a good idea too, ty for the info. I think this prob is solved :)
"I am Jack's lack of surprise..." ~(Tyler Durden)
-=::SPOILER::=-
Edward Norton and Brad Pitt are the same person...:)
In-game: \Biz|Niz/