Author Topic: I can't do it. Lock To Spectators.  (Read 578 times)

0 Members and 1 Guest are viewing this topic.

Offline utkesmer

  • Major(1)
  • Posts: 44
I can't do it. Lock To Spectators.
« on: July 07, 2009, 07:20:44 am »
LockToSpec

I am trying to make a script which does not allow to join team other than "Spectators" when I command '/locktospec (Player ID)' but I can't.

Sorry for my English. :D

This is the simple version of what I want.  (It doesn't work. =D)

Edit : I changed the code, it doesn't give any error now, but doesn't work too. I can not see any mistakes.

Code: [Select]
var
LOCKTOSPEC: string;


function OnCommand(ID: Byte; Text: string): boolean;
begin
  //NOTE: This function will be called when an admin types a / command.
  Result := false; // Return true if you want to ignore the command typed.

 if MaskCheck(Text, '/locktospec') then begin

      LOCKTOSPEC := GetPiece(Text, ' ', 1);
      Command('/setteam5 '+INTTOSTR( NameToID(LOCKTOSPEC) ) );

 end;

end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin

 if not LOCKTOSPEC = IDToName(ID) then begin

      if MaskCheck(Text, '!alpha') then Command('/setteam1 '+INTTOSTR(ID) );
      if MaskCheck(Text, '!bravo') then Command('/setteam2 '+INTTOSTR(ID) );
      if MaskCheck(Text, '!spec') then Command('/setteam5 '+INTTOSTR(ID) );

 end;

end;

procedure OnJoinTeam(ID, Team: byte);
begin

 if LOCKTOSPEC = IDToName(ID) then begin

      Command('/setteam5 '+INTTOSTR(ID) );

 end;

end;

Help.
« Last Edit: July 07, 2009, 07:49:41 am by utkesmer »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: I can't do it. Lock To Spectators.
« Reply #1 on: July 07, 2009, 08:36:31 am »
Here you go, not tested but it should work.

Code: [Select]
var locktospec: array[1..32] of boolean;

function OnCommand(ID: Byte; Text: string): boolean;
var target: byte;
begin
if (getpiece(text,' ',0) = '/locktospec') then if (getpiece(text,' ',1) <> nil) then begin
if getplayerstat(strtoint(getpiece(text,' ',1)),'active')=true then begin
target := strtoint(getpiece(text,' ',1));
locktospec[target] := not locktospec[target];
if locktospec[target] = true then command('/setteam5 '+inttostr(target));
end else writeconsole(ID,'There is no player using ID #'+inttostr(target),$ffff0000);
end else writeconsole(ID,'You must specify a player id!',$ffff0000);
end;

procedure OnJoinTeam(ID, Team: byte);
begin
if (locktospec[ID] = true) AND (team <> 5) then command('/setteam5 '+inttostr(ID));
end;

procedure OnJoinGame(ID, Team: byte);
begin
locktospec[ID] := false;
end;
« Last Edit: July 07, 2009, 08:38:08 am by Hacktank »


Offline utkesmer

  • Major(1)
  • Posts: 44
Re: I can't do it. Lock To Spectators.
« Reply #2 on: July 07, 2009, 01:31:35 pm »
It's working. Thank you but please add a little explanation about it.