Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
writtennotedata.c
Go to the documentation of this file.
1
class
WrittenNoteData
2
{
3
protected
ItemBase
m_WritingImplement
;
4
protected
ItemBase
m_Paper
;
5
//protected int m_Handwriting = -1;
6
protected
string
m_SimpleText
;
7
8
void
WrittenNoteData
(
ItemBase
parent)
9
{
10
11
}
12
13
void
OnRPC
(
PlayerIdentity
sender,
int
rpc_type,
ParamsReadContext
ctx)
14
{
15
Param1<string> param =
new
Param1<string>(
""
);
16
17
//sent from server, executed on client
18
if
(rpc_type ==
ERPCs
.RPC_WRITE_NOTE)
19
{
20
if
(ctx.
Read
(param))
21
{
22
SetNoteText
(param.param1);
23
}
24
25
g_Game
.GetMission().SetNoteMenu(
g_Game
.GetUIManager().EnterScriptedMenu(
MENU_NOTE
,
g_Game
.GetUIManager().GetMenu()));
//NULL means no parent
26
27
ItemBase
pen;
28
ItemBase
paper;
29
//int handwriting;
30
31
if
(
GetNoteInfo
(pen,paper))
32
{
33
g_Game
.GetMission().GetNoteMenu().InitNoteWrite(paper,pen,
m_SimpleText
);
34
}
35
}
36
//sent from client (NoteMenu), executed on server
37
if
(rpc_type ==
ERPCs
.RPC_WRITE_NOTE_CLIENT)
38
{
39
if
(ctx.
Read
(param))
40
{
41
string
old_string =
m_SimpleText
;
42
SetNoteText
(param.param1);
43
DepleteWritingImplement
(
m_WritingImplement
,old_string,
m_SimpleText
);
44
}
45
}
46
if
(rpc_type ==
ERPCs
.RPC_READ_NOTE)
47
{
48
if
(ctx.
Read
(param))
49
{
50
SetNoteText
(param.param1);
51
}
52
53
g_Game
.GetMission().SetNoteMenu(
g_Game
.GetUIManager().EnterScriptedMenu(
MENU_NOTE
,
g_Game
.GetUIManager().GetMenu()));
//NULL means no parent
54
g_Game
.GetMission().GetNoteMenu().InitNoteRead(
m_SimpleText
);
55
}
56
}
57
58
void
InitNoteInfo
(
ItemBase
pen = null,
ItemBase
paper = null)
59
{
60
m_WritingImplement
= pen;
61
m_Paper
= paper;
62
//m_Handwriting = handwriting;
63
}
64
65
bool
GetNoteInfo
(out
ItemBase
pen, out
ItemBase
paper)
66
{
67
pen =
m_WritingImplement
;
68
paper =
m_Paper
;
69
//handwriting = m_Handwriting;
70
return
pen && paper;
71
}
72
73
string
GetNoteText
()
74
{
75
return
m_SimpleText
;
76
}
77
78
void
SetNoteText
(
string
text)
79
{
80
m_SimpleText
= MiscGameplayFunctions.SanitizeString(text);
81
}
82
83
void
DepleteWritingImplement
(notnull
ItemBase
pen,
string
old_text,
string
new_text)
84
{
85
float
qty_per_char = 1.0;
86
float
decrease =
Math
.
Clamp
((new_text.
Length
() - old_text.
Length
()),0,pen.GetQuantityMax());
87
pen.AddQuantity(-(qty_per_char * decrease));
88
}
89
}
90
91
//-----------------------
ItemBase
Definition
inventoryitem.c:742
Math
Definition
enmath.c:7
PlayerIdentity
The class that will be instanced (moddable).
Definition
gameplay.c:389
Serializer::Read
proto bool Read(void value_in)
WrittenNoteData::OnRPC
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Definition
writtennotedata.c:13
WrittenNoteData::InitNoteInfo
void InitNoteInfo(ItemBase pen=null, ItemBase paper=null)
Definition
writtennotedata.c:58
WrittenNoteData::m_WritingImplement
ItemBase m_WritingImplement
Definition
writtennotedata.c:3
WrittenNoteData::m_SimpleText
string m_SimpleText
Definition
writtennotedata.c:6
WrittenNoteData::DepleteWritingImplement
void DepleteWritingImplement(notnull ItemBase pen, string old_text, string new_text)
Definition
writtennotedata.c:83
WrittenNoteData::m_Paper
ItemBase m_Paper
Definition
writtennotedata.c:4
WrittenNoteData::GetNoteText
string GetNoteText()
Definition
writtennotedata.c:73
WrittenNoteData::WrittenNoteData
void WrittenNoteData(ItemBase parent)
Definition
writtennotedata.c:8
WrittenNoteData::SetNoteText
void SetNoteText(string text)
Definition
writtennotedata.c:78
WrittenNoteData::GetNoteInfo
bool GetNoteInfo(out ItemBase pen, out ItemBase paper)
Definition
writtennotedata.c:65
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ERPCs
ERPCs
Definition
erpcs.c:2
ParamsReadContext
Serializer ParamsReadContext
Definition
gameplay.c:15
Math::Clamp
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
MENU_NOTE
const int MENU_NOTE
Definition
constants.c:190
string::Length
proto native int Length()
Returns length of string.
Games
Dayz
scripts
4_world
classes
writtennotedata.c
Generated by
1.17.0