Skip to content

Consistency overhaul #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 106 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
d1ae325
Consistency improvements:
Y-Less Apr 27, 2021
c151017
Revert callback name changes because the compiler is picky about them.
Y-Less Apr 27, 2021
8bad002
More `camelCase` parameter names.
Y-Less Apr 27, 2021
78ef1ca
`id` -> `ID`
Y-Less Apr 27, 2021
35e40a9
Revert forwards again.
Y-Less Apr 27, 2021
c37b66d
`ID` is bad...
Y-Less Apr 27, 2021
e3584e1
More tweaks:
Y-Less Apr 27, 2021
6ec7e5f
Idiomatic DB function naming.
Y-Less Apr 27, 2021
a41db32
Name tweaks.
Y-Less May 4, 2021
04ca6ac
Fix clobbered names.
Y-Less May 4, 2021
2fa5a19
Another tag and name clobber.
Y-Less May 4, 2021
c5b0181
More tags.
Y-Less Oct 3, 2018
5e45fae
More enums.
Y-Less May 8, 2021
a14dace
Lost a load of commits due to repo corruption:
May 9, 2021
fc55463
More correct tag syntax.
May 9, 2021
1c03741
Callback tags.
May 9, 2021
3704e48
Document progressive tag enhancement.
May 9, 2021
cf78bdb
List of all updated callbacks.
May 9, 2021
1d46eb2
`KEY:`.
Y-Less May 11, 2021
e075fb1
Internal enum names.
Y-Less Aug 31, 2021
367be13
Internal enum names.
Y-Less Aug 31, 2021
54eadde
Internal enum names.
Y-Less Aug 31, 2021
32f9805
Internal enum names.
Y-Less Aug 31, 2021
8bd490d
Internal enum names.
Y-Less Aug 31, 2021
7dc15f4
Internal enum names.
Y-Less Aug 31, 2021
5ad1825
Fix a typo in `__SPECTATE_MODE` name.
Y-Less Dec 4, 2021
e13694a
More robust file inclusion/lookup.
Dec 4, 2021
72a0bbd
More definitions.
Dec 4, 2021
6b39b0b
`INVALID_TIMER`.
Dec 4, 2021
1f9f768
Integrate recent PRs.
Dec 4, 2021
6fd3ac2
typo fix: MAX_PLAYER_NAME minimum number.
Dec 18, 2021
51c9d9a
Merge pull request #41 from Kirima2nd/consistency-overhaul
Southclaws Dec 18, 2021
1fcfac3
Sync some defines with a_npc.
Jan 25, 2022
26ebabf
`WEAPON:` tag and `WEAPON_SPLAT` (based on the returned string).
Jan 25, 2022
29fa6fa
Two small camel case fixes.
Jan 29, 2022
b9aa7e9
More parameter renames, and `GPCI`.
Jan 29, 2022
5ebff26
Missing tags.
Jan 29, 2022
2a73ac8
`GetPlayerVehicleid` -> `GetPlayerVehicleID`.
Jan 30, 2022
171bb78
Remove `lenof`.
Jan 31, 2022
f1667df
Spacing fix.
Jan 31, 2022
ebea75e
Rename `CAMERA:` to `CAM_MOVE:` and add `CAM_MODE:`, for less clashy …
Jan 31, 2022
6ffb6a8
Fonts and `centre`.
Jan 31, 2022
7e89741
TD fonts.
Jan 31, 2022
9e17152
`forceSync` isn't a boolean.
Feb 2, 2022
643f3bb
Move readme sections to make more sense.
Y-Less Feb 2, 2022
7927f63
Variable name fix.
Feb 5, 2022
f9d22ce
Fix the pawndoc bug on `print`/`printf`.
Feb 22, 2022
9f1f59f
Switch pawndoc style.
Feb 26, 2022
10fe067
`<library>` header.
Feb 26, 2022
f95bc67
Fix some comment closes.
Feb 26, 2022
994f48c
Fix some comment closes.
Feb 26, 2022
048515f
Add `<library>` identifier to all natives.
Feb 26, 2022
c9a3180
Add `<library>` to some functions without other documentation.
Feb 26, 2022
e9b8955
Fix some inclusions.
Feb 26, 2022
2c1593a
Old-style include guards as well.
Feb 26, 2022
d2b4ee3
You'll prise two space full stops from my cold dead hands!
Feb 26, 2022
af6b7d6
Wrap pawndoc.
Feb 26, 2022
fd0663d
Wrap lines more aggressively.
Feb 26, 2022
054510b
Make the library declaration conditional.
Feb 26, 2022
475a955
Set library on constants.
Feb 27, 2022
1e5a62d
Better constants.
Feb 27, 2022
85b2063
enum documentation
Feb 27, 2022
89e8cf7
Return the correct enum names.
Feb 27, 2022
c885739
Trying to fix the bug.
Feb 27, 2022
3afdb09
Fix pawndoc bugs.
Feb 27, 2022
72c76dd
Add `///` before all enum documentation.
Feb 27, 2022
9c14138
Add `pawndoc.xsl`.
Feb 27, 2022
01a9527
Fix close tag.
Feb 27, 2022
3bcd294
`description=` to `summary=`
Feb 28, 2022
ab9c69e
Switch back to real defines so `#MAX_PLAYERS` etc work correctly. So…
Mar 6, 2022
873c512
Re-enable deprecation warnings.
Mar 6, 2022
bde8012
Fix replacement loop.
Mar 6, 2022
f98c14a
Hide some pawndoc better.
Mar 6, 2022
c8ad7a5
Two missing `a_npc` library tags.
Mar 6, 2022
c335579
Move some player defines around.
Mar 6, 2022
2295182
Separate header comments.
Mar 6, 2022
b0f9fe7
Move some defines to more appropriate files:
Mar 6, 2022
5b3d3a8
Change the include order to resolve some new inter-dependencies.
Mar 6, 2022
72f3957
And match the checks.
Mar 6, 2022
e55f57a
Try fix old a_http includes even more.
Mar 6, 2022
3d89fb0
Add `pawndoc="true"`.
Mar 6, 2022
61501d2
Remove `#define HTTP`.
Mar 7, 2022
5ec4cb3
Move some comments that seemed to cause an issue.
Mar 7, 2022
eff8bfd
Remove empty pawndoc blocks.
Mar 7, 2022
bfb8b6f
`RACECP_TYPE:`
Mar 14, 2022
045fd54
Rename (simplify) the checkpoint tag.
Mar 15, 2022
aafb808
Some more `bool:` return tags.
Mar 16, 2022
2b6b093
Actor `bool:` returns.
Mar 16, 2022
819876e
a_vehicle tags.
Mar 17, 2022
570867e
Another tag.
Mar 17, 2022
92f733a
Make `GetServerVar...` functions aliases for `GetConsoleVar...`.
Mar 18, 2022
2f9dbd3
`__OPEN_MP_VERSION`
Apr 3, 2022
98d7160
More `bool:` return tags.
Apr 8, 2022
bcd211b
More tags
Apr 11, 2022
f058247
Unfortunately callbacks can't have their parameter names changed, so …
Jun 25, 2022
e10ff99
Remove accidental comments from warnings.
Jun 25, 2022
0bf3fc8
Switch strong/weak tag prefixes to `T_`/`t_` - they're less widely us…
Aug 7, 2022
f2d13fd
Move something.
Aug 7, 2022
7b10fd3
`OnPlayerRequestDownload` tag.
Aug 7, 2022
ae862df
Merge remote-tracking branch 'remotes/origin/master' into consistency…
Sep 4, 2022
ceefd22
Back-port weapon slots.
Sep 4, 2022
81ba713
Use weapon slots.
Sep 4, 2022
cf49dbe
More documentation.
Sep 4, 2022
ae3989f
Typo
Sep 4, 2022
c2c58d0
`PLAYER_VARTYPE_`
Sep 4, 2022
8b76202
Prefer `<p/>`
Nov 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
325 changes: 325 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,331 @@ standard library stored here on GitHub too. This means there doesn't need to be
any special-case code written for the standard library, it can just be a package
like all others.

## Const-Correctness

Some functions, like `SendRconCommand`, take strings; some functions, like `GetPlayerName`, modify strings. These are different operations with different considerations. Consider the following code:

```pawn
GetPlayerName(playerid, "Bob");
```

This code doesn't make any sense. "Bob" is a string literal, you can't store someone's name in to the word `"Bob"`, it would be like trying to do:

```pawn
"Bob" = GetPlayerName(playerid);
```

`"Bob"` is a *constant*, it is a value fixed by the compiler that can't be modified at runtime. `GetPlayerName` modifies its values at runtime, so cannot take a constant only a variable. For this reason it is declared as:

```pawn
native GetPlayerName(playerid, name[], size = sizeof (name));
```

But what of `SendRconCommand`? The following *is* valid:

```pawn
SendRconCommand("loadfs objects");
```

`SendRconCommand` does not return a string, it doesn't modify the value passed in. If it were declared in the same way as `GetPlayerName` it would have to take a variable that could be modified:

```pawn
native SendRconCommand(cmd[]);
new cmd[] = "loadfs objects";
// `cmd` must be modifiable because `SendRconCommand` doesn't say it won't.
SendRconCommand(cmd);
```

This is cumbersome and pointless. Again, we know that `SendRconCommand` cannot change the data given, so we tell the compiler this as well. Anything between `""`s is a *constant*, so make `SendRconCommand` accept them with `const`:

```pawn
native SendRconCommand(const cmd[]);
// Allowed again because we know this call won't modify the string.
SendRconCommand("loadfs objects");
```

This is called *const correctness* - using `const` when data will not be modified, and not using `const` when the parameter will be modified. This is mainly only useful for strings and arrays (differentiated in the includes by the use of a `string:` tag) as they are pass-by-reference, but when in doubt use the rules on normal numbers as well.

Functions that are `const` can also take variables which may be modified. `const` means the function promises not modify the variable (`GetPlayerName` in the SA:MP includes incorrectly used `const` and broke this promise), but that doesn't mean you can't pass varaibles that don't mind being modified - there's no such thing as a variable that *must* be modified:

```pawn
native SendRconCommand(const string:cmd[]);
new cmd[32];
format(cmd, _, "loadfs %s", scriptName);
// `cmd` is allowed to be modified, but `SendRconCommand` won't do so.
SendRconCommand(cmd);
```

As a side note, the following code is now also a warning:

```pawn
Func(const &var)
{
printf("%d", var);
}
```

`const` means a variable can't be modified, while `&` means it can. Since modifiying a normal variable is the only reason to pass it by reference adding `const` to the declaration is, as with all warnings, probably a mistake.

## More Tags

The latest version of the SA: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 `<a_samp>`, each one enabling progressively more checks:

```pawn
#define STRONG_TAGS
#include <a_samp>
```

To encourage some adoption, the default is `WEAK_TAGS`. Most old code uses will simply give a warning when the wrong tag is found:

```pawn
// Gives a warning:
SetPlayerControllable(playerid, 1);

// Should be:
SetPlayerControllable(playerid, true);
```

Generally parameters that only accept a limited range of values (for example, object attachment bones) are now all enumerations so that passing invalid values gives a warning:

```pawn
TextDrawAlignment(textid, TEXT_DRAW_ALIGN_LEFT); // Fine
TextDrawFont(textid, 7); // Warning
```

Functions that take or return just `true`/`false` all have `bool:` tags. More functions than might be expected return booleans; most player functions return `true` when they succeed and `false` when the player is not connected, sometimes skipping the need for `IsPlayerConnected`:

```pawn
new Float:x, Float:y, Float:z;
// If the player is connected get their position.
if (GetPlayerPos(playerid, x, y, z))
{
// Timer repeats are on or off, so booleans.
SetTimer("TimerFunc", 1000, false);
}
```

In cases where there were existing defines already for valid values (like `OBJECT_MATERIAL_SIZE_512x64`) these names have been reused for the enumerations and thus tagged. Therefore code that already made use of the defines will continue to operate correctly, and code that wishes to remain backwards-compatible can start using the names in place of (usually) bare numbers (so always put `OBJECT_MATERIAL_TEXT_ALIGN_LEFT` instead of `0`).

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:

```pawn
#define STRONG_TAGS
#include <a_samp>
```

Alternatively, if you really hate help:

```pawn
#define NO_TAGS
#include <a_samp>
```

The only breaking change introduced by these new tags are on callbacks. For some reason tag mismatch warnings in function prototypes are an error, not a warning (probably because of code generation issues related to overloaded operators). The best way to deal with these is to ensure that the `public` part of the callback will compile regardless of tag settings by falling back to `_:` when none is specified:

```pawn
#if !defined SELECT_OBJECT
#define SELECT_OBJECT: _:
#endif
forward OnPlayerSelectObject(playerid, SELECT_OBJECT:type, objectid, modelid, Float:fX, Float:fY, Float:fZ);
```

See lower down for a full list of all updated callbacks. This is the main problem change, but it is important to note that the following code will work with any include, with or without the new tags:

```pawn
#if !defined CLICK_SOURCE
#define CLICK_SOURCE: _:
#endif
public OnPlayerClickPlayer(playerid, clickedplayerid, CLICK_SOURCE:source)
{
return 1;
}
```

Thus writing backwards-compatible code remains possible. Forward for ALS as normal:

```pawn
#if !defined PLAYER_STATE
// Use the default tag (none, `_:`) when the improved includes aren't found.
#define PLAYER_STATE: _:
#endif
public OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate)
{
return Hooked_OnPlayerStateChange(playerid, newstate, oldstate);
}

forward Hooked_OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate);
```

### Tag Warning Example

```pawn
if (GetPVarType(playerid, "MY_DATA") == 1)
{
printf("Found an int");
}
```

This code is correct, and will give the correct answer, so why add warnings?

```pawn
switch (GetPVarType(playerid, "MY_DATA"))
{
case 0:
printf("Unknown type");
case 1:
printf("Found an int");
case 2:
printf("Found a float");
case 3:
printf("Found a string");
case 4:
printf("Found a boolean");
}
```

This code is subtly wrong, take a moment to try and work out how - the compiler will not help you.

It could take a lot of testing and debugging to find the problem here without a lot of familiarity with the functions in question, fortunately the a_samp includes now return a `VARTYPE:` tag from `GetPVarType` and this code will give tag-mismatch warnings. Once we try and fix the warnings using the defined constants the mistakes become instantly obvious:

```pawn
switch (GetPVarType(playerid, "MY_DATA"))
{
case PLAYER_VARTYPE_NONE:
printf("Unknown type");
case PLAYER_VARTYPE_INT:
printf("Found an int");
case PLAYER_VARTYPE_STRING:
printf("Found a float");
case PLAYER_VARTYPE_FLOAT:
printf("Found a string");
case PLAYER_VARTYPE_BOOL:
printf("Found a boolean");
}
```

The string/float mixup still needs some manual review, but it is now far more obvious that those two are the wrong way around. In fact there's a good chance that the person updating the code would have used them the correct way round without even realising that they have now fixed a prior bug. The `VARTYPE_BOOL:` line will give an error that the symbol doesn't exist because there is no type `4`. The old code quite happily compiled without issues and had an impossible branch. The effects aren't serious in this example, but they could be. But, again, the old code will still compile and run. More warnings help to highlight issues, they do not introduce new ones.

### Complete List

* `OnPlayerStateChange`

```pawn
#if !defined PLAYER_STATE
#define PLAYER_STATE: _:
#endif
forward OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate);
```

* `OnPlayerClickPlayer`

```pawn
#if !defined CLICK_SOURCE
#define CLICK_SOURCE: _:
#endif
forward OnPlayerClickPlayer(playerid, clickedplayerid, CLICK_SOURCE:source);
```

* `OnPlayerEditObject`

```pawn
#if !defined EDIT_RESPONSE
#define EDIT_RESPONSE: _:
#endif
forward OnPlayerEditObject(playerid, playerobject, objectid, EDIT_RESPONSE:response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ);
```

* `OnPlayerEditAttachedObject`

```pawn
#if !defined EDIT_RESPONSE
#define EDIT_RESPONSE: _:
#endif
forward OnPlayerEditAttachedObject(playerid, EDIT_RESPONSE:response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ);
```

* `OnPlayerSelectObject`

```pawn
#if !defined SELECT_OBJECT
#define SELECT_OBJECT: _:
#endif
forward OnPlayerSelectObject(playerid, SELECT_OBJECT:type, objectid, modelid, Float:fX, Float:fY, Float:fZ);
```

* `OnPlayerWeaponShot`

```pawn
#if !defined BULLET_HIT_TYPE
#define BULLET_HIT_TYPE: _:
#endif
forward OnPlayerWeaponShot(playerid, weaponid, BULLET_HIT_TYPE:hittype, hitid, Float:fX, Float:fY, Float:fZ);
```

* `OnPlayerKeyStateChange`

```pawn
#if !defined KEY
#define KEY: _:
#endif
forward OnPlayerKeyStateChange(playerid, KEY:newkeys, KEY:oldkeys);
```

* `OnPlayerRequestDownload`

```pawn
#if !defined DOWNLOAD_REQUEST
#define DOWNLOAD_REQUEST: _:
#endif
forward OnPlayerRequestDownload(playerid, DOWNLOAD_REQUEST:type, crc);
```

### Streamer Plugin

There is a PR to extend these improved checks to the streamer plugin as well: https://github.com/samp-incognito/samp-streamer-plugin/pull/435 This PR includes more information on the tags.

* `Streamer_OnItemStreamIn`

```pawn
#if !defined STREAMER_TYPE
#define STREAMER_TYPE: _:
#endif
public Streamer_OnItemStreamIn(STREAMER_TYPE:type, STREAMER_ALL_TAGS:id, forplayerid)
{
}
```

* `Streamer_OnItemStreamOut`

```pawn
#if !defined STREAMER_TYPE
#define STREAMER_TYPE: _:
#endif
public Streamer_OnItemStreamOut(STREAMER_TYPE:type, STREAMER_ALL_TAGS:id, forplayerid)
{
}
```

### Upgrade Tool

Y_Less has been working on a tool to make porting code easier, here:

https://github.com/openmultiplayer/upgrade

This can scan all pawn files (`.inc`, `.p`, `.pawn`, `.pwn`) in a directory and search for function calls that look like the ones in these includes with new tags. It will find hook declarations following a standard `Lib_Native` naming scheme where `Native` is one known to have been enhanced, and thus upgrade these hooks automatically. It will also find many calls to the upgraded natives using bare numbers, so for example:

```pawn
SetTimer("MyFunction", 1000, 0);
```

Will be found and replaced by:

```pawn
SetTimer("MyFunction", 1000, false);
```

See the readme with the tool for more information, including adding your own upgrades, and checking output before applying the changes (always make backups first).

## How Do Versions Work?

### Versions are represented by [Git Tags](https://help.github.com/articles/working-with-tags/)
587 changes: 370 additions & 217 deletions a_actor.inc

Large diffs are not rendered by default.

149 changes: 99 additions & 50 deletions a_http.inc
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,66 +1,115 @@
/* SA-MP threaded HTTP/1.0 client for pawn
*
* (c) Copyright 2010, SA-MP Team
*
*/

#if defined _INC_a_http
#endinput
#endif
#define _INC_a_http
#define _http_included

#define SAMP_CONST_CORRECT
/**
* <library name="a_http" summary="SA-MP threaded HTTP/1.0 client for pawn.">
* <license>
* (c) Copyright 2010, SA-MP Team
* </license>
* <summary pawndoc="true">
* This library uses the enhanced <em>pawndoc.xsl</em> from
* <a href="https://github.com/pawn-lang/pawndoc">pawn-lang/pawndoc</a>.
* This XSL has features such as library and markdown support, and will not
* render this message when used.
* </summary>
* </library>
*/

#pragma tabsize 4
#define SAMP_CONST_CORRECT

/// <p/>

// --------------------------------------------------
// Defines
// --------------------------------------------------

// HTTP requests
#define HTTP_GET (1)
#define HTTP_POST (2)
#define HTTP_HEAD (3)
// Limits

// Invalids

// HTTP error response codes
// These codes compliment ordinary HTTP response codes returned in 'response_code'
// (10x) (20x OK) (30x Moved) (40x Unauthorised) (50x Server Error)
#define HTTP_ERROR_BAD_HOST (1)
#define HTTP_ERROR_NO_SOCKET (2)
#define HTTP_ERROR_CANT_CONNECT (3)
#define HTTP_ERROR_CANT_WRITE (4)
#define HTTP_ERROR_CONTENT_TOO_BIG (5)
#define HTTP_ERROR_MALFORMED_RESPONSE (6)
// Checks

/// <summary>Sends a threaded HTTP request.</summary>
/// <param name="index">ID used to differentiate requests that are sent to the same callback (useful for playerids)</param>
/// <param name="type">The type of request you wish to send</param>
/// <param name="url">The URL you want to request. (Without 'http://')</param>
/// <param name="data">Any POST data you want to send with the request</param>
/// <param name="callback">Name of the callback function you want to use to handle responses to this request</param>
/// <remarks>This function was added in <b>SA-MP 0.3b</b> and will not work in earlier versions!</remarks>
/// <returns><b><c>1</c></b> on success, <b><c>0</c></b> on failure.</returns>
/// <remarks>
/// <b>Request types:</b><p/>
/// <ul>
/// <li><b><c>HTTP_GET</c></b></li>
/// <li><b><c>HTTP_POST</c></b></li>
/// <li><b><c>HTTP_HEAD</c></b></li>
/// </ul>
/// </remarks>
/// <remarks>
/// <b>Response codes:</b><p/>
/// <ul>
/// <li><b><c>HTTP_ERROR_BAD_HOST</c></b></li>
/// <li><b><c>HTTP_ERROR_NO_SOCKET</c></b></li>
/// <li><b><c>HTTP_ERROR_CANT_CONNECT</c></b></li>
/// <li><b><c>HTTP_ERROR_CANT_WRITE</c></b></li>
/// <li><b><c>HTTP_ERROR_CONTENT_TOO_BIG</c></b></li>
/// <li><b><c>HTTP_ERROR_MALFORMED_RESPONSE</c></b></li>
/// <li>+ standard HTTP response codes</li>
/// </ul>
/// </remarks>
native HTTP(index, type, const url[], const data[], const callback[]);
// Enums
///

/**
* <library>a_http</library>
* <summary>HTTP request types</summary>
*/
#define HTTP_METHOD: __TAG(HTTP_METHOD):
enum HTTP_METHOD:__HTTP_METHOD
{
HTTP_GET = 1,
HTTP_POST,
HTTP_HEAD
}
static stock HTTP_METHOD:_@HTTP_METHOD() { return __HTTP_METHOD; }

///

/**
* <library>a_http</library>
* <summary>HTTP error response codes</summary>
* <remarks>
* These codes compliment ordinary HTTP response codes returned in 'responseCode'
* (10x) (20x OK) (30x Moved) (40x Unauthorised) (50x Server Error)
* </remarks>
*/
#define HTTP_ERROR: __TAG(HTTP_ERROR):
enum HTTP_ERROR:__HTTP_ERROR
{
HTTP_ERROR_BAD_HOST = 1,
HTTP_ERROR_NO_SOCKET,
HTTP_ERROR_CANT_CONNECT,
HTTP_ERROR_CANT_WRITE,
HTTP_ERROR_CONTENT_TOO_BIG,
HTTP_ERROR_MALFORMED_RESPONSE
}
static stock HTTP_ERROR:_@HTTP_ERROR() { return __HTTP_ERROR; }

/**
* <library>a_http</library>
* <summary>Sends a threaded HTTP request.</summary>
* <param name="index">ID used to differentiate requests that are sent to the same callback (useful
* for playerids)</param>
* <param name="method">The type of request you wish to send</param>
* <param name="url">The URL you want to request. (Without 'http://')</param>
* <param name="data">Any POST data you want to send with the request</param>
* <param name="callback">Name of the callback function you want to use to handle responses to this
* request</param>
* <remarks>This function was added in <b>SA-MP 0.3b</b> and will not work in earlier versions!</remarks>
* <returns><b><c>1</c></b> on success, <b><c>0</c></b> on failure.</returns>
* <remarks>
* <b>Request types:</b><br />
* <ul>
* <li><b><c>HTTP_GET</c></b></li>
* <li><b><c>HTTP_POST</c></b></li>
* <li><b><c>HTTP_HEAD</c></b></li>
* </ul>
* </remarks>
* <remarks>
* <b>Response codes:</b><br />
* <ul>
* <li><b><c>HTTP_ERROR_BAD_HOST</c></b></li>
* <li><b><c>HTTP_ERROR_NO_SOCKET</c></b></li>
* <li><b><c>HTTP_ERROR_CANT_CONNECT</c></b></li>
* <li><b><c>HTTP_ERROR_CANT_WRITE</c></b></li>
* <li><b><c>HTTP_ERROR_CONTENT_TOO_BIG</c></b></li>
* <li><b><c>HTTP_ERROR_MALFORMED_RESPONSE</c></b></li>
* <li>+ standard HTTP response codes</li>
* </ul>
* </remarks>
* <example>
* <code>
* // HTTP callback. <br />
* public MyHttpResponse(index, responseCode, const data[]) { ... }
* </code>
* </example>
*/
native HTTP(index, HTTP_METHOD:method, const url[], const data[], const callback[]);

// example HTTP callback: public MyHttpResponse(index, response_code, const data[]) { ... }

1,504 changes: 1,012 additions & 492 deletions a_npc.inc
100755 → 100644

Large diffs are not rendered by default.

1,564 changes: 962 additions & 602 deletions a_objects.inc
100755 → 100644

Large diffs are not rendered by default.

5,873 changes: 3,630 additions & 2,243 deletions a_players.inc
100755 → 100644

Large diffs are not rendered by default.

6,530 changes: 3,600 additions & 2,930 deletions a_samp.inc
100755 → 100644

Large diffs are not rendered by default.

416 changes: 309 additions & 107 deletions a_sampdb.inc
100755 → 100644

Large diffs are not rendered by default.

1,998 changes: 1,280 additions & 718 deletions a_vehicles.inc
100755 → 100644

Large diffs are not rendered by default.

Empty file modified pawn.json
100755 → 100644
Empty file.
613 changes: 613 additions & 0 deletions pawndoc.xsl

Large diffs are not rendered by default.