DayZ 1.24
Loading...
Searching...
No Matches
WrittenNoteData.c
Go to the documentation of this file.
2{
4 protected ItemBase m_Paper;
5 //protected int m_Handwriting = -1;
6 protected string m_SimpleText;
7
9 {
10
11 }
12
14 {
16
17 //sent from server, executed on client
18 if (rpc_type == ERPCs.RPC_WRITE_NOTE)
19 {
20 if (ctx.Read(param))
21 SetNoteText(param.param1);
22
23 g_Game.GetMission().SetNoteMenu(g_Game.GetUIManager().EnterScriptedMenu(MENU_NOTE, GetGame().GetUIManager().GetMenu())); //NULL means no parent
24
27 //int handwriting;
28
29 if (GetNoteInfo(pen, paper))
30 g_Game.GetMission().GetNoteMenu().InitNoteWrite(paper, pen, m_SimpleText);
31 }
32 //sent from client (NoteMenu), executed on server
33 if (rpc_type == ERPCs.RPC_WRITE_NOTE_CLIENT)
34 {
35 if (ctx.Read(param))
36 {
37 string old_string = m_SimpleText;
38 SetNoteText(param.param1);
40 }
41 }
42 if (rpc_type == ERPCs.RPC_READ_NOTE)
43 {
44 if (ctx.Read(param))
45 SetNoteText(param.param1);
46
47 g_Game.GetMission().SetNoteMenu(g_Game.GetUIManager().EnterScriptedMenu(MENU_NOTE, GetGame().GetUIManager().GetMenu())); //NULL means no parent
48 g_Game.GetMission().GetNoteMenu().InitNoteRead(m_SimpleText);
49 }
50 }
51
53 {
55 m_Paper = paper;
56 //m_Handwriting = handwriting;
57 }
58
60 {
62 paper = m_Paper;
63 //handwriting = m_Handwriting;
64 return pen && paper;
65 }
66
67 string GetNoteText()
68 {
69 return m_SimpleText;
70 }
71
72 void SetNoteText(string text)
73 {
74 m_SimpleText = MiscGameplayFunctions.SanitizeString(text);
75 }
76
78 {
79 float qty_per_char = 1.0;
80 float decrease = Math.Clamp((new_text.Length() - old_text.Length()), 0, pen.GetQuantityMax());
81 pen.AddQuantity(-(qty_per_char * decrease));
82 }
83}
84
85//-----------------------
DayZGame g_Game
Definition DayZGame.c:3528
ERPCs
Definition ERPCs.c:2
Definition EnMath.c:7
The class that will be instanced (moddable)
Definition gameplay.c:376
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
void DepleteWritingImplement(notnull ItemBase pen, string old_text, string new_text)
void InitNoteInfo(ItemBase pen=null, ItemBase paper=null)
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
void WrittenNoteData(ItemBase parent)
bool GetNoteInfo(out ItemBase pen, out ItemBase paper)
void SetNoteText(string text)
ItemBase m_WritingImplement
proto native CGame GetGame()
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'.
const int MENU_NOTE
Definition constants.c:180