Search the Community
Showing results for '{query}'.
Found 91 results
-
Guten Tag und zwar habe ich da ein kleines Problem mit mit meinem Login System sobald ich einen Query ausführe habe ich folgendes in der server_exceptions.txt stehen ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load the specified file. File name: 'System.ComponentModel.Primitives' at Assembly System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load the specified file. File name: 'System.ComponentModel.TypeConverter' at Assembly System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load file or assembly 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at RuntimeMethodHandleInternal ModuleHandle.ResolveMethod(RuntimeModule module, int methodToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount) at RuntimeMethodHandleInternal ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load the specified file. File name: 'System.ComponentModel.TypeConverter' at Assembly System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load file or assembly 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at void ModuleHandle.ResolveType(RuntimeModule module, int typeToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount, ObjectHandleOnStack type) at RuntimeType ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, int typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.TypeLoadException: Could not load type 'System.Management.WbemDefPath' from assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. at System.Management.ManagementPath.CreateWbemPath(String path) at System.Management.ManagementPath..ctor(String path) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load the specified file. File name: 'System.ComponentModel.TypeConverter' at Assembly System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load file or assembly 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at RuntimeMethodHandleInternal ModuleHandle.ResolveMethod(RuntimeModule module, int methodToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount) at RuntimeMethodHandleInternal ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load the specified file. File name: 'System.ComponentModel.TypeConverter' at Assembly System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.IO.FileNotFoundException: Could not load file or assembly 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.ComponentModel.TypeConverter, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at void ModuleHandle.ResolveType(RuntimeModule module, int typeToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount, ObjectHandleOnStack type) at RuntimeType ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, int typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.TypeInitializationException: The type initializer for 'System.Management.ManagementPath' threw an exception. ---> System.TypeLoadException: Could not load type 'System.Management.WbemDefPath' from assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. at System.Management.ManagementPath.CreateWbemPath(String path) at System.Management.ManagementPath..ctor(String path) at System.Management.ManagementPath..cctor() --- End of inner exception stack trace --- at System.Management.ManagementScope._Clone(ManagementScope scope, IdentifierChangedEventHandler handler) ========================================================= ==================[10/5/19 5:38:43 PM]================== System.ArgumentException: 'windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Parameter name: name at int System.Globalization.EncodingTable.GetCodePageFromName(string name) ========================================================= Alle dlls sind im runtime Order auf meinem Linux server.. Ich habe versucht die System.ComponentModel.TypeConverter aus dem dotnet Ordner hoch zu laden aber dann läuft der Server nicht mehr. Über jede hilfe freue ich mich Edit: Oder kann ich es ignorieren da die querys richtig ausgeführt werden?
-
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
-
Всем привет. В эвенте playerReady имеется следующий функционал: console.log("Отправляем запрос"); global.database.query(`SELECT * FROM accounts WHERE sc_name=?`, [player.socialClub], (err, rows) => { if(err) throw err; console.log("The accounts sc_name " + player.socialClub + " is: " + rows); if(rows.length > 0) { console.log("Аккаунт зарегистрирован"); } else { console.log("Аккаунт НЕ зарегистрирован"); } }); В итоге отправляется в консоль только это "Отправляем запрос", а сам запрос почему то не уходит... В index.js: global.database = require("./database"); А в database.js: var mysql = require('mysql'); var pool = undefined; module.exports.setup = function() { pool = mysql.createPool({ host: 'localhost', user: 'root', database: 'basename', password: '', }); } module.exports.query = function(query, callback){ return pool.getConnection(function(err, connection) { connection.query(query, function(err, result, fields) { connection.release(); callback(err, result, fields); }); }); } Помогите пожалуйста( Кстати если в index.js после подключения сделать: database.query('SELECT * FROM accounts WHERE 1', function(err, rows, fields) { if (err) throw err; console.log('The accounts is: ', rows); }); Как НИ странно запрос отправляется, о чем говорит приход сообщения в логи...
-
I don't know how to use MySQL query. so please help me
-
Добрый вечер. Никак не могу подключится к БД, уже 6 час сижу, вообще ни в какую!!! Помогите пожалуйста(( Код в index.js: global.database = require("./database"); global.database.setup(); global.database.query("SELECT * FROM accounts WHERE ?", [1], (error, result) => { if (error) { console.log("Ошибка - " + error); } else { console.log("Все ок, подключение и тд есть"); } }); А вот код в database.js: var mysql = require('mysql'); var pool = undefined; module.exports.setup = function() { pool = mysql.createPool({ host : "127.0.0.1", user : "root", password : "", database : "mysql" }); } module.exports.query = function(query, callback){ return pool.getConnection(function(err, connection) { connection.query(query, function(err, result, fields) { connection.release(); callback(err, result, fields); }); }); } Ошибка, при запуске консоль думает-думает и выкидывает ошибку и закрывает консоль. Ошибка: Error: async hook stack has become corrupted (actual: 12, expected: 13) Подключался уже и к своей удаленной базе, думал в этом проблема, установил Denwer - ТА ЖЕ ситуация...
-
roleplay Roleplay Projekt sucht Supporter, Mapper und Designer
Tenchuu replied to SnillocTV's topic in Server Werbung
Ich habe rein garnichts geklaut, Snilloc hatte alles auf Github und es war Public zugänglich. Zudem hast du KEINE Lizenz. Aber mach mal weiter mit deinen Lügen. Wird schon schief gehen. Die User sollen selber sehen dass du Nichts kannst! Und damit du nicht immer Items per Datenbank manuell Eintragen musst, habe ich dir mal was kleines gebaut *Lache innerlich* mp.events.addCommand("addshopitem", (player, full, id, itemId, price, shopId, name) => { gm.mysql.handle.query("INSERT INTO shop_items SET id = ?, itemId = ?, price = ?, shopId, = ? name = ?", [id, itemId, price, shopId, name], function (err, res) { if(err) console.log("Error in addshopitem : " + err); player.notify("~g~Du hast erfolgreich das Item" + name + "dem Shop mit der ID " + shopId + " hinzugefügt!") }); }); Usage : /addshopitem <ItemEintragsId> <ItemId> <Price> <ShopID> Keine Ahnung wie man den ganzen Kram nur Zeile für Zeile manuell eintragen kann. Ach und hier deine Logs die nicht funktioniert haben. Gern geschehen. mp.events.add({ "sqlLog": async (player, logfile) => { try { if (!player) return; if (!logfile) return; var charname = "" + player.data.firstname + " " + player.data.lastname; gm.mysql.handle.query("INSERT INTO logs (playername, log, socialclub, ip) VALUES (?, ?, ?, ?)", [charname, logfile, player.socialClub, player.ip], function (err, res) { if (err) console.log("FILE: ERROR on sqlLog for player " + player.data.ingameName + ": " + err); }); } catch (ex) { return console.log("FILE: ERROR on sqlLog for player " + player.data.ingameName + ": " + ex); } } }); mp.events.add({ "adminLog": async (player, logfile) => { try { if (!player) return; if (!logfile) return; var charname = "" + player.data.firstname + " " + player.data.lastname; gm.mysql.handle.query("INSERT INTO adminlogs (playername, log, socialclub, ip) VALUES (?, ?, ?, ?)", [charname, logfile, player.socialClub, player.ip], function (err, res) { if (err) console.log("FILE: ERROR on sqlLog for admin " + player.data.ingameName + ": " + err); }); } catch (ex) { return console.log("FILE: ERROR on sqlLog for admin " + player.data.ingameName + ": " + ex); } } }); -
I've posted a message on the discord server and followed the https://discordapp.com/channels/183979885788659713/379670365061775360/615468230294896640 tutorial, as instructed. Now I can actually create the db context, but I get an error when trying to use it: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform. at new Microsoft.Data.SqlClient.SqlConnection(string connectionString) at DbConnection Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection() at DbConnection Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection() at DbCommand Microsoft.EntityFrameworkCore.Storage.RelationalCommand.CreateCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod) at RelationalDataReader Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at bool Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor+QueryingEnumerable<T>+Enumerator.MoveNext() at TSource System.Linq.Enumerable.Single<TSource>(IEnumerable<TSource> source) at TResult Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute<TResult>(Expression query) at TResult Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute<TResult>(Expression expression) at int System.Linq.Queryable.Count<TSource>(IQueryable<TSource> source) at new TestResource.Main() in D:\Games\RageMP\server-files\bridge\resources\TestResource\Main.cs:line 15 --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor) at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at GTANetworkInternals.GameServer.InstantiateScripts(Assembly targetAssembly, String resourceName)+MoveNext() at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext() at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at GTANetworkInternals.GameServer.StartResource(String resourceName, String parent) using Database; using GTANetworkAPI; using System; using System.Linq; namespace TestResource { public class Main : Script { public Main() { Console.WriteLine("Hello World"); using (var dbContext = new ServerDbContext()) { Console.WriteLine($"There are {dbContext.Accounts.Count()} accounts in the database!"); } } } }
-
Hello, I hope for help here, I'm just about to create a fraction system, but I come in the query whether the player in the group is not further. my plan should look like this, but how the implementation works I unfortunately do not know yet. I would have to put PlayerEnterVehicle on a certain road, or all fraction vehicles
-
hello, i need some help for my function, i make it returned a value under JSON.stringify but since it's an asynchronous function, it sends it to me with promise {result} so I can not use JSON.parse after. If you have a solution to my problem, I do not mind async getItemForPlayerMenu(id) { const playerItem = []; const data = await misc.query(`SELECT u.*, i.itemName, i.usable, i.itemcount FROM user_items u LEFT JOIN items i ON i.id = u.itemId WHERE u.charId = "${id}"`); for (const item of data) { if (item.charId !== id) continue; const v = { id: item.id, owner: item.charId, itemId: item.itemId, amount: item.amount, title: item.itemName, usable: item.usable, poids: item.itemcount } playerItem.push(v); } return JSON.stringify(playerItem); } Promise { '[{"id":1,"owner":6,"itemId":1,"amount":10,"title":"Eau","usable":"Y","poids":1},{"id":2,"owner":6,"itemId":2,"amount":10,"title":"Sandwich","usable":"Y","poids":1}]' }
-
Version 1.0.2
1712 downloads
Features overview Account system with timed bans A simple admin system Spawn protection (optional) Weapon shops and garages Crouching Killstreaks Different firing modes (single, burst, auto, safe mode) Turf capturing Getting started Put the files in their respective places Go to packages/thewire/config.json and write your database information Import the database.sql file using phpMyAdmin and such Start your server, should be done Making yourself admin Make an account Go to accounts table and set Admin field's value to 1 OR run a query to do it: UPDATE accounts SET Admin=1 WHERE Username='YourAccountName' Save and login ingame Team management Go to packages/thewire/data/teamData.json, teams are stored in this file as key:value For ColorName and ColorHex, check WIKI: Fonts and Colors For VehicleColor, check WIKI: Vehicle Colors For BlipColor, check WIKI: Blips If you remove a key:value pair, you'll remove that team Save file & restart the server Adding/removing vehicles Go to packages/thewire/data/teamData.json, vehicles are connected to teams Add your vehicle model name (e.g zentorno) to the Vehicles array of the team(s) you want Go to packages/thewire/data/vehiclePrices.json Add your vehicle model name and price. (e.g "zentorno": 10000) Save files & restart the server Adding/removing weapons Go to packages/thewire/data/weaponPrices.json Make sure the weapon you want to add is valid! See WIKI: Weapons Add your weapon name and price. (e.g "WEAPON_PISTOL50": 900) Save file Go to client_packages/cef/weaponIcons Add your weapon icon with the file name being your weapon hash (not the name!) Restart the server Config.json This file is located in packages/thewire/ and lets you control a lot of things. database: Write your database information here. dbLogging: Lets you control which parts of logging is enabled. A lot of stuff are being logged by default. loginDimension: The dimension joined players get sent to. (Default: -1) startingMoney: The amount of money registered players get. (Default: 1500) spawnProtectionSeconds: Duration of the spawn protection, in seconds. (Default: 5) accountSaveInterval: Interval of the auto save to prevent stat loss, in minutes. (Default: 10) killRewardMin and killRewardMax: The amount of money players get for killing an enemy. (Default: 100 and 200) teamKillPenalty: The amount of money loss players get for team killing. (Default: 1000) killstreakReward: The base amount of money a player gets for a 5+ killstreak. Killstreak reward is calculated as: killstreakCount * reward on every factor of 5. (Default: 100) weaponShopMagCount: How many magazines a player gets when they buy a weapon. (Default: 6) playerVehicleSpawnLimit: How many vehicles a player can have spawned at once. (Default: 5) turfCaptureMaxProgressIncrease: Turf attack progress cap. People more than this amount isn't required in the checkpoint. (Default: 5) turfCaptureRequiredProgress: Required progress to capture a turf. (Default: 50) turfIncomeInterval: Interval of the turf income sharing between team members, in minutes. (Default: 15) bcryptCost: Read this (Default: 10) spawnWeapons: Weapons and ammo the players get when they spawn. This applies to all teams. (Default: Bat and Pistol with 240 ammo) world: World settings, there is actually a time system but it doesn't show itself until a few hours pass. (Default: CLEAR weather and 10:00:00) log4js: Logger settings, you don't really need to touch this. Turfs Teams can capture turfs in this gamemode and make money. All you need to do is stand in a turf checkpoint, wait until the progress reaches 100% (it will be captured faster if there are teammates with you, up to 5 players) Though doing that will alert the turf's current owners. If the owners manage to clear the turf before it is captured, they'll keep it. Turf income happens every 15 minutes which just sums all of your team's turf income and shares it between team members. Admin Commands /tp [x] [y] [z] - Lets you teleport to a position. /agivemoney [player ID] [amount] - Gives money to a player. /agiveweapon [player ID] [weapon name] [ammo] - Gives weapons to a player. /kick [player ID] [reason] - Kicks a player. /banplayer [player ID] [days] [reason] - Bans a player. /banaccount [account ID] [days] [reason] - Bans an account, best used for banning players that are offline. /baninfo [ban ID] - Returns information about a ban. /removeban [ban ID] - Removes a ban. /createweaponshop - Creates a weapon shop on your position. /removeweaponshop [ID] - Removes a weapon shop. /creategarage - Creates a garage on your position. /removegarage [ID] - Removes a garage. /createturf [income] [radius] [name] - Creates a turf on your position. Radius isn't used right now but it will be in 0.4. /removeturf [ID] - Removes a turf. Player Commands /pm [player ID] [message] - Sends a private message to a player. /stats [player ID] - Shows the stats of a player. (Kills, deaths, K/D ratio, money, register date) /givemoney [player ID] [amount] - Sends money from your account to another player's account. /top5 [ranking] - Shows the top 5 online players of a ranking. (Available rankings: kills, money) If you encounter a bug, feel free to leave it as a comment. Hopefully all this text is enough, have fun and see you on the battlefield! -
For some reason the script cant get x, y, z from my database, if im using normal cordinates instead of x,yz its working fine. mp.events.add("server:KeyE", (player) => { gm.databaseManager.getConnection().query("SELECT * FROM garagen WHERE 1=1",[],function(err,res) { console.log("Geht"); if (err) console.log("Error in Garagen: "+err); for(let i = 0; i < res.length; i++) { let GaragenCol = mp.colshapes.newSphere(parseInt(res[0].X),parseInt(res[0].Y),parseInt(res[0].Z), 3, 0); if(GaragenCol.isPointWithin(player.position)) { mp.events.call("server:garagemenu",player,res[i].id); } } }); }); Can anyone help me with that?
-
Hey, so I wanted to create a MySQL Query where something in one table gets updated and something gets created in another table. That works so far, but I want to send a Error Message to the player, if `name1` already exists. public static int CreatePlayerSkin(Client player, AccountModel account, SkinModel skin) { NAPI.Util.ConsoleOutput("Debug 1"); int playerId = 0; using (MySqlConnection connection = new MySqlConnection(connectionString)) { NAPI.Util.ConsoleOutput("Debug 2"); try { NAPI.Util.ConsoleOutput("Debug 3"); connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "UPDATE accounts SET sex = @sex, name = @name WHERE socialName = @socialName LIMIT 1"; command.Parameters.AddWithValue("@sex", account.sex); command.Parameters.AddWithValue("@name", account.realName); command.Parameters.AddWithValue("@socialName", account.socialName); command.ExecuteNonQuery(); player.SetData(EntityData.PLAYER_SEX, account.sex); NAPI.Util.ConsoleOutput("Debug 4"); playerId = (int)command.LastInsertedId; command.CommandText = "INSERT INTO `skins` (`name1`, `socialName`, `firstHeadShape`, `secondHeadShape`, `firstSkinTone`, `secondSkinTone`, `headMix`, `skinMix`, "; command.CommandText += "`hairModel`, `firstHairColor`, `secondHairColor`, `beardModel`, `beardColor`, `chestModel`, `chestColor`, `blemishesModel`, "; command.CommandText += "`ageingModel`, `complexionModel`, `sundamageModel`, `frecklesModel`, `noseWidth`, `noseHeight`, `noseLength`, `noseBridge`, `noseTip`, `noseShift`, "; command.CommandText += "`browHeight`, `browWidth`, `cheekboneHeight`, `cheekboneWidth`, `cheeksWidth`, `eyes`, `lips`, `jawWidth`, `jawHeight`, `chinLength`, "; command.CommandText += "`chinPosition`, `chinWidth`, `chinShape`, `neckWidth`, `eyesColor`, `eyebrowsModel`, `eyebrowsColor`, `makeupModel`, `blushModel`, `blushColor`, "; command.CommandText += "`lipstickModel`, `lipstickColor`) VALUES (@name1, @socName, @firstHeadShape, @secondHeadShape, @firstSkinTone, @secondSkinTone, @headMix, @skinMix, "; command.CommandText += "@hairModel, @firstHairColor, @secondHairColor, @beardModel, @beardColor, @chestModel, @chestColor, @blemishesModel, @ageingModel, "; command.CommandText += "@complexionModel, @sundamageModel, @frecklesModel, @noseWidth, @noseHeight, @noseLength, @noseBridge, @noseTip, @noseShift, @browHeight, "; command.CommandText += "@browWidth, @cheekboneHeight, @cheekboneWidth, @cheeksWidth, @eyes, @lips, @jawWidth, @jawHeight, @chinLength, @chinPosition, @chinWidth, "; command.CommandText += "@chinShape, @neckWidth, @eyesColor, @eyebrowsModel, @eyebrowsColor, @makeupModel, @blushModel, @blushColor, @lipstickModel, @lipstickColor)"; command.Parameters.AddWithValue("@name1", account.realName); command.Parameters.AddWithValue("@socName", player.SocialClubName); command.Parameters.AddWithValue("@firstHeadShape", skin.firstHeadShape); command.Parameters.AddWithValue("@secondHeadShape", skin.secondHeadShape); command.Parameters.AddWithValue("@firstSkinTone", skin.firstSkinTone); command.Parameters.AddWithValue("@secondSkinTone", skin.secondSkinTone); command.Parameters.AddWithValue("@headMix", skin.headMix); command.Parameters.AddWithValue("@skinMix", skin.skinMix); command.Parameters.AddWithValue("@hairModel", skin.hairModel); command.Parameters.AddWithValue("@firstHairColor", skin.firstHairColor); command.Parameters.AddWithValue("@secondHairColor", skin.secondHairColor); command.Parameters.AddWithValue("@beardModel", skin.beardModel); command.Parameters.AddWithValue("@beardColor", skin.beardColor); command.Parameters.AddWithValue("@chestModel", skin.chestModel); command.Parameters.AddWithValue("@chestColor", skin.chestColor); command.Parameters.AddWithValue("@blemishesModel", skin.blemishesModel); command.Parameters.AddWithValue("@ageingModel", skin.ageingModel); command.Parameters.AddWithValue("@complexionModel", skin.complexionModel); command.Parameters.AddWithValue("@sundamageModel", skin.sundamageModel); command.Parameters.AddWithValue("@frecklesModel", skin.frecklesModel); command.Parameters.AddWithValue("@noseWidth", skin.noseWidth); command.Parameters.AddWithValue("@noseHeight", skin.noseHeight); command.Parameters.AddWithValue("@noseLength", skin.noseLength); command.Parameters.AddWithValue("@noseBridge", skin.noseBridge); command.Parameters.AddWithValue("@noseTip", skin.noseTip); command.Parameters.AddWithValue("@noseShift", skin.noseShift); command.Parameters.AddWithValue("@browHeight", skin.browHeight); command.Parameters.AddWithValue("@browWidth", skin.browWidth); command.Parameters.AddWithValue("@cheekboneHeight", skin.cheekboneHeight); command.Parameters.AddWithValue("@cheekboneWidth", skin.cheekboneWidth); command.Parameters.AddWithValue("@cheeksWidth", skin.cheeksWidth); command.Parameters.AddWithValue("@eyes", skin.eyes); command.Parameters.AddWithValue("@lips", skin.lips); command.Parameters.AddWithValue("@jawWidth", skin.jawWidth); command.Parameters.AddWithValue("@jawHeight", skin.jawHeight); command.Parameters.AddWithValue("@chinLength", skin.chinLength); command.Parameters.AddWithValue("@chinPosition", skin.chinPosition); command.Parameters.AddWithValue("@chinWidth", skin.chinWidth); command.Parameters.AddWithValue("@chinShape", skin.chinShape); command.Parameters.AddWithValue("@neckWidth", skin.neckWidth); command.Parameters.AddWithValue("@eyesColor", skin.eyesColor); command.Parameters.AddWithValue("@eyebrowsModel", skin.eyebrowsModel); command.Parameters.AddWithValue("@eyebrowsColor", skin.eyebrowsColor); command.Parameters.AddWithValue("@makeupModel", skin.makeupModel); command.Parameters.AddWithValue("@blushModel", skin.blushModel); command.Parameters.AddWithValue("@blushColor", skin.blushColor); command.Parameters.AddWithValue("@lipstickModel", skin.lipstickModel); command.Parameters.AddWithValue("@lipstickColor", skin.lipstickColor); command.ExecuteNonQuery(); NAPI.Util.ConsoleOutput("Character created"); player.TriggerEvent("cancelCharacterCreation2"); player.SetData(EntityData.PLAYER_TUTORIAL, 2); Globals.OnPlayerSpawn(player); } catch (Exception ex) { NAPI.Util.ConsoleOutput("[EXCEPTION CreateCharacter] " + ex.Message); NAPI.Util.ConsoleOutput("[EXCEPTION CreateCharacter] " + ex.StackTrace); player.TriggerEvent("characterNameDuplicated"); } } return playerId; } So, If `name1` already exists in the table `skins` I want that "catch (Exception ex)" gets called, where it triggers the Event "characterNameDuplicated", but Idk how I should do that. Maybe somebody here has some idea. Btw. that's the WiredPlayers-RP Gamemode from the resource on this forum here. Thanks
-
Version 1.1.0
99 downloads
About this File I used this res to create my res: Shortcuts (Animations) on Numpad 1.0.0 Before first Startup: you import db.sql in your Database and change "Yourname" in the record or leave it. I used RPC in this example, install it. My node_modules are in the archive located. Do this on Login/Startup Serverside gm.mysql.handle.query("SELECT * FROM shortcuts WHERE name = ?", [player.name], function (err10,res10) { if (err10) console.log("Error in loadShortcuts: "+err10); if (res10.length > 0) { res10.forEach(function (shortcutData) { player.data.numpad1A = shortcutData.num1animA; player.data.numpad1B = shortcutData.num1animB; player.data.numpad1C = shortcutData.num1animC; player.data.numpad1D = shortcutData.num1animD; player.data.numpad1Name = shortcutData.num1name; player.data.numpad2A = shortcutData.num2animA; player.data.numpad2B = shortcutData.num2animB; player.data.numpad2C = shortcutData.num2animC; player.data.numpad2D = shortcutData.num2animD; player.data.numpad2Name = shortcutData.num2name; player.data.numpad3A = shortcutData.num3animA; player.data.numpad3B = shortcutData.num3animB; player.data.numpad3C = shortcutData.num3animC; player.data.numpad3D = shortcutData.num3animD; player.data.numpad3Name = shortcutData.num3name; player.data.numpad4A = shortcutData.num4animA; player.data.numpad4B = shortcutData.num4animB; player.data.numpad4C = shortcutData.num4animC; player.data.numpad4D = shortcutData.num4animD; player.data.numpad4Name = shortcutData.num4name; player.data.numpad5A = shortcutData.num5animA; player.data.numpad5B = shortcutData.num5animB; player.data.numpad5C = shortcutData.num5animC; player.data.numpad5D = shortcutData.num5animD; player.data.numpad5Name = shortcutData.num5name; player.data.numpad6A = shortcutData.num6animA; player.data.numpad6B = shortcutData.num6animB; player.data.numpad6C = shortcutData.num6animC; player.data.numpad6D = shortcutData.num6animD; player.data.numpad6Name = shortcutData.num6name; player.data.numpad7A = shortcutData.num7animA; player.data.numpad7B = shortcutData.num7animB; player.data.numpad7C = shortcutData.num7animC; player.data.numpad7D = shortcutData.num7animD; player.data.numpad7Name = shortcutData.num7name; player.data.numpad8A = shortcutData.num8animA; player.data.numpad8B = shortcutData.num8animB; player.data.numpad8C = shortcutData.num8animC; player.data.numpad8D = shortcutData.num8animD; player.data.numpad8Name = shortcutData.num8name; player.data.numpad9A = shortcutData.num9animA; player.data.numpad9B = shortcutData.num9animB; player.data.numpad9C = shortcutData.num9animC; player.data.numpad9D = shortcutData.num9animD; player.data.numpad9Name = shortcutData.num9name; }); }else{ gm.mysql.handle.query("INSERT INTO shortcuts SET name = ?", [player.name], function (insertError) { if (insertError) console.log(`[Shortcuts Init Error] ${err.message}`); if(!insertError){ gm.mysql.handle.query("SELECT * FROM shortcuts WHERE name = ?", [player.name], function (err10,res10) { if (err10) console.log("Error in loadShortcuts: "+err10); if (res10.length > 0) { res10.forEach(function (shortcutData) { player.data.numpad1A = shortcutData.num1animA; player.data.numpad1B = shortcutData.num1animB; player.data.numpad1C = shortcutData.num1animC; player.data.numpad1D = shortcutData.num1animD; player.data.numpad1Name = shortcutData.num1name; player.data.numpad2A = shortcutData.num2animA; player.data.numpad2B = shortcutData.num2animB; player.data.numpad2C = shortcutData.num2animC; player.data.numpad2D = shortcutData.num2animD; player.data.numpad2Name = shortcutData.num2name; player.data.numpad3A = shortcutData.num3animA; player.data.numpad3B = shortcutData.num3animB; player.data.numpad3C = shortcutData.num3animC; player.data.numpad3D = shortcutData.num3animD; player.data.numpad3Name = shortcutData.num3name; player.data.numpad4A = shortcutData.num4animA; player.data.numpad4B = shortcutData.num4animB; player.data.numpad4C = shortcutData.num4animC; player.data.numpad4D = shortcutData.num4animD; player.data.numpad4Name = shortcutData.num4name; player.data.numpad5A = shortcutData.num5animA; player.data.numpad5B = shortcutData.num5animB; player.data.numpad5C = shortcutData.num5animC; player.data.numpad5D = shortcutData.num5animD; player.data.numpad5Name = shortcutData.num5name; player.data.numpad6A = shortcutData.num6animA; player.data.numpad6B = shortcutData.num6animB; player.data.numpad6C = shortcutData.num6animC; player.data.numpad6D = shortcutData.num6animD; player.data.numpad6Name = shortcutData.num6name; player.data.numpad7A = shortcutData.num7animA; player.data.numpad7B = shortcutData.num7animB; player.data.numpad7C = shortcutData.num7animC; player.data.numpad7D = shortcutData.num7animD; player.data.numpad7Name = shortcutData.num7name; player.data.numpad8A = shortcutData.num8animA; player.data.numpad8B = shortcutData.num8animB; player.data.numpad8C = shortcutData.num8animC; player.data.numpad8D = shortcutData.num8animD; player.data.numpad8Name = shortcutData.num8name; player.data.numpad9A = shortcutData.num9animA; player.data.numpad9B = shortcutData.num9animB; player.data.numpad9C = shortcutData.num9animC; player.data.numpad9D = shortcutData.num9animD; player.data.numpad9Name = shortcutData.num9name; }); } }) } }) } }); if you need more contact me- 1 comment
-
- 3
-
-
- rpc
- Javascript
-
(and 3 more)
Tagged with:
-
[Gamemode] Project V: RPG (Node.js, MongoDB, Vue.js)
Always91 replied to Willdurkumpf's topic in Resources
[N] Starting network... - OK: (IPv4-only) at 127.0.0.1:22005 (node:8776) ExperimentalWarning: The ESM module loader is experimental. Loading packages "camera" loaded "server" loaded [P] Plugin bridge.dll loaded! Started HTTP server at 22006 port. (node:8776) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. [DEBUG] Server started at Thu Oct 10 2019 15:59:09 GMT+0200 (GMT+02:00) [Houses] 5 loaded. [Data] 5 loaded. [Business] 9 loaded. (node:8776) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'x' of null at global.UpdateBizz3D (C:\RAGEMP\server-files\packages\server\src\systems\business\index.js:101:24) at Business.forEach (C:\RAGEMP\server-files\packages\server\src\systems\business\index.js:74:7) at Array.forEach (<anonymous>) at query.then (C:\RAGEMP\server-files\packages\server\src\systems\business\index.js:73:14) at process._tickCallback (internal/process/next_tick.js:68:7) (node:8776) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:8776) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. hello great job but unfortunately the camera hangs in the air without giving me the registration I do not know how to solve this error I have solved others but I do not know this I really hope someone help me thanks and sorry for my English -
Hello everyone! Many of you have decided to use Entity Framework instead of raw SQL but failed somehow in the process (myself included)! This is why I am creating this quick guide with some examples on how to use Entity Framework Core with MySQL database in RAGEMP C# gamemode. It's not perfect, but it will work just fine. If you find a mistake or have a better way of doing something, please let me know! Let's start! Requirements: - Visual Studio 17 or better - Net Core 2.2 - RageMP C# 0.3.7 - MySQL database (I use XAMPP) 1. First, you will need some dependencies. Open up the nuget package manager and add these dependencies to your project: Microsoft.EntityFrameworkCore - Version 2.2.0 Microsoft.EntityFrameworkCore.Tools - Version 2.2.0 Pomelo.EntityFrameworkCore.MySql - Version 2.1.4 Pomelo.EntityFrameworkCore.MySql.Design - Version 1.1.2 Pomelo.EntityFrameworkCore.MySql is a MySQL provider. There are many more providers, but Pomelo's is just fine. How it looks when everything's added: NOTE: As of writing this, you have to use exactly those versions I had screenshot above! 2. Now we are ready to create a DbContext class. I will just copy and paste and explain needed with comments! using System; using System.Collections.Generic; using System.Reflection; using System.Text; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; namespace EFCoreTutorial { public class DefaultDbContext : DbContext { // Connection string, more details below private const string connectionString = "Server=localhost;Database=efcoretutorial;Uid=root;Pwd="; // Initialize a new MySQL connection with the given connection parameters protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseMySql(connectionString); } // Account model class created somewhere else public DbSet<Account> Accounts { get; set; } } } Server = the address of the server, in this case localhost Database = name of the database Uid = user accessing the database Pwd = database password, leave empty if none 3. Create a model class, in this case it's called Account using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace EFCoreTutorial { public class Account { [Key] public int Id { get; set; } public string Username { get; set; } public string Password { get; set; } } } 4. Let's make a simple registration command. using System; using System.Collections.Generic; using System.Linq; using System.Text; using GTANetworkAPI; namespace EFCoreTutorial { public class Commands : Script { [Command("register")] public void AccountCmdRegister(Client player, string username, string password) { RegisterAccount(player, username, password); NAPI.Chat.SendChatMessageToPlayer(player, "~g~Registration successful!"); } public static void RegisterAccount(Client client, string username, string password) { // create a new Account object var account = new Account { Username = username, Password = password }; // When created like this, the context will be immediately deleted AKA disposed. // This will make sure you don't have slowdowns with database calls if one day your server becomes popular using (var dbContext = new DefaultDbContext()) { // Add this account data to the current context dbContext.Accounts.Add(account); // And finally insert the data into the database dbContext.SaveChanges(); } } } } 4a. To check if you are properly connected to the database without going into the game, make a query when a resource starts, for example: using System; using System.Collections.Generic; using System.Linq; using System.Text; using GTANetworkAPI; namespace EFCoreTutorial { public class Main : Script { [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { using (var dbContext = new DefaultDbContext()) { var playerCount = dbContext.Accounts.Count(); NAPI.Util.ConsoleOutput("Total players in the database: " + playerCount); } } } } 5. Before we can test the command or the above example, we need to make a migration. Manual migrations are the only way as of EF Core. To use them in our gamemodes which are most often only libraries (.dlls), we need to "trick the system" into thinking our gamemode is executable. The easiest way is to "create" a console application. First, open your project properties, ALT + F7. Change output type to "Console Application" Save with CTRL + S! Create a new class called Program.cs with the code below: using System; using System.Collections.Generic; using System.Text; namespace EFCoreTutorial { public class Program { public static void Main(string[] args) { } } } Yes, that's right. You only need the Main method. It's because the console app approach looks for "Main" as a starting point. Save and build the project! Now let's make the first migration. Open up the Package Manager Console and type "add-migration FirstMigration" (FirstMigration is only the name). After the migration class has been created, type once again into the console "update-database". The very first migration is now added and inside your database you will find Accounts table: Note: If there are any errors by this stage, then you are most likely not connected to your Database. This guide will not cover that! 6. We are almost done. For server to properly work, it will need runtime dlls. When you first start RAGEMP client, you will download some runtime files. Those are not enough and you have to take some extra steps. Go to the "RAGEMP" root folder, then "dotnet" folder and copy everything. Paste it inside the "runtime" folder (RAGEMP\server-files\bridge\runtime). When you build your project, it will also give you runtime files. Copy everything from bin/debug/netcoreapp2.2 (default build path) except Bootstrapper.dll , Newtonsoft.Json.dll and everything that starts with YourProjectName (EFCoreTutorial in my case). Paste it once again inside the "runtime" folder (RAGEMP\server-files\bridge\runtime). Finally, open YourProjectName.csproj with notepad and add this line <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> like so: Save and close. 7. You are all set up! From now on you don't have to worry about missing runtimes, errors and whatnot. This is everything Entity Framework Core requires to work properly in RAGEMP. Changelog: - Added appsettings.json, a better way of handling connection strings. Thanks @horseyhorsey! - Some clarification - Cleaned and updated the code per @Adam's suggestion This was my first tutorial/guide. Leave feedback and opinions. Thank you for reading! xForcer
- 30 replies
-
- 9
-
-
-
- csharp
- entityframework
-
(and 2 more)
Tagged with:
-
That would be asynchronous like a mysql query, but still slower.
-
const business = require('./sBusiness'); const misc = require('../sMisc'); const i18n = require('../sI18n'); let weaponShops = {}; function createWeaponShopEntities(id, position) { let colShape = mp.colshapes.newSphere(position.x, position.y, position.z, 1.0); colShape.weaponShopID = id; weaponShops[id] = { colShape: colShape, marker: mp.markers.new(1, new mp.Vector3(position.x, position.y, position.z - 2.25), 2.0, { color: [224, 50, 50, 200] }), label: mp.labels.new(`Waffen Shop (${id})`, position, { los: true, font: 4, drawDistance: 20.0, color: [255, 255, 255, 255] }), blip: mp.blips.new(110, position, { name: "Waffen Shop", scale: 1.0, color: 0, shortRange: true }) }; } function deleteWeaponShopEntities(id) { if (weaponShops[id]) { if (weaponShops[id].colShape) weaponShops[id].colShape.destroy(); if (weaponShops[id].marker) weaponShops[id].marker.destroy(); if (weaponShops[id].label) weaponShops[id].label.destroy(); if (weaponShops[id].blip) weaponShops[id].blip.destroy(); } } async function loadWeaponShops() { const d = await misc.query("SELECT * FROM weapon_shops", (error, rows) => { if (e) { console.log(`Weapon shop loading failed: ${e.message}`); } else { rows.forEach((row) => createWeaponShopEntities(row.ID, new mp.Vector3(row.ShopX, row.ShopY, row.ShopZ))); console.log(`Loaded ${rows.length} weapon shop(s).`); } }); }; loadWeaponShops(); async function createWeaponShop(position) { return new Promise((resolve, reject) => { const d = misc.query("INSERT INTO weapon_shops SET ShopX=?, ShopY=?, ShopZ=?", [position.x, position.y, position.z], (error, result) => { if(e) { console.log(`Weapon Shop adding failed: ${e.message}`); reject(error); } else { createWeaponShopEntities(result.insertId, position); resolve(result.insertId); } }); }); }; createWeaponShop(); async function deleteWeaponShop(id) { return new Promise((resolve, reject) => { const d = misc.query("DELETE FROM weapon_shops WHERE ID=?", [id], (error, result) => { if(e) { console.log(`Weapon Shop removing failed: ${e.message}`); reject(error); } else { if(result.affectedRows > 0) { deleteWeaponShopEntities(id); delete weaponShops[id]; } resolve(result.affectedRows); } }); }); }; deleteWeaponShop(); Irgend wie fehlt da ein Catch oder wie darf ich den Fehler verstehen?
-
Hi , I'm trying a mysql connection for my server, but it stops and shuts down as soon as the event is called. What could this be? does anyone know advice? Is the database configuration so correct? I use the bridge server c # and client js on Server c# [RemoteEvent("register2")] public void Register2(Client player, string username, string password) { Databasesql.Query($"INSERT INTO Playerdata(Username,Password) VALUES ('{username}','{password}')"); } and the database config c# public static class Databasesql { public static string myConnectionString = "SERVER=localhost;Database=gtav;UID=gta;PASSWORD=gtatest;"; public static long Query(string Query) { using (var conn = new MySqlConnection(myConnectionString)) { try { conn.Open(); var cmd = conn.CreateCommand(); cmd.CommandText = Query; cmd.ExecuteNonQuery(); conn.Close(); return cmd.LastInsertedId; } catch (MySqlException ex) { NAPI.Util.ConsoleOutput($"[Database][Error] {ex.Message}"); return -1; } } }
-
Good day, friends, help solve the problem. The fact is that MYSQL is connected, and the query is not executed at all. Does not write anything to the console. Help Sorry for my English var mysql = require('mysql'); let mysqlc = mysql.createConnection({ host: '...', user: '...', password: '...', database: '...' }); mysqlc.connect(function(e) { console.log('Connecting ... '); if(e) { console.log("Error connecting to the database with error "+e); } else { console.log('Database connected!') } }); mp.events.add("CheckedLogin", (UserName, Password) => { console.log('Call ... '); mysqlc.query("SELECT * FROM `Player` WHERE `UserName`=", [UserName], function(e, r) { console.log('Load ... '); if(e) { console.log('Error on connection ... '); throw e; } else { console.log('Password is '); } }); mysqlc.end(); }); The event call works, but after the query in the database, nothing works ... Thank!
-
Hello! I made this resource, and when i enter any information in game the console says this: C:\Users\varad\Desktop\PleasantRoleplay\packages\PleasantRoleplay\user-system\Login.js:11: TypeError: Cannot read property 'query' of null db.Handle.query("SELECT * FROM accounts WHERE username = ?", username, function(e, result) { Login.js: var db = require('../mysql/Connection'); mp.events.add('playerJoin', player => { player.call('loginShowPanel'); let alpha = player.alpha; player.alpha = 0; }); mp.events.add('loginSendInformation', (player, username, password) => { db.Handle.query("SELECT * FROM accounts WHERE username = ?", username, function(e, result) { if ( result.length ) { player.call('loginClosePanel'); let alpha = player.alpha; player.alpha = 255; } else player.outputChatBox("<b style='color: red'>This Username doesn't exist!</b>"); }); }); Connection.js: var mysql = require('mysql'); module.exports = { Handle: null, Connect: function(callback) { this.Handle = mysql.createConnection({ host : 'localhost', user : 'root', password : '', database : 'pleasantroleplay' }); this.Handle.connect(function(e) { if ( !e ) { callback(); } else console.log ("DATABASE ERROR" + e); }); } }; Index.js: require('./mysql/Connection'); require('./user-system/Login.js'); I have added Mysql module through npm.
-
[2019-05-12T23:01:51.895] [ERROR] default - UPDATE users SET ip = '178.68.102.28', logdate = '5/12/2019, 11:01:00 PM', position = '{"x":382.7,"y":6556.7,"z":27.4,"rot":333.7,"dim":0}', health = '100', loyality = '0' WHERE id = '1' (node:2308) UnhandledPromiseRejectionWarning: Error: ER_LOCK_WAIT_TIMEOUT: Lock wait timeout exceeded; try restarting transaction at Query.Sequence._packetToError (C:\RAGEMP\server-files\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14) at Query.ErrorPacket (C:\RAGEMP\server-files\node_modules\mysql\lib\protocol\sequences\Query.js:77:18) at Protocol._parsePacket (C:\RAGEMP\server-files\node_modules\mysql\lib\protocol\Protocol.js:278:23) at Parser.write (C:\RAGEMP\server-files\node_modules\mysql\lib\protocol\Parser.js:76:12) at Protocol.write (C:\RAGEMP\server-files\node_modules\mysql\lib\protocol\Protocol.js:38:16) at Socket.<anonymous> (C:\RAGEMP\server-files\node_modules\mysql\lib\Connection.js:91:28) at Socket.<anonymous> (C:\RAGEMP\server-files\node_modules\mysql\lib\Connection.js:502:10) at Socket.emit (events.js:182:13) at addChunk (_stream_readable.js:283:12) at readableAddChunk (_stream_readable.js:264:11) -------------------- at Pool.query (C:\RAGEMP\server-files\node_modules\mysql\lib\Pool.js:199:23) at Promise (C:\RAGEMP\server-files\packages\RP\index.js:1:1304) at new Promise (<anonymous>) at Object.dbquery (C:\RAGEMP\server-files\packages\RP\index.js:1:1283) at Object.query (C:\RAGEMP\server-files\packages\RP\index.js:1:1425) at Object.e.saveBasicData (C:\RAGEMP\server-files\packages\RP\index.js:1:52111) at Object.saveAccount (C:\RAGEMP\server-files\packages\RP\index.js:1:50908) at Object.self (C:\RAGEMP\server-files\packages\RP\index.js:1:52996) at Object.fire (<anonymous>:721:8) at eval (eval at add (unknown source), <anonymous>:3:11) (node:2308) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 9) Error server
-
[M] Announcing into master server... Loading packages "react" loaded [M] Connected to master list. Server listening on: 3090 "union-rp" loaded Запуск сервера... Сервер запущен! [P] Plugin bridge.so loaded! Started HTTP server at 22006 port. /home/rageplanet/ragemp-srv/packages/union-rp/events/OnPlayerCommand.js:35 for (var i = 0; i < result.length; i++) { ^ TypeError: Cannot read property 'length' of undefined at Query.DB.Handle.query [as _callback] (/home/rageplanet/ragemp-srv/package s/union-rp/events/OnPlayerCommand.js:35:32) at Query.Sequence.end (/home/rageplanet/ragemp-srv/node_modules/mysql/lib/pr otocol/sequences/Sequence.js:83:24) at /home/rageplanet/ragemp-srv/node_modules/mysql/lib/Pool.js:205:13 at Handshake.onConnect (/home/rageplanet/ragemp-srv/node_modules/mysql/lib/P ool.js:58:9) at Handshake.<anonymous> (/home/rageplanet/ragemp-srv/node_modules/mysql/lib /Connection.js:525:10) at Handshake._callback (/home/rageplanet/ragemp-srv/node_modules/mysql/lib/C onnection.js:491:16) at Handshake.Sequence.end (/home/rageplanet/ragemp-srv/node_modules/mysql/li b/protocol/sequences/Sequence.js:83:24) at Protocol.handleNetworkError (/home/rageplanet/ragemp-srv/node_modules/mys ql/lib/protocol/Protocol.js:369:14) at PoolConnection.Connection._handleNetworkError (/home/rageplanet/ragemp-sr v/node_modules/mysql/lib/Connection.js:421:18) at PoolConnection.Connection._handleConnectTimeout (/home/rageplanet/ragemp- srv/node_modules/mysql/lib/Connection.js:417:8) [email protected]:/home/rageplanet/ragemp-srv# ^C [email protected]:/home/rageplanet/ragemp-srv# ls В чём может быть проблема ?
-
Sorry for the error, the only thing he writes to the console is: console.log ('Call ...'); At the very beginning of the event, and I put the message in the console after mysqlc.query, he also writes, but everything in mysqlc.query cohd something passes by.
-
Any idea to add "if statement" to check if the letters is not a-z or 0-9 then give them errors I find some function to check it but I don't know how to use it Sorry about this question I'm pretty new case 1: //Register State { if(username.length >= 3 && pass.length >= 5){ gm.mysql.handle.query('SELECT * FROM `accounts` WHERE `username` = ?', [username], function(err, res){ if(res.length > 0){ player.call("loginHandler", ["takeninfo"]); } else { bcrypt.hash(pass, null, null, function(err, hash) { if(!err){ gm.mysql.handle.query('INSERT INTO `accounts` SET username = ?, password = ?', [username, hash], function(err, res){ if(!err){ player.name = username; player.call("loginHandler", ["registered"]); gm.auth.registerAccount(player); console.log("\x1b[92m" + username + "\x1b[39m has just registered."); } else { console.log("\x1b[31m[ERROR] " + err) } }); } else { console.log("\x1b[31m[BCrypt]: " + err) } }); } }); } else { player.call("loginHandler", ["tooshort"]); } break; }
-
[Gamemode] Project V: RPG (Node.js, MongoDB, Vue.js)
BlackFlex replied to Willdurkumpf's topic in Resources
Please explain better how to install this server. I have this errors. And none login screen. Started HTTP server at 22006 port. (node:1536) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. [DEBUG] Server started at Mon Sep 16 2019 01:02:35 GMT+0200 (GMT+02:00) [Data] 5 loaded. [Business] 9 loaded. (node:1536) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'x' of null at global.UpdateBizz3D (C:\Users\Vano\Desktop\gta5-ragemp-server-master\Server\packages\server\src\systems\business\index.js:101:24) at Business.forEach (C:\Users\Vano\Desktop\gta5-ragemp-server-master\Server\packages\server\src\systems\business\index.js:74:7) at Array.forEach (<anonymous>) at query.then (C:\Users\Vano\Desktop\gta5-ragemp-server-master\Server\packages\server\src\systems\business\index.js:73:14) at process._tickCallback (internal/process/next_tick.js:68:7) (node:1536) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:1536) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. [Houses] 5 loaded.
