SA-MP Forums Archive
[Include] Simple Include - Add Virtual Word to your Objects - 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] Simple Include - Add Virtual Word to your Objects (/showthread.php?tid=342988)



Simple Include - Add Virtual Word to your Objects - CidadeNovaRP - 15.05.2012

The title says it all, just use the function:
CreateObjectEx (model, Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz, Float: draw, virtualword)

This is CODE:
pawn Код:
#include <a_samp>

new Timer[MAX_PLAYERS];

enum OInfo
{
    Model,
    Float:X,
    Float:Y,
    Float:Z,
    Float:RX,
    Float:RY,
    Float:RZ,
    Float:DRAW,
    VirtualWord,
    bool:Criado[MAX_PLAYERS],
    Objeto
};

new Objetos, ObjectInfo[MAX_OBJECTS][OInfo];

public OnPlayerConnect(playerid)
{
    Timer[playerid] = SetTimerEx("AtualizarObjetos", 1500, true, "i", playerid);
    return 1;
}

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect object_OnPlayerConnect
forward object_OnPlayerConnect(playerid);

public OnPlayerDisconnect(playerid)
{
    KillTimer(Timer[playerid]);
    return 1;
}

#if defined _ALS_OnPlayerDisconnect
    #undef OnPlayerDisconnect
#else
    #define _ALS_OnPlayerDisconnect
#endif
#define OnPlayerDisconnect object_OnPlayerDisconnect
forward object_OnPlayerDisconnect(playerid);

stock CreateObjectEx(model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:draw, virtualword)
{
    Objetos ++;
    if(Objetos >= MAX_OBJECTS) return print("Limete de Objetos Exedido"), Objetos --;
    ObjectInfo[Objetos][VirtualWord] = virtualword;
    ObjectInfo[Objetos][Model] = model;
    ObjectInfo[Objetos][X] = x;
    ObjectInfo[Objetos][Y] = y;
    ObjectInfo[Objetos][Z] = z;
    ObjectInfo[Objetos][RX] = rx;
    ObjectInfo[Objetos][RY] = ry;
    ObjectInfo[Objetos][RZ] = rz;
    ObjectInfo[Objetos][DRAW] = draw;
    return 1;
}

forward AtualizarObjetos(playerid);
public AtualizarObjetos(playerid)
{
    new o;
    while(o < MAX_OBJECTS)
    {
        if(GetPlayerVirtualWorld(playerid) == ObjectInfo[o][VirtualWord])
        {
            if(IsPlayerInRangeOfPoint(playerid, ObjectInfo[o][DRAW], ObjectInfo[o][X], ObjectInfo[o][Y], ObjectInfo

[o][Z]))
            {
                if(ObjectInfo[o][Criado][playerid] == false)
                {
                    ObjectInfo[o][Objeto] = CreatePlayerObject(playerid, ObjectInfo[o][Model], ObjectInfo[o]

[X], ObjectInfo[o][Y], ObjectInfo[o][Z], ObjectInfo[o][RX], ObjectInfo[o][RY], ObjectInfo[o][RX], ObjectInfo[o][DRAW]);
                    ObjectInfo[o][Criado][playerid] = true;
                }
            }
            else
            {
                ObjectInfo[o][Criado][playerid] = false;
                DestroyPlayerObject(playerid, ObjectInfo[o][Objeto]);
            }
        }
        else
        {
            ObjectInfo[o][Criado][playerid] = false;
            DestroyPlayerObject(playerid, ObjectInfo[o][Objeto]);
        }
        o++;
    }
}

native CreateObjectEx(model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:draw, virtualword);
I hope you enjoy .