SA-MP Forums Archive
[Include] Easy Object Moving (0.3d RC5) - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Easy Object Moving (0.3d RC5) (/showthread.php?tid=289726)



Easy Object Moving (0.3d RC5) - Jochemd - 12.10.2011

Hello,

I made a very easy include which could save you some work changing your script. As you know, you have to stop the object first to make it move from it's current spot. You don't have to do it anymore with this easy include.

Since the script is only 50 lines long, I'll not use Pastebin or anything related.

Usage: Including is enough. You don't have to do anything else.

pawn Код:
/*
    Easy Object Moving by Jochemd
    This is just an easy include. Use it if you think it could you save you some time
   
    Jochem
*/


new ObjectMoving[MAX_OBJECTS];

/* Hook the OnObjectMoved callback in your main script */
#if defined _ALS_OnObjectMoved
    #undef OnObjectMoved
#else
    #define _ALS_OnObjectMoved
#endif
#define OnObjectMoved jOnObjectMoved
#define MoveObject jMoveObject
#define StopObject jStopObject
forward jOnObjectMoved(objectid);
/* It will be automatically called now. Do not edit this above. */


/* Easy stocks. A variable gets set to 1 whenever the object starts moving. Once it stops moving, it gets set back to 0.*/
stock jMoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX = -1000.0, Float:RotY = -1000.0, Float:RotZ = -1000.0)
{
    if(IsObjectMoving(objectid)) StopObject(objectid);
    ObjectMoving[objectid] = 1;
    return MoveObject(objectid, X, Y, Z, Speed, RotX, RotY, RotZ);
}

stock jStopObject(objectid)
{
    if(IsObjectMoving(objectid))
    {
        StopObject(objectid);
        return 1;
    }
    else return 0;
}

stock IsObjectMoving(objectid)
{
    return ObjectMoving[objectid];
}

public jOnObjectMoved(objectid)
{
    ObjectMoving[objectid] = 0;
    return 1;
}
I've also included a "IsObjectMoving" into it.

pawn Код:
CMD:objectmoving(playerid,params[])
{
    new objectid = strval(params);
    if(IsObjectMoving(objectid)) SendClientMessage(playerid,-1,"The Object ID you entered is currently moving.");
    else SendClientMessage(playerid,-1,"The Object ID you entered is currently NOT moving.");
    return 1;
}
I hope this comes useful for people who can't script it themselfs. It's actually pretty easy to make.

Jochem

Due to lack of GTA I couldn't test this script - I am not sure if it's working, but I think it is. If not, excuse me and I'll fix it.


Re : Easy Object Moving (0.3d RC5) - Naruto_Emilio - 12.10.2011

Nice release..., but please test before releasing..


Re: Easy Object Moving (0.3d RC5) - wups - 12.10.2011

The defines must be AFTER the functions.
Why? Take a look at this:
pawn Код:
stock jMoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX = -1000.0, Float:RotY = -1000.0, Float:RotZ = -1000.0)
{
    if(IsObjectMoving(objectid)) StopObject(objectid);
    ObjectMoving[objectid] = 1;
    return jMoveObject(objectid, X, Y, Z, Speed, RotX, RotY, RotZ);
}



Re: Easy Object Moving (0.3d RC5) - Jochemd - 12.10.2011

Quote:
Originally Posted by wups
Посмотреть сообщение
The defines must be AFTER the functions.
Why? Take a look at this:
pawn Код:
stock jMoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX = -1000.0, Float:RotY = -1000.0, Float:RotZ = -1000.0)
{
    if(IsObjectMoving(objectid)) StopObject(objectid);
    ObjectMoving[objectid] = 1;
    return jMoveObject(objectid, X, Y, Z, Speed, RotX, RotY, RotZ);
}
I saw the same while balintx was explaining me something, but thanks for saying.


Re: Easy Object Moving (0.3d RC5) - FireCat - 12.10.2011

Nice lol


Re: Easy Object Moving (0.3d RC5) - Jochemd - 12.10.2011

I am fixing this now - I just heard the hooks don't work


Re: Easy Object Moving (0.3d RC5) - Kar - 12.10.2011

Missing some things

ObjectMoving[objectid] = 0; is not reset on stopobject

ObjectMoving[objectid] = 0; is not reset when a object is destroyed