Jump to content

[REL] Custom Web Browser


Recommended Posts

You can make a table that saves the last pages you visit, like:

local lastVisited = { } 
  
-- When you enter to a website 
table.insert ( lastVisited, guiGetText ( url ) ) 
-- Or 
lastVisited = guiGetText ( url ) 

And when the players clicks the last page button, set the URL to the last visited page.

Keep it up, it's a very nice script :)

Sorry for my bad English :S

Link to comment
You can make a table that saves the last pages you visit, like:
local lastVisited = { } 
  
-- When you enter to a website 
table.insert ( lastVisited, guiGetText ( url ) ) 
-- Or 
lastVisited = guiGetText ( url ) 

And when the players clicks the last page button, set the URL to the last visited page.

Keep it up, it's a very nice script :)

Sorry for my bad English :S

Thank, Ive using tables, and inserts works correct, but not works correctly navigation from urls in table. I dont know why, bcs in theory it works good, but in practice - doesnt work xD

Link to comment

This sounds very stupid, but, ¿do you try to make it 'tostring'? Like...

local url = guiGetText ( url ) 
local urlTable = tostring ( url ) 
table.insert ( last, urlTable ) 

I make this with a script that i have and it works in setting text to memo. :roll:

Link to comment
This sounds very stupid, but, ¿do you try to make it 'tostring'? Like...
local url = guiGetText ( url ) 
local urlTable = tostring ( url ) 
table.insert ( last, urlTable ) 

I make this with a script that i have and it works in setting text to memo. :roll:

-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

Link to comment
-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

You can try something like this:

-- define these two at the start 
history = {} 
curPos = 1 
  
-- define these when navigating 
total = #history 
history[url] = getBrowserURL(browser) -- store the current page url 
  
-- in example 
  
function back() 
    if curPos > 1 then 
        curPos = curPos - 1 
    end 
    setBrowserURL(browser,history[curPos]) 
end 
  
function forward() 
    local total = #history 
     
    if curPos < #history then 
        curPos = curPos + 1 
    end 
end 

There are some mistakes here and there but you get the idea.

Edited by Guest
Link to comment
-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

You could try something like this:

-- define these two at the start 
history = {} 
curPos = 1 
  
-- define these when navigating 
total = #history 
history[url] = getBrowserURL(browser) -- store the current page url 
  
-- in example 
  
function back() 
    if curPos > 1 then 
        curPos = curPos - 1 
    end 
    setBrowserURL(browser,history[curPos]) 
end 
  
function forward() 
    local total = #history 
     
    if curPos < #history then 
        curPos = curPos + 1 
    end 
end 

Not tested sorry if I made any mistakes.

Yea, something like this is what i wanna say :lol:

Link to comment
-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

You can try something like this:

-- define these two at the start 
history = {} 
curPos = 1 
  
-- define these when navigating 
total = #history 
history[url] = getBrowserURL(browser) -- store the current page url 
  
-- in example 
  
function back() 
    if curPos > 1 then 
        curPos = curPos - 1 
    end 
    setBrowserURL(browser,history[curPos]) 
end 
  
function forward() 
    local total = #history 
     
    if curPos < #history then 
        curPos = curPos + 1 
    end 
end 

There are some mistakes here and there but you get the idea.

It doesnt works, i dont know why, but the same system ive created for browser, of course with browser tab navigation history, and it doesnt work.

Link to comment
It doesnt works, i dont know why, but the same system ive created for browser, of course with browser tab navigation history, and it doesnt work.

Well, then something is conflicting in your script or you're not doing it right. Can you show us what you have that doesn't work?

Link to comment
Well, then something is conflicting in your script or you're not doing it right. Can you show us what you have that doesn't work?

Main file.

Line 338: Element - Cache (it is table of visited pages), element - Position (number of link in history), element - SaveInCache (when navigating from next/prev, it false, bcs no need to save link)

Line 250 and 260: Event for click on buttons Next and Previous

Line 445 and 448, 523 and 526: check for cache to make buttons enabled or disabled for click (like in browser)

Line 462: Enabling cache saving

Line 533: When loading page, insert loaded link in Cache table

Line 631: Function loadWebURL have argument to saving URL in Cache

Link to comment

Ah, just ignore those changes on Github I wasn't paying attention to the "return false end". I will take a better look at it tonight. Apologies!

Can you answer BluePie's question, though? What is it exactly that's not working in your code? Are the pages not loading or are you unable to navigate? What's happening in-game?

Link to comment
  • 3 weeks later...
Again. Doesnt work correctly moving between table links. For ex - when clicking "Back", sometimes browser thinks that previous page is first, and block this button, in forward - same.

Yeah, I made a small test browser and I had the same issue. It seems that some of the events sometimes return more than just one page so it can make it a little difficult for you.

Maybe you can look at the official webbrowser resource that comes with the MTA server, to see how they did it.

Link to comment
  • 2 months later...
  • 2 weeks later...

So time to report bugs :P

1. If I go to google, I can't open any link from there (just nothing happens, I guess it's same with all external links).

2. When I open youtube and minimize MTA the sound still continues, wouldn't it be better to link it to the MTA volume and when game minimized=sound muted?

3. Maybe make it possible for each client to set his own bookmarks (admin should set one main homepage for all)? That would be cool.

Link to comment
  • 1 year later...

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...