[SCRIPT] Jail Door

Started by BigcaT_, Feb 12, 2015, 07:22 AM

Previous topic - Next topic

BigcaT_

I made this command today. ;D    Here's the code:

Updated!
function onScriptLoad()
{
g <- false;
gate2 <- CreateObject( 3685, 1, 384.108, -505.87, 9.65089, 255 );
}

function onPlayerCommand(player,cmd,text)
{
local plr = text ? GetPlayer(text) : player;
else if (cmd == "freeze" || cmd == "jail")
{
    if (!plr || !plr.IsSpawned) EM("Invalid player.",player);
else
{
    plr.Pos = Vector(381.9696, -505.1464, 9.3956);
plr.IsFrozen = true;
    if ( g == true )//OPENING[ {
    gate2.MoveTo(Vector(384.108, -505.87, 9.65089), 2500 );
        g = false;
    }
    }
}
else if (cmd == "unfreeze" || cmd == "unjail")
{
    if (!plr || !plr.IsSpawned) EM("Invalid player.",player);
else
{
    plr.IsFrozen = false;
    if ( g == false )
{
gate2.MoveTo(Vector( 383.031, -507.158, 9.65089), 2500 );
g = true;
}
    }
}
}

function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}

Hope you can love it. :-*

Miracle

lol,It should be "plr"  instead of "player".

.

Quote from: Miracle on Feb 13, 2015, 05:24 AMlol,It should be "plr"  instead of "player".

If you mean in the second code snippet. Then I guess it was left like that because other people might import/copy that code into their code and since they use `player` there was no point in using another name. Think of it as a convention.
.

BigcaT_

Quote from: Miracle on Feb 13, 2015, 05:24 AMlol,It should be "plr"  instead of "player".
Thanks. I see.