SA-MP Forums Archive
Help, Moving object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help, Moving object (/showthread.php?tid=180661)



Help, Moving object - Crashty - 02.10.2010

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..


Re: Help, Moving object - iRana - 02.10.2010

Try to define object in Gamemodeint.


Re: Help, Moving object - Crashty - 02.10.2010

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

This line is already there


Re: Help, Moving object - VIRUXE - 02.10.2010

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.


Re: Help, Moving object - Bessensap - 02.10.2010

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);



Re: Help, Moving object - Crashty - 02.10.2010

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!.