Jump to content

Search the Community

Showing results for tags 'Quit'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • RAGE Multiplayer
    • Announcements
    • Discussion
    • Suggestions
  • Scripting
    • Scripting
    • Resources
  • Community
    • Support
    • Servers
    • Media Gallery
  • Non-English
    • Русский - Russian
    • Français - French
    • Deutsch - German
    • Espanol - Spanish
    • Română - Romanian
    • Portuguesa - Portuguese
    • Polski - Polish

Categories

  • Scripts
  • Gamemodes
  • Libraries
  • Plugins
  • Maps
  • Tools

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Youtube


Skype


Web


VK

Found 2 results

  1. Hey Guys, hope you can help me with my problem. i want to end a function in a Event, if the player disconnects or leave the Server. But i only get crashes. Here my Code: function playerQuit(player) { console.log(`${player.name} has quit.`); } mp.events.add("playerQuit", playerQuit); // After player die mp.events.add("playerDeath", (player, reason, killer) => { //Set values hospital -> player dead/alive //hospitaltime -> time that he have to be in hospital player.hospital = 1; player.hospitaltime = 12; //update values in database gm.mysql.handle.query('UPDATE `accounts` SET hospital = ?, hospitaltime = ? WHERE username = ?', [player.hospital, player.hospitaltime, player.name], function(err, res, row){ if(err) console.log(err); }); if(player){ gm.mysql.handle.query('SELECT hospital, hospitaltime FROM `accounts` WHERE username = ?', [player.name], function(err, res){ if(err) console.log(err); //Read Values from Database player.hospital = parseInt(res[0]["hospital"]); player.hospitaltime = parseInt(res[0]["hospitaltime"]); }); //if player is dead do -> if(player.hospital == 1){ var timeLeft = parseInt(player.hospitaltime); var timerID = setInterval(countdown, 5000); //Countdown for hospitaltime function countdown(){ //if time over player have to be spawned and timeout have to be cleared if(timeLeft == 1){ clearTimeout(timerID); player.hospitaltime = 0; player.hospital = 0; gm.mysql.handle.query('UPDATE `accounts` SET hospital = ?, hospitaltime = ? WHERE username = ?', [player.hospital , player.hospitaltime, player.name], function(err, res, row){ if(err) console.log(err); }); player.spawn(new mp.Vector3(-799.5113525390625, -99.25785827636719, 37.604530334472656)); return; } else { // if player leave put values in database if(playerQuit.player.name == player.name){ clearTimeout(timerID); player.hospital = 1; player.hospitaltime = timeLeft; gm.mysql.handle.query('UPDATE `accounts` SET hospital = ?, hospitaltime = ? WHERE username = ?', [player.hospital , player.hospitaltime, player.name], function(err, res, row){ if(err) console.log(err); }); return; } //write new values timeLeft--; gm.mysql.handle.query('UPDATE `accounts` SET hospitaltime = ? WHERE username = ?', [timeLeft, player.name], function(err, res, row){ if(err) console.log(err); }); } } } } }); to test this code i have in my cmd.js this: mp.events.addCommand('kick', (player, target) => { let newTarget = mp.players.at(target); if(!target || isNaN(target)) return player.outputChatBox("Syntax: /kick [playerID]"); if(newTarget === null) return player.outputChatBox("There is no player online with the ID given.") newTarget.outputChatBox("You have been kicked from the server."); newTarget.kick('Kicked.'); }); My server crashes everytime when i kick me, when im in the hospital. it also crashes without this Code section: // if player leave put values in database if(playerQuit.player.name == player.name){ clearTimeout(timerID); player.hospital = 1; player.hospitaltime = timeLeft; gm.mysql.handle.query('UPDATE `accounts` SET hospital = ?, hospitaltime = ? WHERE username = ?', [player.hospital , player.hospitaltime, player.name], function(err, res, row){ if(err) console.log(err); }); return; } i get following logs in my console: Error: asyc stack has become corrutep (actual: 29, expected: 30) 1: 00007FF824079805 2: 00007FF824059B82 3: 00007FF824069CB3 4: 00007FF82409ABD0 5: 00007FF82415BCDE 6: 00007FF8241F810D 7: 00007FF8241F5066 [...]***more of them*** Edit: The problem was, that i had 2 events with the same name. now it does not crash anymore
  2. Hey guys, i just started new with JS and ragemp(big noob) and have a question. It probably sounds dumb. I wanted to get a console log after a player disconntects. I got this from the wiki and put it in my "./packages/project/index.js": function playerQuitHandler(player, exitType, reason) { let str = player.name; if (exitType != "kicked") { str += " quit."; } else { str = ` kicked. Reason: ${reason}.`; } console.log(str); } mp.events.add("playerQuit", playerQuitHandler); After i quit game i only get a message like(the message also comes a bit late): [N] 127.0.0.1:51274 has been disconnected. i probably forget something to add but dont know what. Thank you for your help! edit: did "solve" the problem by using: mp.events.add("playerQuit", (player) => { console.log(player.name + " quit."); );
×
×
  • Create New...