[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
#2

First off all. I don't think you did a full 'tutorial', try to give more information. Not like small sentences.

Here use this as a guide: https://sampforum.blast.hk/showthread.php?tid=65567
Reply
#3

There are pretty much informations what you have to do...
Reply
#4

Quote:
Code:
public OnGameModeInit ()
{
    
    TestGate1 = CreateObject(Add your closed gate coordinates here); //Gate Object Closed
    
    return 1;
}
}
No need for the extra bracket. You need to explain more though, nice tutorial otherwise.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)