Moving 3 objects with 1 cmd
#1

Hi, i'm noob scripting, and got hard to do it, tried a lot but i need help.
I got this script searching the forum, but I want to move 3 objects.
The other 2 objects is


Код:
zsawall  (Object ID 19359)

closed

( 2658.9016, -1518.2900, 39.2486,   0.0000, 0.0000, 89.1446 )

opened

( 2660.2017, -1518.2900, 39.2486,   0.0000, 0.0000, 89.1446 )

//----------------------------------------------------------

zsadoorint - (Object ID 1537)

closed

( 2657.27100, -1518.02466, 38.09280,   0.00000, 0.00000, -182.00000)

opened

( 2658.5439, -1518.0027, 38.0928,   0.00000, 0.00000, -182.00000)
Код:
new
    zsabookcase,
    bool: zsabookcaseState
;

//---------------------------------------------

    zsabookcase = CreateObject( 14455,2662.2791, -1518.4174, 39.5401,0,0, 179.1134 ); // bookcase.

    zsabookcaseState = false;

//----------------------------------------------

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/7895123", true ) )
    {
        if ( cmdtext[ 8 ] )
            return false;

        if ( !IsPlayerInRangeOfPoint( playerid, 2.0, 2656.6663, -1518.6973, 39.1067 ) )
            return SendClientMessage( playerid, -1, "You are not close enough." );
        zsabookcaseState = ! zsabookcaseState;

        switch ( zsabookcaseState )
        {
            case true : // True = Gate is opened
                MoveObject( zsabookcase, 2663.7615, -1518.4259, 39.4907, 1.0 );

            default : // Else ( false ) = Gate is closed
                MoveObject( zsabookcase, 2662.2791, -1518.4174, 39.5401, 1.0 );
        }

        SendClientMessage( playerid, -1, ( zsabookcaseState ) ? ( "ZSA - Access Granted" ) : ( "Closing Access" ) );
                             // ^ iGateState == true   ^ Then  ^ Gate is open  ^ Else     ^ Gate is closed

        return 1;
    }

    return 0;
}
Reply
#2

Can anyone help me?
Reply
#3

Please help me, who knows?!
I need this script...
Reply
#4

pawn Код:
case true:
{
  MoveObject(...);
  MoveObject(...);
}
default:
{
  MoveObject(...);
  MoveObject(...);
}
Reply
#5

Already tried it, and as I said, i am noob with script, so please, someone help me with this one.
it's so hard for me...
Reply
#6

pawn Код:
new object[3];
object[0] = CreateObject(...);
object[1] = CreateObject(...);
object[2] = CreateObject(...);

case true:
{
  MoveObject(object[0],...);
  MoveObject(object[1],...);
  MoveObject(object[2],...);
}
default:
{
  MoveObject(object[0],...);
  MoveObject(object[1],...);
  MoveObject(object[2],...);
}
You need to create a variable for ea object, or a array with the index of how many objects. MoveObject has to know what objects to move so we need to save the objects id. Then you just use MoveObject on each one.

More info on MoveObject https://sampwiki.blast.hk/wiki/MoveObject
Reply
#7

Quote:
Originally Posted by DeStunter
Посмотреть сообщение
pawn Код:
new object[3];
object[0] = CreateObject(...);
object[1] = CreateObject(...);
object[2] = CreateObject(...);

case true:
{
  MoveObject(object[0],...);
  MoveObject(object[1],...);
  MoveObject(object[2],...);
}
default:
{
  MoveObject(object[0],...);
  MoveObject(object[1],...);
  MoveObject(object[2],...);
}
You need to create a variable for ea object, or a array with the index of how many objects. MoveObject has to know what objects to move so we need to save the objects id. Then you just use MoveObject on each one.

More info on MoveObject https://sampwiki.blast.hk/wiki/MoveObject
Thank you for your help DeStunter!
Now i just got some errors, that i think you can explan me

pawn Код:
#include <a_samp>

new object[3];//~~~~~~~~~~~~~~~~~//

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{

    object[0] = CreateObject(14455,2662.2791, -1518.4174, 39.54010,0,0, 179.1134,0.0);//BOOKCASE
    object[1] = CreateObject(19359,2658.9016, -1518.2900, 39.2486,   0.0000, 0.0000, 89.1446,0.0);//ZSAWALL
    object[2] = CreateObject(1537, 2657.27100, -1518.02466, 38.09280,   0.00000, 0.00000, -182.00000,0.0);//ZSADOORINT

    return 1;
}



public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/7895123", true ) )
    {
        if ( cmdtext[ 8 ] )
            return false;

        if ( !IsPlayerInRangeOfPoint( playerid, 2.0, 2656.6663, -1518.6973, 39.1067 ) )
            return SendClientMessage( playerid, -1, "You are not close enough." );
        object[3]State = ! object[3]State;

        switch ( object[3]State )
        {
            case true : // True = Gate is opened
            {
              MoveObject(object[0], 2663.7615, -1518.4259, 39.4907, 1.0 );
              MoveObject(object[1], 2663.7615, -1518.4259, 39.4907, 1.0 );
              MoveObject(object[2], 2663.7615, -1518.4259, 39.4907, 1.0 );
            }
            default : // Else ( false ) = Gate is closed
            {
              MoveObject(object[0], 2662.2791, -1518.4174, 39.5401, 1.0 );
              MoveObject(object[1], 2662.2791, -1518.4174, 39.5401, 1.0 );
              MoveObject(object[2], 2662.2791, -1518.4174, 39.5401, 1.0 );
            {
        }

        SendClientMessage( playerid, -1, ( object[3]State ) ? ( "ZSA - Access Granted" ) : ( "Closing Access" ) );
                             // ^ iGateState == true   ^ Then  ^ Gate is open  ^ Else     ^ Gate is closed

        return 1;
    }

    return 0;
}
pawn Код:
C:\Users\Ygor\Desktop\vamuve\zhq.pwn(52) : error 032: array index out of bounds (variable "object")
C:\Users\Ygor\Desktop\vamuve\zhq.pwn(52) : error 017: undefined symbol "State"
C:\Users\Ygor\Desktop\vamuve\zhq.pwn(52) : error 032: array index out of bounds (variable "object")
C:\Users\Ygor\Desktop\vamuve\zhq.pwn(52) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)