[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


Messages In This Thread
nObject Cycle V0.1.1 - by Norn - 01.11.2011, 03:25
Re: nObject Cycle V0.1 - by SampEver1 - 01.11.2011, 03:54
Re: nObject Cycle V0.1 - by Salsa - 01.11.2011, 04:44
Re: nObject Cycle V0.1 - by X3nZ - 01.11.2011, 04:46
Re: nObject Cycle V0.1 - by wups - 01.11.2011, 10:03
Re: nObject Cycle V0.1 - by rbN. - 01.11.2011, 12:19
Re: nObject Cycle V0.1 - by TheArcher - 01.11.2011, 12:26
Re: nObject Cycle V0.1 - by FireCat - 01.11.2011, 12:42
Re: nObject Cycle V0.1 - by KingHual - 01.11.2011, 12:43
Re: nObject Cycle V0.1 - by vassilis - 01.11.2011, 12:57

Forum Jump:


Users browsing this thread: 1 Guest(s)