[Include] nObject Cycle V0.1
#1

v0.1.1
nObject Cycle is a simple include that allows you to dynamically create cycling objects, basically it will go from one point to another and then cycle back through the positions until it meets the original position, then restarting the entire process.

The seconds variable in recording is the amount of time in which a new cycle point will be created based on the players position.

[ame]http://www.youtube.com/watch?v=UMwVDG74Xqw&feature=player_embedded[/ame]
[ame]http://www.youtube.com/watch?v=G2N6LrcZmpk[/ame]

Example record command:
pawn Код:
COMMAND:noc_record(playerid,params[])
{
    if(!GetPVarInt(playerid, "nocRecording")) {
        new mid, sec, Float:dgsped, fdgname[MAX_NOC_NODE_FLENGTH], Float:dd, string[128];
        if (!sscanf(params, "ddfsf", mid, sec, dgsped, fdgname, dd)) {
            if(NOC_VALIDO(mid)) {
                if(strlen(fdgname) <= MAX_NOC_NODE_FLENGTH) {
                    NOC_RecordCycle(playerid,  mid, sec, dgsped, fdgname, dd);
                }
                else {
                    format(string, sizeof(string), "[NOC:] Filenames must be below or equal to %d characters in length.", MAX_NOC_NODE_FLENGTH);
                    SendClientMessage(playerid, COLOR_RED, string);
                }
            }
            else {
                SendClientMessage(playerid, COLOR_RED, "[ERROR:] Incorrect object model.");
            }
        }
        else return SendClientMessage(playerid, COLOR_WHITE, "[ERROR:] /noc_record <model> <seconds> <speed> <file> <drawdistance>");
    }
    else
    {
        NOC_StopRecord(playerid);
    }
    return true;
}
Example usage:

pawn Код:
new DERP_ID, SEAT, BENCH;
public OnGameModeInit()
{
    DERP_ID = NOC_CreateObjectCycle(19335, 0.00, 0.00, 89.86, 300.00, "hot_air_balloon", 100.00);
    BENCH = NOC_CreateObjectCycle(11470, 0.00, 0.00, 0.00, 300.00, "bench_ls_airport", 20.00);
    SEAT = NOC_CreateObjectCycle(1562, 0.00, 0.00, 0.00, 300.00, "seat_ls_airport", 20.00);
    NOC_StartCycle(DERP_ID);
    NOC_StartCycle(BENCH);
    NOC_StartCycle(SEAT);
    return 1;
}
Functions/Callbacks (Some are for the include only and not to be used outside of the include.)
pawn Код:
forward NOC_Exists(nodeid);
forward NOC_ItemExists(nodeitemid);
forward NOC_StopCycle(nodeid);
forward NOC_StartCycle(nodeid);
forward NOC_CreateObjectCycle(modelid, Float:rX, Float:rY, Float:rZ, Float:DrawDistance, node[MAX_NOC_NODE_FLENGTH], Float:speed);
forward NOC_GetFromObjectID(objectid);
forward NOC_OnCycleChange(nodeid, change);
forward NOC_OnCycleReachedPoint(nodeid, point);
forward NOC_RecordCycle(playerid, model, seconds, Float:speed, nfname[MAX_NOC_NODE_FLENGTH], Float:drawdistance);
forward NOC_RecordTimer(playerid);
forward NOC_VALIDO( objectid );
forward NOC_StopRecord(playerid);
forward NOC_RFNOCOwnerSpace();
forward NOC_RFNOCNSpace();
forward NOC_ReturnObjectID(nodeid);
forward NOC_PauseCycle(nodeid);
forward NOC_CycleActive(nodeid);
forward NOC_ReloadCycle(nodeid);
forward NOC_SetSpeed(nodeid, speed);
forward NOC_CyclePointCount(nodeid);
Callback(s)
pawn Код:
forward NOC_OnCycleChange(nodeid, change);
forward NOC_OnCycleReachedPoint(nodeid, point);
OnCycleChange() Example
pawn Код:
public NOC_OnCycleChange(nodeid, change)
{
    switch(change) {
        case 0:
        {
            printf("[NOC] Cycle ID %d accelerated.", nodeid);
        }
        case 1:
        {
            printf("[NOC] Cycle ID %d reversed.", nodeid);
        }
    }
}
OnCycleReachedPoint() Example
pawn Код:
public NOC_OnCycleReachedPoint(nodeid, point) {
    if(nodeid == CAR_UNITY && point == 1)
    {
        NOC_PauseCycle(nodeid);
        SetTimerEx("NOC_PauseCycle", 10000, false, "i", nodeid);
        SendClientMessageToAll(COLOR_WHITE, "[INFO:] Tour car leaving Unity Station in 10 seconds.");
    }
    return true;
}
Download

# Updates
Quote:

31/10/11: Object now faces the next position it's navigating to.
1/11/11: Functions
NOC_PauseCycle(nodeid)
NOC_CycleActive(nodeid)
NOC_ReloadCycle(nodeid)
NOC_SetSpeed(nodeid, speed)
NOC_CyclePointCount(nodeid)

1/11/11: Callback
NOC_OnCycleReachedPoint(nodeid, point)

Reply
#2

Nice
Reply
#3

Nice Job
Reply
#4

Norn does it again

Nice job.
Reply
#5

Now that's original!
Reply
#6

thats cool :P Maybe going to use it
Reply
#7

Impressive. Good job nord.
Reply
#8

Looks nice, corn!
Reply
#9

So... if you quicly go in zig-zag, the object will then just go forward? Anyway nice job
Reply
#10

hey i didnt understand well might from my english but if i understood..you mean that you can make through this the objects to be moving in-game?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)