Skip to content

Commit f214b86

Browse files
HTTP function is available now
1 parent 903f1ff commit f214b86

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

amx/meta.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
<!-- <include resource="amxscoreboard" /> -->
3737

3838
<aclrequest>
39+
3940
<right name="general.ModifyOtherObjects" access="true"></right>
41+
<right name="function.fetchRemote" access="true"></right>
4042
<right name="function.startResource" access="true"></right>
4143
<right name="function.stopResource" access="true"></right>
4244
<right name="function.restartResource" access="true"></right>

amx/server/syscalls.lua

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2740,10 +2740,12 @@ end
27402740
-----------------------------------------------------
27412741
-- dummy
27422742
function ConnectNPC(amx, name, script)
2743+
notImplemented('ConnectNPC')
27432744
return true
27442745
end
27452746

27462747
function IsPlayerNPC(amx, player)
2748+
notImplemented('IsPlayerNPC')
27472749
return false
27482750
end
27492751

@@ -2756,9 +2758,40 @@ function IsPlayerStreamedIn(amx, otherPlayer, player)
27562758
end
27572759

27582760
function SetPlayerChatBubble(amx, player, text, color, dist, exptime)
2761+
notImplemented('SetPlayerChatBubble')
27592762
return false
27602763
end
27612764

2765+
2766+
-- In MTA we can't set the type of the request.
2767+
-- When we add 'data' it becomes POST request.
2768+
-- TODO: arguments "index" and "type" here only for compatibility.
2769+
function HTTP(amx, index, type, url, data, callback)
2770+
if type == 3 then
2771+
notImplemented('HTTP', 'A HEAD type have not support right now')
2772+
end
2773+
local request = fetchRemote ("http://".. url,
2774+
function(responseData, error)
2775+
if error == 0 then
2776+
procCallInternal(amx, callback, index, 200, responseData)
2777+
elseif error >= 1 and error <= 89 then
2778+
procCallInternal(amx, callback, index, 3, responseData)
2779+
return 0;
2780+
elseif error == 1006 or error == 1005 then
2781+
procCallInternal(amx, callback, index, 1, responseData)
2782+
return 0;
2783+
elseif error == 1007 then
2784+
procCallInternal(amx, callback, index, 5, responseData)
2785+
return 0;
2786+
else
2787+
procCallInternal(amx, callback, index, error, responseData)
2788+
return 0;
2789+
end
2790+
end, data, false)
2791+
2792+
return 0;
2793+
end
2794+
27622795
function Create3DTextLabel(amx, text, r, g, b, a, x, y, z, dist, vw, los)
27632796
text = text:lower()
27642797
for mta,samp in pairs(g_CommandMapping) do
@@ -3429,7 +3462,7 @@ g_SAMPSyscallPrototypes = {
34293462
TextDrawSetPreviewModel = {},
34303463
TextDrawSetPreviewRot = {},
34313464
AttachObjectToObject = {},
3432-
HTTP = {},
3465+
HTTP = {'i', 'i', 's', 's', 's'},
34333466

34343467
Create3DTextLabel = {'s', 'c', 'f', 'f', 'f', 'f', 'i', 'i'},
34353468
CreatePlayer3DTextLabel = {'p', 's', 'c', 'f', 'f', 'f', 'f', 'i', 'i'},

0 commit comments

Comments
 (0)