01/12/2022 18:24 
	
	
	
		Eu tentei de diversas formas, pedi ajuda pra corrigir minhas tentativas, mas nunca consegui, sempre crasha o servidor ou da algum problema parecido...
Muita gente do servidor sente falta de um radio com voice e frequencia pra não precisar ficar rodando discord e samp (economizando bateria e fps)
Alguém aqui no fórum consegue fazer isso funcionar?
Seria de ótimo uso pra praticamente todos os servidores...
Pra tentar ajudar eu tirei o voice como um filterscript, alguém consegue fazer um comando
/radio 1-9999 pra galera se conectar em frequencias e conversar com voice?
	
	
	
	
Muita gente do servidor sente falta de um radio com voice e frequencia pra não precisar ficar rodando discord e samp (economizando bateria e fps)
Alguém aqui no fórum consegue fazer isso funcionar?
Seria de ótimo uso pra praticamente todos os servidores...
Pra tentar ajudar eu tirei o voice como um filterscript, alguém consegue fazer um comando
/radio 1-9999 pra galera se conectar em frequencias e conversar com voice?
Código:
#include <a_samp>
#include <sampvoice>
#include <sscanf2>
#include <zcmd>
// global chat adm 1
new SV_GSTREAM:gstream = SV_NULL;
// local chat player 1
new SV_LSTREAM:lstream[MAX_PLAYERS] = { SV_NULL, ... };
// GM 1
// new GetPVarInt(playerid,"hasVoiceOnClient")
// 0 = sem voice, 1 = com voice, 2 = com voice, sem mic
// GM 2
// GetPVarInt(playerid,"admin")
// pra dizer se é admin
public SV_VOID:OnPlayerActivationKeyPress(SV_UINT:playerid, SV_UINT:keyid) 
{
    // Press 'B'
    if (keyid == 0x42) {
        // local chat player 2
        if(lstream[playerid]) SvAttachSpeakerToStream(lstream[playerid], playerid);
    }
    // Press 'Z' (admins)
    if(GetPVarInt(playerid,"admin") >= 6) {
        if (keyid == 0x5A && gstream) SvAttachSpeakerToStream(gstream, playerid);
    }
}
public SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid, SV_UINT:keyid)
{
    // Release 'B'
    if (keyid == 0x42) {
        if(lstream[playerid]) SvDetachSpeakerFromStream(lstream[playerid], playerid);
    }
    // Release 'Z'
    if (keyid == 0x5A) {
        if(gstream) SvDetachSpeakerFromStream(gstream, playerid);
    }
}
public OnPlayerConnect(playerid) {
    // Checking for plugin availability
    if (SvGetVersion(playerid) == SV_NULL)
    {
        // Could not find plugin sampvoice.
        SetPVarInt(playerid,"hasVoiceOnClient",0);
    }
    // Checking for a microphone
    else if (SvHasMicro(playerid) == SV_FALSE)
    {
        // The microphone could not be found.
        SetPVarInt(playerid,"hasVoiceOnClient",2);
    }
    // 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")))
    {
        // Attach the player to the global stream as a listener
        if (gstream) SvAttachListenerToStream(gstream, playerid);
        // Assign microphone activation keys to the player
        SvAddKey(playerid, 0x42);
        SvAddKey(playerid, 0x5A);
        // 
        SetPVarInt(playerid,"hasVoiceOnClient",1);
    }
}
public OnPlayerDisconnect(playerid, reason) {
    // Removing the player's local stream after disconnecting
    if (lstream[playerid])
    {
        SvDeleteStream(lstream[playerid]);
        lstream[playerid] = SV_NULL;
    }
}
public OnFilterScriptInit() {
    // samp voice 5
    gstream = SvCreateGStream(0xffff0000, "Global");
}
public OnFilterScriptExit() {
    // samp voice 6
    if (gstream) SvDeleteStream(gstream);
}
CMD:radio(playerid, params[])
{
  new string[255], frequency_id;
  if(sscanf(params, "d", frequency_id))
  {
    SendClientMessage(playerid, -1, "[RADIO] Utilize /radio [1 a 9999] para alterar o canal da frequencia");
    SendClientMessage(playerid, -1, "[RADIO] Utilize /radio 0 para desligar o radio");
    return true;
  }
  return 1;
}