Skip to content

Commit f3bff01

Browse files
authored
Merge pull request #49 from NexiusTailer/master
Corrections in docs, add natives
2 parents 922d9b9 + b1ae547 commit f3bff01

8 files changed

Lines changed: 167 additions & 34 deletions

File tree

documentation/readme-expert.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,14 @@ You will note that all these new features either use existing keywords, `#`, or
167167

168168
### More Tags
169169

170-
open.mp includes introduce many more tags to functions and callbacks. These are useful in the long run, but slightly annoying to upgrade to. There are three symbols: `NO_TAGS`, `WEAK_TAGS`, and `STRONG_TAGS`; that you can define before including `<open.mp>`, each one enabling progressively more checks.
171-
172-
To make the transition easier, the default is `NO_TAGS`, but you can also make tags *weak*:
170+
open.mp includes introduce many more tags to functions and callbacks. These are useful in the long run, but slightly annoying to upgrade to. There are three symbols: `NO_TAGS`, `WEAK_TAGS`, and `STRONG_TAGS`; that you can define before including `<open.mp>`, each one enabling progressively more checks:
173171

174172
```pawn
175-
#define WEAK_TAGS
173+
#define STRONG_TAGS
176174
#include <open.mp>
177175
```
178176

179-
In this case, most old code uses will simply give a warning when the wrong tag is found:
177+
To encourage some adoption, the default is `WEAK_TAGS`. Most old code uses will simply give a warning when the wrong tag is found:
180178

181179
```pawn
182180
// Gives a warning:
@@ -218,17 +216,17 @@ You can enable `void:` tag warnings with a define before including `open.mp`, th
218216
#include <open.mp>
219217
```
220218

221-
Again, you can make these new tags *weak*, meaning that you get warnings when passing untagged values to tagged parameters, but not the other way around. This applies to function returns so saving a tag result in an untagged variable will not give a warning:
219+
For parameters the default is to make these new tags *weak*, meaning that you get warnings when passing untagged values to tagged parameters, but not the other way around. This applies to function returns so saving a tag result in an untagged variable will not give a warning. This second group can also be upgraded by specifying the use of *strong* tags instead:
222220

223221
```pawn
224-
#define WEAK_TAGS
222+
#define STRONG_TAGS
225223
#include <open.mp>
226224
```
227225

228-
This second group can also be upgraded by specifying the use of *strong* tags instead:
226+
Alternatively, if you need to move your legacy codebase as is:
229227

230228
```pawn
231-
#define STRONG_TAGS
229+
#define NO_TAGS
232230
#include <open.mp>
233231
```
234232

@@ -362,7 +360,11 @@ native GetServerVarAsString(const cvar[], buffer[], len = sizeof (buffer));
362360

363361
### Spelling Consistency
364362

365-
The SA:MP includes had a mixture of both English (`Bumper`, `Armour`, `Petrol`, etc) and American (`Color`, `Hood`, `Stereo`, etc) spellings of words. The open.mp includes have introduced *more* variants, for example `Trunk` has now been added as an alternative spelling to `Boot`; but along-side this change have settled on canonical and deprecated variants. In line with the code in the server itself, the English spellings are the preferred variants going forwards.
363+
The SA:MP includes had a mixture of both British English (`Bumper`, `Armour`, `Petrol`, etc) and American English (`Color`, `Hood`, `Stereo`, etc) spellings of words. The open.mp includes have introduced *more* variants, for example `Trunk` has now been added as an alternative spelling to `Boot`; but along-side this change have settled on canonical and deprecated variants. In line with the code in the server itself, the British spellings are the preferred variants going forwards; and while American spellings will continue to be supported indefinitely some have had warnings added to notify users of this consistency improvement. if you wish to stick with the mixed spellings you can add a define to the top of your code:
364+
365+
```pawn
366+
#define MIXED_SPELLINGS
367+
```
366368

367369
Function Changes
368370
------------------

documentation/readme-intermediate.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ main()
126126
}
127127
```
128128

129-
To make the transition easier, the default is `NO_TAGS`. The tags can also be *weak* - passing an integer instead of an enum value is a warning, but the reverse isn't:
129+
The tags are all *weak* - passing an integer instead of an enum value is a warning, but the reverse isn't. The latter can be enabled by making the tags *strong*:
130130

131131
```pawn
132-
#define WEAK_TAGS
132+
#define STRONG_TAGS
133133
#include <open.mp>
134134
```
135135

136-
The latter can be enabled by making the tags *strong*:
136+
Alternatively, if you need to move your legacy codebase as is:
137137

138138
```pawn
139-
#define STRONG_TAGS
139+
#define NO_TAGS
140140
#include <open.mp>
141141
```
142142

omp_actor.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ native bool:GetActorSpawnInfo(actorid, &skin, &Float:spawnX = 0.0, &Float:spawnY
372372

373373
/**
374374
* <library>omp_actor</library>
375+
* <summary>Get an array variable of the IDs of the created actors on the server.</summary>
376+
* <param name="actors">An array into which to store the actor IDs, passed by reference.</param>
377+
* <param name="size">The size of the array.</param>
378+
* <seealso name="GetPlayers" />
379+
* <seealso name="GetVehicles" />
380+
* <returns>The number of actors stored in the array.</returns>
375381
*/
376382
native GetActors(actors[], size = sizeof (actors));
377383

omp_network.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,20 @@ native Float:NetStats_PacketLossPercent(playerid);
501501
*/
502502
native CONNECTION_STATUS:NetStats_ConnectionStatus(playerid);
503503

504+
/**
505+
* <library>omp_network</library>
506+
* <summary>Gets the player's current connection status.</summary>
507+
* <param name="playerid">The ID of the player to get the connection status of</param>
508+
* <seealso name="NetStats_ConnectionStatus" />
509+
* <seealso name="GetPlayerNetworkStats" />
510+
* <seealso name="GetNetworkStats" />
511+
* <seealso name="IsPlayerConnected" />
512+
* <seealso name="OnPlayerConnect" />
513+
* <seealso name="OnPlayerDisconnect" />
514+
* <returns>The player's connection status, as an integer value.</returns>
515+
*/
516+
native CONNECTION_STATUS:GetPlayerConnectMode(playerid) = NetStats_ConnectionStatus;
517+
504518
/**
505519
* <library>omp_network</library>
506520
* <summary>Get a player's IP and port.</summary>

omp_object.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ native Float:GetPlayerObjectMoveSpeed(playerid, objectid);
11421142
* <library>omp_object</library>
11431143
* <summary></summary>
11441144
*/
1145-
native Float:GetPlayerObjectTarget(playerid, objectid, &Float:targetX = 0.0, &Float:targetY = 0.0, &Float:targetZ = 0.0);
1145+
native bool:GetPlayerObjectTarget(playerid, objectid, &Float:targetX = 0.0, &Float:targetY = 0.0, &Float:targetZ = 0.0) = GetPlayerObjectMovingTargetPos;
11461146

11471147
/**
11481148
* <library>omp_object</library>

omp_player.inc

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ native bool:SendClientMessage(playerid, colour, const format[], OPEN_MP_TAGS:...
15901590
* <b><c>0</c></b>: The function failed to execute. The player is not connected.
15911591
* </returns>
15921592
*/
1593-
#pragma deprecated Use `SendClientMessagef`
1593+
#pragma deprecated Use `SendClientMessage`
15941594
native bool:SendClientMessagef(playerid, colour, const format[], OPEN_MP_TAGS:...) = SendClientMessage;
15951595

15961596
/**
@@ -1627,7 +1627,7 @@ native bool:GameTextForPlayer(playerid, const format[], time, style, OPEN_MP_TAG
16271627
* is not connected.
16281628
* </returns>
16291629
*/
1630-
#pragma deprecated Use `GameTextForPlayerf`
1630+
#pragma deprecated Use `GameTextForPlayer`
16311631
native bool:GameTextForPlayerf(playerid, const format[], time, style, OPEN_MP_TAGS:...) = GameTextForPlayer;
16321632

16331633
/**
@@ -2860,41 +2860,143 @@ native Float:GetPlayerCameraZoom(playerid);
28602860

28612861
/**
28622862
* <library>omp_player</library>
2863+
* <summary>Check if the player camera target is enabled.</summary>
2864+
* <param name="playerid">The ID of the player to check the camera target is enabled.</param>
2865+
* <seealso name="EnablePlayerCameraTarget" />
2866+
* <returns>
2867+
* <b><c>1</c></b>: If camera target enabled.<br />
2868+
* <b><c>0</c></b>: If camera target not enabled or the player specified does not exist.
2869+
* </returns>
28632870
*/
28642871
native bool:IsPlayerCameraTargetEnabled(playerid);
28652872

28662873
/**
28672874
* <library>omp_player</library>
2875+
* <summary>Toggle player's widescreen.</summary>
2876+
* <param name="playerid">The ID of the player to toggle the widescreen.</param>
2877+
* <param name="wide">true for turn on and false for turn off.</param>
2878+
* <seealso name="IsPlayerWidescreenToggled" />
2879+
* <returns>
2880+
* <b><c>1</c></b>: The function was executed successfully.<br />
2881+
* <b><c>0</c></b>: The function failed to execute. This means the player specified does not exist.
2882+
* </returns>
28682883
*/
28692884
native bool:TogglePlayerWidescreen(playerid, bool:wide);
28702885

28712886
/**
28722887
* <library>omp_player</library>
2888+
* <summary>Checks if a player widescreen is on or off.</summary>
2889+
* <param name="playerid">The ID of the player to check.</param>
2890+
* <seealso name="TogglePlayerWidescreen" />
2891+
* <returns>
2892+
* <b><c>1</c></b>: The player widescreen is on.<br />
2893+
* <b><c>0</c></b>: The player widescreen is off or the player specified does not exist.
2894+
* </returns>
28732895
*/
28742896
native bool:IsPlayerWidescreenToggled(playerid);
28752897

28762898
/**
28772899
* <library>omp_player</library>
2900+
* <summary>Get the ID of the player or vehicle the player is spectating.</summary>
2901+
* <param name="playerid">The ID of the player.</param>
2902+
* <seealso name="PlayerSpectatePlayer" />
2903+
* <seealso name="PlayerSpectateVehicle" />
2904+
* <seealso name="TogglePlayerSpectating" />
2905+
* <seealso name="GetPlayerSpectateType" />
2906+
* <returns>ID of the player or vehicle.</returns>
28782907
*/
28792908
native GetPlayerSpectateID(playerid);
28802909

28812910
/**
28822911
* <library>omp_player</library>
2912+
* <summary>Returns the player's spectate type.</summary>
2913+
* <param name="playerid">The ID of the player to get spectate type of.</param>
2914+
* <seealso name="PlayerSpectatePlayer" />
2915+
* <seealso name="PlayerSpectateVehicle" />
2916+
* <seealso name="TogglePlayerSpectating" />
2917+
* <seealso name="GetPlayerSpectateID" />
2918+
* <returns>The player's spectate type.</returns>
28832919
*/
28842920
native GetPlayerSpectateType(playerid);
28852921

28862922
/**
28872923
* <library>omp_player</library>
2924+
* <summary>Get the player animation flags.</summary>
2925+
* <param name="playerid">The player id you want to get the animation flags from.</param>
2926+
* <seealso name="ApplyAnimation" />
2927+
* <returns>The player animation flags as an integer.</returns>
2928+
*/
2929+
native GetPlayerAnimFlags(playerid);
2930+
2931+
/**
2932+
* <library>omp_player</library>
2933+
* <summary>Get the player animation flags.</summary>
2934+
* <param name="playerid">The player id you want to get the animation flags from.</param>
2935+
* <seealso name="ApplyAnimation" />
2936+
* <returns>The player animation flags as an integer.</returns>
2937+
*/
2938+
native GetPlayerAnimationFlags(playerid) = GetPlayerAnimFlags;
2939+
2940+
/**
2941+
* <library>omp_player</library>
2942+
* <summary>Check if the player is in driveby mode.</summary>
2943+
* <param name="playerid">The ID of the player to check.</param>
2944+
* <returns>
2945+
* <b><c>1</c></b>: The player is in driveby mode.<br />
2946+
* <b><c>0</c></b>: The player is not in driveby mode or the player specified does not exist.
2947+
* </returns>
2948+
*/
2949+
native bool:IsPlayerInDriveByMode(playerid);
2950+
2951+
/**
2952+
* <library>omp_player</library>
2953+
* <summary>Check if the player special action is cuffed.</summary>
2954+
* <param name="playerid">The ID of the player to check.</param>
2955+
* <returns>
2956+
* <b><c>1</c></b>: The player is cuffed.<br />
2957+
* <b><c>0</c></b>: The player is not cuffed or the player specified does not exist.
2958+
* </returns>
2959+
*/
2960+
native bool:IsPlayerCuffed(playerid);
2961+
2962+
/**
2963+
* <library>omp_player</library>
2964+
* <summary>Gets a player's Z Aim (related to the camera and aiming).</summary>
2965+
* <param name="playerid">The ID of the player to get Z Aim of.</param>
2966+
* <seealso name="GetPlayerCameraPos" />
2967+
* <returns>The player's Z Aim as a float value.</returns>
28882968
*/
28892969
native Float:GetPlayerZAim(playerid);
28902970

28912971
/**
28922972
* <library>omp_player</library>
2973+
* <summary>Gets a player's Z Aim (related to the camera and aiming).</summary>
2974+
* <param name="playerid">The ID of the player to get Z Aim of.</param>
2975+
* <seealso name="GetPlayerCameraPos" />
2976+
* <returns>The player's Z Aim as a float value.</returns>
2977+
*/
2978+
native Float:GetPlayerAimZ(playerid) = GetPlayerZAim;
2979+
2980+
/**
2981+
* <library>omp_player</library>
2982+
* <summary>Get an array variable of the IDs of the current players on the server.</summary>
2983+
* <param name="players">An array into which to store the player IDs, passed by reference.</param>
2984+
* <param name="size">The size of the array.</param>
2985+
* <seealso name="GetVehicles" />
2986+
* <seealso name="GetActors" />
2987+
* <returns>The number of players stored in the array.</returns>
28932988
*/
28942989
native GetPlayers(players[], size = sizeof (players));
28952990

28962991
/**
28972992
* <library>omp_player</library>
2993+
* <summary>Check if the player is using the official SA-MP client.</summary>
2994+
* <param name="playerid">The ID of the player to check.</param>
2995+
* <seealso name="SendClientCheck" />
2996+
* <returns>
2997+
* <b><c>1</c></b>: The player is using official client.<br />
2998+
* <b><c>0</c></b>: The player is not using official client or the player specified does not exist.
2999+
* </returns>
28983000
*/
28993001
native bool:IsPlayerUsingOfficialClient(playerid);
29003002

omp_textdraw.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ native bool:TextDrawSetOutline(Text:textid, outlineSize);
386386
* after modifying the textdraw and the change will be visible.</remarks>
387387
*/
388388
#if !defined MIXED_SPELLINGS
389-
#pragma deprecated Use `TextDrawBackgroundColor`. To silence this warning and use different spellings define `MIXED_SPELLINGS` or define `SAMP_COMPAT` for general SA-MP API compatibility.
389+
#pragma deprecated Use `TextDrawBackgroundColour`. To silence this warning and use different spellings define `MIXED_SPELLINGS` or define `SAMP_COMPAT` for general SA-MP API compatibility.
390390
#endif
391391
native bool:TextDrawBackgroundColor(Text:textid, backgroundColor);
392392

omp_vehicle.inc

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -877,9 +877,9 @@ native bool:AddVehicleComponent(vehicleid, component);
877877
/**
878878
* <library>omp_vehicle</library>
879879
* <summary>Remove a component from a vehicle.</summary>
880-
* <param name="vehicleid">ID of the vehicle</param>
880+
* <param name="vehicleid">ID of the vehicle.</param>
881881
* <param name="component">ID of the <a href="https://www.open.mp/docs/scripting/resources/carcomponentid">component</a>
882-
* to remove</param>
882+
* to remove.</param>
883883
* <seealso name="AddVehicleComponent" />
884884
* <seealso name="GetVehicleComponentInSlot" />
885885
* <seealso name="GetVehicleComponentType" />
@@ -891,9 +891,9 @@ native bool:RemoveVehicleComponent(vehicleid, component);
891891
/**
892892
* <library>omp_vehicle</library>
893893
* <summary>Is this component legal on this vehicle?</summary>
894-
* <param name="vehicleid">ID of the vehicle</param>
894+
* <param name="vehicleid">ID of the vehicle.</param>
895895
* <param name="component">ID of the <a href="https://www.open.mp/docs/scripting/resources/carcomponentid">component</a>
896-
* to remove</param>
896+
* to check.</param>
897897
* <seealso name="AddVehicleComponent" />
898898
* <seealso name="GetVehicleComponentInSlot" />
899899
* <seealso name="GetVehicleComponentType" />
@@ -904,11 +904,24 @@ native bool:VehicleCanHaveComponent(vehicleid, componentid);
904904

905905
/**
906906
* <library>omp_vehicle</library>
907-
* <summary>Get the number of seats in this vehicle</summary>
908-
* <param name="vehicleid">ID of the vehicle</param>
907+
* <summary>Gets the number of seats for a vehicle model.</summary>
908+
* <param name="vehicleid">ID of the vehicle model.</param>
909+
* <returns>
910+
* <b><c>number of seats</c></b>: The number of seats as an integer.<br />
911+
* </returns>
909912
*/
910913
native GetVehicleSeats(vehicleid);
911914

915+
/**
916+
* <library>omp_vehicle</library>
917+
* <summary>Gets the number of seats for a vehicle model.</summary>
918+
* <param name="modelid">The ID of the vehicle model.</param>
919+
* <returns>
920+
* <b><c>number of seats</c></b>: The number of seats as an integer.<br />
921+
* </returns>
922+
*/
923+
native GetVehicleMaxPassengers(vehicleid) = GetVehicleSeats;
924+
912925
/**
913926
* <library>omp_vehicle</library>
914927
* <summary>Change a vehicle's primary and secondary colours.</summary>
@@ -1616,6 +1629,12 @@ native void:EnableVehicleFriendlyFire();
16161629

16171630
/**
16181631
* <library>omp_vehicle</library>
1632+
* <summary>Get an array variable of the IDs of the created vehicles on the server.</summary>
1633+
* <param name="vehicles">An array into which to store the vehicle IDs, passed by reference.</param>
1634+
* <param name="size">The size of the array.</param>
1635+
* <seealso name="GetPlayers" />
1636+
* <seealso name="GetActors" />
1637+
* <returns>The number of vehicles stored in the array.</returns>
16191638
*/
16201639
native GetVehicles(vehicles[], size = sizeof (vehicles));
16211640

@@ -1632,16 +1651,6 @@ native GetVehicles(vehicles[], size = sizeof (vehicles));
16321651
*/
16331652
native GetVehicleOccupant(vehicleid, seatid);
16341653

1635-
/**
1636-
* <library>omp_vehicle</library>
1637-
* <summary>Gets the number of seats for a vehicle model.</summary>
1638-
* <param name="modelid">The ID of the model.</param>
1639-
* <returns>
1640-
* <b><c>number of seats</c></b>: The number of seats as an intiger.<br />
1641-
* </returns>
1642-
*/
1643-
native GetVehicleMaxPassengers(modelid);
1644-
16451654
/**
16461655
* <library>omp_vehicle</library>
16471656
* <summary>Returns the number of occupants in the given vehicle.</summary>

0 commit comments

Comments
 (0)