DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
PlayerBaseClient.c
Go to the documentation of this file.
2{
4 static bool m_PersonalLightEnabledOnCurrentServer = false; // "disablePersonalLight" in server.cfg decides if this is true or false
5 static bool m_PersonalLightDisabledByDebug = false;
6 static bool m_PersonalLightIsSwitchedOn = true;
7
9 static void CreatePersonalLight()
10 {
11 if (!m_PersonalLight && ( !GetGame().IsServer() || !GetGame().IsMultiplayer() ))
12 {
13 m_PersonalLight = ScriptedLightBase.CreateLight(PersonalLight, "0 0 0");
14 }
15 }
16
17 /*
18 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
19 {
20 super.OnRPC(sender, rpc_type, ctx);
21
22 switch( rpc_type )
23 {
24 case ERPCs.RPC_TOGGLE_PERSONAL_LIGHT:
25 {
26 Param1<bool> is_enabled = new Param1<bool>(false);
27
28 if (ctx.Read(is_enabled))
29 {
30 m_PersonalLightEnabledOnCurrentServer = is_enabled.param1;
31 UpdatePersonalLight();
32 }
33
34 break;
35 }
36 }
37 }*/
38
40 {
41 super.OnGameplayDataHandlerSync();
42 m_PersonalLightEnabledOnCurrentServer = !CfgGameplayHandler.GetDisablePersonalLight();
43 UpdatePersonalLight();
44 UpdateHitDirectionValues();
45 }
46
47
49 static void SwitchPersonalLight(bool state)
50 {
51 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
52 {
53 m_PersonalLightIsSwitchedOn = state;
54 UpdatePersonalLight();
55 }
56 }
57
59 static void UpdatePersonalLight()
60 {
61 string param;
62
63 CreatePersonalLight();
64
65 // Allow PL unless it's disabled by debug or client-side starting parameter
66 if ( !GetCLIParam("disablePersonalLight", param) && !m_PersonalLightDisabledByDebug && m_PersonalLightIsSwitchedOn )
67 {
68 m_PersonalLight.SetEnabled(m_PersonalLightEnabledOnCurrentServer);
69 }
70 else
71 {
72 m_PersonalLight.SetEnabled(false);
73 }
74 }
75
77 {
79 }
80}
static bool GetDisablePersonalLight()
static void CheckValues()
range 0..180, randomized offset of direction to make it less acurate
static void UpdateHitDirectionValues()
static void SwitchPersonalLight(bool state)
Controls the ON/OFF switch of the Personal Light. PL will still shine only if the server allows it.
static void UpdatePersonalLight()
Updates state of PL.
static void CreatePersonalLight()
Creates PL if it doesn't exist already.
static ScriptedLightBase m_PersonalLight
override void OnGameplayDataHandlerSync()
proto native CGame GetGame()
proto bool GetCLIParam(string param, out string val)
Returns command line argument.