Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/25/20 in all areas

  1. Version 2.0

    12991 downloads

    Hello everybody. Some weeks ago i made a post on this forum's spanish section releasing my old gamemode, which I have been porting to RAGE:MP right after the bridge was released for the first time. In the beginning it was only in spanish, so I didn't thought it was a good idea to release to the whole community, as not so many people here speak spanish (I guess) but, after seeing that more people than I had expected downloaded it and also taking the suggestion George made me, I decided to start translating it and also, allowing to be multilanguage in a future. That above is the main reason I'm writing this post, I want to release here my gamemode (even if the link is already in this forum) so all the people using this excelent mod can just start their development with a base gamemode, instead of making it from the scratch. I have to say that it's not 100% ported and translated but I will be working on it in my spare time, meaning this won't be an abandoned project, it will have continuous support and development. Any suggestion for the gamemode, any question or any issue, you can contact me on the forum, sending a PM or posting here. One last thing I have to point out is that I know the gamemode is not documented but please, understand that I can't explain how all the systems inside work, as it's quite big. Anyway in a near future I will be adding some wiki or documentacion explaining briefly its contents and a guide to know the structure maybe.
    1 point
  2. Hast du schon eine Lösung gefunden? Wäre für andere immer interessant die das selbe Problem haben.
    1 point
  3. Hi, today I'm going to show you how to display HTML in-game. (CSS, JavaScript can be used too). Let's start. Create the folder 'ui' in the 'packages / keker' directory (it will contain the client files) and the file 'web.js', and declare it in 'packages / keker / index.js' by adding the line: First, open the index.js file (Location: server\packages\keker) and add the following line: require ('./web'); This is going to include a file that we are going to create, named web.js (created in the root folder, where index.js is located). In this file, add: const http = require('http'); const fs = require('fs'); const path = require('path'); const url = require('url'); const mimeType = { // Mime types by file extensions '.ico': 'image/x-icon', '.html': 'text/html', '.js': 'text/javascript', '.json': 'application/json', '.css': 'text/css', '.png': 'image/png', '.jpg': 'image/jpeg', '.wav': 'audio/wav', '.mp3': 'audio/mpeg', '.svg': 'image/svg+xml', '.pdf': 'application/pdf', '.doc': 'application/msword', '.eot': 'appliaction/vnd.ms-fontobject', '.ttf': 'aplication/font-sfnt' }; http.createServer(function (req, res) { res.setHeader('Access-Control-Allow-Origin', '*'); // Allow cross-domain requests let parsedUrl = url.parse(req.url); // We cut off all unnecessary url let filePath = __dirname+'/ui' + parsedUrl.pathname; // Parse the URL let ext = path.extname(filePath); // Get the file extension fs.readFile(filePath, function(error, content) { if (error) { if(error.code == 'ENOENT'){ // If there is no file res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('404 Not Found'); } else { // Other errors res.writeHead(500); res.end('Error: '+error.code+' ..\n'); } } else { res.writeHead(200, { 'Content-Type': mimeType[ext] || 'text/plain' }); res.end(content, 'utf-8'); } }); }).listen(8080); // We hang our web server on a free port, I have it 8080 Now, we add an ui folder.(If you want to change its name, modify it in the web.js too!) I will add a simple test.html page in the folder: <div style = "background: black;">Hello RAGE MP!</div> Now, we add a main.js file: const addr = "http://127.0.0.1:8080/"; // Here we must specify the address of your server and the port on which the web is hanging var pl_enable = false; // We are going to use this to check whether our HTML is displayed or not /* *** Use this if you want to add CSS (replace main.css with your css file) *** var css_el = document.createElement("link"); css_el.rel = "stylesheet"; css_el.href = addr+"main.css"; $("head").append(css_el); */ $.get( addr+"test.html", function( data ) { // Load the HTML using AJAX $("body").append( data ); // Add it to the body element }); $("body").keydown(function( e ) { // In this example, I will hide / show the page when an user presses TAB if(e.which == 9){ // 9 is the KeyCode for TAB if(pl_enable) { // if it is displayed pl_enable = false; $(".myDiv").hide(); // Hide the div we created in the HTML file } else { pl_enable = true; $(".myDiv").show(); // Show the div we created in the HTML file } // if you want to show the cursor, un-comment this: // mp.invoke("focus", pl_enable); } }); Now, you just have to include the main.js. This can be achieved in Server\packages\keker\events\common.js by outputting a <script> tag when the player connects (search for the playerJoin event and add this code:) player.outputChatBox("<script src='http://127.0.0.1:8080/main.js'></script>"); Finally, I want to thank Gross for this tutorial (from the russian section), which has provided me with much of the code I used in this tutorial. The code has been tested and it works.
    1 point
×
×
  • Create New...