25/01/2021 17:46
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:
alguém pode me ajudar a terminar a parte que eu não sei e me dizer se to fazendo algo errado?
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?