move object wiht command then auto move back
#1

I have my command working so that i type /gate and it opens but i dont want a /cgate i want the gate to close in lets say 10 seconds how would i do that =)
Reply
#2

https://sampwiki.blast.hk/wiki/MoveObject

Can you post the part where you have the command?
Reply
#3

read the post ffs does it say i need help moving my object no it say i need help with automaticly moving them after a set time.
Reply
#4

Yes, and I edited my message after noticing that. So please cut the "ffs" if you really want some help here.
Reply
#5

my bad i didnt see the repost and my open code is :

Code:
CMD:gate(playerid, params[])
{
if(INI_Open(getINI(playerid)))
{
PlayerInfo[playerid][Faction] = INI_ReadInt("Faction");
PlayerInfo[playerid][Factionrank] = INI_ReadInt("Factionrank");
}

if(PlayerInfo[playerid][Faction] == LSPD)
{
if(PlayerInfo[playerid][Factionrank] > 0)//Any rank
{
if(!isnull(params))
{
return SendClientMessage(playerid,SYellow,"Usage: /gate.");
}
else
{

if(IsPlayerInRangeOfPoint(playerid, 10.0, 1588.90, -1637.94, 16.00))
{
SendClientMessage(playerid,SYellow,"The Lspd Garage gate is now opening.");
return MoveObject(lspdgaragegate, 1596.90, -1637.94, 16.00, 6.0);
}
else
{
return SendClientMessage(playerid,SYellow,"You must be near the gate to use this.");
}

}
}
return SendClientMessage(playerid,SYellow,"You must be atlest rank 1 LSPD to use this.");
}//RANK 1 END
else return SendClientMessage(playerid,SYellow,"You must be LSPD to use that command.");
}
Reply
#6

Something like this should do the trick:
pawn Code:
new IsGateOpen, IsGateClosing, IsGateClosed;

forward CloseGate();

CMD:gate(playerid, params[])
{
    if(INI_Open(getINI(playerid))) {
        PlayerInfo[playerid][Faction] = INI_ReadInt("Faction");
        PlayerInfo[playerid][Factionrank] = INI_ReadInt("Factionrank");
    }

    if(PlayerInfo[playerid][Faction] == LSPD) {
                                                  //Any rank
        if(PlayerInfo[playerid][Factionrank] > 0) {
            if(!isnull(params)) {
                return SendClientMessage(playerid,SYellow,"Usage: /gate.");
            }
            else {

                if(IsPlayerInRangeOfPoint(playerid, 10.0, 1588.90, -1637.94, 16.00)) {
                    if(IsGateOpen == 1) return SendClientMessage(playerid,SYellow, "The Lspd Garage gate is already being opened or is open.");
                    SendClientMessage(playerid,SYellow,"The Lspd Garage gate is now closing.");
                    IsGateOpen = 1;
                    IsGateClosing = 0;
                    IsGateClosed = 0;
                    MoveObject(lspdgaragegate, 1596.90, -1637.94, 16.00, 6.0);
                }
                else {
                    return SendClientMessage(playerid,SYellow,"You must be near the gate to use this.");
                }

            }
        }
        return SendClientMessage(playerid,SYellow,"You must be atlest rank 1 LSPD to use this.");
    }                                             //RANK 1 END
    else return SendClientMessage(playerid,SYellow,"You must be LSPD to use that command.");
}

CMD:cgate(playerid, params[])
{
    if(INI_Open(getINI(playerid))) {
        PlayerInfo[playerid][Faction] = INI_ReadInt("Faction");
        PlayerInfo[playerid][Factionrank] = INI_ReadInt("Factionrank");
    }

    if(PlayerInfo[playerid][Faction] == LSPD) {
                                                  //Any rank
        if(PlayerInfo[playerid][Factionrank] > 0) {
            if(!isnull(params)) {
                return SendClientMessage(playerid,SYellow,"Usage: /cgate.");
            }
            else {

                if(IsPlayerInRangeOfPoint(playerid, 10.0, 1588.90, -1637.94, 16.00)) {
                    if(IsGateClosing == 1) return SendClientMessage(playerid,SYellow, "The Lspd Garage gate is already being closed.");
                    if(IsGateClosed == 1) return SendClientMessage(playerid,SYellow, "The Lspd Garage gate is already closed.");
                    SendClientMessage(playerid,SYellow,"The Lspd Garage gate is now closing.");
                    IsGateClosing = 1;
                    IsGateOpen = 0;
                    SetTimer("CloseGate", 10000, false);
                }
                else {
                    return SendClientMessage(playerid,SYellow,"You must be near the gate to use this.");
                }

            }
        }
        return SendClientMessage(playerid,SYellow,"You must be atlest rank 1 LSPD to use this.");
    }                                             //RANK 1 END
    else return SendClientMessage(playerid,SYellow,"You must be LSPD to use that command.");
}

public CloseGate()
{
    MoveObject(lspdgaragegate, x, y, z, 6.0); // Change x, y, z to the coordinates of the gate closed.
    IsGateClosing = 0;
    IsGateClosed = 1;
    return 1;
}
Just remember to change x, y, z in MoveObject inside public CloseGate to the coordinates of the gate when it's closed.
Note:The reason why I added the variables and extra if statements is so players can't spam your server with the timer, and therefor cause a lagg.
Reply
#7

that is two commands though. i mean how can i make it one command just for example /gate then the gate opens once its open it closes automatically 10 seconds later.
Reply
#8

Aa ok. Here you go, try this:
pawn Code:
forward CloseGate();

CMD:gate(playerid, params[])
{
    if(INI_Open(getINI(playerid))) {
        PlayerInfo[playerid][Faction] = INI_ReadInt("Faction");
        PlayerInfo[playerid][Factionrank] = INI_ReadInt("Factionrank");
    }

    if(PlayerInfo[playerid][Faction] == LSPD) {
                                                  //Any rank
        if(PlayerInfo[playerid][Factionrank] > 0) {
            if(!isnull(params)) {
                return SendClientMessage(playerid,SYellow,"Usage: /gate.");
            }
            else {

                if(IsPlayerInRangeOfPoint(playerid, 10.0, 1588.90, -1637.94, 16.00)) {
                    SendClientMessage(playerid,SYellow,"The Lspd Garage gate is now opening.");
                    SetTimer("CloseGate", 10000, false);
                    return MoveObject(lspdgaragegate, 1596.90, -1637.94, 16.00, 6.0);
                }
                else {
                    return SendClientMessage(playerid,SYellow,"You must be near the gate to use this.");
                }

            }
        }
        return SendClientMessage(playerid,SYellow,"You must be atlest rank 1 LSPD to use this.");
    }                                             //RANK 1 END
    else return SendClientMessage(playerid,SYellow,"You must be LSPD to use that command.");
}


public CloseGate()
{
    MoveObject(lspdgaragegate, x, y, z, 6.0); // Change x, y, z to the coordinates of the gate closed.
    return 1;
}
Reply
#9

That works thank you very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)