-
Notifications
You must be signed in to change notification settings - Fork 1
/
SAMP.dev.cs
324 lines (261 loc) · 17.1 KB
/
SAMP.dev.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace SAMP_API
{
class API
{
public const String PATH = "SAMPDEV.dll";
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int Init();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetParam(string _szParamName, string _szParamValue);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetGTACommandLine(ref StringBuilder line, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern bool IsMenuOpen();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern bool ScreenToWorld(float x, float y, out float worldX, out float worldY, out float worldZ);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern bool WorldToScreen(float x, float y, float z, out float screenX, out float screenY);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerCPed();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerHealth();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerArmor();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerMoney();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerSkinID();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerInterior();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerInAnyVehicle();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerDriver();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerPassenger();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerInInterior();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerX(out float posX);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerY(out float posY);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerZ(out float posZ);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerPosition(out float posX, out float posY, out float posZ);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerInRange2D(float posX, float posY, float radius);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsPlayerInRange3D(float posX, float posY, float posZ, float radius);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetCityName(ref StringBuilder cityName, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetZoneName(ref StringBuilder zoneName, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextCreate(string Font, int FontSize, bool bBold, bool bItalic, int x, int y, int color, string text, bool bShadow, bool bShow);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextDestroy(int ID);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextSetShadow(int id, bool b);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextSetShown(int id, bool b);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextSetColor(int id, int color);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextSetPos(int id, int x, int y);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextSetString(int id, string str);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int TextUpdate(int id, string Font, int FontSize, bool bBold, bool bItalic);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxCreate(int x, int y, int w, int h, int dwColor, bool bShow);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxDestroy(int id);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetShown(int id, bool bShown);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetBorder(int id, int height, bool bShown);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetBorderColor(int id, int dwColor);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetColor(int id, int dwColor);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetHeight(int id, int height);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetPos(int id, int x, int y);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int BoxSetWidth(int id, int width);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int LineCreate(int x1, int y1, int x2, int y2, int width, int color, bool bShow);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int LineDestroy(int id);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int LineSetShown(int id, bool bShown);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int LineSetColor(int id, int color);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int LineSetWidth(int id, int width);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int LineSetPos(int id, int x1, int y1, int x2, int y2);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ImageCreate(string path, int x, int y, int rotation, int align, bool bShow);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ImageDestroy(int id);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ImageSetShown(int id, bool bShown);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ImageSetAlign(int id, int align);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ImageSetPos(int id, int x, int y);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ImageSetRotation(int id, int rotation);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int DestroyAllVisual();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ShowAllVisual();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int HideAllVisual();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetFrameRate();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetScreenSpecs(out int width, out int height);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetCalculationRatio(int width, int height);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetOverlayPriority(int id, int priority);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetOverlayCalculationEnabled(int id, bool enabled);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetServerIP(ref StringBuilder ip, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetServerPort();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int SendChat(string msg);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ShowGameText(string msg, int time, int style);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int AddChatMessage(string msg);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int ShowDialog(int id, int style, string caption, string text, string button, string button2);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerNameByID(int id, ref StringBuilder playername, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerIDByName(string name);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerName(ref StringBuilder playername, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerId();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsChatOpen();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsDialogOpen();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehiclePointer();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleSpeed(float factor);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern float GetVehicleHealth();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleModelId();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleModelName(ref StringBuilder name, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleModelNameById(int vehicleID, ref StringBuilder name, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleType();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleFreeSeats(out int seatFL, out int seatFR, out int seatRL, out int seatRR);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleFirstColor();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleSecondColor();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetVehicleColor(out int color1, out int color2);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleSeatUsed(int seat);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleLocked();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleHornEnabled();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleSirenEnabled();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleAlternateSirenEnabled();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleEngineEnabled();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleLightEnabled();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleCar();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehiclePlane();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleBoat();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleTrain();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int IsVehicleBike();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int HasWeaponIDClip(int weaponID);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponID();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponType();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponSlot();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponName(int dwWeapSlot, ref StringBuilder _szWeapName, int max_len);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponClip(int dwWeapSlot);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponTotalClip(int dwWeapSlot);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponState();
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponAmmo(int weaponType);
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPlayerWeaponAmmoInClip(int weaponType);
public static void SendChatEx(string message, params object[] args)
{
if (message.Length != 0)
{
if (args.Length > 0)
message += " " + string.Join(" ", args);
SendChat(message);
}
}
public static void AddChatMessageEx(string text, string color = "FFFFFF")
{
AddChatMessage("{" + color + "}" + text);
}
public static void AddChatMessageEx(string text, Color color)
{
AddChatMessage("{" + ColorToHexRGB(color) + "}" + text);
}
public static void AddChatMessageEx(string prefix, string prefixColor, string text, string color = "FFFFFF")
{
AddChatMessage("{" + prefixColor + "}" + prefix + " {" + color + "}" + text);
}
public static void AddChatMessageEx(string prefix, Color prefixColor, string text, Color color)
{
AddChatMessage("{" + ColorToHexRGB(prefixColor) + "}" + prefix + " {" + ColorToHexRGB(color) + "}" + text);
}
public static string GetPlayerNameByIDEx(int id)
{
StringBuilder builder = new StringBuilder(32);
GetPlayerNameByID(id, ref builder, builder.Capacity);
return builder.ToString();
}
public static String ColorToHexRGB(Color color)
{
return color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
}
public static String ColorToHexARGB(Color color)
{
return color.A.ToString("X2") + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
}
}
}