Author Topic: Admin invisibility?  (Read 1424 times)

0 Members and 1 Guest are viewing this topic.

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Admin invisibility?
« on: December 18, 2007, 08:03:24 pm »
I'm trying to make a script that gives an admin invisibility and takes it away on command.  But only if your the admin.  I kind of have an idea what to do but I still need help.  I know you have to make them get predator and then make it last forever and then somehow take away predator.

Here's a kindofish start, help...

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

function OnCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
  if Text = '/invis' then if Invisible[ID] then begin
    WriteConsole(ID,'Invisibility has been disabled.',$FFFFFFFF);
    Invisible[ID] := false;
  end else begin
    WriteConsole(ID,'Invisibility has been enabled.',$FFFFFFFF);
    Invisible[ID] := true;
  end;
begin
  if Invisible[ID] then
  GiveBonus(ID, 1);
  end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  Invisible[ID] := false;
end;

Edit:
Yeah...anyway I think I know how to do it, you can make it repeat the Givebonus every like 20 or 30 seconds depending on how long predator usually lasts and then the existing code would make it stop repeating it and you would just have to wait for your existing predator to stop?  I just don't know how to make something repeat like every so many seconds.
« Last Edit: December 19, 2007, 07:28:26 am by Gnintendo »

Offline poutch

  • Major(1)
  • Posts: 34
Re: Admin invisibility?
« Reply #1 on: December 18, 2007, 11:55:56 pm »
Ok i'll help you a bit, i can see that you got inspired by another post ^^

You have to call the function that gives invisibility somewhere ... if you read the help by enesce you will see how to make it :

http://enesce.com/help/html/Functions/SpawnObject.html
Look at the syntax examples, it will help you

try to do that and then u ll have another challenge to repeat the process with a timer or else your admin will have the invisibility just for the time of one pred kit
www.pleez.fr .... coming soon

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Admin invisibility?
« Reply #2 on: December 19, 2007, 06:15:22 am »
Or u could modify the amount of damage dealt under the OnPlayerDamage event, but grenades + other explosives won't work all the time, but as far as i know, if u set the damage to some really low negative number, it works..

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Re: Admin invisibility?
« Reply #3 on: December 19, 2007, 07:26:42 am »
Sorry but none of those really helped.

The GiveBonus I have up there is undocumented but does the same thing as the spawnobject.

DorkeyDearCurt, read more carefully next time.

Invisibility

...

Yeah...anyway I think I know how to do it, you can make it repeat the Givebonus every like 20 or 30 seconds depending on how long predator usually lasts and then the existing code would make it stop repeating it and you would just have to wait for your existing predator to stop?  I just don't know how to make something repeat like every so many seconds.

Offline KwS Pall

  • Major(1)
  • Posts: 49
  • I'm going to write Tibia for Soldat
Re: Admin invisibility?
« Reply #4 on: December 19, 2007, 09:19:58 am »
Code: [Select]
Procedure AppOnIdle(Ticks: integer);
begin
if Ticks mod (60 * 25) = 0 then begin
 //code you wanna repeat every 25 secs (predator tme)
 end;
end;

i don't know that script will work because i haven't access to my computer so use something like this
I'm going to write Tibia for Soldat

Offline poutch

  • Major(1)
  • Posts: 34
Re: Admin invisibility?
« Reply #5 on: December 19, 2007, 11:47:07 am »
Sorry but none of those really helped.

The GiveBonus I have up there is undocumented but does the same thing as the spawnobject.

DorkeyDearCurt, read more carefully next time.

Invisibility

...

Yeah...anyway I think I know how to do it, you can make it repeat the Givebonus every like 20 or 30 seconds depending on how long predator usually lasts and then the existing code would make it stop repeating it and you would just have to wait for your existing predator to stop?  I just don't know how to make something repeat like every so many seconds.

I can give you the whole code but i think that you wan't to learn it yourself.
First try to correct your code, you have 2 "main" begins in your oncommand function.


well i guess that you wanted to do that :

function OnCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
  if Text = '/invis' then
    if Invisible[ID] then begin
      WriteConsole(ID,'Invisibility has been disabled.',$FFFFFFFF);
      Invisible[ID] := false;
    end else begin
      WriteConsole(ID,'Invisibility has been enabled.',$FFFFFFFF);
      Invisible[ID] := true;
      GiveBonus(ID, 1);
    end;
end;

that will enable invisibility instantly when you cast the command.
You w'ont be able to disable it instantly though as you have to wait for the last pred kit to end.

Now you just need to add a timer as told in the other post to recast your invisibility every X sec if Invisible[ID] = true
« Last Edit: December 19, 2007, 11:56:26 am by poutch »
www.pleez.fr .... coming soon

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Re: Admin invisibility?
« Reply #6 on: December 19, 2007, 04:02:29 pm »
So I have this?
Code: [Select]
var
  Invisible: array[1..32] of boolean;
function OnCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
  if Text = '/invis' then
    if Invisible[ID] then begin
      WriteConsole(ID,'Invisibility has been disabled.',$FFFFFFFF);
      Invisible[ID] := false;
    end else begin
      WriteConsole(ID,'Invisibility has been enabled.',$FFFFFFFF);
      Invisible[ID] := true;
      GiveBonus(ID, 1);
    end;
end;
Procedure AppOnIdle(ID, Ticks: integer);
begin
if Ticks mod (60 * 25) = 0 then begin
if Invisible[ID] = true
end;
end;
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  Invisible[ID] := false;
end;

Offline KwS Pall

  • Major(1)
  • Posts: 49
  • I'm going to write Tibia for Soldat
Re: Admin invisibility?
« Reply #7 on: December 19, 2007, 04:11:33 pm »
So I have this?
Code: [Select]
var
 Invisible: array[1..32] of boolean;
function OnCommand(ID: Byte; Text: string): boolean;
begin
 Result := false;
 if Text = '/invis' then
 if Invisible[ID] then begin
 WriteConsole(ID,'Invisibility has been disabled.',$FFFFFFFF);
 Invisible[ID] := false;
 end else begin
 WriteConsole(ID,'Invisibility has been enabled.',$FFFFFFFF);
 Invisible[ID] := true;
 GiveBonus(ID, 1);
 end;
end;
Procedure AppOnIdle(ID, Ticks: integer);
begin
if Ticks mod (60 * 25) = 0 then begin
if Invisible[ID] = true then begin
GiveBonus(ID,1); //dunno if this will work
end;
end;
end;
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
 Invisible[ID] := false;
end;

you must check if the ID is an admin
I'm going to write Tibia for Soldat

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Re: Admin invisibility?
« Reply #8 on: December 19, 2007, 04:18:10 pm »
Every second it says [error] invisibility -> (apponidle) not enough parameters.
« Last Edit: December 19, 2007, 04:55:39 pm by Gnintendo »

Offline Boblekonvolutt

  • Soldier
  • **
  • Posts: 222
  • "YOU are a CAR."
Re: Admin invisibility?
« Reply #9 on: December 19, 2007, 04:58:39 pm »
Replace the apponidle part with this
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
Counter: Byte;
begin
  if Ticks mod (60 * 25) = 0 then begin

    for Counter := 1 to 32 do // run through all the players
      if Invisible[Counter] = true then begin // and do this for them
        GiveBonus(Counter, 1); //dunno if this will work
      end;

  end;
end;

And why would you need to check if a player is admin? OnCommand only runs if you're an admin.

Offline poutch

  • Major(1)
  • Posts: 34
Re: Admin invisibility?
« Reply #10 on: December 19, 2007, 05:16:23 pm »
you must check if the ID is an admin

OnCommands apply only to admins

Date Posted: December 19, 2007, 05:10:26 pm
So I have this?
Code: [Select]
var
  Invisible: array[1..32] of boolean;
function OnCommand(ID: Byte; Text: string): boolean;
begin
  Result := false;
  if Text = '/invis' then
    if Invisible[ID] then begin
      WriteConsole(ID,'Invisibility has been disabled.',$FFFFFFFF);
      Invisible[ID] := false;
    end else begin
      WriteConsole(ID,'Invisibility has been enabled.',$FFFFFFFF);
      Invisible[ID] := true;
      GiveBonus(ID, 1);
    end;
end;
Procedure AppOnIdle(ID, Ticks: integer);
begin
if Ticks mod (60 * 25) = 0 then begin
if Invisible[ID] = true
end;
end;
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  Invisible[ID] := false;
end;

Your apponidle procedure is wrong. You do a if with no then and you have to use something like :

for i:= 1 to 32 do               // that s to check all the characters
  if Invisible then            // same as if Invisible[ID] = true then
    GiveBonus(i,1);             // never used Givebonus and did't test it, i just retake your syntax here


Also, to be clear, you should let a space between the different stuff in the code :
after the global vars (the Invisible array) and after the functions and procedures
« Last Edit: December 19, 2007, 05:24:24 pm by poutch »
www.pleez.fr .... coming soon

Offline Gnintendo

  • Major
  • *
  • Posts: 61
Re: Admin invisibility?
« Reply #11 on: December 19, 2007, 06:24:51 pm »
you must check if the ID is an admin

OnCommands apply only to admins

Date Posted: December 19, 2007, 05:10:26 pm
So I have this?
Code: [Select]
var
 Invisible: array[1..32] of boolean;
function OnCommand(ID: Byte; Text: string): boolean;
begin
 Result := false;
 if Text = '/invis' then
 if Invisible[ID] then begin
 WriteConsole(ID,'Invisibility has been disabled.',$FFFFFFFF);
 Invisible[ID] := false;
 end else begin
 WriteConsole(ID,'Invisibility has been enabled.',$FFFFFFFF);
 Invisible[ID] := true;
 GiveBonus(ID, 1);
 end;
end;
Procedure AppOnIdle(ID, Ticks: integer);
begin
if Ticks mod (60 * 25) = 0 then begin
if Invisible[ID] = true
end;
end;
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
 Invisible[ID] := false;
end;

Your apponidle procedure is wrong. You do a if with no then and you have to use something like :

for i:= 1 to 32 do // that s to check all the characters
 if Invisible then // same as if Invisible[ID] = true then
 GiveBonus(i,1); // never used Givebonus and did't test it, i just retake your syntax here


Also, to be clear, you should let a space between the different stuff in the code :
after the global vars (the Invisible array) and after the functions and procedures
I already tested his code, it works.

Offline poutch

  • Major(1)
  • Posts: 34
Re: Admin invisibility?
« Reply #12 on: December 19, 2007, 07:37:34 pm »
What do you mean by "his code" ?
when i said it s wrong, i was talking about your code :

---
if Invisible[ID] = true
end;
---

And you should also initialise the array to all false at the start of server (else it will still work i guess but there may be some memory issues because you test a variable that is not initialised when you do the first "/invis" command) :

procedure ActivateServer()
begin
  for i := 1 to 32
    Invis := false;
end;
« Last Edit: December 19, 2007, 07:47:31 pm by poutch »
www.pleez.fr .... coming soon