SA-MP Forums Archive
Gate automatically closes - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Gate automatically closes (/showthread.php?tid=69733)



Gate automatically closes - karla - 20.03.2009

How to make gate, waht will open by a cmd, but closes automatically after 5 seconds?


Re: Gate automatically closes - Castle - 20.03.2009

here is an Example:
pawn Код:
//Top of script
forward objTimer();
new obj, objstatus = 1;


public OnGameModeInit()
{
    obj = CreateObject(objid, X, Y, Z, rX, rY, rZ);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/gate", true) == 0)
    {
        if(objstatus = 1)
        {
            MoveObject(obj, newX, newY, newZ);
            objstatus = 0;
        }
        SetTimer("objTimer", 5000, false);//5000 = 5 seconds
        return 1;
    }
    return 1;
}

public objTimer()
{
    if(objstatus == 0)
    {
        MoveObject(objID, oldX, oldY, oldZ);
        objstatus = 1;
    }
    return 1;
}
This should work, Hope you under stand this

newX/Y/Z = where to move
oldX/Y/Z = Original location to move back the opbject



Re: Gate automatically closes - karla - 20.03.2009

and, how this will make gate close automatically
Which line?


Re: Gate automatically closes - Castle - 20.03.2009

read the SetTimer("objTimer, 5000, false);
as you might see there is a Forward and Call back READ it!



Re: Gate automatically closes - karla - 20.03.2009

Quote:
Originally Posted by Castle
read the SetTimer("objTimer, 5000, false);
as you might see there is a Forward and Call back READ it!
Thanks man, Firstly i saw the tiny part of yout script, sorry about that.


Re: Gate automatically closes - Castle - 20.03.2009

when i was writing the code i pressed 'submit' by mistake so i edited