[Include] Easy Object Moving (0.3d RC5)
#1

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.
Reply
#2

Nice release..., but please test before releasing..
Reply
#3

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);
}
Reply
#4

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.
Reply
#5

Nice lol
Reply
#6

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

Missing some things

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)