Portal SAMP
[Ajuda] Como colocar voip no servidor? - 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] Como colocar voip no servidor? (/showthread.php?tid=3915)



Como colocar voip no servidor? - Mist - 21/08/2023

queria coloca voip no meu serve eu uso desse geito mais ngm me escuta alguem consegue me ajuda ?

Código PHP:
public OnGameModeInit()
{
    gstream SvCreateGStream(0xffff0000"G"); // blue color
    return 1;
}

public 
OnPlayerConnect(playerid)
{

    if(!SvGetVersion(playerid))
    {
        SendClientMessage(playerid, -1"{0390fc}[ERP]{FFFFFF} Voce foi indenficado como um cliente com VOIP pressione 'B' para falar!");
    }
    else if(!SvHasMicro(playerid))
    {
         SendClientMessage(playerid, -1"{0390fc}[ERP]{FFFFFF} Seu microfone não foi encontrado");
    }
    else
    {
        lstream[playerid] = SvCreateDLStreamAtPlayer(30.0SV_INFINITYplayerid0xff0000ff"L");
        SendClientMessage(playerid, -1"{0390fc}[ERP]{FFFFFF} Voce foi indenficado como um cliente com VOIP pressione 'B' para falar!");
        if (gstreamSvAttachListenerToStream(gstreamplayerid);
        SvAddKey(playerid0x42);//Z
        //SvAddKey(playerid, 0x5A);//B
    }
    return 1;
}

public 
SV_VOID:OnPlayerActivationKeyPress(SV_UINT:playeridSV_UINT:keyid)
{
    if(keyid == 0x42 && lstream[playerid])
    {
        SvAttachSpeakerToStream(lstream[playerid], playerid); //local
    }
    return 1;
}

public 
SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid,SV_UINT:keyid)
{
    if(keyid == 0x42 && lstream[playerid])
    {
        SvDetachSpeakerFromStream(lstream[playerid], playerid);
    }


dc: bear.martins


RE: Como colocar voip no servidor? - White_Blue - 21/08/2023

Preste atenção ao título do tópico, não coloque "Help me" ao invés disso, coloque um título auto explicativo de acordo com o conteúdo do tópico, e sempre que for colocar código no tópico, não coloque de qualquer jeito, coloque dentro de um bloco de código PHP, pois assim facilita a leitura do mesmo.

Leia as instruções de uso contidas no tópico do Github do SA-MP Voice: https://github.com/CyberMor/sampvoice

Exemplo contido no repositório:

Código PHP:
#include <sampvoice>

#define GLOBAL_CHANNEL 0
#define  LOCAL_CHANNEL 1

new SV_UINT:gstream SV_NONE;
new 
SV_UINT:lstream[MAX_PLAYERS] = { SV_NONE, ... };

public 
OnPlayerConnect(playerid)
{
    if (
SvGetVersion(playerid) == 0// Checking for plugin availability
    
{
        
SendClientMessage(playerid, -1"Failed to find plugin.");
    }
    else if (
SvHasMicro(playerid) == SV_FALSE// Checking for microphone availability
    
{
        
SendClientMessage(playerid, -1"Failed to find microphone.");
    }
    else
    {
        if (
gstream != SV_NONE)
        {
            
SvSetKey(playerid0x5AGLOBAL_CHANNEL); // Z key
            
SvAttachStream(playeridgstreamGLOBAL_CHANNEL);
            
SvAttachListener(gstreamplayerid);
            
SvSetIcon(gstream"speaker");

            
SendClientMessage(playerid, -1"Press Z to talk to global chat.");
        }
        if ((
lstream[playerid] = SvCreateStream(40.0)) != SV_NONE)
        {
            
SvSetKey(playerid0x42LOCAL_CHANNEL); // B key
            
SvAttachStream(playeridlstream[playerid], LOCAL_CHANNEL);
            
SvSetTarget(lstream[playerid], SvMakePlayer(playerid));
            
SvSetIcon(lstream[playerid], "speaker");

            
SendClientMessage(playerid, -1"Press B to talk to local chat.");
        }
    }
}

public 
OnPlayerDisconnect(playeridreason)
{
    
// Removing the player's local stream after disconnecting
    
if (lstream[playerid] != SV_NONE)
    {
        
SvDeleteStream(lstream[playerid]);
        
lstream[playerid] = SV_NONE;
    }
}

public 
OnGameModeInit()
{
    
// Uncomment the line to enable debug mode
    // SvEnableDebug();

    
gstream SvCreateStream();
}

public 
OnGameModeExit()
{
    if (
gstream != SV_NONE)
    {
        
SvDeleteStream(gstream);
        
gstream SV_NONE;
    }