11.06.2015, 16:09
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;
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(ObjectID, X, Y, Z, Xr, Yr, Zr);
Код:
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.
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(ObjectID, X, Y, Z, Xr, Yr, Zr);
Код:
Gate:Did You Remember First Step? Its Here! ==:That Mean The Gate Is This Object.
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()
PHP код:
public OnGameModeInit()
Ok,We Will Move The Object With A Simple Command,So Under:
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
PHP код:
if (strcmp("/opengate", cmdtext, true, 10) == 0)
{
MoveObject(Gate,nX,nY,nZ, 0.97);
}
return 1;
}
if (strcmp("/closegate", cmdtext, true, 10) == 0)
{
MoveObject(Gate,X, Y, Z ,0.97);
}
return 1;
}
Код:
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
PHP код:
if (strcmp("/opengate", cmdtext, true, 10) == 0)
{
MoveObject(Gate,nX,nY,nZ, 0.97);
SetTimer("gateclose", 5000, 0);
}
return 1;
}
Код:
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.
PHP код:
forward gateclose();
public gateclose()
{
MoveObject(gate, X,Y,Z, 0.97);
return 1;
}
Код:
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
Its All,Now Go And Move Yourselves From Here,I Want To Sleep ,,Good Luck In Your Maps. -----------Roe-----------