SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 29/06/2009, 08:26 PM   #1
boelie
Gangsta
 
boelie's Avatar
 
Join Date: Apr 2009
Location: San Fierro
Posts: 647
Reputation: 1
Default Trying OnObjectMoved( to make one object move to different locations

Hello,

I'm trying to make one object move to more locations then just one ( as seen in samp wiki )
when i try..it moves direct to the last point and keeps forgetting the other possitions.
I got no errors
maybe its just a } or { but i cant find it, please help

( o ye..i did float xk yk zk and xm ym zm )



Code:
public OnObjectMoved(objectid)
{

	GetObjectPos(obj, xk , yk , zk );

	if (obj == xk, yk, zk)
	{
	MoveObject(obj,273.3177,1888.3771,17.6406, 5.00);
	}




	GetObjectPos(obj, xl , yl , zl );

	if (obj == xl, yl, zl)
	{
	MoveObject(obj,264.5370,1888.0536,17.4770, 5.00);
	}
	

	

	GetObjectPos(obj, xm , ym , zm );

	if (obj == xm, ym, zm)
	{
	MoveObject(obj,264.3640,1879.8628,17.6406, 5.00);
	}
__________________
boelie is offline  
Old 29/06/2009, 08:32 PM   #2
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Trying OnObjectMoved( to make one object move to different locations

It's because the code doesn't wait for your object to move to the first position, then second, etc.. It just executes. Try putting the final coords of each move into the if statement, rather then using GetObjectPosition
dice7 is offline  
Old 30/06/2009, 07:40 AM   #3
boelie
Gangsta
 
boelie's Avatar
 
Join Date: Apr 2009
Location: San Fierro
Posts: 647
Reputation: 1
Default Re: Trying OnObjectMoved( to make one object move to different locations

You mean not using getobjectpos at all ?
How can i use 'if' then? can you please give an example ?
__________________
boelie is offline  
Old 30/06/2009, 07:53 AM   #4
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Trying OnObjectMoved( to make one object move to different locations

This is just your code, but slightly edied
pawn Code:
public OnObjectMoved(objectid)
{

    if (obj == something happens)
    {
    MoveObject(obj,273.3177,1888.3771,17.6406, 5.00);
    }




    GetObjectPos(obj, xl , yl , zl );

    if (xl==273.3177 && yl == 1888.3771 && zl == 17.6406)
    {
    MoveObject(obj,264.5370,1888.0536,17.4770, 5.00);
    }
   

    ////same here

    GetObjectPos(obj, xm , ym , zm );

    if (264.5370,1888.0536,17.4770)
    {
    MoveObject(obj,264.3640,1879.8628,17.6406, 5.00);
    }
dice7 is offline  
Old 30/06/2009, 08:20 AM   #5
Ignas1337
Gangsta
 
Join Date: Jul 2007
Posts: 546
Reputation: 1
Default Re: Trying OnObjectMoved( to make one object move to different locations

when is exactly the callback called. On start of movement or after the movement is done?
Ignas1337 is offline  
Old 30/06/2009, 08:29 AM   #6
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Trying OnObjectMoved( to make one object move to different locations

It's called when the object stops moving
dice7 is offline  
Old 30/06/2009, 08:31 AM   #7
Ignas1337
Gangsta
 
Join Date: Jul 2007
Posts: 546
Reputation: 1
Default Re: Trying OnObjectMoved( to make one object move to different locations

umm so you need it like this...
pawn Code:
// on top
new object;
//on init
object = CreateObject(...);
//on moved
if(objectid==object)
{
// do something here with the object
}
Ignas1337 is offline  
Old 30/06/2009, 09:19 AM   #8
boelie
Gangsta
 
boelie's Avatar
 
Join Date: Apr 2009
Location: San Fierro
Posts: 647
Reputation: 1
Default Re: Trying OnObjectMoved( to make one object move to different locations

LOL i was just wondering what to do with the 'if' (something happens) part
now it works!

Thanks very much both of you . I learned alot today
__________________
boelie is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
move object DennisArenz Help Archive 2 02/05/2010 08:40 AM
Help getting object to move jwa3003 Help Archive 2 15/04/2010 06:47 AM
Move Object - need ! Johny_Rocker Help Archive 7 31/03/2010 03:53 PM
move object Brian_Furios Help Archive 1 11/03/2010 07:59 PM


All times are GMT. The time now is 01:16 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.