Frequently asked scripting questions

From GTA Network Wiki
Jump to: navigation, search

Frequently asked scripting questions

Getting Started

First of all, you should check out our Getting Started section, a lot of things are already explained there. Also take a look at the Server Resources. A lot of things are already included. Like the NativeUI a simple login/register script and much more.

How do I get autocompletion?

You can follow any of these guides, depending on your OS:

How do I make a command accept more than 1 word as its parameter?

Use the GreedyArg parameter in the Command attribute, like this:

[Command("me", GreedyArg = true)]
public void TestCommand(Client sender, string message)

How do I change a command's usage text?

Set the second argument in the command's constructor, for example:

[Command("me", "Usage: ~r~/me [your message]", GreedyArg = true)]
public void TestCommand(Client sender, string message)

How do I get the vehicle a player is in?

Take a look at GetPlayerVehicle. If you also want to know which seat a player is in, you can use GetPlayerVehicleSeat.

How do I get the player's current ammo?

You can use GetPlayerWeaponAmmo.

How do I set the player's hair color?

You can use the native _SET_PED_HAIR_COLOR in combination with this list of Hair Colors. This only works on the freemode skins (GTAO characters).

How can I use clientside scripts or CEF?

This Wiki is only for serverside. Check out the Wiki of RageMP for clientside informations:

How do I show a blip/marker only for 1 player?

Use a clientside command instead of a serverside command. You can tell a client to do this from the server by triggering a client event using TriggerClientEvent.

Do I have to inherit from the Script class for every class I make?

No. Most often you will need to inherit the Script class when you use Events and Commands. You can use NAPI functions wherever you want.

How can I open doors on buildings like ammunation? (Doormanager)

Follow this short guide about the Doormanager.