Author Topic: Event_Invisibility & Event_TakeCurrentItem  (Read 1670 times)

I would code these myself but I honestly don't have much experience with events.

The first one is simple. I just want it so that if a player clicks a block he becomes invisible.

Code: [Select]
function invisibility(%client)
{
%client.player.hideNode("ALL");
}
I don't know how much this code will help, lol. But use it for the event
(yes, I want the name to be shown still)

onActivate -> Player -> setInvisibility

Now for the more difficult one. I'd like it so that a player can click a block with
their key, and the key will be taken from them.

onKeyMatch -> client? or player? -> takeItem

Thank you guys for looking through this. If you're wondering why I need this,
I'm just trying to make it so that someone will have two choices:
(invisibility or change datablock)

They only get to pick one using their key.
I know there are other ways to do this, but I gave my reasons. It HAS to be this way.

Again thanks for looking over this.  :cookieMonster:

Sorry, this was posted in the wrong section. I don't know whether to wait to be moved
or to create a new one in the correct section.

TakeItem is already an event called RemoveItem or something (idk)

somewhere is the actual events for the old bots made specifically for players. you could use EditAppearance for that. if it's not then I'd have to upload a link when I can

also if you are using hide node then the players avatar will reset if they change something in the options

Use the removeItem event and the editPlayerAppearance event, hidenode ALL

also if you are using hide node then the players avatar will reset if they change something in the options
Ah, get avatar locker for this.

there could just be an invisible playertype somewhere too. i imagine someone would have made it

Code: server.cs (21 lines)
function Player::setInvisibility(%player,%value)
{
    if(%value)
        %player.isInvisible = true;
    else
        %player.isInvisible = false;

    if(%player.isInvisible)
        %player.invisibilityLoop();
}
registerOutputEvent("Player", "setInvisibility", "bool");

function Player::invisibilityLoop(%player)
{
    if(!isObject(%player)) return;
    if(%player.getState() $= "Dead") return;
    cancel(%player.invisibilitySch);
    if(!%player.isInvisible) return;
    %player.hideNode("ALL");
    %player.invisibilitySch = %player.schedule(10,invisibilityLoop);
}


Code: server.cs (21 lines)
function Player::setInvisibility(%player,%value)
{
    if(%value)
        %player.isInvisible = true;
    else
        %player.isInvisible = false;

    if(%player.isInvisible)
        %player.invisibilityLoop();
}
registerOutputEvent("Player", "setInvisibility", "bool");

function Player::invisibilityLoop(%player)
{
    if(!isObject(%player)) return;
    if(%player.getState() $= "Dead") return;
    cancel(%player.invisibilitySch);
    if(!%player.isInvisible) return;
    %player.hideNode("ALL");
    %player.invisibilitySch = %player.schedule(10,invisibilityLoop);
}


That seems horribly inefficient, what is the point of the loop? Setting players to be visible also won't do anything.

Point of the loop is in case their body unhides nodes.

Point of the loop is in case their body unhides nodes.
So package that function and prevent them from changing their avatar while invisible instead of running an inefficient loop.

When I get home I'll rewrite that