Getting Started with Commands: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
Line 2: Line 2:


= Intro =
= Intro =
Commands are simple and easy to use via your server chat to do many things. Today we will show you how simple is it to create easy commands that can be useful for your server. Let's see the example below.
<syntaxhighlight lang="javascript">
mp.events.addCommand("weapon", (player, fullText, weapon, ammo) => {
var weaponHash = mp.joaat(weapon);
player.giveWeapon(weaponHash, parseInt(ammo) || 10000);
});
</syntaxhighlight>
This example shows a command with name '''weapon''' which gives the player weapon with ammo. If the player doesn't specify the ammo, the system will give him 10000 ammo automatically.
How does it work?
Simply you go to the chat and type <code>/weapon <weapon_name> <ammo></code>
For example, <code>/weapon weapon_pistol 100</code>. This example gives me a pistol with 100 ammo.
to see the list of weapons [[Weapons|Click Here]].

Revision as of 08:59, 3 October 2017

Intro

Commands are simple and easy to use via your server chat to do many things. Today we will show you how simple is it to create easy commands that can be useful for your server. Let's see the example below.

mp.events.addCommand("weapon", (player, fullText, weapon, ammo) => {
	var weaponHash = mp.joaat(weapon);

	player.giveWeapon(weaponHash, parseInt(ammo) || 10000);

});

This example shows a command with name weapon which gives the player weapon with ammo. If the player doesn't specify the ammo, the system will give him 10000 ammo automatically.

How does it work? Simply you go to the chat and type /weapon <weapon_name> <ammo> For example, /weapon weapon_pistol 100. This example gives me a pistol with 100 ammo. to see the list of weapons Click Here.