[Tutorial] Moving Objects
#1

Moving Objects Tutorial
By Skizzo_Trick

Hello everyone,im soo borred so i decided to make a Moving Objects Tutorial.
For beginning,let's put the object
Put this in GM/FS Beginning:
pawn Код:
new Gate;//This will create your object/gate name
Ok,now let's define that gate:
pawn Код:
Gate = CreateObject(2587, X, Y, Z, Xr, Yr, Zr);
Quote:
2587 ---ID of the Object
2001.195679 ----X Position
1547.113892 ----Y Position
14.283400 ----Z Position
0.0, 0.0, 96.0 ---- X,Y,Z Rotations of the object

You can always find X,Y,Z positions with
pawn Код:
/save
InGame!


Now let's put the objects moving!
Put this after OnPlayerCommandText:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/pgate", cmdtext, true, 10) == 0)
            {
            MoveObject(Gate,X, Y, Z+/-3,0.97);//This will move the gate
            }
            return 1;
        }
        if (strcmp("/pgateclose", cmdtext, true, 10) == 0)
            {
            MoveObject(Gate,X, Y, Z,3,0.97);//This will move the gate back to the old position
            }
            return 1;
        }

return 1;
}
My commands will move the gate up/down!

Quote:
Gate ----The object name that we have fixed in the GM Begin
X ----The new X position(can be the same with first one if you wish to move the gate in another position!)
Y ----The new Y position(can be the same with first one if you wish to move the gate in another position!)
Z ----The new Z Position(can be the same with first one if you wish to move the gate in another position!)
0.97 ----The speed of which the object will be moved with.

This was the simple mod,but if you want an automatic gate,try this

pawn Код:
public OnPlayerCommandText(...)
{
        if (strcmp("/pgate", cmdtext, true, 10) == 0)
            {
            MoveObject(Gate,X, Y, Z+/-3,0.97);//This will move the gate
            SendClientMessage(playerid,COLOR_BLUE,"You have opened the gate,it will be closed in 7 seconds!");//This will send an message announcing the gate Stats!
            SetTimer("GateClose", 7000, 0);//This will start the counting till the gate will be closed!
            }
            return 1;
        }

return 1;
}


forward GateClose(playerid)//This will forward the closing gate function
public GateClose(playerid)//This will define the closing gate function
{
      MoveObject(Gate,X, Y, Z-/+3,0.97);//This will move the gate
      PlayerPlaySound(playerid, 1153, x,y,z);// This will play the gate sound near the gate
      return 1;
}


1)Do not copy/paste this tutorial
2)All the rights goes to Skizzo_Trick
Reply
#2

Nice! This could help me once I get start to get back at scripting.

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 74 seconds.

Reply
#3

Always bro xD
Reply
#4

Nice and very useful. Good job.
Reply
#5

this could help some people, nice
Reply
#6

Код:
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(9) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : error 076: syntax error in the expression, or invalid function call
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(17) : warning 217: loose indentation
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(19) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(23) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(26) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(28) : warning 203: symbol is never used: "Gate"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.

help?
Reply
#7

Quote:
Originally Posted by Sweet_Mafia™
Посмотреть сообщение
Код:
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(9) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : error 076: syntax error in the expression, or invalid function call
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(15) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(17) : warning 217: loose indentation
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(19) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(23) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(26) : error 010: invalid function or declaration
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(28) : warning 203: symbol is never used: "Gate"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.

help?
Код:
C:\Users\Sweet Mafia.Admin-HP\Desktop\gate_one.pwn(28) : warning 203: symbol is never used: "Gate"
This means that you have entered a wrong name.
Check where you typed Gate = CreateObject(...);
or search if you putted gate,not Gate
You need to SHIFT the first letter
Reply
#8

can i just paste in the whole coordinate i get from converting object? or do i have to edit it.
Reply
#9

I don't know how relevant it is, but you should learn to indent a little better... I have seen several tutorials about moving objects, as well; try something different or make it a bit more advanced next time.
Reply
#10

Can you please tell me what is wrong with this and correct it.

pawn Код:
//Los Santos Military Transportation Electric Gates

#include <a_samp>

new aGate;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    aGate = CreateObject(976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/gate", cmdtext, true, 10) == 0)
            {
            MoveObject (976,2720.53076172,-2401.33911133,12.46093750,0.00000000,0.00000000,90 .00000000);//This will move the gate
            }
            return 1;
        }
        if (strcmp("/closegate", cmdtext, true, 10) == 0)
            {
            MoveObject (976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);//This will move the gate back to the old position
            }
            return 1;
        }

return 1;
}
Reply
#11

Quote:
Originally Posted by Sweet_Mafia™
View Post
Can you please tell me what is wrong with this and correct it.

pawn Code:
//Los Santos Military Transportation Electric Gates

#include <a_samp>

new aGate;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    aGate = CreateObject(976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/gate", cmdtext, true, 10) == 0)
            {
            MoveObject (976,2720.53076172,-2401.33911133,12.46093750,0.00000000,0.00000000,90 .00000000);//This will move the gate
            }
            return 1;
        }
        if (strcmp("/closegate", cmdtext, true, 10) == 0)
            {
            MoveObject (976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);//This will move the gate back to the old position
            }
            return 1;
        }

return 1;
}
Lol,this code is tottally fucked up...MoveObject(Gate,...)
Your making Moving Objects tutorials?)
Reply
#12

nice work man!
Reply
#13

bumped, read reply above ^^^^^^^^^^
Reply
#14

Well I did what you said but i still get 4 erroes, please correct and post as reply.

pawn Code:
//Los Santos Military Transportation Electric Gates

#include <a_samp>

new Gate;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    aGate = CreateObject(976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/gate", cmdtext, true, 10) == 0)
            {
            MoveObject (Gate,2720.53076172,-2401.33911133,12.46093750,0.00000000,0.00000000,90 .00000000);
            }
            return 1;
        }
        if (strcmp("/closegate", cmdtext, true, 10) == 0)
            {
            MoveObject (Gate,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);
            }
            return 1;
        }

return 1;
}
Reply
#15

pawn Code:
//Los Santos Military Transportation Electric Gates

#include <a_samp>

new Gate;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    Gate = CreateObject(976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/gate", cmdtext, true, 10) == 0)
            {
            MoveObject (Gate,2720.53076172,-2401.33911133,12.46093750,0.90);
            }
            return 1;
        }
        if (strcmp("/closegate", cmdtext, true, 10) == 0)
            {
            MoveObject (Gate,2720.53076172,-2409.44506836,12.46093750,0.90);
            }
            return 1;
        }

return 1;
}
Reply
#16

I pasted in the stuff you gave and i get these errors, could you possibly send me all your includes?

Code:
C:\Users\Sweet Mafia.Admin-HP\Desktop\Untitled.pwn(12) : error 001: expected token: ",", but found "."
C:\Users\Sweet Mafia.Admin-HP\Desktop\Untitled.pwn(12) : error 029: invalid expression, assumed zero
C:\Users\Sweet Mafia.Admin-HP\Desktop\Untitled.pwn(12) : warning 215: expression has no effect
C:\Users\Sweet Mafia.Admin-HP\Desktop\Untitled.pwn(12) : error 001: expected token: ";", but found ")"
C:\Users\Sweet Mafia.Admin-HP\Desktop\Untitled.pwn(12) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#17

I can't just give you all the includes .
If you respect all the steps,you will survive.
Im back now,ready to answer questions xD
Reply
#18

Yea, whisperftw Is the man, Auuu !
Here's yo script, and srsly if you delete these two lines your not a man ...

pawn Code:
//Los Santos Military Transportation Electric Gates

#define FILTERSCRIPT
#include <a_samp>

new Gate;

public OnFilterScriptInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    Gate = CreateObject(976, 2720.53076172, -2409.44506836, 12.46093750, 0.0, 0.0, 90.0);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (!strcmp("/gate", cmdtext, true, 5))
            {
            MoveObject (Gate,2720.53076172,-2401.33911133,12.46093750,0.90);
            return 1;
            }
        {
        if (!strcmp("/closegate", cmdtext, true, 10))
            {
            MoveObject (Gate,2720.53076172,-2409.44506836,12.46093750,0.90);
            return 1;
            }
        return 0;
}
}
// All Credits to whisperftw, need help ? PM on SA-MP Forums
// If you delete these two lines you are NOT a MAN !
If anything is needed Ask me on forums :3
Reply
#19

Quote:
Originally Posted by Sweet_Mafia™
View Post
Can you please tell me what is wrong with this and correct it.

pawn Code:
//Los Santos Military Transportation Electric Gates

#include <a_samp>

new aGate;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    aGate = CreateObject(976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/gate", cmdtext, true, 10) == 0)
            {
            MoveObject (976,2720.53076172,-2401.33911133,12.46093750,0.00000000,0.00000000,90 .00000000);//This will move the gate
            }
            return 1;
        }
        if (strcmp("/closegate", cmdtext, true, 10) == 0)
            {
            MoveObject (976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90 .00000000);//This will move the gate back to the old position
            }
            return 1;
        }

return 1;
}
Now it will work....

pawn Code:
#include <a_samp>

new aGate;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    aGate = CreateObject(976,2720.53076172,-2409.44506836,12.46093750,0.00000000,0.00000000,90.00000000);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        if(strcmp ("/gate", cmdtext, true) == 0)
            {
            MoveObject(aGate, 2720.53076172, -2401.33911133, 12.46093750,2);//This will move the gate
            return 1;
        }
        if(strcmp ("/closegate", cmdtext, true) == 0)
            {
            MoveObject(aGate, 2720.53076172, -2409.44506836, 12.46093750, 2);//This will move the gate back to the old position
            return 1;
        }

        return 0;
}
Reply
#20

How can I make ... multiple commands in a single command?

I`ll give you an example: Let`s say I want to open a gate with /opengate and /og aswell ... do I have to make 2 separate commands for this?

Later Edit: I found how to do it, thanks anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)