Jump to content

Snow-Man2

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Snow-Man2's Achievements

Square

Square (6/54)

0

Reputation

  1. i have found the problem that i was destroying theBrowser instead of destroying the Browser Element in this case initBrowser lol my bad
  2. okay thank you, i will do that it makes the same issue, its not solved yet this is what i have done my game crashes each time i try to close the browser bindKey("F5", "down", function() if isTimer(spamTimer) then return false end if not isElement(theBrowser) then local initBrowser = guiCreateBrowser(0, 0, sX, sY, true, true, false) theBrowser = guiGetBrowser(initBrowser) addEventHandler("onClientBrowserCreated", theBrowser, loadTheBrowser) else setBrowserRenderingPaused (theBrowser, true) destroyElement(theBrowser) theBrowser = nil end spamTimer = setTimer(function() end, 1000, 1) end)
  3. i use this destroyElement(theBrowser) theBrowser = nil
  4. thank you so much, its fixed now, when i did that line it returned object to me, so i used this leaderboardStats[0] and now it shows data on leaderboard but why each time i try to close the browser my game crashes even other people got the same problem like me, the game crashes for all of us
  5. i have realized that im using toJSON on server side and i have got rid of it now im not getting any errors just output on browser this type: string index.html:73 Parsed leaderboard data: [{…}]0: mostWanted: []npcKills: []pvpKills: Snow-Man: mostWanted: 0npcKills: 1pvpKills: 0stuntPoints: 0[[Prototype]]: Object[[Prototype]]: ObjectstuntPoints: Array(0)length: 0[[Prototype]]: Array(0)[[Prototype]]: Objectlength: 1[[Prototype]]: Array(0) its the output of console.log("type: ", typeof(leaderboardDataJSON)) and console.log("Parsed leaderboard data:", leaderboardStats); so no errors anymore but im not seeing these data showed up on html leaderboard
  6. when i did that i gave me the result as an object and then i have did what you told me to use this const result = JSON.parse(leaderboardStats[0]) then i got this error index.html:89 Error parsing leaderboard data: SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at window.populateLeaderboard (index.html:71:43) at <anonymous>:1:1
  7. this is the output of the result : leaderboard data: [ "[ { \"stuntPoints\": [ ], \"mostWanted\": [ ], \"pvpKills\": { \"Snow-Man\": { \"stuntPoints\": 0, \"mostWanted\": 0, \"pvpKills\": 0, \"npcKills\": 1 } }, \"npcKills\": [ ] } ]" ]
  8. thank you for replying, im getting this errror : Uncaught SyntaxError: missing ) after argument list
  9. i have some data like counts how many kills players got and will display them on html page, its a leaderboard page and when i press F5 to see the information for each player, the list is empty and not getting errors
  10. Snow-Man2

    MTA Crashes

    hello guys, im facing this problem each time i work on browser on MTA, each time it crashes i get this error : Version = 1.6-release-22746.0.000 Time = Fri Oct 4 12:08:06 2024 Module = C:\WINDOWS\SYSTEM32\d3d9.dll Code = 0xC0000005 Offset = 0x000601CC EAX=05FBF8A8 EBX=0EB5E4E0 ECX=00000000 EDX=00000000 ESI=004CFFE1 EDI=004D0041 EBP=0177FB88 ESP=0177FB74 EIP=696701CC FLG=00210206 CS=0023 DS=002B SS=002B ES=002B FS=0053 GS=002B and this is MTA Diag : https://pastebin.mtasa.com/2961377346
  11. html page works well, it can be displayed when i press on F5, so dont think that problem in this case
  12. function updateLeaderboard() local leaderboardData = { pvpKills = { ["player1"] = { pvpKills = 10, npcKills = 5, stuntPoints = 200, mostWanted = 2 }, ["player2"] = { pvpKills = 8, npcKills = 4, stuntPoints = 150, mostWanted = 1 } } } local leaderboardJSON = toJSON(leaderboardData) triggerClientEvent("updateLeaderboard", resourceRoot, leaderboardJSON) end this is what i have done on server side, i have added that table later to test faster. everything was working perfectly since it was displaying on dxDrawText but i wanted to go more further with this script and changed it to html page. so i can have better looking but found out that no errors and have changed everything possible to make it work even tried iprint everything and it already sends the data but it doesnt display. i have tested the javascript function on console and it works with no problem my main issue here is that im not having errors to catch and fix. so i thought its 100% sure the problem on javascript but no errors as well
  13. everything works correctly without errors and even no errors on console log this event "updateLeaderboard" called from server side so i can transfer data from server side to html list i dont see any changes done to my actual code that you did
  14. Hello guys, im working on script that sends information from Lua to html table but i dont know why it doesnt work. addEvent("updateLeaderboard", true) addEventHandler("updateLeaderboard", root, function(leaderboardData) local leaderboardJSON = toJSON(leaderboardData) local escapedJSON = string.gsub(leaderboardJSON, "'", "\\'") outputChatBox("Leaderboard JSON: " .. escapedJSON) if isElement(theBrowser) then local script = string.format("populateLeaderboard('%s');", escapedJSON) executeBrowserJavascript(theBrowser, script) end end) bindKey("b", "down", function() local leaderboardData = { pvpKills = { ["player1"] = { pvpKills = 10, npcKills = 5, stuntPoints = 200, mostWanted = 2 }, ["player2"] = { pvpKills = 8, npcKills = 4, stuntPoints = 150, mostWanted = 1 } } } local testJSON = toJSON(leaderboardData) local escapedTestJSON = string.gsub(testJSON, "'", "\\'") iprint(escapedTestJSON) if isElement(initBrowser) then local script = string.format("populateLeaderboard('%s');", escapedTestJSON) outputChatBox("SCRIPT : " ..script) --iprint("Working") executeBrowserJavascript(theBrowser, script) end end) i have shared my testing part too this is javascript side : document.addEventListener("DOMContentLoaded", function () { const leaderboardBody = document.getElementById('leaderboard-body'); window.populateLeaderboard = function (leaderboardDataJSON) { console.log("populateLeaderboard called with data:", leaderboardDataJSON); try { const leaderboardStats = JSON.parse(leaderboardDataJSON); console.log("Parsed leaderboard data:", leaderboardStats); leaderboardBody.innerHTML = ''; for (const playerName in leaderboardStats.pvpKills) { const playerData = leaderboardStats.pvpKills[playerName]; const row = document.createElement('tr'); row.innerHTML = ` <td>${playerName}</td> <td>${playerData.pvpKills}</td> <td>${playerData.npcKills}</td> <td>${playerData.stuntPoints}</td> <td>${playerData.mostWanted}</td> `; leaderboardBody.appendChild(row); } } catch (error) { console.error("Error parsing leaderboard data: ", error); } }; });
×
×
  • Create New...