SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/07/2011, 07:02 PM   #1
slymatt
Huge Clucker
 
slymatt's Avatar
 
Join Date: Apr 2011
Posts: 201
Reputation: 3
Default move object wiht command then auto move back

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 =)
__________________
slymatt is offline  
Old 24/07/2011, 07:09 PM   #2
Facepunch
Big Clucker
 
Facepunch's Avatar
 
Join Date: Jan 2011
Posts: 61
Reputation: 2
Default Re: move object wiht command then auto move back

http://wiki.sa-mp.com/wiki/MoveObject

Can you post the part where you have the command?
Facepunch is offline  
Old 24/07/2011, 07:11 PM   #3
slymatt
Huge Clucker
 
slymatt's Avatar
 
Join Date: Apr 2011
Posts: 201
Reputation: 3
Default Re: move object wiht command then auto move back

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.
__________________
slymatt is offline  
Old 24/07/2011, 07:13 PM   #4
Facepunch
Big Clucker
 
Facepunch's Avatar
 
Join Date: Jan 2011
Posts: 61
Reputation: 2
Default Re: move object wiht command then auto move back

Yes, and I edited my message after noticing that. So please cut the "ffs" if you really want some help here.
__________________
Facepunch is offline  
Old 24/07/2011, 07:16 PM   #5
slymatt
Huge Clucker
 
slymatt's Avatar
 
Join Date: Apr 2011
Posts: 201
Reputation: 3
Default Re: move object wiht command then auto move back

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.");
}
__________________
slymatt is offline  
Old 24/07/2011, 09:17 PM   #6
Prumpuz
Big Clucker
 
Join Date: Apr 2008
Location: Iceland
Posts: 149
Reputation: 12
Default Re: move object wiht command then auto move back

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.
__________________
"It's no wonder that truth is stranger than fiction. Fiction has to make sense." - Mark Twain.

Last edited by Prumpuz; 24/07/2011 at 09:52 PM.
Prumpuz is offline  
Old 24/07/2011, 11:39 PM   #7
slymatt
Huge Clucker
 
slymatt's Avatar
 
Join Date: Apr 2011
Posts: 201
Reputation: 3
Default Re: move object wiht command then auto move back

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.
__________________
slymatt is offline  
Old 25/07/2011, 12:04 AM   #8
Prumpuz
Big Clucker
 
Join Date: Apr 2008
Location: Iceland
Posts: 149
Reputation: 12
Default Re: move object wiht command then auto move back

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;
}
__________________
"It's no wonder that truth is stranger than fiction. Fiction has to make sense." - Mark Twain.
Prumpuz is offline  
Old 25/07/2011, 01:27 AM   #9
slymatt
Huge Clucker
 
slymatt's Avatar
 
Join Date: Apr 2011
Posts: 201
Reputation: 3
Default Re: move object wiht command then auto move back

That works thank you very much
__________________
slymatt is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move Object Help tzeny Help Archive 4 09/02/2011 12:22 PM
Object move billiout Help Archive 2 24/08/2010 11:51 AM
Help getting object to move jwa3003 Help Archive 2 15/04/2010 06:47 AM
Move Object - need ! Johny_Rocker Help Archive 7 31/03/2010 03:53 PM
Move object command [KML]Dabug Help Archive 3 15/04/2009 07:38 AM


All times are GMT. The time now is 05:20 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.