<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>https://rage.grandroleplay.ru/index.php?action=history&amp;feed=atom&amp;title=Getting_Started_with_Client-side</id>
	<title>Getting Started with Client-side - История изменений</title>
	<link rel="self" type="application/atom+xml" href="https://rage.grandroleplay.ru/index.php?action=history&amp;feed=atom&amp;title=Getting_Started_with_Client-side"/>
	<link rel="alternate" type="text/html" href="https://rage.grandroleplay.ru/index.php?title=Getting_Started_with_Client-side&amp;action=history"/>
	<updated>2026-07-24T20:33:53Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://rage.grandroleplay.ru/index.php?title=Getting_Started_with_Client-side&amp;diff=10143&amp;oldid=prev</id>
		<title>imported&gt;Unknown в 10:55, 6 декабря 2019</title>
		<link rel="alternate" type="text/html" href="https://rage.grandroleplay.ru/index.php?title=Getting_Started_with_Client-side&amp;diff=10143&amp;oldid=prev"/>
		<updated>2019-12-06T10:55:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Client-side is the side where you have better control over a single player and provides you access to more information about the game world, but less information about the other players. You can use client-side to create &amp;#039;&amp;#039;&amp;#039;GUI&amp;#039;&amp;#039;&amp;#039; (Graphical User Interface), visual effects, and much more.&lt;br /&gt;
&lt;br /&gt;
== Using Client-side ==&lt;br /&gt;
&lt;br /&gt;
Client-side has a different pattern than server-side. Requiring the files are a bit different, and you can&amp;#039;t use &amp;#039;&amp;#039;&amp;#039;NPM Packages&amp;#039;&amp;#039;&amp;#039; like server-side. Client-side&amp;#039;s requiring files system needs to start from the root folder until the file you want to require. Let us give you a little example of the structure of client-side.&lt;br /&gt;
&lt;br /&gt;
:1. Go to the client_packages &amp;#039;&amp;#039;&amp;#039;folder&amp;#039;&amp;#039;&amp;#039; inside your server-files and create a new file called &amp;#039;&amp;#039;&amp;#039;index.js&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
:2. Create a folder and name it whatever you want, let&amp;#039;s say &amp;#039;&amp;#039;&amp;#039;gamemode&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
:Now your structure should be like this:&lt;br /&gt;
&amp;lt;gallery widths=600px heights=77px&amp;gt;File:Client_struct_1.png&amp;lt;/gallery&amp;gt;&lt;br /&gt;
:3. Edit your &amp;#039;&amp;#039;&amp;#039;index.js&amp;#039;&amp;#039;&amp;#039; and add &amp;lt;code&amp;gt;require(&amp;#039;./gamemode/index&amp;#039;);&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;require(&amp;#039;./gamemode&amp;#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
:4. Open your &amp;#039;&amp;#039;&amp;#039;gamemode&amp;#039;&amp;#039;&amp;#039; folder and create a new file called &amp;#039;&amp;#039;&amp;#039;index.js&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
:5. In the file, add any test script you want and it should work once you enter the game. For example, add &amp;lt;code&amp;gt;mp.gui.chat.push(&amp;#039;Hello World&amp;#039;)&amp;lt;/code&amp;gt;. You should get the message once you join the server.&lt;br /&gt;
&lt;br /&gt;
== Create your first client-side resource ==&lt;br /&gt;
&lt;br /&gt;
As we learned how the structure works in the previous section, now we&amp;#039;ll create our first resource to show how client-side actually works. &amp;#039;&amp;#039;&amp;#039;Remember&amp;#039;&amp;#039;&amp;#039; the index we added inside the &amp;#039;&amp;#039;&amp;#039;gamemode&amp;#039;&amp;#039;&amp;#039; folder, it&amp;#039;s the first file that triggered when you completely download your files, so now we&amp;#039;ll create a simple resource which sets your discord rich presence into a custom made message.&lt;br /&gt;
&lt;br /&gt;
:1. Create a folder called modules (optional) inside your &amp;#039;&amp;#039;&amp;#039;gamemode&amp;#039;&amp;#039;&amp;#039; folder.&lt;br /&gt;
:2. Create a file called &amp;#039;&amp;#039;&amp;#039;discord.js&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
:3. Add the following code:&lt;br /&gt;
{{ClientsideCode|&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//We registered an event to the client side&amp;#039;s events tree which sets discord status.&lt;br /&gt;
mp.events.add(&amp;#039;setDiscordStatus&amp;#039;, (serverName, status) =&amp;gt; {&lt;br /&gt;
  mp.discord.update(serverName, status)&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
:4. Go back to your &amp;#039;&amp;#039;&amp;#039;index.js&amp;#039;&amp;#039;&amp;#039; inside the &amp;#039;&amp;#039;&amp;#039;gamemode&amp;#039;&amp;#039;&amp;#039; folder and add &amp;lt;code&amp;gt;require(&amp;#039;./gamemode/modules/discord&amp;#039;);&amp;lt;/code&amp;gt;. &lt;br /&gt;
::Like that you required the discord module once you join/download the server. &lt;br /&gt;
::It&amp;#039;s always necessary to add the &amp;#039;&amp;#039;&amp;#039;rootFolder&amp;#039;&amp;#039;&amp;#039; in your required file-path to get the file, it&amp;#039;s not like server-side where you can just do &amp;lt;code&amp;gt;require(&amp;#039;./modules/discord&amp;#039;);&amp;lt;/code&amp;gt;.&lt;br /&gt;
:5. Now in your &amp;#039;&amp;#039;&amp;#039;index.js&amp;#039;&amp;#039;&amp;#039;, add &amp;lt;code&amp;gt;mp.events.call(&amp;#039;setDiscordStatus&amp;#039;, &amp;#039;Playing on Freeroam&amp;#039;, &amp;#039;Playing as Ronald McDonald&amp;#039;)&amp;lt;/code&amp;gt;. &lt;br /&gt;
::&amp;#039;&amp;#039;If you&amp;#039;re new to the events system, check &amp;#039;&amp;#039;&amp;#039;[[Getting Started with Events|Getting Started with Events tutorial]]&amp;#039;&amp;#039;&amp;#039;.&amp;#039;&amp;#039;&lt;br /&gt;
::&amp;#039;&amp;#039;If you want autocomplete, check &amp;#039;&amp;#039;&amp;#039;[[Getting Started with Development|Getting Started with Development tutorial]]&amp;#039;&amp;#039;&amp;#039;.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Your code structure should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery widths=776px heights=133px&amp;gt;&lt;br /&gt;
File:Client_struct_2.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
Now join the server and check your discord status. It should look like this:&lt;br /&gt;
&amp;lt;gallery widths=250px heights=100px&amp;gt;&lt;br /&gt;
File:UpdatedRichPresence.jpg&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Final notes ==&lt;br /&gt;
You have accomplished your first client-sided resource. You can view more [https://rage.mp/files/ resources] created by the community.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
{{ScriptingTutorials}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Unknown</name></author>
	</entry>
</feed>