open.mp forum
[Plugin] samp voice frequency - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Plugin] samp voice frequency (/showthread.php?tid=2295)



samp voice frequency - hiwyn - 2022-05-18

I tried but fail to put radio frequencies on samp voice...

2 problems:

1- you can hear and talk to everyone in any frequency, i mean you are in 3000, you can talk to people on 5000
2- server crashes a while after people use this

What i'm doing wrong?

global
Code:
#define MAX_RADIOS 9999 forward ConnectRadioVoice(playerid); forward DisconnectRadioVoice(playerid); new SV_GSTREAM:StreamFreq[MAX_RADIOS] = SV_NULL; new players_in_radiofrequency[MAX_RADIOS];

OnPlayerActivationKeyPress
Code:
// radio voice if(radio_frequency[playerid] == 0) { SvAttachSpeakerToStream(StreamFreq[radio_frequency[playerid]], playerid); } // voice local else { SvAttachSpeakerToStream(lstream[playerid], playerid); }

OnPlayerActivationKeyRelease
Code:
// 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 local stream if the 'B' key is released if (keyid == 0x42 && StreamFreq[radio_frequency[playerid]]) { SvDetachSpeakerFromStream(StreamFreq[radio_frequency[playerid]], playerid); }

functions from command
Code:
public ConnectRadioVoice(playerid) { new rfid = radio_frequency[playerid]; if(StreamFreq[rfid] == SV_NULL) { new string[128]; format(string, sizeof(string), "Radio %i", rfid); StreamFreq[rfid] = SvCreateGStream(0xFF00FFFF, string); SvAttachListenerToStream(StreamFreq[rfid], playerid); } else { SvAttachListenerToStream(StreamFreq[rfid], playerid); } players_in_radiofrequency[rfid] = 1; return 1; } public DisconnectRadioVoice(playerid) { new rfid = radio_frequency[playerid]; players_in_radiofrequency[rfid] -= 1; if(players_in_radiofrequency[rfid] <= 0) { StreamFreq[rfid] = SV_NULL; } return 1; }

command
Code:
CMD:radio(playerid, params[]) { new frequency_id; if(sscanf(params,"i", frequency_id)) return SendClientMessage(playerid, -1, "Use: /testid [id]"); if(frequency_id > MAX_RADIOS || frequency_id < 1) return SendClientMessage(playerid, -1, "O numero deve ser entre 1 e MAX_RADIOS"); radio_frequency[playerid] = frequency_id; if(frequency_id == 0) DisconnectRadioVoice(playerid); else ConnectRadioVoice(playerid); return 1; }



RE: samp voice frequency - hiwyn - 2022-06-11

bump!!!


RE: samp voice frequency - Markski - 2022-06-11

new SV_GSTREAM:StreamFreq[MAX_RADIOS] = SV_NULL;



I'm wondering if this is a correct way to initialize the value for all the slots in an array. This might have to do with your issue if not...