Search the Community

Showing results for tags 'event'.



More search options

  • 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


About Me


Facebook


Youtube


Skype


Web


VK

Found 5 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. ok simple, what am i doing wrong? Yes I am new to JS: Serverside: mp.events.add('testEvent',(para1,para2,para3) => { console.log('para1:'+para1); console.log('para2:'+para2); console.log('para3:'+para3); }); Clientside: mp.events.callRemote('testEvent',1,2,3); Console: para1:[object Object] para2:1 para3:2 thanks for help! Hank edit: discovered https://wiki.rage.mp/index.php?title=Getting_Started_with_Events
  3. Hey! I just want to know, how can i cancel the chat message sending (event), because my code isn't working. Here is my code: mp.events.add("playerChat", (player, text) => { return true; });
  4. A similar but official and better system has been integrated into RageMP. To initialize at startup Call this anywhere public MainClass() : Script { //call before any events public MainClass() { RageEventHelper helper = new RageEventHelper(); } } Usage 1. Copy and paste the spoiler code in a new .cs file (Make sure to use needed libraries like LINQ) 2. See example below Notes 1. You are responsible for properly delegating every event at startup. Look in the example below. Only do this once in the main script file and you are set. 2. Events must be public static void methods Example (How to delegate the events properly at startup) public class MainClass : Script { public MainClass() { RageEventHelper helper = new RageEventHelper(); Event.OnPlayerEnterVehicleAttempt += OnPlayerEnterVehicleAttempt; Event.OnUpdate += OnUpdate; } public void OnPlayerEnterVehicleAttempt(Client player, Vehicle veh, sbyte seat) { RageEventExtender.InvokeAllMethods<OnPlayerEnterVehicleAttemptEvent>(RageEventExtender.OnPlayerEnterVehicleAttemptEvents, player, veh, seat); } public void OnUpdate() { RageEventExtender.InvokeAllMethods<OnUpdateEvent>(RageEventExtender.OnUpdateEvents, null); } } In another file (How to use the events) public class AnotherClass { [OnPlayerEnterVehicleAttempt] public static void OnEnterAttempt(Client player, Vehicle veh, sbyte seat) { //enter } [OnUpdate] public static void OnUpdateThing() { //update } }
  5. Всем привет. Зашел я значить на вики, да бы посмотреть что и как, какой функционал допилили, описание немного почитать. Наткнулся на серверною и клиентскою часть ивентов и охренел. Хочу спросить у вас дорогие форумчане - почему так мало ивентов, будут ли допиливать новые, что слышали по этому поводу?. С описанием функций и примерами тоже проблемы, но это вопрос времени. И помимо этого хочу задать такой вопрос. (возможно он не много глупый) Я так понимаю что серверною часть можно писать на разных языках. И если это так то поправочка к первому вопросу, меня интересуют ивенты на nodejs.