Search the Community

Showing results for tags 'CSharp'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


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

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



About Me






Found 51 results

  1. Hello everyone! This will be a short guide on how to use colors when using custom chat, not the default one. I know I am not the only one frustrated about this so that's why I want to share this to everyone. Important credits: - Carlos (ex RageMP member) Helped me the most, basically solving everything and giving me a big smile. I still owe you a beer - @Chainksain This dude actually has the same way of doing things as me so big shoutout to him for examples Let's start! Requirements: - Visual Studio 17 or better - Net Core 2.2 - RageMP C# 0.3.7 1. First, create a class that will be used for your chat colorization stuff. Everything will be commented using System; namespace CustomChatColorsTutorial { public static class ChatColorization { // Few general colors public const string ColorRed = "#A80707"; public const string ColorDodgerBlue = "#1E90FF"; /// <summary> /// HEX colorization /// </summary> /// <param name="text">The text you want to colorize</param> /// <param name="color">Use colors from ChatColorization class</param> /// <returns></returns> public static string ColorizeText(string text, string color) { return "<strong style='color:" + color + "'>" + text + "</strong>"; } } } 2. To use colors, do something like this: using System; using GTANetworkAPI; using GTANetworkMethods; namespace CustomChatColorsTutorial { public static class Chat { public void SendExampleMessage(Client player) { NAPI.Chat.SendChatMessageToPlayer(player, ChatColorization.ColorizeText("This is an example", ChatColorization.ColorDodgerBlue)); } } } This will output: This is an example 3. This was simple so far, I agree. But what about mixing few colors in one sentence? Let's say we want to send an error message but nice and clean. This is how we do it: using System; namespace CustomChatColorsTutorial { public static class ChatColorization { // Few general colors public const string ColorRed = "#A80707"; public const string ColorDodgerBlue = "#1E90FF"; // Remember: If you don't explicitly colorize text, it will use your custom chat's default color (white) // In this case, brackets will be white public static string ErrorMessage(string message) { return "(" + ColorizeText("Error", ColorRed) + ") - " + message; } /// <summary> /// HEX colorization /// </summary> /// <param name="text">The text you want to colorize</param> /// <param name="color">Use colors from ChatColorization class</param> /// <returns></returns> public static string ColorizeText(string text, string color) { return "<strong style='color:" + color + "'>" + text + "</strong>"; } } } And then we use that in our Chat class using System; using GTANetworkAPI; using GTANetworkMethods; namespace CustomChatColorsTutorial { public static class Chat { public void SendExampleMessage(Client player) { NAPI.Chat.SendChatMessageToPlayer(player, ChatColorization.ErrorMessage("Something bad happened, please contact the adminstrator!")); } } } This will output: (Error) - Something bad happened, please contact the adminstrator! That's it! You can now use custom colors in your custom chat. If you need assistance, just ask. If something is wrong, please tell me to correct it. Leave feedback. Thank you for reading! xForcer Changelog: Cleaner formatting of ErrorMessage. Removed substring constants
  2. I write the basic code in my solution project (example from wiki) and start the server, after spawn, it should output the notify but it does not output it. Please, help. log output The invoked member is not supported in a dynamic assembly. System.Private.CoreLib at System.Reflection.Emit.InternalAssemblyBuilder.get_Location() The invoked member is not supported in a dynamic assembly.
  3. Hello, I wanted to ask how to add NativeUI. I used C # as a programming language. So as I add it in the server and in Visual Studio. Thanks in advance! Greetings, Tobi
  4. Xabi


    Version 1.1.0


    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.
  5. Okay. So since there is no server - side implementation for C# AttachEntityToEntity() I'm told to do it in the client-side. However when I pass the arguments to my client-side with the TextLabel and Vehicle objects. I'm not sure how to attach them. TextLabel being attached to the Vehicle. I've used the class's .handle attribute the .Id attribute. But nothing seems to work. I'll provide the code for the respective sides. Server - side // Server Side // private static string VehTxtLblKey = "VehicleTextLabel"; [RemoteEvent("VehicleSpawnFromClient")] public void NativeVehSpawn(Client player, bool locked, bool engine, string vName) { uint vHash = NAPI.Util.GetHashKey(vName); Vehicle veh; veh = NAPI.Vehicle.CreateVehicle(vHash, player.Position.Around(5), 0.0f, 0, 0, locked: locked, engine: engine); TextLabel tLabel; tLabel = NAPI.TextLabel.CreateTextLabel($"[{vName}]", veh.Position, 15.0f, 1.5f, 1, new Color(0, 0, 255, 255), true); veh.SetSharedData(VehTxtLblKey, tLabel); NAPI.ClientEvent.TriggerClientEventForAll("AttachVehTxtLblForAll", VehTxtLblKey, veh); player.SendNotification($"You have created {vName}"); } // End of Server Side // Client - side public VehicleTextdraw() { Events.Add("AttachVehTxtLblForAll", VehTxtLblAll); } public void VehTxtLblAll(object [] args) { string tlKey = (string)args[0]; Vehicle veh = (Vehicle)args[1]; TextLabel tlLabel = (TextLabel)veh.GetSharedData(tlKey); if (!RAGE.Game.Entity.IsEntityAttachedToEntity(tlLabel.Id, veh.Id)) { Chat.Output($"Entity is being attached!"); RAGE.Game.Entity.AttachEntityToEntity(tlLabel.Id, veh.Id, 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0, false); } } If anyone could help me out here, then that'll be a huge help.
  6. I want use other dll in my client-side project (C#), but when i start server, i receiv errors in clientside_cs.txt CS0246: The type or namespace name 'Contracts' could not be found (are you missing a using directive or an assembly reference?) -> C:\RAGEMP\client_resources\\cs_packages\AccountScript.cs:0 Can i use other dll in my client-side?
  7. Hey, Mein Name ist Emil [mada.lime] und ich bin zusammen mit Justin [Tairu] die Projektleitung von lazyworks. Wir sind ein Neuer Hardcore Roleplay Server, bei dem die Development Phase bald beginnen soll. Dafür suchen wir ein paar Kompetente Entwickler für das Team. Wir suchen Developer im Bereich C#, js und html dabei solltet ihr bereits Erfahrungen im Beriech RageMP Development gesammelt haben und grundlegende so wie weiterführende Custom Scripts schreiben können. Der Server wird ab 16 Jahren zugelassen sein, dies schreibe ich hier, da ich weiß dass einige Developer Verständlicherweise nicht für minderjährige programmieren wollen. Wir werden jedoch eine Hard-Whitelist verwenden und auf Qualität des RP’s setzen. Weitere Informationen würden in folgenden Gesprächen besprochen werden. Hierzu steht unser Discord Server für weitere Kontaktaufnahmen gerne zur Verfügung:
  8. Hello. I've been meddling around with the RageMP API and I've learned most of it myself with the help of the discord members. Shoutout to Xabi, Sake and everyone else for helping me out with this language. Anywho I've come to realise that when I had started out there was nothing that would guide me through the process of making a server or creating the script for that matter. So here I bring you a YouTube playlist of the RageMP C# language tutorial. It is still under progress but I keep uploading new tutorials daily. And I mostly describe most of the elements so the videos might seem longer than usual tutorials. But I'd suggest to not skip anything and go over everything that I have to offer thoroughly. And if you do like my tutorials then do subscribe and like it too! And happy coding!
  9. Hey! I've been busy developing an RP server lately, and i can get the Server-side working pretty good, but the time has come to start scripting client resources also. The problem is, that i can't find a tutorial or even a wiki page on how to start with the C# client side, because i don't want to code in Javascript, that would mean learning a new language and i don't want to go trough that hassle. So, can anyone explain to me how to make my first C# client side server resource? The only one who have been doing these kinds of tutorials were Stuyk, but he had removed every video regarding this topic. Thanks in advance.
  10. Hey Guys When i Add 'enable-clientside-cs ' File into my rage MP Folder i get Fatal error While im trying to Open My rage Any one knows this Problem ? And i cant get connect To ANy servers On rage While i have That Error
  11. Hallöchen, wie kann ich NativeUI bei Visual Studio hinzufügen sowie auch im Server? Danke im vorraus. Grüße, codeqod | Tobi
  12. Version 2.1


    With this script you can easily create custom timer. The file is fully commented and should be easy to understand. The file in Shared is required - and then use either the file in Server or in Client depending on where you are using it. You have to use the constructor to create the timer. Examples: Examples: // Yes, the method can be private // private void testTimerFunc(Client player, string text) { NAPI.Chat.SendChatMessageToPlayer(player, "[TIMER] " + text); } void testTimerFunc() { NAPI.Chat.SendChatMessageToAll("[TIMER2] Hello"); } [Command("ttimer")] public void timerTesting(Client player) { // Lamda for parameter // new Timer(() => testTimerFunc(player, "hi"), 1000, 1); // Normal without parameters // new Timer(testTimerFunc, 1000, 1); // Without existing method // var timer = new Timer(() => { NAPI.Chat.SendChatMessageToPlayer(player, "[TIMER3] Bonus is da best"); }, 1000, 0); // Kill the timer // timer.Kill(); }
  13. adri1

    SAMP Dialogs

    Version 1.0.0


    SA-MP Dialogs for RAGE MP (C# clientside). This is my first resource so may contains bugs... You must enable C# clientside! Usage is simple: examples in Test.cs Dialog(string dialog_name, string dialog_caption, string dialog_info, string[] dialog_buttons, string[] dialog_list_items = null, string dialog_input = null, string dialog_password_input = null)
  14. Hey, I'm trying to play around a bit with the C# development of RageMP to get to know it, however I got stuck in something I think it's either me doing something wrong, or possibly bug. I suppose the first, as no one else seems to cover this problem I've. I've this very simple script so far, running on NetCore 2.0, RageMP at latest stable version, but yet my server crash each time I leave a vehicle, even though I don't have any events hooked into that. However what I found very peculiar is that if I remove/comment out the OnPlayerEnterVehicle function, the crashes are gone! I've tried to debug this in VS2017 but it says this runtime error comes from external source, so it can't point at anything specific in my script. Any suggestions of what this could be? Suggestions on how to debug it further is also appreciated The runtime error The project using System; using GTANetworkAPI; namespace MyCustomResource { public class Main : Script { [ServerEvent(Event.ResourceStart)] //This type of event is mainly used for handling stuff after this resource has been initiated. public void ResourceStart() { Console.WriteLine("\n--------------------------------------"); Console.WriteLine("Blank Script by your name here v2"); Console.WriteLine("--------------------------------------\n"); } [Command("hi", Alias = "hello, hey, howdy")] public void SayHi(Client player) { NAPI.Chat.SendChatMessageToPlayer(player, "Hello!"); } [Command("car")] public void CmdCreateCar(Client client) { NAPI.Vehicle.CreateVehicle(VehicleHash.Adder, client.Position.Around(5), 0f, 0, 0, "Test"); //Spawned vehicle is visible in all Dimensions } [ServerEvent(Event.PlayerEnterVehicle)] public void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seatID) { Console.WriteLine("TEst"); } } }
  15. 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
  16. Всем привет!!! Решил записать видео версию тутера по запуску своего сервера Rage Multiplayer с серверной частью на C#. Важно!!! Название библиотеки в файле meta.xml указывать с расширением Server.dll Поехали: Ссылка на Bridge: Нажми меня я все скачаю Содержимое файла meta.xml <meta> <info name="Tuter" type="script" /> <script src="Server.dll" /> </meta> Содержимое файла settings.xml <?xml version="1.0"?> <config xmlns:xsi="" xmlns:xsd=""> <resource src="Tuter" /> </config> Строка необходимая для добавления в файл "Название проекта".csproj: <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> Наглядный пример: <PropertyGroup> <TargetFramework>netcoreapp2.1</TargetFramework> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <RootNamespace>Tuter</RootNamespace> </PropertyGroup> Строка копирования библиотек в целевой каталог: xcopy "$(OutDir)*" "E:\RageMP\Bridge\resources\Tuter\*.*" /Q /D /Y Вроде все. Всем пока.
  17. Is it possible to write fully on C# client & server side without loss of functionality ? Or need to write on JS?
  18. 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=, 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.
  19. I'm trying to add a SQL Server Database to my RAGE server, using Entity Framework Core. I've created a resource and a separate project (in the same solution) for the database, getting to the following folder structure: and my Main.cs looks like this: using Database; using GTANetworkAPI; using System; namespace LoginRegister { public class Main : Script { [ServerEvent(Event.ResourceStart)] public void EventOnResourceStart() { try { using var context = new ServerDbContext(); } catch (Exception e) { Console.WriteLine("ERROR!"); } } } } And when I run server.exe, I get the following error in the console (which disappears when I remove the DbContext creation part from EventOnResourceStart:
  20. Version 1.1


    Developer Helper - It will help to quickly turn on, off and restart the server, very convenient. How to install - Unzip all files in the "server-files" folder, then run .exe file and everything should work. The interface is intuitive. Sources on my github >.<
  21. Our dev team is looking for a nice and friendly developer for our new project. If somebody has time and desire then join the discord and contact the head of devemopment. We have a big community with 700 persons. Actually we have 3 devs we speak German and English. If you are interested dm the head of development. And if you want we will pay you when you help us. Discord:
  22. This occurs due to player stamina hitting zero, resulting in hp being lost. Below is the workaround for this in both C# and JavaScript. C# //Subscribe the Tick event Events.Tick += Tick; public void Tick(List<Events.TickNametagData> nametags) { RAGE.Game.Player.RestorePlayerStamina(1.0F); } JavaScript'render', () => {; });
  23. Привет!!! Продолжаем. Рассмотрим настройку среды разработки для клиентской части. Сразу извините за звук, поехали: Строка настройки событий после сборки: del "E:\RageMP\client_packages\cs_packages\*.*" /Q for /R %CD% %%i in (*.cs) do ( xcopy %%i "E:\RageMP\client_packages\cs_packages\" /Q /Y /EXCLUDE:exclude.txt ) Пока!!!
  24. Good evening, I have a big problem with the two methods mentioned above in the title, I try to get the clothes that my player wears on him, the problem is that every time the method GetClothesDrawable returns to me the value 0, no matter which slot I give it to you, do you have any idea how I can do to get the hold that my player wears? Thank you in advance for your answer.
  25. Hi guys! Please tell me how to know. Can I start server-side development in C#? And in parallel to develop the client-side in JavaScript language? I want to use 2 languages simultaneously for development. Each side has its own. How can I implement this?