Portal SAMP
[Ajuda] Voice SAMP - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Voice SAMP (/showthread.php?tid=584)

Páginas: 1 2 3 4


RE: Voice SAMP - robertjwx - 25/01/2021

Tem como algum de vocês me ajudar a fazer o meu?
Meu servidor não tem ORGs definidas, os caras criam varias gangues por dia ali na hora, não ia dar pra fazer desse jeito...

Queria fazer:
- voice local pra geral
- voice global pra admins
- voice radio, teriam varias frequencias de radio de 1-999999, onde os caras entrariam pra conversar com voice de time (radio)

comecei e tentei fazer assim:
Código:
// samp_voice 1
#include <sampvoice>

// samp_voice 2
new SV_GSTREAM:gstream = SV_NULL;
new SV_LSTREAM:lstream[MAX_PLAYERS] = { SV_NULL, ... };

#define MAX_RADIOS 999999
new player_frequency[MAX_PLAYERS];
new SV_GSTREAM:rstream[MAX_RADIOS] = { SV_NULL, ... };


// samp_voice 3
/*
    The public OnPlayerActivationKeyPress and OnPlayerActivationKeyRelease
    are needed in order to redirect the player's audio traffic to the
    corresponding streams when the corresponding keys are pressed.
*/
public SV_VOID:OnPlayerActivationKeyPress(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if(keyid == 0x58 && rstream[fid])
    {
        SvAttachSpeakerToStream(rstream[fid], playerid);
    }
    // Attach player to local stream as speaker if 'Z' key is pressed
    else if (keyid == 0x5A && lstream[playerid])
    {
        SvAttachSpeakerToStream(lstream[playerid], playerid);
    }
    // Attach the player to the global stream as a speaker if the 'B' key is pressed
    else if (keyid == 0x42 && gstream)
    {
        SvAttachSpeakerToStream(gstream, playerid);
    }
}
public SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if (keyid == 0x58 && rstream[fid])
    {
        SvDetachSpeakerFromStream(rstream[fid], playerid);
    }
    // Detach the player from the local stream if the 'Z' key is released
    else if (keyid == 0x5A && lstream[playerid])
    {
        SvDetachSpeakerFromStream(lstream[playerid], playerid);
    }
    // Detach the player from the global stream if the 'B' key is released
    else if(admin[playerid] >= 2 && keyid == 0x42 && gstream)
    {
        SvDetachSpeakerFromStream(gstream, playerid);
    }
}








// samp_voice 4
public OnPlayerConnect(playerid)
{
    // Checking for plugin availability
    if (SvGetVersion(playerid) == SV_NULL)
    {
        SendClientMessage(playerid, -1, "Could not find plugin sampvoice.");
    }
    // Checking for a microphone
    else if (SvHasMicro(playerid) == SV_FALSE)
    {
        SendClientMessage(playerid, -1, "The microphone could not be found.");
    }
    // Create a local stream with an audibility distance of 40.0, an unlimited number of listeners
    // and the name 'Local' (the name 'Local' will be displayed in red in the players' speakerlist)
    else if ((lstream[playerid] = SvCreateDLStreamAtPlayer(40.0, SV_INFINITY, playerid, 0xff0000ff, "Local")))
    {
        SendClientMessage(playerid, -1, "Press X to talk to radio chat and Z to talk to local chat.");
        if(admin[playerid] >= 2) {
            SendClientMessage(playerid, -1, "Press B to talk to global.");
        }

        // Attach the player to the global stream as a listener
        if (gstream) SvAttachListenerToStream(gstream, playerid);

        // listener radio
        ???

        // Assign microphone activation keys to the player
        SvAddKey(playerid, 0x42); // [B] global
        SvAddKey(playerid, 0x5A); // [Z] local
        SvAddKey(playerid, 0x58); // [X] radio
    }
}

// samp_voice 5
public OnPlayerDisconnect(playerid, reason)
{
    // Removing the player's local stream after disconnecting
    if (lstream[playerid])
    {
        SvDeleteStream(lstream[playerid]);
        lstream[playerid] = SV_NULL;
    }
    // remove radio stream
    new fid = player_frequency[playerid];
    if (rstream[fid])
    {
        SvDeleteStream(rstream[fid]);
        rstream[fid] = SV_NULL;
    }
    // remove global stream (tá certo isso aqui? n tinha)
    if (gstream)
    {
        SvDeleteStream(gstream);
        gstream = SV_NULL;
    }
}


// samp_voice 6
public OnGameModeInit()
{
    // Uncomment the line to enable debug mode
    // SvDebug(SV_TRUE);

    gstream = SvCreateGStream(0xffff0000, "Global");
}


// samp_voice 7
public OnGameModeExit()
{
    if (gstream) SvDeleteStream(gstream);
}


// samp_voice 8
CMD:frequencia(playerid, params[]) {
    if(admin[playerid] < 6) return 0;
    new fid, string[80];
    if(sscanf(params,"i", fid)) return SendClientMessage(playerid, -1, "Use: /frequencia [id]");
    format(string, sizeof(string), "AdmCmd: %s voice frequency %s.", PlayerName(playerid), fid );
    ABroadCast(COLOR_LIGHTRED, string, 6);
    mission[id] = mid;
    return 1;
}

alguém pode me ajudar a terminar a parte que eu não sei e me dizer se to fazendo algo errado?


RE: Voice SAMP - robertjwx - 27/01/2021

(25/01/2021 17:46)robertjwx Escreveu: Tem como algum de vocês me ajudar a fazer o meu?
Meu servidor não tem ORGs definidas, os caras criam varias gangues por dia ali na hora, não ia dar pra fazer desse jeito...

Queria fazer:
- voice local pra geral
- voice global pra admins
- voice radio, teriam varias frequencias de radio de 1-999999, onde os caras entrariam pra conversar com voice de time (radio)

comecei e tentei fazer assim:
Código:
// samp_voice 1
#include <sampvoice>

// samp_voice 2
new SV_GSTREAM:gstream = SV_NULL;
new SV_LSTREAM:lstream[MAX_PLAYERS] = { SV_NULL, ... };

#define MAX_RADIOS 999999
new player_frequency[MAX_PLAYERS];
new SV_GSTREAM:rstream[MAX_RADIOS] = { SV_NULL, ... };


// samp_voice 3
/*
    The public OnPlayerActivationKeyPress and OnPlayerActivationKeyRelease
    are needed in order to redirect the player's audio traffic to the
    corresponding streams when the corresponding keys are pressed.
*/
public SV_VOID:OnPlayerActivationKeyPress(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if(keyid == 0x58 && rstream[fid])
    {
        SvAttachSpeakerToStream(rstream[fid], playerid);
    }
    // Attach player to local stream as speaker if 'Z' key is pressed
    else if (keyid == 0x5A && lstream[playerid])
    {
        SvAttachSpeakerToStream(lstream[playerid], playerid);
    }
    // Attach the player to the global stream as a speaker if the 'B' key is pressed
    else if (keyid == 0x42 && gstream)
    {
        SvAttachSpeakerToStream(gstream, playerid);
    }
}
public SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if (keyid == 0x58 && rstream[fid])
    {
        SvDetachSpeakerFromStream(rstream[fid], playerid);
    }
    // Detach the player from the local stream if the 'Z' key is released
    else if (keyid == 0x5A && lstream[playerid])
    {
        SvDetachSpeakerFromStream(lstream[playerid], playerid);
    }
    // Detach the player from the global stream if the 'B' key is released
    else if(admin[playerid] >= 2 && keyid == 0x42 && gstream)
    {
        SvDetachSpeakerFromStream(gstream, playerid);
    }
}








// samp_voice 4
public OnPlayerConnect(playerid)
{
    // Checking for plugin availability
    if (SvGetVersion(playerid) == SV_NULL)
    {
        SendClientMessage(playerid, -1, "Could not find plugin sampvoice.");
    }
    // Checking for a microphone
    else if (SvHasMicro(playerid) == SV_FALSE)
    {
        SendClientMessage(playerid, -1, "The microphone could not be found.");
    }
    // Create a local stream with an audibility distance of 40.0, an unlimited number of listeners
    // and the name 'Local' (the name 'Local' will be displayed in red in the players' speakerlist)
    else if ((lstream[playerid] = SvCreateDLStreamAtPlayer(40.0, SV_INFINITY, playerid, 0xff0000ff, "Local")))
    {
        SendClientMessage(playerid, -1, "Press X to talk to radio chat and Z to talk to local chat.");
        if(admin[playerid] >= 2) {
            SendClientMessage(playerid, -1, "Press B to talk to global.");
        }

        // Attach the player to the global stream as a listener
        if (gstream) SvAttachListenerToStream(gstream, playerid);

        // listener radio
        ???

        // Assign microphone activation keys to the player
        SvAddKey(playerid, 0x42); // [B] global
        SvAddKey(playerid, 0x5A); // [Z] local
        SvAddKey(playerid, 0x58); // [X] radio
    }
}

// samp_voice 5
public OnPlayerDisconnect(playerid, reason)
{
    // Removing the player's local stream after disconnecting
    if (lstream[playerid])
    {
        SvDeleteStream(lstream[playerid]);
        lstream[playerid] = SV_NULL;
    }
    // remove radio stream
    new fid = player_frequency[playerid];
    if (rstream[fid])
    {
        SvDeleteStream(rstream[fid]);
        rstream[fid] = SV_NULL;
    }
    // remove global stream (tá certo isso aqui? n tinha)
    if (gstream)
    {
        SvDeleteStream(gstream);
        gstream = SV_NULL;
    }
}


// samp_voice 6
public OnGameModeInit()
{
    // Uncomment the line to enable debug mode
    // SvDebug(SV_TRUE);

    gstream = SvCreateGStream(0xffff0000, "Global");
}


// samp_voice 7
public OnGameModeExit()
{
    if (gstream) SvDeleteStream(gstream);
}


// samp_voice 8
CMD:frequencia(playerid, params[]) {
    if(admin[playerid] < 6) return 0;
    new fid, string[80];
    if(sscanf(params,"i", fid)) return SendClientMessage(playerid, -1, "Use: /frequencia [id]");
    format(string, sizeof(string), "AdmCmd: %s voice frequency %s.", PlayerName(playerid), fid );
    ABroadCast(COLOR_LIGHTRED, string, 6);
    mission[id] = mid;
    return 1;
}

alguém pode me ajudar a terminar a parte que eu não sei e me dizer se to fazendo algo errado?


alguém?


RE: Voice SAMP - robertjwx - 29/01/2021

alguém?


RE: Voice SAMP - robertjwx - 31/01/2021

alguém?


RE: Voice SAMP - robertjwx - 01/02/2021

alguém?


RE: Voice SAMP - xbruno1000x - 01/02/2021

Fiz um post destrinchando esse plugin.
Leia sobre a função SvAttachListenerToStream e saberá o que fazer.
https://portalsamp.com/showthread.php?tid=707&pid=2631#pid2631

(Caso ainda não saiba o que é pra fazer, é só verificar a ORG do player que está usando o SvAttachSpeakerToStream e usar a função SvAttachListenerToStream nos players de mesma ORG)


RE: Voice SAMP - robertjwx - 03/02/2021

(01/02/2021 21:10)xbruno1000x Escreveu: Fiz um post destrinchando esse plugin.
Leia sobre a função SvAttachListenerToStream e saberá o que fazer.
https://portalsamp.com/showthread.php?tid=707&pid=2631#pid2631

(Caso ainda não saiba o que é pra fazer, é só verificar a ORG do player que está usando o SvAttachSpeakerToStream e usar a função SvAttachListenerToStream nos players de mesma ORG)

Então... Parece que a parte do SvAttachSpeakerToStream pela frequencia de radio já tá de boa, mas ainda falta a parte do SvAttachListenerToStream
        // listener radio

        ???

Que eu não sei como fazer...

Dado esse meu exemplo:

Código:
// samp_voice 1
#include <sampvoice>

// samp_voice 2
new SV_GSTREAM:gstream = SV_NULL;
new SV_LSTREAM:lstream[MAX_PLAYERS] = { SV_NULL, ... };

#define MAX_RADIOS 999999
new player_frequency[MAX_PLAYERS];
new SV_GSTREAM:rstream[MAX_RADIOS] = { SV_NULL, ... };


// samp_voice 3
/*
    The public OnPlayerActivationKeyPress and OnPlayerActivationKeyRelease
    are needed in order to redirect the player's audio traffic to the
    corresponding streams when the corresponding keys are pressed.
*/
public SV_VOID:OnPlayerActivationKeyPress(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if(keyid == 0x58 && rstream[fid])
{
SvAttachSpeakerToStream(rstream[fid], playerid);
}
    // Attach player to local stream as speaker if 'Z' key is pressed
    else if (keyid == 0x5A && lstream[playerid])
    {
    SvAttachSpeakerToStream(lstream[playerid], playerid);
    }
    // Attach the player to the global stream as a speaker if the 'B' key is pressed
    else if (keyid == 0x42 && gstream)
    {
    SvAttachSpeakerToStream(gstream, playerid);
    }
}
public SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if (keyid == 0x58 && rstream[fid])
{
SvDetachSpeakerFromStream(rstream[fid], playerid);
}
    // Detach the player from the local stream if the 'Z' key is released
    else if (keyid == 0x5A && lstream[playerid])
    {
    SvDetachSpeakerFromStream(lstream[playerid], playerid);
    }
    // Detach the player from the global stream if the 'B' key is released
    else if(admin[playerid] >= 2 && keyid == 0x42 && gstream)
    {
    SvDetachSpeakerFromStream(gstream, playerid);
    }
}








// samp_voice 4
public OnPlayerConnect(playerid)
{
    // Checking for plugin availability
    if (SvGetVersion(playerid) == SV_NULL)
    {
        SendClientMessage(playerid, -1, "Could not find plugin sampvoice.");
    }
    // Checking for a microphone
    else if (SvHasMicro(playerid) == SV_FALSE)
    {
        SendClientMessage(playerid, -1, "The microphone could not be found.");
    }
    // Create a local stream with an audibility distance of 40.0, an unlimited number of listeners
    // and the name 'Local' (the name 'Local' will be displayed in red in the players' speakerlist)
    else if ((lstream[playerid] = SvCreateDLStreamAtPlayer(40.0, SV_INFINITY, playerid, 0xff0000ff, "Local")))
    {
        SendClientMessage(playerid, -1, "Press X to talk to radio chat and Z to talk to local chat.");
        if(admin[playerid] >= 2) {
        SendClientMessage(playerid, -1, "Press B to talk to global.");
        }

        // Attach the player to the global stream as a listener
        if (gstream) SvAttachListenerToStream(gstream, playerid);

        // listener radio
        ???

        // Assign microphone activation keys to the player
        SvAddKey(playerid, 0x42); // [B] global
        SvAddKey(playerid, 0x5A); // [Z] local
        SvAddKey(playerid, 0x58); // [X] radio
    }
}

// samp_voice 5
public OnPlayerDisconnect(playerid, reason)
{
    // Removing the player's local stream after disconnecting
    if (lstream[playerid])
    {
        SvDeleteStream(lstream[playerid]);
        lstream[playerid] = SV_NULL;
    }
    // remove radio stream
    new fid = player_frequency[playerid];
    if (rstream[fid])
    {
        SvDeleteStream(rstream[fid]);
        rstream[fid] = SV_NULL;
    }
    // remove global stream (tá certo isso aqui? n tinha)
    if (gstream)
    {
        SvDeleteStream(gstream);
        gstream = SV_NULL;
    }
}


// samp_voice 6
public OnGameModeInit()
{
    // Uncomment the line to enable debug mode
    // SvDebug(SV_TRUE);

    gstream = SvCreateGStream(0xffff0000, "Global");
}


// samp_voice 7
public OnGameModeExit()
{
    if (gstream) SvDeleteStream(gstream);
}


// samp_voice 8
CMD:frequencia(playerid, params[]) {
    if(admin[playerid] < 6) return 0;
    new fid, string[80];
    if(sscanf(params,"i", fid)) return SendClientMessage(playerid, -1, "Use: /frequencia [id]");
    format(string, sizeof(string), "AdmCmd: %s voice frequency %s.", PlayerName(playerid), fid );
    ABroadCast(COLOR_LIGHTRED, string, 6);
    mission[id] = mid;
    return 1;
}

Tu consegue me dizer como fazer?


RE: Voice SAMP - xbruno1000x - 03/02/2021

Código:
if(Player estiver em tal FREQUENCIA)
{
   SvAttachListenerToStream(Var's)
}

Já tentou assim?


RE: Voice SAMP - robertjwx - 19/02/2021

Eu tentei esse código:
Código:
// samp_voice 1
#include <sampvoice>

// samp_voice 2
new SV_GSTREAM:gstream = SV_NULL;
new SV_LSTREAM:lstream[MAX_PLAYERS] = { SV_NULL, ... };

#define MAX_RADIOS 999999
new player_frequency[MAX_PLAYERS];
new SV_GSTREAM:rstream[MAX_RADIOS] = { SV_NULL, ... };


// samp_voice 3
/*
    The public OnPlayerActivationKeyPress and OnPlayerActivationKeyRelease
    are needed in order to redirect the player's audio traffic to the
    corresponding streams when the corresponding keys are pressed.
*/
public SV_VOID:OnPlayerActivationKeyPress(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if(keyid == 0x58 && rstream[fid])
    {
        SvAttachSpeakerToStream(rstream[fid], playerid);
    }
    // Attach player to local stream as speaker if 'Z' key is pressed
    else if (keyid == 0x5A && lstream[playerid])
    {
        SvAttachSpeakerToStream(lstream[playerid], playerid);
    }
    // Attach the player to the global stream as a speaker if the 'B' key is pressed
    else if (keyid == 0x42 && gstream)
    {
        SvAttachSpeakerToStream(gstream, playerid);
    }
}
public SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid, SV_UINT:keyid)
{
    // 'X' - https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
    new fid = player_frequency[playerid];
    if (keyid == 0x58 && rstream[fid])
    {
        SvDetachSpeakerFromStream(rstream[fid], playerid);
    }
    // Detach the player from the local stream if the 'Z' key is released
    else if (keyid == 0x5A && lstream[playerid])
    {
        SvDetachSpeakerFromStream(lstream[playerid], playerid);
    }
    // Detach the player from the global stream if the 'B' key is released
    else if(admin[playerid] >= 2 && keyid == 0x42 && gstream)
    {
        SvDetachSpeakerFromStream(gstream, playerid);
    }
}








// samp_voice 4
public OnPlayerConnect(playerid)
{
    // Checking for plugin availability
    if (SvGetVersion(playerid) == SV_NULL)
    {
        SendClientMessage(playerid, -1, "Could not find plugin sampvoice.");
    }
    // Checking for a microphone
    else if (SvHasMicro(playerid) == SV_FALSE)
    {
        SendClientMessage(playerid, -1, "The microphone could not be found.");
    }
    // Create a local stream with an audibility distance of 40.0, an unlimited number of listeners
    // and the name 'Local' (the name 'Local' will be displayed in red in the players' speakerlist)
    else if ((lstream[playerid] = SvCreateDLStreamAtPlayer(40.0, SV_INFINITY, playerid, 0xff0000ff, "Local")))
    {
        SendClientMessage(playerid, -1, "Press X to talk to radio chat and Z to talk to local chat.");
        if(admin[playerid] >= 2) {
            SendClientMessage(playerid, -1, "Press B to talk to global.");
        }

        // Attach the player to the global stream as a listener
        if (gstream) SvAttachListenerToStream(gstream, playerid);

        // listener radio
        if (lstream[playerid])
        {
           SvAttachListenerToStream(lstream[playerid], playerid)
        }

        // Assign microphone activation keys to the player
        SvAddKey(playerid, 0x42); // [B] global
        SvAddKey(playerid, 0x5A); // [Z] local
        SvAddKey(playerid, 0x58); // [X] radio
    }
}

// samp_voice 5
public OnPlayerDisconnect(playerid, reason)
{
    // Removing the player's local stream after disconnecting
    if (lstream[playerid])
    {
        SvDeleteStream(lstream[playerid]);
        lstream[playerid] = SV_NULL;
    }
    // remove radio stream
    new fid = player_frequency[playerid];
    if (rstream[fid])
    {
        SvDeleteStream(rstream[fid]);
        rstream[fid] = SV_NULL;
    }
    // remove global stream (tá certo isso aqui? n tinha)
    if (gstream)
    {
        SvDeleteStream(gstream);
        gstream = SV_NULL;
    }
}


// samp_voice 6
public OnGameModeInit()
{
    // samp_voice 6
    // Uncomment the line to enable debug mode
    // SvDebug(SV_TRUE);
    gstream = SvCreateGStream(0xffff0000, "Global");
}


// samp_voice 7
public OnGameModeExit()
{
    if (gstream) SvDeleteStream(gstream);
}


// samp_voice 8
CMD:frequencia(playerid, params[]) {
    if(admin[playerid] < 6) return 0;
    new fid, string[80];
    if(sscanf(params,"i", fid)) return SendClientMessage(playerid, -1, "Use: /frequencia [id]");
    format(string, sizeof(string), "AdmCmd: %s voice frequency %s.", PlayerName(playerid), fid );
    ABroadCast(COLOR_LIGHTRED, string, 6);
    player_frequency[playerid] = fid;
    return 1;
}

Compilou certinho, aí eu adicionei o plugin no server.cfg:
Código:
plugins crashdetect.so mysql.so sscanf.so YSF.so streamer.so pawnraknet.so sampvoice.so

Aí quando eu fui iniciar o servidor, não abre mais...

./samp03svr
Código:
[log-core] fatal signal '11' (SIGSEGV) catched  

Segmentation fault



RE: Voice SAMP - xbruno1000x - 19/02/2021

VOICE Global não pode ser apagado na OnPlayerDisconnect. Você mexe nele na OnGameModeInit e na OnGameModeExit.