Author Topic: Radio Mod  (Read 1138 times)

I know theres one i was at a server and it had this add on and it had an OnplayerTalk
and something
and it did this
[123.12 Test FM]:HELLO this is a test
If you have it Please give it to me


Variables my friend dude.

no need for this as talking is server wide, unless you take that out and make radio bricks with a radius, which has been done before

no need for this as talking is server wide, unless you take that out and make radio bricks with a radius, which has been done before
Will the server i been to that had this mod was server wide


Can someone lest tell me how to get it or make it

I know several people made these including myself.

Code: [Select]


//Radio system
$Rky_radio=1;
$Rky_radiodist=30;
$Rky_radiosh=1;

registerOutputEvent("GameConnection", "OnRadio", "", 0);

function GameConnection::OnRadio(%client){
%client.onradio=1;
%client.usebroadcastname=0;
}

registerOutputEvent("GameConnection", "OnReceiver", "", 0);

function GameConnection::OnReceiver(%client){
%client.onrec=1;
}

registerOutputEvent("GameConnection", "RadioBroadcastName", "string 32 100", 0);

function GameConnection::RadioBroadcastName(%client,%name){
%client.broadcastname=%name;
}

registerOutputEvent("GameConnection", "OnRadioBroadcast", "", 0);

function GameConnection::OnRadioBroadcast(%client){
%client.usebroadcastname=1;
%client.onradio=1;
}

registerOutputEvent("GameConnection", "RadioAutoBroadcast", "string 32 100" TAB "string 64 300" TAB "string 64 300", 0);

function GameConnection::RadioAutoBroadcast(%client,%name,%text,%text2){
%client.broadcastname=%name;
%client.usebroadcastname=1;
%client.onradio=1;
servercmdmessagesent(%client,%text SPC %text2);

}

registerOutputEvent(fxDTSBrick, "setAtenna", "",1);

function fxDtsBrick::SetAntenna(%player,%client)
{
%client.radioantenpos=%player.getposition();
%client.radioantenna=1;
}

function servercmdsquelch(%client){
%client.squelch++;
if(%client.squelch>1){
%client.squelch=0;
messageclient(%client,'',"Squelch off.");
}else{
messageclient(%client,'',"Squelch on.");
}
}


function strRandomize(%string,%amount)
{
%charList = "abcdefghijklmnopqrstuvwxyz";
%numList = "123456789";
if(%amount >= 1 && strLen(%string) >= %amount)
{
for(%i=0;%i<=%amount;%i++)
{
echo(%i);
if(%i == 0)
{
%i = 1;
}
//Pick random character in string to replace
%replaceChar = getRandom(1,strLen(%string));
if($rky_radioSH){
%amountofsht=getrandom(2,5);
%shtstring = "SCHTSTHT";
%shtmes = getsubstr(%shtstring,0,%amountofsht);
%string = strReplace(%string,%string,getSubStr(%string,0,%replaceChar-1) @ "\c0" @ %shtmes @ "\c6" @ getSubStr(%string,%replaceChar+%amountofsht-getrandom(1,%amountofsht),strlen(%string)-%replaceChar));
}else{
%chance = getRandom(1,2);
switch(%chance)
{
case 1:
//Letters
%string = strReplace(%string,%string,getSubStr(%string,0,%replaceChar-1) @ getSubStr(%charList,getRandom(0,strLen(%charList)-1),1) @ getSubStr(%string,%replaceChar,strlen(%string)-%replaceChar));
case 2:
//Numbers
%string = strReplace(%string,%string,getSubStr(%string,0,%replaceChar-1) @ getSubStr(%numList,getRandom(0,strLen(%numList)-1),1) @ getSubStr(%string,%replaceChar,strlen(%string)-%replaceChar));
}
}
}
}
return %string;
}



//following is untested
package radiotest
{
function serverCmdMessageSent(%client, %text){
if($Rky_radio && !%client.onradio && isobject(%client.player)){
%t2=%client.clanprefix;
%t3=%client.name;
%t4=%client.clansuffix;
%position=getwords(%client.player.gettransform(),0,2);
InitContainerRadiusSearch(%position,$Rky_radiodist,$TypeMasks::PlayerObjectType);
while((%targetObject=containerSearchNext()) !$= 0)
{
%crlient=%targetObject.client;
if(%crlient !=%client && !%targetobject.ismonster && isobject(%crlient)){
%dist = vectordist(%crlient.player.getposition(),%position);
%average+=%dist;
%averagecount++;
%shtamount=0;
if(%dist>20){
%shtamount=getrandom(0,1);
if(strlen(%text) > 50){
%shtamount=getrandom(0,2);
}
}
if(%crlient.onrec){
%shtamount=0;
%crlient.onrec--;
}
messageClient(%crlient,'',"\c2[" @ mceil(%dist) @ "]\c7"@%t2@"\c3"@%t3@"\c7"@%t4@"\c6:<"@$serverfont@">\c6"@strrandomize(%text,%shtamount));
}
}
%av=%average/%averagecount;
messageClient(%client,'',"\c0[" @ mceil(%av) @ ":" @ %averagecount @ "]\c7"@%t2@"\c3"@%t3@"\c7"@%t4@"\c6:<"@$serverfont@">\c6"@%text);
return;
}else if(isobject(%client.player) && $Rky_radio){
%client.onradio--;
%t2=%client.clanprefix;
%t3=%client.name;
%t4=%client.clansuffix;
if(%client.usebroadcastname){
%t2="";
%t4="";
%t3=%client.broadcastname;
}
%position=getwords(%client.player.gettransform(),0,2);
echo(%client SPC "test");
for(%i=0;%i<ClientGroup.getCount();%i++){
%nogo=0;
%crlient = ClientGroup.getObject(%i);
if(%crlient !=%client){
%dist = vectordist(%crlient.player.getposition(),%position);
if(%client.radioatenna){
%dist = vectordist(%crlient.player.getposition(),%client.radioantenpos);
%client.maxraddist=300;
}else{
%client.maxraddist=700;
}
%average+=%dist;
%averagecount++;
if(%dist>30){
%shtamount=getrandom(0,2);
if(%shtamount >= 1){
%shtamount -= 1;
}
}
if(%dist>90){
%shtamount=getrandom(0,1);
if(strlen(%text) > 70){
%shtamount=getrandom(0,2);
}
}
if(%dist>200){
%shtamount=getrandom(0,2);
if(strlen(%text) > 70){
%shtamount=getrandom(0,3);
}
}
if(!%client.maxraddist){
%client.maxraddist=700;
}
if(%dist > %client.maxraddist){
%nogo=1;
}

if(%crlient.onrec){
%shtamount--;
%crlient.onrec--;
}
if(!%crlient.squelch || %dist < 50){
if(!%nogo){
messageClient(%crlient,'',"\c1[" @ mceil(%dist) @ "]\c7"@%t2@"\c3"@%t3@"\c7"@%t4@"\c6:<"@$serverfont@">\c6"@strrandomize(%text,%shtamount));}}
}
}
%av=%average/%averagecount;
echo(%av SPC "test");
messageClient(%client,'',"\c1[" @ mceil(%av) @ ":" @ %averagecount @ "]\c7"@%t2@"\c3"@%t3@"\c7"@%t4@"\c6:<"@$serverfont@">\c6"@%text);
return;
}

echo("test32");
if(!%client.global){
if(%client.hasothername){
announce("\c7" @ %client.clantagfake1 @ "\c3" @ %client.othername @ "\c7" @ %client.clantagfake2 @ "\c6:" SPC "<" @ $serverfont @ ">\c6" @ %text);
}else{
chatmessageall(%client,'\c7%2\c3%3\c7%4\c6: %1',"<"@$serverfont@">\c6"@%text,%client.clanprefix,%client.name,%client.clansuffix);
}
}

else{
%t2=%client.clanprefix;
%t3=%client.name;
%t4=%client.clansuffix;
%position=%client.player.position;
InitContainerRadiusSearch(%position,20,$TypeMasks::PlayerObjectType);
while((%targetObject=containerSearchNext()) !$= 0)
{
%crlient=%targetObject.client;
messageClient(%crlient,'',"\c7"@%t2@"\c2"@%t3@"\c7"@%t4@"\c6:<"@$serverfont@">\c2"@%text);
}
}
}
};
activatepackage(radiotest);

That's the gist of it, there are probably issues but
A) its too late for me to fix them right now and
B) Someone else probably will fix them or call me stupid (both?)

There are issues because I had to pull the messagesent part out of a larger script and I haven't tested it in this format.

-code snip-
That's the gist of it, there are probably issues but
A) its too late for me to fix them right now and
B) Someone else probably will fix them or call me stupid (both?)

There are issues because I had to pull the messagesent part out of a larger script and I haven't tested it in this format.
you're stupid, lemme fix
Code: [Select]
//do radio stuff please!hope that solves your problems!
/sarcasm

I know several people made these including myself.


That's the gist of it, there are probably issues but
A) its too late for me to fix them right now and
B) Someone else probably will fix them or call me stupid (both?)

There are issues because I had to pull the messagesent part out of a larger script and I haven't tested it in this format.
thanks for the code ill look into how to pack this code up