I am trying to make a Radio thing for Survival RP, but right now I've hit a snag. I use this part to search for other radios, and then the radios found search their radius for people to message with the original message from the source radio. Right now, it only messages the source radio with it's own message. I'm thinking this problem has something to do with the while loops not being closed before the next. But if I close them, it won't work properly. Or will it? Yeah, it doesn't work if I close them. How could I make this work?
if(strstr(%text, ", over") > -1)//This checks to see if it's actually in the sentence
{ //^That makes it so I don't get errors saying there's a -1 starting point
if(getSubStr(%text, strlen(%text) - strlen(", over"), strlen(%text)) $= ", over")
{
//echo("This part worked");
InitContainerRadiusSearch(%speakerpos,$Survival::ChatRange, $TypeMasks::FxBrickAlwaysObjectType);
while((%radio = ContainerSearchNext()) != 0)
{
if(%radio.getDatablock().getName() $= "RadioBrick" && isObject(%radio.attachment))
{
%Radiopos = %radio.getTransform();
RadioSearch(%RadioPos,%CPrefix,%CName,%CSuffix,%text);
}
}
}
}
}
}
And the functions that go with it:
//These are some functions for the search
function RadioSearch(%Pos,%CPrefix,%CName,%CSuffix,%text)
{
InitContainerRadiusSearch(%Pos, $Survival::RadioRange, $TypeMasks::FxBrickAlwaysObjectType);
while((%oRadio = ContainerSearchNext()) != 0)
{
if(%oRadio.getDatablock().getName() $= "RadioBrick" && isObject(%oRadio.attachment))
{
%oRadioPos = %oRadio.getTransform();
RadioPSearch(%oRadioPos,%CPrefix,%CName,%CSuffix,%text);
}
}
}
function RadioPSearch(%Pos,%CPrefix,%Cname,%CSuffix,%text)
{
InitContainerRadiusSearch(%Pos, $Survival::ChatRange, $TypeMasks::PlayerObjectType);
while((%RListener = ContainerSearchNext()) != 0)
{
messageClient(%RListener.client,"","\c5[Local] \c7"@ %Cprefix @"\c3"@ %Cname @"\c7"@ %Csuffix @"\c6: "@ %text);
}
}
I don't know why this doesn't work, please help.