[Tutorial] Movable gate
#1

Hello,I am sure that there are many of you that know already to make this script in less then 5 minutes but maybe there are new scripters too who can't script a movable gate so this will kinda be like a tutorial.

First of all add this on your GM/script top

Code:
#include <a_samp>
Second add this under "#include <a_samp>"

Code:
#define COLOR_RED 0xff0000FF
So it would look like this

Code:
#include <a_samp>
#define COLOR_RED 0xff0000FF
3rd, name your gate like this "new TestGate1;" (you can choose what name you want but you have to use "Gate") under
Code:
#include <a_samp>
So it would look like this

Code:
#include <a_samp>
#define COLOR_RED 0xff0000FF
new TestGate1;
4th add these to "public OnGameModeInit ()" so it would look like this

Code:
public OnGameModeInit ()
{
    
    TestGate1 = CreateObject(Add your closed gate coordinates here); //Gate Object Closed
    
    return 1;
}
5th add these to "public OnPlayerCommandText(playerid, cmdtext[])" so it would look like this

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/open", true) == 0) {
    SendClientMessage(playerid, COLOR_RED,"The gate is open"); //You can change the color on whatever you want,but if you change the color you also have to edit the " #define COLOR_RED 0xff0000FF " on top of your script.
    MoveObject(TestGate1, add your gate opened coordinates, 1); //The 1 is the gates speed
    return 1;
    }


    if(strcmp(cmdtext, "/close", true) == 0) {
    SendClientMessage(playerid, COLOR_RED,"The gate is closed");
    MoveObject(TestGate1, add your closed gate coordinates, 1); //The 1 is the gates speed
    return 1;
	}


    return 0;
}

At the end this is how all the script needs to look

Code:
#include <a_samp>
#define COLOR_RED 0xff0000FF
new TestGate1;


public OnGameModeInit ()
{
   
    TestGate1 = CreateObject(968,2462.5000000,-1662.1999512,13.0000000,0.0000000,270.0000000,270.0000000); //Gate Object Closed
    
    return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/open", true) == 0) {
    SendClientMessage(playerid, COLOR_RED,"The gate is open");
    MoveObject(TestGate1, 2462.5000000,-1662.1999512,13.0000000, 1); //Does are random numbers I just made them for this tutorial.
    return 1;
    }


    if(strcmp(cmdtext, "/close", true) == 0) {
    SendClientMessage(playerid, COLOR_RED,"The gate is closed");
    MoveObject(TestGate1, 2462.5000000,-1662.1999512,13.0000000, 1); //Does are random numbers I just made them for this tutorial.
    return 1;
	}


    return 0;
}
Thats all peace
Reply


Messages In This Thread
Movable gate - by Jhony_Blaze - 08.03.2013, 20:36
Re: Movable gate - by JustinAn - 08.03.2013, 22:54
Re: Movable gate - by Jhony_Blaze - 09.03.2013, 15:19
Re: Movable gate - by Ryan_Bowe - 14.03.2013, 23:50

Forum Jump:


Users browsing this thread: 1 Guest(s)