[ajuda] attach
#5

Fiz algo do tipo hб algum tempo, basta adaptar pra veнculos:
pawn Код:
enum info
{
    id,
    player
};

new objects[MAX_OBJECTS][info];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    ShotExplosion(playerid);
    return 1;
}

ShotExplosion(playerid)
{
    new Float:CamX, Float:CamY, Float:CamZ, Float:VectorX, Float:VectorY,
    Float:VectorZ, Float:ObjectX, Float:ObjectY, Float:ObjectZ, Float:Scale = 30.0,
    Float:pos[3], slot = GetEmptySlot();

    if(slot == -1) return true;

    GetPlayerCameraPos(playerid, CamX, CamY, CamZ);
    GetPlayerCameraFrontVector(playerid, VectorX, VectorY, VectorZ);
    ObjectX = CamX + floatmul(VectorX, Scale);
    ObjectY = CamY + floatmul(VectorY, Scale);
    ObjectZ = CamZ + floatmul(VectorZ, Scale);
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    objects[slot][id] = CreateObject(18690, pos[0], pos[1], pos[2], 0.0, 0.0, 0.0);
    MoveObject(objects[slot][id], ObjectX, ObjectY, ObjectZ, 35.0);
    objects[slot][player] = playerid;
    return 1;
}

public OnObjectMoved(objectid)
{
    new InternalID = GetObjectInternalID(objectid);
    if(InternalID != -1)
    {
        new Float:pos[3];
        GetObjectPos(objectid, pos[0], pos[1], pos[2]);
        CreateExplosion(pos[0], pos[1], pos[2], 10, 2.0);
        DestroyObject(objectid);
    }
    return true;
}

GetObjectInternalID(objectid)
{
    for(new i = 0; i < sizeof objects; ++i) if(objectid == objects[i][id]) return i;
    return -1;
}

GetEmptySlot()
{
    for(new i = 0; i < sizeof objects; ++i) if(!IsValidObject(objects[i][id])) return i;
    return -1;
}
Reply


Messages In This Thread
[ajuda] attach - by Cristhian - 13.10.2011, 01:56
Re: [ajuda] attach - by Vai_Besta - 13.10.2011, 02:26
Re: [ajuda] attach - by Cristhian - 13.10.2011, 13:43
Re: [ajuda] attach - by ViniBorn - 13.10.2011, 13:45
Re: [ajuda] attach - by CyNiC - 13.10.2011, 14:33

Forum Jump:


Users browsing this thread: 3 Guest(s)