19/02/2021 21:09
(Esta mensagem foi modificada pela última vez a: 19/02/2021 21:24 por robertjwx.)
(19/02/2021 19:05)xbruno1000x Escreveu:(19/02/2021 17:34)robertjwx Escreveu:(19/02/2021 10:13)xbruno1000x Escreveu: VOICE Global não pode ser apagado na OnPlayerDisconnect. Você mexe nele na OnGameModeInit e na OnGameModeExit.
Blz, troquei, agr deixei 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
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;
}
}
// 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;
}
mas o servidor continua não ligando:
cfg
Código:plugins crashdetect.so mysql.so sscanf.so YSF.so streamer.so pawnraknet.so sampvoice.so
cmd ./samp03svr
Código:[log-core] fatal signal '11' (SIGSEGV) catched
Segmentation fault
tem alguma ideia do que possa ser?
segfault são quase impossíveis de serem encontradas pelo que sei, recomendo utilizar um backup do gamemode, ou desfazer mudanças recentes.
eu só coloquei os códigos do voice que eu postei aqui e o plugin...
se eu tiro tudo isso volta a rodar...
dps sem tirar o voice, mas usando o código de exemplo da documentação:
Código:
#include <sampvoice>
new SV_GSTREAM:gstream = SV_NULL;
new SV_LSTREAM:lstream[MAX_PLAYERS] = { SV_NULL, ... };
/*
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)
{
// Attach player to local stream as speaker if 'B' key is pressed
if (keyid == 0x42 && lstream[playerid]) SvAttachSpeakerToStream(lstream[playerid], playerid);
// Attach the player to the global stream as a speaker if the 'Z' key is pressed
if (keyid == 0x5A && gstream) SvAttachSpeakerToStream(gstream, playerid);
}
public SV_VOID:OnPlayerActivationKeyRelease(SV_UINT:playerid, SV_UINT:keyid)
{
// Detach the player from the local stream if the 'B' key is released
if (keyid == 0x42 && lstream[playerid]) SvDetachSpeakerFromStream(lstream[playerid], playerid);
// Detach the player from the global stream if the 'Z' key is released
if (keyid == 0x5A && gstream) SvDetachSpeakerFromStream(gstream, playerid);
}
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 Z to talk to global chat and B to talk to local chat.");
// 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);
}
}
public OnPlayerDisconnect(playerid, reason)
{
// Removing the player's local stream after disconnecting
if (lstream[playerid])
{
SvDeleteStream(lstream[playerid]);
lstream[playerid] = SV_NULL;
}
}
public OnGameModeInit()
{
// Uncomment the line to enable debug mode
// SvDebug(SV_TRUE);
gstream = SvCreateGStream(0xffff0000, "Global");
}
public OnGameModeExit()
{
if (gstream) SvDeleteStream(gstream);
}
também não funcionou, será que eu to fazendo algo erado?