Help, Moving object
#1

Hello

I'm trying to make a test object move, But there's a problem, The object do move, But another object stays there where the original object moved :\




Here's my code:
pawn Код:
if(strcmp(cmd,"/test",true)==0)
    {
        new test;
        test = CreateObject(980, 2091.7006835938, -1753.1389160156, 15.178255081177, 0, 0, 0);
       
        if(gTeam[playerid] == 1)
        {
            if(IsPlayerInRangeOfPoint(playerid,30,2091.7006835938, -1753.1389160156, 15.178255081177))
            {
                MoveObject(test,2091.7006835938, -1753.1389160156, 30.178255081177,5);
            }
            else
            {
                SendClientMessage(playerid,RED2,"You are too far!");
            }
        }
       
        else
        {
            SendClientMessage(playerid,GREEN,"You can't do that in your team!");
        }
        return 1;
    }


p.s: some of the "{,}" position changes in CODE for some reason..
Reply
#2

Try to define object in Gamemodeint.
Reply
#3

CreateObject(980, 2091.7006835938, -1753.1389160156, 15.178255081177, 0, 0, 0);

This line is already there
Reply
#4

Everytime you execute that command a new object is created.

Maybe, define a global variable, create an object at gamemodeinit and assign it's id to the global variable.

Then just remove the object creation within your command.
Reply
#5

Quote:
Originally Posted by Crashty
Посмотреть сообщение
CreateObject(980, 2091.7006835938, -1753.1389160156, 15.178255081177, 0, 0, 0);

This line is already there
do this;
pawn Код:
//at the list of all you're new's (which i assume you have?)
new test;
pawn Код:
test = CreateObject(980, 2091.7006835938, -1753.1389160156, 15.178255081177, 0, 0, 0);
//at OnGameModeInIt or if its a FS OnFilterScriptInIt
then:

pawn Код:
if(strcmp(cmd,"/test",true)==0)
    {
        if(gTeam[playerid] == 1)
        {
            if(IsPlayerInRangeOfPoint(playerid,30,2091.7006835938, -1753.1389160156, 15.178255081177))
            {
                MoveObject(test,2091.7006835938, -1753.1389160156, 30.178255081177,5);
            }
            else
            {
                SendClientMessage(playerid,RED2,"You are too far!");
            }
        }
       
        else
        {
            SendClientMessage(playerid,GREEN,"Your  can't do that in your team!");
        }
        return 1;
    }
If you want to know what changed i removed this.
pawn Код:
new test;
        test = CreateObject(980, 2091.7006835938, -1753.1389160156, 15.178255081177, 0, 0, 0);
Reply
#6

I did that and still... A new object will move and one will stay there

EDIT: My bad! this worked! I just forgot to remove the old "CreateObject", thanks a lot for helping me
My problem is solved!.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)