Hi,
I’m following the tutorial in the FiveM documentation for creating my first script in C# : Creating your first script in C# - Cfx.re Docs
I’ve setup my Visual Studio 2017 like said there : Scripting in C# - Cfx.re Docs
But when I try to build my project, VS tells me that IsModelInCdimage, IsModelAVehicle, Game and World doesnt exist.
CitizenFX.Core is in the references.
Below, the code i’m using.
using System;
using System.Collections.Generic;
using CitizenFX.Core;
using static CitizenFX.Core.Native.API;
namespace MyResourceNameClient
{
public class Class1 : BaseScript
{
public Class1()
{
EventHandlers["onClientResourceStart"] += new Action<string>(OnClientResourceStart);
}
private void OnClientResourceStart(string resourceName)
{
if (GetCurrentResourceName() != resourceName) return;
RegisterCommand("car", new Action<int, List<object>, string>(async (source, args, raw) =>
{
// account for the argument not being passed
var model = "adder";
if (args.Count > 0)
{
model = args[0].ToString();
}
// check if the model actually exists
// assumes the directive `using static CitizenFX.Core.Native.API;`
var hash = (uint)GetHashKey(model);
if (!IsModelInCdimage(hash) || !IsModelAVehicle(hash))
{
TriggerEvent("chat:addMessage", new
{
color = new[] { 255, 0, 0 },
args = new[] { "[CarSpawner]", $"It might have been a good thing that you tried to spawn a {model}. Who even wants their spawning to actually ^*succeed?" }
});
return;
}
// create the vehicle
var vehicle = await World.CreateVehicle(model, Game.PlayerPed.Position, Game.PlayerPed.Heading);
// set the player ped into the vehicle and driver seat
Game.PlayerPed.SetIntoVehicle(vehicle, VehicleSeat.Driver);
// tell the player
TriggerEvent("chat:addMessage", new
{
color = new[] { 255, 0, 0 },
args = new[] { "[CarSpawner]", $"Woohoo! Enjoy your new ^*{model}!" }
});
}), false);
}
}
}
Is there anything wrong ?
Thanks for your help,

