Server SIded mod toggling


#1

I am looking for a way to take the friendly fire function on the server side, and toggle it on and off.

How would I go about doing this? Is it even possible?

I would be using this code from another thread:

CLIENT (only if ScriptHookV is allowed by the server)

NETWORK::NETWORK_SET_FRIENDLY_FIRE_OPTION(true);
PED::SET_CAN_ATTACK_FRIENDLY(PLAYER::PLAYER_PED_ID(), true, true);

SERVER

local playerPed = GetPlayerPed(-1)
NetworkSetFriendlyFireOption(true)
SetCanAttackFriendly(playerPed, true, true)

ALSO, how would I go about doing this in C#?

Any and all help, is appreciated.


#2

If ScriptHook is disabled, or local mods don’t repeatedly change this flag, yes.

Use an event handler and pass a boolean around - true is enabled, false is disabled.

public class MyScript : BaseScript
{
	public MyScript()
	{
		EventHandlers["myScript:setFriendlyFire"] += new Action<bool>(enabled =>
		{
			Function.Call(Hash.NETWORK_SET_FRIENDLY_FIRE_OPTION, enabled);
			Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, LocalPlayer.Character, enabled, enabled);
		});
	}
}

Server:

TriggerClientEvent('myScript:setFriendlyFire', -1, false)

#3

Selenium, you are… the GREATEST!!

Thank you.