SA-MP Forums Archive
[Include] nObject Cycle V0.1 - 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] nObject Cycle V0.1 (/showthread.php?tid=294278)



nObject Cycle V0.1.1 - Norn - 01.11.2011

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)




Re: nObject Cycle V0.1 - SampEver1 - 01.11.2011

Nice


Re: nObject Cycle V0.1 - Salsa - 01.11.2011

Nice Job


Re: nObject Cycle V0.1 - X3nZ - 01.11.2011

Norn does it again

Nice job.


Re: nObject Cycle V0.1 - wups - 01.11.2011

Now that's original!


Re: nObject Cycle V0.1 - rbN. - 01.11.2011

thats cool :P Maybe going to use it


Re: nObject Cycle V0.1 - TheArcher - 01.11.2011

Impressive. Good job nord.


Re: nObject Cycle V0.1 - FireCat - 01.11.2011

Looks nice, corn!


Re: nObject Cycle V0.1 - KingHual - 01.11.2011

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


Re: nObject Cycle V0.1 - vassilis - 01.11.2011

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?