Converting your script

From GT-MP
Jump to: navigation, search

Converting your script

This page will be going over how to convert a GTA:Network resource into a GT-MP one.

Requirements

  • Basic C# programming knowledge

Server side (C#)

In the GT-MP scripting API, some objects have been moved to different namespaces. Currently, in GTA:Network resources, these are the only namespaces used:

using GTANetworkServer;
using GTANetworkShared;

You'll now need to reference these namespaces:

using GrandTheftMultiplayer.Server;
using GrandTheftMultiplayer.Server.API;
using GrandTheftMultiplayer.Server.Elements;
using GrandTheftMultiplayer.Server.Constant;
using GrandTheftMultiplayer.Server.Managers;
using GrandTheftMultiplayer.Shared;
using GrandTheftMultiplayer.Shared.Math;

Visual Studio 2017 will automatically hint at which namespaces you need to include in order for it to find certain classes. If you're not using this version of Visual Studio, or using a different editor entirely, copying all usings shown above should also do the trick.

You can also take a look at this example resource: Vehicle Spawner

Please note that some VehicleHash and PedHash enum members have changed names to correct spelling mistakes. They'll appear in the errors when you try to build your resource, and you should be able to resolve them manually.

Clientside

In the clientside API, the functions for API.getCursorPositionMantainRatio(), API.getScreenResolutionMantainRatio() and API.screenToWorldMantainRatio have been thanged to corrent for spelling mistakes. Mantain -> Maintain