[Include] CNStramer - First Streamer of objects by Brazil
#1

Well, this Streamer has a very simple use, simply add it as Include and take about 10 clicks to configure it, test it on two maps dMagnus, which are:
https://sampforum.blast.hk/showthread.php?tid=273170
and
https://sampforum.blast.hk/showthread.php?tid=282440
Both did not lag or crash, but still, like all other Streamer's, there is the possibility to crash if there are many objects in one place only, this will be fixed in next version which will be deleted objects farther away from the player to not houva an explosion on the edge of objects per player in the SA-MP.

The code is as follows:
pawn Код:
#include <a_samp>



/*                  Configuraзгo:      Valor:    */
      #define       MAX_OBJECTOS       2500
      #define       MIN_INTERVAL       0500
      #define       MAX_DISTANCE       300.0
/*                                               */



#define Loop(%0,%1) for(new %0; %0 < %1; ++%0)
#define Function%0(%1) forward %0(%1); \
public %0(%1)

enum ObjetoI
{
    Model,
    Virtual,
    Interior,
    Float:Draw,
    Float:X,
    Float:Y,
    Float:Z,
    Float:rX,
    Float:rY,
    Float:rZ,
    bool:Criado,
    bool:Movendo
}

enum ObjetoD
{
    Float:X,
    Float:Y,
    Float:Z,
    Float:rX,
    Float:rY,
    Float:rZ,
    Float:Velocidade
}

new ObjetoInfo[MAX_OBJECTOS][ObjetoI], ObjetoData[MAX_OBJECTOS][ObjetoD], ObjectPlayer[MAX_PLAYERS][MAX_OBJECTOS];
new ObjetosCriados[MAX_PLAYERS];

/*
function
**** - Creates an object defined
return
**** - Returns the id of the created object
parameters
**** - Model, Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz, Float: speed, virtualworld, interior
comments
**** - no
*/

stock CreateObjectEx(model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:draw = MAX_DISTANCE, virtualworld = 0, interior = 0)
{
    new objid;
    while(objid < MAX_OBJECTOS)
    {
        static bool:AntiFlood;
        if(objid == MAX_OBJECTOS-1 && AntiFlood == false) printf("Limite de %d objetos exedido. Aumente o limite ou retire objetos.", MAX_OBJECTOS), AntiFlood = true;
        if(ObjetoInfo[objid][Criado] == false)
        {
            ObjetoInfo[objid][Criado] = true;
            ObjetoInfo[objid][Model] = model;
            ObjetoInfo[objid][Interior] = interior;
            ObjetoInfo[objid][Virtual] = virtualworld;
            ObjetoInfo[objid][Draw] = draw;
            ObjetoInfo[objid][rZ] = rz;
            ObjetoInfo[objid][rY] = ry;
            ObjetoInfo[objid][rX] = rx;
            ObjetoInfo[objid][Z] = z;
            ObjetoInfo[objid][Y] = y;
            ObjetoInfo[objid][X] = x;
            break;
        }
        ++objid;
    }
    return objid;
}

/*
function
**** - Moves an object defined
return
**** - Returns to 1
parameters
**** - Objid, Float: x, Float: y, Float: z, Float: speed, Float: rx, Float: ry, Float: rz
comments
**** - no
*/

stock MoveObjectEx(objid, Float:x, Float:y, Float:z, Float:velocidade, Float:rx = -1000.0, Float:ry = -1000.0, Float:rz = -1000.0)
{
    if(rx == -1000.0) rx = ObjetoInfo[objid][rX];
    else if(ry == -1000.0) ry = ObjetoInfo[objid][rY];
    else if(rz == -1000.0) rz = ObjetoInfo[objid][rZ];
    ObjetoInfo[objid][Movendo] = true;
    ObjetoData[objid][rZ] = rz;
    ObjetoData[objid][rY] = ry;
    ObjetoData[objid][rX] = rx;
    ObjetoData[objid][Z] = z;
    ObjetoData[objid][Y] = y;
    ObjetoData[objid][X] = x;
    ObjetoData[objid][Velocidade] = velocidade;
    return 1;
}

/*
function
**** - For an object defined
return
**** - Returns to 1
parameters
**** - objid
comments
**** - To stop the object automatically calls the callback "OnObjectMoved"
*/

stock StopObjectEx(objid)
{
    ObjetoInfo[objid][Movendo] = false;
    CallRemoteFunction("OnObjectMoved", "i", objid);
    Loop(i, MAX_PLAYERS)
    {
        StopPlayerObject(i, objid);
    }
    return 1;
}

/*
function
**** - Sets the object to set pos
return
**** - Returns to 1
parameters
**** - Objid, Float: x, Float: y, Float: z
comments
**** - When using the "SetObjectPosEx", the object not to the move (if moving)
*/

stock SetObjectPosEx(objid, Float:x, Float:y, Float:z)
{
    ObjetoInfo[objid][Z] = z;
    ObjetoInfo[objid][Y] = y;
    ObjetoInfo[objid][X] = x;
    Loop(i, MAX_PLAYERS)
    {
        SetPlayerObjectPos(i, objid, x, y, z);
    }
    return 1;
}

/*
function
**** - Sets the object rotation set
return
**** - Returns to 1
parameters
**** - Objid, Float: rx, Float: ry, Float: rz
comments
**** - no
*/

stock SetObjectRotEx(objid, Float:rx, Float:ry, Float:rz)
{
    ObjetoInfo[objid][rZ] = rz;
    ObjetoInfo[objid][rY] = ry;
    ObjetoInfo[objid][rX] = rx;
    Loop(i, MAX_PLAYERS)
    {
        SetPlayerObjectRot(i, objid, rx, ry, rz);
    }
    return 1;
}

/*
function
**** - Destroy the object set
return
**** - Returns to 1
parameters
**** - objid
comments
**** - no
*/

stock DestroyObjectEx(objid)
{
    if(ObjetoInfo[objid][Movendo] == true) StopObjectEx(objid);
    ObjetoInfo[objid][Criado] = false;
    return 1;
}

/*
function
**** - Checks whether the object is valid
return
**** - Returns a 1 if it is valid and 0 if not
parameters
**** - objid
comments
**** - no
*/

stock IsValidObjectEx(objid)
{
    if(ObjetoInfo[objid][Criado] == true) return 1;
    return 0;
}

/*
function
**** - Geta the coordinates of an object defined
return
**** - Returns to 1
parameters
**** - Objid, & Float: x, & Float: y, & Float: z
comments
**** - no
*/

stock GetObjectPosEx(objid, &Float:x, &Float:y, &Float:z)
{
    z = ObjetoInfo[objid][Z];
    y = ObjetoInfo[objid][Y];
    z = ObjetoInfo[objid][X];
    return 1;
}

/*
function
**** - Geta rotations of an object defined
return
**** - Returns to 1
parameters
**** - Objid, & Float: rx, & Float: ry, & Float: rz
comments
**** - no
*/

stock GetObjectRotEx(objid, &Float:rx, &Float:ry, &Float:rz)
{
    rz = ObjetoInfo[objid][rZ];
    ry = ObjetoInfo[objid][rY];
    rz = ObjetoInfo[objid][rX];
    return 1;
}

/*
function
**** - Sets the interior of an object defined
return
**** - Returns to 1
parameters
**** - Objid, interior
comments
**** - no
*/

stock SetObjectInterior(objid, interior)
{
    ObjetoInfo[objid][Interior] = interior;
    return 1;
}

/*
function
**** - Sets the virtual world of an object defined
return
**** - Returns to 1
parameters
**** - Objid, interior
comments
**** - virtualworld
*/

stock SetObjectVirtualWorld(objid, virtualworld)
{
    ObjetoInfo[objid][Virtual] = virtualworld;
    return 1;
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-( Atualizar os Objetos )-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
Function AtualizarObjetos()
{
    Loop(i, MAX_PLAYERS)
    {
        if(!IsPlayerConnected(i)) continue;
        Loop(objid, MAX_OBJECTOS)
        {
            if(GetPlayerInterior(i) == ObjetoInfo[objid][Interior] && GetPlayerVirtualWorld(i) == ObjetoInfo[objid][Virtual] && IsPlayerInRangeOfPoint(i, ObjetoInfo[objid][Draw], ObjetoInfo[objid][X], ObjetoInfo[objid][Y], ObjetoInfo[objid][Z]) && ObjetoInfo[objid][Criado] == true)
            {
                if(ObjectPlayer[i][objid] == -1)
                {
                    if(ObjetosCriados[i] >= 950) DestroyObjectFromDistance(i), --ObjetosCriados[i];
                    ++ObjetosCriados[i];
                    ObjectPlayer[i][objid] = CreatePlayerObject(i, ObjetoInfo[objid][Model], ObjetoInfo[objid][X], ObjetoInfo[objid][Y], ObjetoInfo[objid][Z], ObjetoInfo[objid][rX], ObjetoInfo[objid][rY], ObjetoInfo[objid][rZ]);
                    if(ObjetoInfo[objid][Movendo] == true) MovePlayerObject(i, ObjectPlayer[objid][i], ObjetoData[objid][X], ObjetoData[objid][Y], ObjetoData[objid][Z], ObjetoData[objid][Velocidade], ObjetoData[objid][rX], ObjetoData[objid][rY], ObjetoData[objid][rZ]);
                }
            }
            else
            {
                DestroyPlayerObject(i, ObjectPlayer[i][objid]);
                ObjectPlayer[i][objid] = -1;
            }
        }
    }
    return 1;
}

stock DestroyObjectFromDistance(playerid)
{
    new Float:objectPos[3], Float:playerDistance = 100000.0, objectId;
    Loop(objid, MAX_OBJECTS)
    {
        GetObjectPos(objid, objectPos[0], objectPos[1], objectPos[2]);
        if(GetPlayerDistanceFromPoint(playerid, objectPos[0], objectPos[1], objectPos[2]) < playerDistance)
        {
            playerDistance = GetPlayerDistanceFromPoint(playerid, objectPos[0], objectPos[1], objectPos[2]);
            objectId = objid;
        }
    }
    DestroyPlayerObject(playerid, objectId);
    return 1;
}

#if defined FILTERSCRIPT
public OnFilterScriptInit()
#else
public OnGameModeInit()
#endif
{
        SetTimer("AtualizarObjetos", MIN_INTERVAL, true);
#if defined FILTERSCRIPT
        return (funcidx("ALSS_OnFilterScriptInit") != -1 ? CallLocalFunction("ALSS_OnFilterScriptInit", "") : 1);
}
        #if defined _ALS_OnFilterScriptInit
                #undef OnFilterScriptInit
        #else
                #define _ALS_OnFilterScriptInit
        #endif
        #define OnFilterScriptInit ALSS_OnFilterScriptInit
forward ALSS_OnFilterScriptInit();
#else
        return (funcidx("ALSS_OnGameModeInit") != -1 ? CallLocalFunction("ALSS_OnGameModeInit", "") : 1);
}
        #if defined _ALS_OnGameModeInit
                #undef OnGameModeInit
        #else
                #define _ALS_OnGameModeInit
        #endif
        #define OnGameModeInit ALSS_OnGameModeInit
forward ALSS_OnGameModeInit();
#endif

//Peguei estб ALS desta Include: http://pastebin.com/d4hfMvQx

public OnPlayerObjectMoved(playerid, objectid)
{
    ObjetoInfo[objectid][Movendo] = false;
    ObjetoInfo[objectid][X] = ObjetoData[objectid][X];
    ObjetoInfo[objectid][Y] = ObjetoData[objectid][Y];
    ObjetoInfo[objectid][Z] = ObjetoData[objectid][Z];
    ObjetoInfo[objectid][rX] = ObjetoData[objectid][rX];
    ObjetoInfo[objectid][rY] = ObjetoData[objectid][rY];
    ObjetoInfo[objectid][rZ] = ObjetoData[objectid][rZ];
    CallRemoteFunction("OnObjectMoved", "i", objectid);
    return 1;
}
#if defined _ALS_OnPlayerObjectMoved
    #undef OnPlayerObjectMoved
#else
    #define _ALS_OnPlayerObjectMoved
#endif
#define OnPlayerObjectMoved gb_OnPlayerObjectMoved
forward gb_OnPlayerObjectMoved(playerid, objectid);

#define CreateObject CreateObjectEx
#define MoveObject MoveObjectEx
#define StopObject StopObjectEx
#define SetObjectPos SetObjectPosEx
#define SetObjectRot SetObjectRotEx
#define DestroyObject DestroyObjectEx
#define IsValidObject IsValidObjectEx
#define GetObjectPos GetObjectPosEx
#define GetObjectRot GetObjectRotEx
The setting is just at the top of Include. The Include weighs a little in your gamemode, but will not give lag or anything in GamePlay ^ ^

Include Updated, now with the "No-Crash" and "Free-Slot".
The function On-Crash, by exceeding the limit of objects allowed per player for SA-MP, the Streamer automatically delete the object farthest from the player, since the function-free slot is not used more + + objects, since the objects are now populated / created by slots, or if you delete the object 30 and has 100 objects, the slot 30 is released and can create more than one object in it.

Pros
1 - Enough crashs;
2 - No more lag;
3 - Hang as many objects you want;
4 - No need to make changes to your code;
5 - Easy instalзгo;

Cons
1 - Can weigh heavily yours. Amx; *

* Depends on MAX_OBJECTOS (OBJECTS same, because he wanted to leave everything in retinho configs) and MAX_PLAYERS, so I recommend that you upgrade your MAX_PLAYERS and MAX_OBJECTOS consistently with the values ​​that are actually used. Or place the objects in a FS so there is no latency time of BUILD.


Sorry my bad inglish, i'm used the ****** Translate, original topic:
https://sampforum.blast.hk/showthread.php?tid=355985
Reply
#2

First? This is just a generic streamer and have been released many streamers. LOL MAN

-> https://sampforum.blast.hk/showthread.php?tid=118572

--

Anyway, good project

Quote:

Sorry my bad inglish, i'm used the ****** Translate, original topic:

For us Brazilians is really hard speak to the English. Whom does not have a teacher dedicated to it, is lost in sentences (inverse sentences lol)
Reply
#3

Well, i'm sure this one is not the first one made by one of us brazilian's, Also, i'm pretty sure the normal "Streamer" is much better than this one(no doubt),Would be much better for you use the search function's before come here and start claiming yours as the first work.

By the way, i'm pretty sure most of people won't change to your streamer,Anyways nice "job", keep it up.



@PS: Your english sucks alot, Would be better if you put some effort on ****** translate.
Reply
#4

pawn Код:
CNStramer - First Streamer of objects by Brazil
This is serious? Search before say something ...

Anyway, cool project ...
Reply
#5

Not There is only one... good work!
Reply
#6

Primeiro Streamer do BRASIL postado aqui galera, nгo primeiro de todos...
Obrigado pelos comentarios, ******, estou a desenvolver uma nova atualizaзгo, obrigado pelas dicas.

Translate for inglish:
First of BRAZIL Streamer posted here guys, not first of all ...
Thanks for the comments, ******, I am developing a new update, thanks for the tips.
Reply
#7

Quote:
Originally Posted by CidadeNovaRP
Посмотреть сообщение
Primeiro Streamer do BRASIL postado aqui galera, nгo primeiro de todos...
Obrigado pelos comentarios, ******, estou a desenvolver uma nova atualizaзгo, obrigado pelas dicas.

Translate for inglish:
First of BRAZIL Streamer posted here guys, not first of all ...
Thanks for the comments, ******, I am developing a new update, thanks for the tips.
There are "streamers brazilians" launched in 2005 - 2007. It is better to look, before you say something

Tip: Use a good "zoning system" (busque por zoneamento), speed up the matching process.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)