Skip to content

Commit 02f4224

Browse files
lsvMorettiFabianTerhorst
authored andcommitted
Added weapon extensions to IPlayer & Added XML commenting (#44)
* Added XML commenting to IPlayer & added WeaponComponent extensions * Added XML comments to IPlayer object * Added weapon extensions for IPlayer
1 parent 4be7be2 commit 02f4224

File tree

1 file changed

+183
-5
lines changed

1 file changed

+183
-5
lines changed

api/AltV.Net/Elements/Entities/IPlayer.cs

Lines changed: 183 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,150 @@ namespace AltV.Net.Elements.Entities
66
{
77
public interface IPlayer : IEntity
88
{
9+
/// <summary>
10+
/// The players model / skin
11+
/// </summary>
912
new uint Model { get; set; }
1013

14+
/// <summary>
15+
/// Returns true if player is connected - false if not connected
16+
/// </summary>
1117
bool IsConnected { get; }
1218

19+
/// <summary>
20+
/// Returns the players alt:V username
21+
/// </summary>
1322
string Name { get; }
1423

24+
/// <summary>
25+
/// Returns the players Social Club ID
26+
/// </summary>
1527
ulong SocialClubId { get; }
1628

29+
/// <summary>
30+
/// Returns the players Hardware ID Hash
31+
/// </summary>
1732
ulong HardwareIdHash { get; }
1833

1934
ulong HardwareIdExHash { get; }
2035

2136
string AuthToken { get; }
2237

38+
/// <summary>
39+
/// Gets and Sets the players health
40+
/// </summary>
2341
ushort Health { get; set; }
2442

43+
/// <summary>
44+
/// Gets and Sets the players max health
45+
/// </summary>
2546
ushort MaxHealth { get; set; }
2647

48+
/// <summary>
49+
/// Returns if the player is dead. True = player is dead
50+
/// </summary>
2751
bool IsDead { get; }
2852

53+
/// <summary>
54+
/// Returns if the player is jumping. True = player jumping
55+
/// </summary>
2956
bool IsJumping { get; }
3057

58+
/// <summary>
59+
/// Returns if the player is currently in RagDoll state.
60+
/// </summary>
3161
bool IsInRagdoll { get; }
3262

63+
/// <summary>
64+
/// Returns if the player is aiming.
65+
/// </summary>
3366
bool IsAiming { get; }
3467

68+
/// <summary>
69+
/// Returns if the player is firing.
70+
/// </summary>
3571
bool IsShooting { get; }
3672

73+
/// <summary>
74+
/// Returns if the player is reloading
75+
/// </summary>
3776
bool IsReloading { get; }
3877

78+
/// <summary>
79+
/// Sets and returns the players current armor
80+
/// </summary>
3981
ushort Armor { get; set; }
4082

83+
/// <summary>
84+
/// Sets and returns the max armor for the player
85+
/// </summary>
4186
ushort MaxArmor { get; set; }
4287

88+
/// <summary>
89+
/// Gets the current movement speed of the player in m/s
90+
/// </summary>
4391
float MoveSpeed { get; }
4492

93+
/// <summary>
94+
/// Returns the current weapon the player is holding
95+
/// </summary>
4596
uint Weapon { get; }
4697

98+
/// <summary>
99+
/// Returns the ammo in the current weapon the player is holding
100+
/// </summary>
47101
ushort Ammo { get; }
48102

103+
/// <summary>
104+
/// Returns the World Position of where the player is currently aiming
105+
/// </summary>
49106
Position AimPosition { get; }
50107

108+
/// <summary>
109+
/// The current rotation of the players head
110+
/// </summary>
51111
Rotation HeadRotation { get; }
52112

113+
/// <summary>
114+
/// Returns if the player is in a vehicle
115+
/// </summary>
53116
bool IsInVehicle { get; }
54117

118+
/// <summary>
119+
/// Returns the current vehicle. Null if not in a vehicle
120+
/// </summary>
55121
IVehicle Vehicle { get; }
56122

123+
/// <summary>
124+
/// Returns the current weapon the player has equipped
125+
/// </summary>
57126
uint CurrentWeapon { get; set; }
58127

128+
/// <summary>
129+
/// Returns the IEntity object if the player is aiming at
130+
/// </summary>
59131
IEntity EntityAimingAt { get; }
60132

61133
Position EntityAimOffset { get; }
62134

135+
/// <summary>
136+
/// Returns if the players weapon flashlight or weapon is active (Being aimed)
137+
/// </summary>
63138
bool IsFlashlightActive { get; }
64139

65-
/**
66-
* The current vehicle seat
67-
* driver: 1
68-
*/
140+
/// <summary>
141+
/// Returns the current seat the player is in. Drivers = 1
142+
/// </summary>
69143
byte Seat { get; }
70144

145+
/// <summary>
146+
/// Returns the current ping of the player
147+
/// </summary>
71148
uint Ping { get; }
72149

150+
/// <summary>
151+
/// Returns the IP of the player
152+
/// </summary>
73153
string Ip { get; }
74154

75155
/// <summary>
@@ -80,42 +160,140 @@ public interface IPlayer : IEntity
80160
/// <exception cref="EntityRemovedException">This entity was removed</exception>
81161
void Spawn(Position position, uint delayMs = 0);
82162

163+
/// <summary>
164+
/// Despawns a player
165+
/// </summary>
83166
void Despawn();
84167

168+
/// <summary>
169+
/// Sets the current date and time for a player
170+
/// </summary>
171+
/// <param name="day"></param>
172+
/// <param name="month"></param>
173+
/// <param name="year"></param>
174+
/// <param name="hour"></param>
175+
/// <param name="minute"></param>
176+
/// <param name="second"></param>
85177
void SetDateTime(int day, int month, int year, int hour,
86178
int minute, int second);
87179

180+
/// <summary>
181+
/// Sets the current weather for the player
182+
/// </summary>
183+
/// <param name="weather"></param>
88184
void SetWeather(uint weather);
89185

186+
/// <summary>
187+
/// Gives the player a weapon, ammo and if it is active
188+
/// </summary>
189+
/// <param name="weapon">weapon hash</param>
190+
/// <param name="ammo">ammo count</param>
191+
/// <param name="selectWeapon">True - Places into hand</param>
90192
void GiveWeapon(uint weapon, int ammo, bool selectWeapon);
91193

194+
/// <summary>
195+
/// Removes the weapon by hash
196+
/// </summary>
197+
/// <param name="weapon"></param>
92198
void RemoveWeapon(uint weapon);
93199

200+
/// <summary>
201+
/// Removes all player weapons
202+
/// </summary>
94203
void RemoveAllWeapons();
95204

205+
/// <summary>
206+
/// Kicks the player with reason
207+
/// </summary>
208+
/// <param name="reason">Reason why the player is kicked</param>
96209
void Kick(string reason);
97210

211+
/// <summary>
212+
/// Triggers client side event for a player
213+
/// </summary>
214+
/// <param name="eventName">Event Trigger</param>
215+
/// <param name="args">Parameters</param>
98216
void Emit(string eventName, params object[] args);
99217

218+
/// <summary>
219+
/// Adds a weapon component to a weapon
220+
/// </summary>
221+
/// <param name="weapon">Weapon hash</param>
222+
/// <param name="weaponComponent">Weapon Component hash</param>
100223
void AddWeaponComponent(uint weapon, uint weaponComponent);
101224

225+
/// <summary>
226+
/// Removes a weapon component from a weapon
227+
/// </summary>
228+
/// <param name="weapon">Weapon hash</param>
229+
/// <param name="weaponComponent">Weapon Component hash</param>
102230
void RemoveWeaponComponent(uint weapon, uint weaponComponent);
103231

232+
/// <summary>
233+
/// Gets the current weapon components for the weapon in hand
234+
/// </summary>
235+
/// <param name="weaponComponents">Array of component hashes</param>
104236
void GetCurrentWeaponComponents(out uint[] weaponComponents);
105237

238+
/// <summary>
239+
/// Sets the weapon tint to a weapon
240+
/// </summary>
241+
/// <param name="weapon">Weapon hash</param>
242+
/// <param name="tintIndex">tintIndex</param>
106243
void SetWeaponTintIndex(uint weapon, byte tintIndex);
107244

245+
/// <summary>
246+
/// Returns weapon tint of current weapon
247+
/// </summary>
248+
/// <returns></returns>
108249
byte GetCurrentWeaponTintIndex();
109250

110251
ReadOnlyPlayer Copy();
111252
}
112253

113254
public static class PlayerExtensions
114255
{
256+
/// <summary>
257+
/// Sets the players current Date and Time
258+
/// </summary>
259+
/// <param name="player">The player</param>
260+
/// <param name="dateTime">The DateTime object</param>
115261
public static void SetDateTime(this IPlayer player, DateTime dateTime) => player.SetDateTime(dateTime.Day,
116262
dateTime.Month, dateTime.Year, dateTime.Hour, dateTime.Minute, dateTime.Second);
117263

264+
/// <summary>
265+
/// Sets the players current weather
266+
/// </summary>
267+
/// <param name="player">The Player</param>
268+
/// <param name="weatherType">The weather type</param>
118269
public static void SetWeather(this IPlayer player, WeatherType weatherType) =>
119-
player.SetWeather((uint) weatherType);
270+
player.SetWeather((uint)weatherType);
271+
272+
/// <summary>
273+
/// Adds a weapon component to model
274+
/// </summary>
275+
/// <param name="player">The Player</param>
276+
/// <param name="weaponModel">The Weapon</param>
277+
/// <param name="weaponComponent">The Component</param>
278+
public static void AddWeaponComponent(this IPlayer player, WeaponModel weaponModel, uint weaponComponent) =>
279+
player.AddWeaponComponent((uint)weaponModel, weaponComponent);
280+
281+
/// <summary>
282+
/// Removes a weapon component from model
283+
/// </summary>
284+
/// <param name="player">The player</param>
285+
/// <param name="weaponModel">The weapon</param>
286+
/// <param name="weaponComponent">The component to be removed</param>
287+
public static void RemoveWeaponComponent(this IPlayer player, WeaponModel weaponModel, uint weaponComponent) =>
288+
player.RemoveWeaponComponent((uint)weaponModel, weaponComponent);
289+
290+
/// <summary>
291+
/// Sets the weapon tint to a weapon
292+
/// </summary>
293+
/// <param name="player">The player</param>
294+
/// <param name="weaponModel">The weapon</param>
295+
/// <param name="tintIndex">The tint index</param>
296+
public static void SetWeaponTintIndex(this IPlayer player, WeaponModel weaponModel, byte tintIndex) =>
297+
player.SetWeaponTintIndex((uint)weaponModel, tintIndex);
120298
}
121299
}

0 commit comments

Comments
 (0)