[ajuda] attach
#1

Bom attachei uma arma no meu carro, agora como faзo pra ela atirar?
Reply
#2

Faзa um sistema que toda vez que for apertado 'Fire' crie uma explosгo alguns metros a frente do carro
Reply
#3

podes me dar uma dica de como fazer isso ?
Reply
#4

GetPlayerPos + CreateExplosion + GetVehicleZAngle
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)