[Tutorial] Movable Objects? -- Full Explained!
#1

Movable Object?




Who I'm?

Name:Roberto-You Can Call Me Roe
UserName:Roberto80

What I'm Doing Here?

Its My First Tutorial,Its About How To Make Movable Objects!
Its Easy,Read Next And You Will Move Gta,LOL!


Let's Start

1-Defining Object
First Of All,If You Want To Create A Object,You Don't Need To Define It;
But If You Want To Modify it,You Must Define.
So Let's Define Our Object,It Will Be A Gate.
So In Top Of Your FilterScript Or GameMode Add Your Defined Object,To Define It,Use "new":
Example:
PHP код:
new gate
Don't Miss The ";" , Its Important.

2-Creating The Object
Ok Now We Must Create The Object;
To Create A Object,You Can Use MTA Map Editor:Download--Convert To Samp
Or You Can Use Map Editor:Thread Here
Ok,So The Code Of Created Object Will be Like This:
PHP код:
CreateObject(ObjectIDXYZXrYrZr); 
So,Let's Explain It:
Код:
CreateObject:This Will Create The Object.
ObjectID:This Is The Model Of The Object(The ID),You Can Find Objects IDs Here.
X,Y,Z:The X,Y,Z Position Of The Object.
Xr,Yr,Zr:The X,Y,Z Rotation Of Object.
To Find The Positions,Rotations Of Object,You Can Use "/save" In Game.
What Is That Object? It's The Gate! So SAMP Will Don't Know Alone,LOL! So,We Must Say That The Gate Is This Object. So It Will Be Like This:
PHP код:
Gate == CreateObject(ObjectIDXYZXrYrZr); 
Ok,Let Me Explain:
Код:
Gate:Did You Remember First Step? Its Here!
==:That Mean The Gate Is This Object.
3-Adding It
After Step (2),We Must Add The Code To The FilterScript/GameMode To See It In Game!
So Get The Code,Copy It..If You Are Making It In A Filterscript,Paste It Under:
PHP код:
public OnFilterScriptInit() 
Or If You Are Making A GameMode,Paste It Under:
PHP код:
public OnGameModeInit() 
4-Moving The Object
Ok,We Will Move The Object With A Simple Command,So Under:
PHP код:
public OnPlayerCommandText(playeridcmdtext[]) 
Add This:
PHP код:
if (strcmp("/opengate"cmdtexttrue10) == 0)
{
         
MoveObject(Gate,nX,nY,nZ0.97);
}
return 
1;
}
if (
strcmp("/closegate"cmdtexttrue10) == 0)
{
         
MoveObject(Gate,XY,0.97);
}
return 
1;

Ok,Let's See What Is This:
Код:
if (strcmp("...",cmdtext, true, 10) == 0):This Is The Important To Create A Command(Pawno Code).
/opengate \ /closegate:This Will Open/Close The Gate,Its The Command.
MoveObject:This Is The Code Used To Move A Object.
Gate:Its The Object Who We Created Before!
nX,nY,nZ:It's The New Position Of The Gate.
0.9:Its The Speed Of Gate Move!
X,Y,Z:We Use This To Get The Gate Back To His Old Position
If You Want It To Close Alone,We Will Make Some Different Things,We Will Remove The Gate Close Command,And Add Something To The Command To Open The Gate,It Will Be Like This:
PHP код:
if (strcmp("/opengate"cmdtexttrue10) == 0)
{
         
MoveObject(Gate,nX,nY,nZ0.97);
         
SetTimer("gateclose"50000);
}
return 
1;

Let's Explain:
Код:
SetTimer:It Will Set A Timer For Something,We Will Use It To Close The Gate.
gateclose:Its The Callback That We Will Use.
7000:Time To Close The Gate,5000 means 5 seconds.
And In The Last Of The Script,Add This:
PHP код:
forward gateclose();
public 
gateclose()
{
     
MoveObject(gateX,Y,Z0.97);
     return 
1;

Explain:
Код:
Forward gateclose():This We Will Use To Define The Callback
public gateclose():Under This ,We Will Say What Will Happen When 5 Seconds Are Done
The Object Will Be Moved To Their Old Location!



Its All,Now Go And Move Yourselves From Here,I Want To Sleep ,,Good Luck In Your Maps. -----------Roe-----------
Reply
#2

Nothing special for MoveObject!

But good to start!
Reply
#3

Good job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)