[Tutorial] Moving A Gate With Command - Auto Closing
#1

pawn Code:
#include <a_samp> // As usual, add this include to the top so your script will work.

new gate; // The objectid your gate will be using
new timer[MAX_PLAYERS]; // Creates your auto-closing timer
//Add these two ABOVE your OnFilterScriptInit() or OnGameModeInit()

public OnFilterScriptInit() // or OnGameModeInit() if you are using a gamemode
{
    gate = CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance);
    // Example: CreateObject(969, 155, 12.6, 10.95, 0.0, 0.0, 90.0, 20.0);
    // Place this under OnFilterScriptInit(), or OnGameModeInit() if you are using it in a gamemode.
}

public OnPlayerCommandText(playerid, cmdtext[]) // This is where we make the open command
{
    if (strcmp("/open", cmdtext, true, 10) == 0) // When a player types '/open'
    {
      if(IsPlayerInRangeOfPoint(playerid, distance, X, Y, Z)) // Will detect whether they are near the gate or not
           { // It is recommended you set the RangeOfPoint to the coordinates of your 'closed' gate
           MoveObject(gate, 520.0, -170.0, 19.0, 5.0, Float:RotX, Float:RotY, Float:RotZ); // Example: MoveObject(gate, 12,15, 10, 5.0, 120.0, 0.0, 90.0); Float:RotX, Y and Z should match your 'CreateObject' rotations
           SendClientMessage(playerid, 0xEF994300, "The gate is opening and will close in 10 seconds."); // Send the player that typed /open, this message
           timer[playerid] = SetTimerEx("gateclose",10000,false,"i",playerid); // Will activate a timer called 'gateclose' after 10 seconds, once the player has typed 'open'. Does not repeat itself.
           // If you want to change timer: 1 Second = 1000, 5 seconds = 5000, 40 seconds = 40000, 1 minute = 60000 etc.
        }
        }
    return 1;
    }
    forward gateclose(); //Defines our 'gateclose' timer when a player types /open, and what we want the gate to do
    public gateclose()
    {
    MoveObject(gate, X, Y, Z, speed, Float:RotX, Float:RotY, Float:RotZ); // This will move the gate back to the 'closed' position
    // which will be the same as the position in your FilterScriptInit()
    }
NOTE: The co-ordinates used in this example, are not recommended for use as they are random and most likely will not function the way you want them to. The co-ordinates were not taken from any script, they were generated on creating this example.
Reply
#2

Nice Tut
Reply
#3

Nice tutorial,but please put the code in a [pawn] [/pawn] tags so your explanations will be more understood-able.
Reply
#4

A bad tutorial, of it's even one. This is just a 'copy this and paste it into your code' thread.
Reply
#5

Actually no... I made this myself... you can check in the Moving A Gate Command, I added auto close feature to it for a person who requested it...
Reply
#6

This is a rather bad tutorial. It doesn't explain anything, and is merely a "copy this, paste it here" tutorial. The gate won't automatically close either, as you're calling "timer2" when setting the time, rather than "closegate".

Edit: Sorry, that seemed a little harsh.
Reply
#7

It doesn't explain as it should. By add these at the top and these at the bottom, if I was begginer I wouldn't understand what those lines do. Moreover, you have the Parameters from the functions, that everyone can find them easily on wiki.
Good Job, but I wanna see better work the next time than this one.
Reply
#8

Where was this tutorial exactly 'Copied' from? I created it in one of my filterscripts and simply made it easier, so then it resembled the original tutorial...

EDIT: My mistake, I copied this from my filterscript so I guess I forgot to change it :S
Reply
#9

Quote:
Originally Posted by Threshold
View Post
Where was this tutorial exactly 'Copied' from? I created it in one of my filterscripts and simply made it easier, so then it resembled the original tutorial...
I never said you copied it, but this tutorial doesn't tutor anyone, it just allows them to copy a (broken) script and compile it.
Reply
#10

Thanks.

But if I want this gate to be opened only by Admins , I should change this :
Quote:

if(IsPlayerInRangeOfPoint(playerid, 10.0, 519.0, -171.7866,17.99))

To

Quote:

if(IsPlayerAdmin(playerid,params[]))

?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)