HttpWrite

From Multi Theft Auto: Wiki
Revision as of 01:19, 26 October 2007 by Jbeta (talk | contribs) (Documented)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function adds text to the output of the current HTML file of the HTTP interface.

Syntax

bool httpWrite ( string text )

Shortcut syntax

The following shortcut syntax is also supported:

[html]
<* = text *>

which is equivalent to:

[html]
<* httpWrite(text) *>

Required Arguments

  • text: the string of text to be added to the page's output.

Returns

Returns true if the text was added to the output buffer successfully, false otherwise.

Example

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( getRandomQuote() ) *>
   </body>
</html>

The first httpWrite call (in shortcut syntax) adds the links to scripts generated by the ajax resource, enabling use of the getRandomQuote function.

The second httpWrite call writes the quote generated by the function to the HTML output.

See Also

These functions can only be used from within lua blocks in HTML pages hosted by the server