Jump to content

MTA:SA unexpected symbol near '<'


jean001

Recommended Posts

I just make a script to input a HTML into MTA:SA and i found error say "SCRIPT ERROR: html-test\index.html:1: unexpected symbol near '<' "

here my HTML code & lua script

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
</head>
<body>
    <img src="https://www.kibrispdr.org/data/gta-v-wallpaper-27.jpg" width="1340px" height="670px">
</body>
</html>
local screenWidth, screenHeight = guiGetScreenSize()
local page = "http://mta/local/index.html"
local webBrowser = guiCreateBrowser(0, 0, screenWidth, screenHeight, true, true, false)
local theBrowser = guiGetBrowser(webBrowser)

addEventHandler("onClientBrowserCreated", theBrowser, 
    function()
        loadBrowserURL(source, page)
        showCursor(true)
    end)

 

Link to comment

Why are you trying to run a .html file through Lua?

To do this correctly, you need to have two seperate files; one for the web page and your client side Lua code which loads the web page itself, from your error it looks like everything is in one file as you have displayed it? You cannot run HTML code and Lua within the same file.

Link to comment

Oh Sorry it's my mistake, i make two file there is index.html and client.lua the source code on the post should be have 2 like this

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
</head>
<body>
    <img src="https://www.kibrispdr.org/data/gta-v-wallpaper-27.jpg" width="1340px" height="670px">
</body>
</html>

client.lua

local screenWidth, screenHeight = guiGetScreenSize()
local page = "http://mta/local/index.html"
local webBrowser = guiCreateBrowser(0, 0, screenWidth, screenHeight, true, true, false)
local theBrowser = guiGetBrowser(webBrowser)

addEventHandler("onClientBrowserCreated", theBrowser, 
    function()
        loadBrowserURL(source, page)
        showCursor(true)
    end)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...