SA-MP Forums Archive
[ajuda] attach - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [ajuda] attach (/showthread.php?tid=289806)



[ajuda] attach - Cristhian - 13.10.2011

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


Re: [ajuda] attach - Vai_Besta - 13.10.2011

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


Re: [ajuda] attach - Cristhian - 13.10.2011

podes me dar uma dica de como fazer isso ?


Re: [ajuda] attach - ViniBorn - 13.10.2011

GetPlayerPos + CreateExplosion + GetVehicleZAngle


Re: [ajuda] attach - CyNiC - 13.10.2011

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;
}