httpWrite | Multi Theft Auto: Wiki Skip to content

httpWrite

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Shortcut syntax

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function adds text to the output of the current HTTP file of the HTTP interface. The function can only be used on parsed (i.e not marked as raw) HTTP pages. httpWrite can support outputing binary data, if you specify the length of the data you are outtputing. If you do this, you should ensure you set an accurate content-type using httpSetResponseHeader otherwise it may be displayed inconsistently by browsers.

Syntax

httpWrite ( )

Code Examples

server

Example 1:This sample resource page will output a random quote from a player using a function previously exported to http from a Lua script in the resource.

[html]
<html>
<head>
<* = call ( getResourceFromName("ajax"), "start", getResourceName(getThisResource()) ) *>
</head>
<body>
<b>Random quote:</b> <* httpWrite( call ( getThisResource(), "getRandomQuote" ) ) *>
</body>
</html>