-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextdraw.cs
252 lines (216 loc) · 7.63 KB
/
textdraw.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
using System;
using GrandTheftMultiplayer.Server.API;
using GrandTheftMultiplayer.Server.Elements;
using GrandTheftMultiplayer.Server.Managers;
using System.IO;
namespace TextDraw
{
public class TextDraw : Script
{
private int _tdeStatus = 0;
private string _fileName = "TDE_EXPORT";
private ConfigData _configData = new ConfigData
{
Author = "[RW]Robi & Appi",
Version = "0.3.4 Stable"
};
public TextDraw()
{
API.onClientEventTrigger += OnClientEventTrigger;
API.onPlayerConnected += OnPlayerConnected;
API.onResourceStart += OnResourceStart;
}
[Command("tde")]
public void Tde(Client player)
{
if(_tdeStatus == 1)
{
API.sendNotificationToPlayer(player, "TextDraw editor is already active, [/tdeclose]");
return;
}
API.triggerClientEvent(player, "Show_TDE");
_tdeStatus = 1;
}
[Command("tdeclose", Alias = "tdcls")]
public void TdeClose(Client player)
{
if(_tdeStatus == 0)
{
API.sendNotificationToPlayer(player, "TextDraw editor is already closed, [/tde]");
return;
}
API.triggerClientEvent(player, "Close_TDE");
_tdeStatus = 0;
}
[Command("tdcreate", "/createtd [1 - Text, 2 - Box]", Alias = "tdc")]
public void TdCreate(Client player, int id)
{
if (id == 1 || id == 2) API.triggerClientEvent(player, "CreateTD", id);
else API.sendNotificationToPlayer(player, "Invalid Type, 1 - Text, 2 - Box");
}
[Command("tdfloat", "/tdfloat width [0 - left, 1 - center, 2 - right], height [0 - up, 1 - center, 2 - down]", Alias = "tdf")]
public void TdFloat(Client player, int bfloatWidth, int bfloatHeight)
{
if(bfloatWidth < 0 || bfloatWidth > 2 || bfloatHeight < 0 || bfloatHeight > 2)
{
API.sendNotificationToPlayer(player, "Invalid aligment (min 0, max 2)");
return;
}
API.triggerClientEvent(player, "TDFloat", bfloatWidth, bfloatHeight);
}
[Command("aligment", "/aligment [0 - left, 1 - center, 2 - right]", Alias = "tda")]
public void TdAligment(Client player, int aligment)
{
if(aligment < 0 || aligment > 2)
{
API.sendNotificationToPlayer(player, "Invalid aligment (min 0, max 2)");
return;
}
API.triggerClientEvent(player, "TDAligment", aligment);
}
[Command("font", "/font [0-7]")]
public void TdFont(Client player, int font)
{
if(font < 0 || font > 7)
{
API.sendNotificationToPlayer(player, "Invalid Font (min 0, max 7)");
return;
}
API.triggerClientEvent(player, "TDFont", font);
}
[Command("shadow", "/shadow [0 - no, 1 - yes]", Alias = "tdsh")]
public void TdShadow(Client player, int shadow)
{
if(shadow < 0 || shadow > 1)
{
API.sendNotificationToPlayer(player, "Invalid shadow (min 0, max 1)");
return;
}
API.triggerClientEvent(player, "TDShadow", shadow > 0);
}
[Command("outline", "/outline [0 - no, 1 - yes]", Alias = "tdo")]
public void TdOutline(Client player, int outline)
{
if(outline < 0 || outline > 1)
{
API.sendNotificationToPlayer(player, "Invalid outline (min 0, max 1)");
return;
}
API.triggerClientEvent(player, "TDOutline", outline > 0);
}
[Command("tdcolor", Alias = "tdcl")]
public void TdColor(Client player)
{
API.triggerClientEvent(player, "TDColor");
}
[Command("tdrgba")]
public void TdColorRgba(Client player, int r, int g, int b, int a)
{
API.triggerClientEvent(player, "TDColorRgba", r, g, b, a);
}
[Command("tdtext", "/tdtext [text]", Alias = "tdt", GreedyArg = true)]
public void TdText(Client player, string text)
{
API.triggerClientEvent(player, "TDText", text);
}
[Command("tdremove", "/tdr", Alias = "tdr")]
public void TdRemove(Client player)
{
API.triggerClientEvent(player, "TDRemove");
}
[Command("tdmove", "/tdm", Alias = "tdm")]
public void TdMove(Client player)
{
API.triggerClientEvent(player, "TDMove");
}
[Command("tdsize", "/tdsize [width] [height]", Alias = "tds")]
public void TdSize(Client player, float w, float h = 100f)
{
API.triggerClientEvent(player, "TDSize", w, h);
}
[Command("tdfilename", "/tdfilename [fileName]", Alias = "tdfn")]
public void TdFileName(Client player, string saveFileName)
{
_fileName = saveFileName;
player.sendChatMessage("~y~TDE: ~w~ new file name - ~g~" + saveFileName);
}
[Command("tdedit", "Using: /tded", Alias = "tded")]
public void TdEdit(Client player)
{
API.triggerClientEvent(player, "EditTD");
}
[Command("tdexport", "Using: /tdexp", Alias = "tdexp")]
public void TdExport(Client player)
{
var coordsFile = !File.Exists(_fileName + ".txt") ? new StreamWriter(_fileName + ".txt") : File.AppendText(_fileName + ".txt");
var src = DateTime.Now;
var sec = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second);
coordsFile.WriteLine("//TDE EDITOR by " + _configData.Author + ", v" + _configData.Version);
coordsFile.WriteLine("//TextDraws generated on " + sec.Day + "." + sec.Month + "." + sec.Year + " - " + sec.Hour + ":" + sec.Minute + ":" + sec.Second);
coordsFile.Close();
API.triggerClientEvent(player, "Export");
player.sendChatMessage("TextDraws has been exported, all textdraws are in the ~g~" + _fileName + ".txt~w~ file");
}
[Command("help")]
public void TdShowHelp(Client player)
{
ShowHelp(player);
}
[Command("tddebug", Alias = "tdd")]
public void TdDebug(Client player)
{
API.triggerClientEvent(player, "TDEDebug");
}
/*
*
* Methods
*
*/
public void OnResourceStart()
{
API.consoleOutput("====================[TDE]====================");
API.consoleOutput("TextDraw Editor was loaded v" + _configData.Version);
API.consoleOutput("Authors: " + _configData.Author);
API.consoleOutput("=============================================");
}
public void OnPlayerConnected(Client player)
{
player.triggerEvent("SetConfig", _configData.Author, _configData.Version);
player.sendChatMessage("TDE Editor " + _configData.Version + " by ~r~" + _configData.Author);
player.sendChatMessage("Type ~y~/tde ~w~for open the TDE Editor.");
}
public void OnClientEventTrigger(Client player, string eventName, params object[] arguments)
{
switch (eventName)
{
case "Export":
var coordsFile = !File.Exists(_fileName + ".txt") ? new StreamWriter(_fileName + ".txt") : File.AppendText(_fileName + ".txt");
coordsFile.WriteLine(arguments[0].ToString());
coordsFile.Close();
break;
case "Help":
ShowHelp(player);
break;
}
}
public void ShowHelp(Client player)
{
player.triggerEvent("OpenHelpWindow");
/*player.sendChatMessage("~y~TDE Commands:", "~w~/font [0-7]");
player.sendChatMessage("~y~TDE Commands:", "~w~/aligment (/tda) [0 - left, 1 - center, 2 - right]");
player.sendChatMessage("~y~TDE Commands:", "~w~/tdfloat (/tdf) (Analog Float Css) [0 - left, 1 - center, 2 - right]");
player.sendChatMessage("~y~TDE Commands:", "~w~/tdcreate (/tdc) [1 - Text, 2 - Box]");
player.sendChatMessage("~y~TDE Commands:", "~w~/tdcolor (/tdcl) [rgba (0-255)]");
player.sendChatMessage("~y~TDE Commands:", "~w~/tdmove (/tdm) - move the current textdraw.");
player.sendChatMessage("~y~TDE Commands:", "~w~/tdsize (/tds) - change width / height size of the current textdraw.");
player.sendChatMessage("~y~TDE Commands:", "~w~/tdtext (/tdt) - change text of the current textdraw.");
player.sendChatMessage("~y~TDE Commands:", "~w~/shadow (/tdsh) [0 - no, 1 - yes], /outline (/tdo) [0 - no, 1 - yes]");
player.sendChatMessage("Type ~y~/tde ~w~for open the TDE Editor.");*/
}
}
public struct ConfigData
{
public string Author { get; set; }
public string Version { get; set; }
}
}