I want to check when someone tries toggling a switch, and only allow it if their user id is in a list. Is there a way to do this, perhaps intercepting RpcMessages?
Making ElectricSwitch usable by only certain players?
In response to Zugzwang ():I want to check when someone tries toggling a switch, and only allow it if their user id is in a lis...
I've tryed intercepting RPCs for many things, but had no success (maybe just a lack of knowledge on my side). Also Wulf doesn't answer when I asked him if it's possible.
Upd. The most obvious way to do that - find specific object and check every second if its toggled.
Upd. The most obvious way to do that - find specific object and check every second if its toggled.
Checking its status won't tell me if the person who flipped it was allowed or not.
That sounds really cpu intensive. For now I'm just going to set up a special CodeLock that operates the system when certain command codes are entered into it. It's too bad, I liked the look of the ElectricSwitch. Maybe I'll revisit the issue if we get some electricity hooks in the future.
You can use "CanNetworkTo"
I can't seem to get CanNetworkTo to trigger on my switches. Am I missing something obvious?
I spawn the switch, add my SwitchController MonoBehaviour to it, but get no output at all from this CanNetworkTo.
bool CanNetworkTo(BaseNetworkable entity, BasePlayer target)
{
//Puts("CanNetworkTo works!");
//return true;
if (entity is ElectricSwitch)
{
Puts("can network to ElectricSwitch ?");
SwitchController sc = entity.GetComponent<SwitchController>();
if (sc != null)
{
Puts("found switch controller");
return false;
}
}
return true;
}I spawn the switch, add my SwitchController MonoBehaviour to it, but get no output at all from this CanNetworkTo.