How to create a single command which open and close same gate
#1

Hello guys, I am wondering how to create a command that can open and close the same gate.


This is the command I've created, but that only opens it, I want to use the same command to close it too.

Код:
CMD:rr(playerid, params[])
{
    SendClientMessage(playerid, COLOR_GREEN,"RR gate is open");
    MovePlayerObject(playerid, Gate4[playerid], -134.2530, 1125.6167, 16.9396, 1);
    Gate4[playerid] = CreateObject(11327, -134.2530, 1125.6167, 21.4020,  0.0000, 0.0000, -0.4200);
	return 1;
}
Also something that I want to know is how do I create a command that when I press /enter I can be set to a chosen place with my car.


Thanks!
Reply
#2

EDIT: Nevermind, I'm a retard. Didn't read it properly. Hold on.

pawn Код:
new gate4;

new gate4open = 0;


public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    gate4 = CreateObject(11327, -134.2530,1125.6167, 21.4020, 0.0000,0.0000,-0.4200);
   
    return 1;
}

CMD:rr(playerid, params[])
{
    if(gate4open == 0)
    {
        MovePlayerObject(playerid, gate4, -134.2530, 1125.6167, 16.9396, 1);
        SendClientMessage(playerid, -1,"RR gate is open");
        gate4open = 1;
    }
    if(gate4open == 1)
    {
        MovePlayerObject(playerid, gate4, -134.2530, 1125.6167, 21,4020, 1);
        SendClientMessage(playerid, -1, "RR gate is closed");
        gate4open = 0;
    }
    return 1;
}
Try this.
Reply
#3

Alright.

First add this at top :-

Код:
new Yourgatename;
Under Public GameModeInIt:-

Код:
{
    Yourgatename = CreateObject(object id, pos=x, pos=y, pos=z, rotate=x, rotate=y, rotate=z, 100.0);// I am not sure if I know the last one
    return 1;
}
https://sampforum.blast.hk/showthread.php?tid=353988

Read this This will help you!
Reply
#4

Quote:
Originally Posted by Keyhead
Посмотреть сообщение
EDIT: Nevermind, I'm a retard. Didn't read it properly. Hold on.

pawn Код:
new gate4;

new gate4open = 0;


public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    gate4 = CreateObject(11327, -134.2530,1125.6167, 21.4020, 0.0000,0.0000,-0.4200);
   
    return 1;
}

CMD:rr(playerid, params[])
{
    if(gate4open == 0)
    {
        MovePlayerObject(playerid, gate4, -134.2530, 1125.6167, 16.9396, 1);
        SendClientMessage(playerid, -1,"RR gate is open");
        gate4open = 1;
    }
    if(gate4open == 1)
    {
        MovePlayerObject(playerid, gate4, -134.2530, 1125.6167, 21,4020, 1);
        SendClientMessage(playerid, -1, "RR gate is closed");
        gate4open = 0;
    }
    return 1;
}
Try this.
It has few thing you forgot to put there, but thanks!
Reply
#5

So I tried that but doesn't works ...
Reply
#6

Any help ? I know how to do it the other way but I want to learn to do it using zcmd..
Reply
#7

Post your code which isn't working.
Reply
#8

Quote:
Originally Posted by Matess
Посмотреть сообщение
Post your code which isn't working.
Код:
CMD:rr(playerid, params[])
{
    if(Gate4 == 0)
    {
        MovePlayerObject(playerid, test9[playerid], -134.2530, 1125.6167, 17.1016, 1);
        SendClientMessage(playerid, COLOR_GREEN, "RR gate is open");
        Gate4 = 1;
    }
    else if(Gate4 == 1)
    {
        MovePlayerObject(playerid, test9[playerid], -134.2530, 1125.6167, 21.4020, 1);
        SendClientMessage(playerid, COLOR_RED, "RR gate is closed");
        Gate4 = 0;
    }
    return 1;
}
I don't get any errors tho...
Reply
#9

Show me the definition of test9, Gate4 and where are you creating playerobjects
Reply
#10

Quote:
Originally Posted by Matess
Посмотреть сообщение
Show me the definition of test9, Gate4 and where are you creating playerobjects
This is how test9 and Gate4 are defined

Код:
new test9[MAX_PLAYERS];
new Gate4;
This is the object I created under OnGameModeInit

Код:
Gate4 = CreateObject(11327, -134.2530,1125.6167, 21.4020, 0.0000,0.0000,-0.4200);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)