Moving Object Help Please? :)
#1

Okay well before I give you my code, here's my problem. I made 2 objects in MTA and converted them correctly and made a /open /close command for them, that all works. BUT.. The problem is they only open and close once, then I can't use /open /close again cos It don't work. So heres my code and hope you can help.
Код:
new lspd1;
new lspd2;
---------------
Код:
lspd1 = CreateObject(2933,1588.59997559,-1638.09997559,14.19999981,0.00000000,0.00000000,0.00000000); //LSPD CLOSED
	lspd2 = CreateObject(2933,1596.40002441,-1638.00000000,14.19999981,0.00000000,0.00000000,0.00000000); //LSPD OPEN
---------------
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/0214 close",cmdtext,true,10) == 0) {
      	new string[50];
        new movetime = MoveObject(lspd2, 1588.59997559,-1638.09997559,14.19999981, 2.00);
        format(string, sizeof(string), "LSPD GATES ARE CLOSING.", movetime);
        SendClientMessage(playerid, 0xFF000000, string);
        return 1;
	}
    if(strcmp("/0214 open",cmdtext,true,10) == 0) {
      	new string[50];
        new movetime = MoveObject(lspd1, 1596.40002441,-1638.00000000,14.19999981, 2.00);
        format(string, sizeof(string), "LSPD GATES ARE OPENING.", movetime);
        SendClientMessage(playerid, 0xFF000000, string);
        return 1;
	}
Reply
#2

why are you formating the string without even using the "movetime" ?
pawn Код:
if(strcmp("/0214 close",cmdtext,true,10) == 0) {
        MoveObject(lspd2, 1588.59997559,-1638.09997559,14.19999981, 2.00);
        SendClientMessage(playerid, 0xFF000000, "LSPD GATES ARE CLOSING.");
        return 1;
    }
    if(strcmp("/0214 open",cmdtext,true,10) == 0) {
        MoveObject(lspd1, 1596.40002441,-1638.00000000,14.19999981, 2.00);
        SendClientMessage(playerid, 0xFF000000, "LSPD GATES ARE OPENING.");
        return 1;
    }
much easier
Reply
#3

Can you post a screenshot with it? look, if it was a gate that consists of one door, then you should only use one object to move, not two objects.
If you use a gate of two doors (or objects) then you should move both away from each other when opening, and in closing, move them close to each other. What you did is that you moved every object alone, and that's why nothing happened when you type the commands again.
Reply
#4

So I take the movetime out and it works? Like you didnt exactly tell me what to do?
Reply
#5

pawn Код:
if(strcmp("/close",cmdtext,true,10) == 0) {
        MoveObject(lspd2, 1588.59997559,-1638.09997559,14.19999981, 3.0,0.0,0.0,0.0);
        SendClientMessage(playerid, 0xFF000000, "LSPD GATES ARE CLOSING.");
        return 1;
    }
    if(strcmp("/open",cmdtext,true,10) == 0) {
        MoveObject(lspd1, 1596.40002441,-1638.00000000,14.19999981, 3.0,0.0,0.0,0.0);
        SendClientMessage(playerid, 0xFF000000, "LSPD GATES ARE OPENING.");
        return 1;
    }
try this one
Reply
#6

no it will not work but im showing you a way that you dont need to format the string, what Chris White said is very true you have two oobjects (GATES) and you only open 1 and you close a different one so that is why the dont close/open back.

you need to get teh x,y,z of both gates OPENED,CLOSED positions
pawn Код:
if(strcmp("/0214 close",cmdtext,true,10) == 0) {
        MoveObject(lspd1, x,y,z, 2.00);//change it to you closepos
        MoveObject(lspd2, 1588.59997559,-1638.09997559,14.19999981, 2.00);
        SendClientMessage(playerid, 0xFF000000, "LSPD GATES ARE CLOSING.");
        return 1;
    }
    if(strcmp("/0214 open",cmdtext,true,10) == 0) {
        MoveObject(lspd1, 1596.40002441,-1638.00000000,14.19999981, 2.00);
        MoveObject(lspd2, x,y,z, 2.00);//change it to you open pos
        SendClientMessage(playerid, 0xFF000000, "LSPD GATES ARE OPENING.");
        return 1;
    }
Reply
#7

Lol. I've used the SAMP map editor to see what you mean. If you take a closer look, you can see that you did this:
pawn Код:
if(strcmp("/0214 close",cmdtext,true,10) == 0) {
        new string[50];
        new movetime = MoveObject(lspd2, 1588.59997559,-1638.09997559,14.19999981, 2.00);
        format(string, sizeof(string), "LSPD GATES ARE CLOSING.", movetime);
        SendClientMessage(playerid, 0xFF000000, string);
        return 1;
    }
and I think you should use the object lspd1 instead of lspd2, so the whole code becomes like this:
pawn Код:
if(strcmp("/0214 close",cmdtext,true,10) == 0) {
        new string[50];
        new movetime = MoveObject(lspd1, 1588.59997559,-1638.09997559,14.19999981, 2.00);
        format(string, sizeof(string), "LSPD GATES ARE CLOSING.", movetime);
        SendClientMessage(playerid, 0xFF000000, string);
        return 1;
    }
    if(strcmp("/0214 open",cmdtext,true,10) == 0) {
        new string[50];
        new movetime = MoveObject(lspd1, 1596.40002441,-1638.00000000,14.19999981, 2.00);
        format(string, sizeof(string), "LSPD GATES ARE OPENING.", movetime);
        SendClientMessage(playerid, 0xFF000000, string);
        return 1;
    }
Try this one, and if it didn't work try using lspd2 instead of lspd1
BTW, I think that you don't need lspd2 object at all.
Reply
#8

Ohhh! I Know what you mean now. I realise what I've done. Thanks For That!

((Rep +1))
Reply
#9

THANKS GUYS, WORKS!
Reply
#10

You're more than welcome. If you need another help, PM me or post in here :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)