How to make moving/rotating objects -
ricardo178 - 24.01.2011
Hello guys, i have learn with a toturial but it was a litle hard to understund then i will try to make it the most simple then possible explaining all!
So to make an object move you need:
1є: Have the object in your script... i will use this one:
pawn Code:
CreateObject(971,263.51126099,-1333.59973145,55.90000153,0.00000000,0.00000000,35.99719238);
I want it to open and move to:
pawn Code:
CreateObject(971,256.13381958,-1338.08825684,55.71572876,0.00000000,0.00000000,35.99719238);
Ok, first we will define the objectid and we can do that:
In the top of your script put:
pawn Code:
#include <a_samp>
new tutgate;
What do new tutgate; do? It containts the object ID after creating it (CreateObjects returns the object ID)"
Now, we will put the object into the GameMode/FilterScript:
Put this at Public OnGameModeInit or public OnFilterScriptInit:
pawn Code:
tutgate = CreateObject(971,263.51126099,-1333.59973145,55.90000153,0.00000000,0.00000000,35.99719238);
Now, lets go make the commands!
You will do this under public OnPlayerCommandText(playerid, cmdtext[])
pawn Code:
if(strcmp(cmdtext, "/Opentutgate", true) == 0)
{
MoveObject(tutgate, 256.13381958,-1338.08825684,55.71572876, 1);
SendClientMessage(playerid, 0xB4B5B7FF, "TutGate Opened");
return 1;
}
Ok, now i will explain all:
pawn Code:
if(strcmp(cmdtext, "/Opentutgate", true) == 0)
This is the normal format of a strcmp cmd...
You allways need to open the script with a breacket...
pawn Code:
MoveObject(tutgate, 256.13381958,-1338.08825684,55.71572876, 1);
MoveObject = Function that make it move!
tutgate = Object to move!
256.13381958,-1338.08825684,55.71572876 = Coordenates to move!
1 = Speed it move, it can open fast or slow!
pawn Code:
SendClientMessage(playerid, 0xB4B5B7FF, "TutGate Opened");
SendClientMessage = Send mensage to the player whos types it!
playerid = define taht only who type the cmd see the message!
0xB4B5B7FF = Color of message!
"TutGate is Opened" = Message
That close your script!
All explained, to make the close cmd, only do the some but put the coordenates to close!
It will look just like this:
pawn Code:
#include <a_samp>
new tutgate;
public OnFilterScriptInit()
{
tutgate = CreateObject(971,263.51126099,-1333.59973145,55.90000153,0.00000000,0.00000000,35.99719238);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/Opentutgate", true) == 0)
{
MoveObject(tutgate, 256.13381958,-1338.08825684,55.71572876, 1);
SendClientMessage(playerid, 0xB4B5B7FF, "TutGate Opened");
return 1;
}
return 0;
}
About Rotate Objects...
It is the something but the code should be like that:
[pawn]
Not MoveObject but yes:
SetObjectRot(ObjectId, coordenateX, coordenateY, coordenateZ);
Hope it is HelpFull!
Re: How to make moving/rotating objects -
Anthonyx3' - 24.01.2011
Can't you just set the x i think to like +5 or something like that?
Re: How to make moving/rotating objects -
ricardo178 - 24.01.2011
Quote:
Originally Posted by Anthonyx3'
Can't you just set the x i think to like +5 or something like that?
|
No, you need to know where you want the object moves to!
If you want it moves up, down, right, left or whatever rotate!
Re: How to make moving/rotating objects -
Anthonyx3' - 24.01.2011
Yeah...you could do something like +5 to the x or y to move it instead of saving code twice
Re: How to make moving/rotating objects -
ricardo178 - 24.01.2011
Yeah but it help if i explane all think per think coz you know script but begginers don't
Tuts are normally to Begginers, i have read mutch tuts!
Re : How to make moving/rotating objects -
Hip-hop - 26.01.2011
SetObjectRot(objectid, Float:RotX, Float:RotY, Float:RotZ);
No speed ...
But nice Tutorial
Re: Re : How to make moving/rotating objects -
ricardo178 - 26.01.2011
Quote:
Originally Posted by Hip-hop
SetObjectRot(objectid, Float:RotX, Float:RotY, Float:RotZ);
No speed ...
But nice Tutorial
|
Changed and thanks
Re: How to make moving/rotating objects -
Kwarde - 26.01.2011
It's pretty well explained.
But please 'explain' why you have the 'new tutgate;' and what it does.
"It containts the object ID after creating it (CreateObjects returns the object ID)"
and
"So you can use it to move/destroy/etc the gate"
However, 7.5/10
- Kevin
Re: How to make moving/rotating objects -
ricardo178 - 26.01.2011
Quote:
Originally Posted by Kwarde
It's pretty well explained.
But please 'explain' why you have the 'new tutgate;' and what it does.
"It containts the object ID after creating it (CreateObjects returns the object ID)"
and
"So you can use it to move/destroy/etc the gate"
However, 7.5/10
- Kevin
|
Thanks and i will edit it right now....
P.S: I will use your defenicion if no problem
I just don't know what words use to explain, sometimes it's hard!
Re : How to make moving/rotating objects -
Cedriic - 28.01.2011
It's a pretty nice tutorial. I am new at pawno, and it helped a lot. Yet; It's not working. It's completely warning/error free. I try to do the command, and nothing happens. Not even "Unknown Command". This is getting me mad, all this work for nothing. It's an elevator map, in which I put 4 doors that diverge from each other, and 1 shaft(electric fence) that can go up and down. Help? Has this happened to anyone else? Thanks.