Search the Community

Showing results for tags 'MySQL'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • RAGE Multiplayer
    • Announcements
    • Discussion
    • Suggestions
    • RDR2 Multiplayer
  • 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 15 results

  1. Just so title say, what you guys thinks is better for some simple gamemode. MySQL or .JSON type of storing data. I tried to use one and another. Must say that MySQL is more safer for storing data and more organized (my opinion). But I chose .JSON because it's much easier to get use to work with it, and much simpler for coding then mySQL. What do you guys think?
  2. 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 - Latest RageMP and C# Bridge files - 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
  3. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Не удается найти указанный файл. at new ServerSide.mysqli(string host, string user, string password, string db) at new ServerSide.Manager() in D:\rumod\ragemp\server-files\ragemp_csharp_scripts\ragemp_uncomiled_scripts_csharp\ServerSide\Manager.cs:line 9 --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at GTANetworkInternals.GameServer.<InstantiateScripts>d__61.MoveNext() at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext() at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable) at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at GTANetworkInternals.GameServer.StartResource(String resourceName, String parent) Я подключил модуль MySql, написал реализации класса, но появляются такие ошибки. Сразу скажу, что он не может найти библиотеку я понимаю, дело в том, что она присутствует. I connected the MySql module, wrote class implementations, but such errors appear. I must say right away that he cannot find the library, I understand, the fact is that it is present.
  4. Version 1.2

    2225 downloads

    Basic MySQL Gamemode Github Link: https://github.com/MrPancakers/ragemp-mysql Resource Thread: Discord: MrPancakers#9283 This is a template of a very basic login/registration system you can implement into your game mode to get started. This template only stores usernames, passwords(encrypted with BCrypt), position and money so anything extra will need to be implemented yourself. This is intended for beginners so the code is pretty basic and nothing fancy has been done so it is easily readable. If you find any issues, leave a comment on my thread or leave a comment on this resource. Installation You'll need to have a MySQL server setup, either using WAMP/XAMPP/or from a server. To keep this short I will not go through setting these up, simply Google 'How to set up WAMP' for example to get it set up. Unzip the source and place it inside of your server files folder. Open your command prompt and change your directory to your server folder. Then do 'npm install' to install the required node_modules. Create a new database and call it whatever you want (Inside the script it is called 'ragemp-mysql'). Once created, import the ragemp-mysql.sql into your newly created database. Go to packages/mysql/mysql.js and open it. At the top is the connection info, change this to whatever your IP and MySQL username/password is. If you're hosting this locally and you haven't made/changed the MySQL info, the default should be fine. You're all set to go.
  5. Version 0.0.2

    414 downloads

    This resource will help many newcomers in the development of the server. At this gamemode, used the sequelize framework, for easy work with the database. Also used frameworks ReactJS + ReduxJS special for CEF. GitHub URL: https://github.com/HEXisGOD/RAGEMP_sequelize_react_redux Installing 1. Download this archive, unpack it in RAGE:MP new server folder. 2. To work with the database locally I suggest using Denwer. 3. Config connection data at packages\sequelize\modules\db.js 4. Import example database into phpMyAdmin 5. Then start server, and test it !) Needed node modules 1. MySQL2 - [ npm install mysql2 -save ] 2. Sequelize - [ npm install sequelize -save ] - Thanks @kemperrr for make "pleaseCallCEF" function and event on ReactJS!! This is first version, During the time there can be changes and improvements!!
  6. (username is player.name normally just changed it to test something, with player.name its the same error. so username = player.name) Server Side Code: https://imgur.com/a/mgQMsdi Console Error Message: https://imgur.com/a/cmt2Tg8 Help would be awesome, thanks in advantage.
  7. Hey, ich bin ziemlich neu im C# Programmieren, belege derzeitig noch einen Video Kurs auf udemy.com und programmiere nebenbei kleinweise eine RP Resource. Ich stehe nun kurz davor das ganze mit einer Datenbank zu verbinden. Nun wollte ich fragen, ob es egal ist das ganze einfach nur via Mysql mit der Datenbank zu verbinden oder gibt es noch bessere Wege. Nebenbei wollte ich fragen, ob eine Verbindung mit der Datenbank alleine via C# möglich wäre und ob's empfehlenswert ist. Liebe Grüße, Jeff
  8. Hey is it possible to spawn vehicles with tuning modification. And how to save Tuning modifications in mysql and load them when a player join the server.
  9. Version 1.0.0

    787 downloads

    Nothing special, just a small Register / Login. Let me know, if something doesn't work correctly or I could do something better. https://github.com/raydNDev/RAGEMP-RegisterLogin
  10. DjEnzo

    How to use MySQL

    Hi guys! Am about to start programming my new server, but I cannot use MySQL. I started with this tutorial -> https://rage.mp/forums/topic/1807-c-getting-started-debugging/ This is how my code looks like: using System; using System.Data; using GTANetworkAPI; using MySql.Data.MySqlClient; namespace GTV { class MySQL { private string connectionString = "SERVER=localhost;" + "DATABASE=gtv;" + "UID=root;" + "PASSWORD=;" + "SslMode=none"; public bool FirstConnect() { MySqlConnection db = new MySqlConnection(connectionString); db.Open(); string state = db.State.ToString(); NAPI.Util.ConsoleOutput(state); if (db.State == ConnectionState.Open) return true; else return false; } } } And here my pretty long exception: What did I do wrong? Thank you for your help.
  11. При использование базы данных, сервер через пару минут после запуска выдаёт исключения: ==================[14.07.2018 4:32:29]================== System.Net.Sockets.SocketException (0x80004005): Программа на вашем хост-компьютере разорвала установленное подключение at void System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size) ========================================================= ==================[14.07.2018 4:32:29]================== System.IO.IOException: Unable to write data to the transport connection: Программа на вашем хост-компьютере разорвала установленное подключение. ---> System.Net.Sockets.SocketException: Программа на вашем хост-компьютере разорвала установленное подключение at void System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size) --- End of inner exception stack trace --- at void System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size) ========================================================= ==================[14.07.2018 4:32:29]================== System.IO.IOException: Unable to write data to the transport connection: Программа на вашем хост-компьютере разорвала установленное подключение. ---> System.Net.Sockets.SocketException: Программа на вашем хост-компьютере разорвала установленное подключение at void System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size) --- End of inner exception stack trace --- at void System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size) at void MySql.Data.MySqlClient.TimedStream.Write(byte[] buffer, int offset, int count) ========================================================= Метод подключения к базе данных: private const string connectionString = "Server=localhost;Database=db;port=3306;User Id=root;password=;SslMode=none"; public static void TestConnection() { MySqlConnection conn = new MySqlConnection(connectionString); try { NAPI.Util.ConsoleOutput("[Database] Connection to MySQL ..."); conn.Open(); } catch (Exception ex) { NAPI.Util.ConsoleOutput("[Database] " + ex.ToString()); } conn.Close(); NAPI.Util.ConsoleOutput("[Database] Done"); } Порты 22005 и 22006 открыты, отключение файервола изменений не принесло
  12. Добрый день. Я начинающий скриптер. Как реализовать авторизацию и Регистрацию в игре через MYSQL? прошу дать пошаговую инструкцию. Благодарю.
  13. radmir745

    MySQL

    Появилась проблема с MySQL. Куда надо установить node mysql и где его подключать?