I have researched all of the questions that match my query and tried their solutions however none appear to work for me so I am asking how I convert a string to a ushort
I have this set up all ready
public static string vid
{
get { return "<vehicleid>"; }
}
I've tried to use this : short[] result = vid.Select(c => (ushort)c).ToArray();
but when I go to put the vid ushort into this bit
[RocketCommand("vehicle", "This command spawns you a vehicle!", "<vehicleid>", AllowedCaller.Player)]
public void ExecuteCommandVehicle(IRocketPlayer caller, string[] command)
{
UnturnedPlayer spawner = (UnturnedPlayer)caller;
spawner.GiveVehicle(vid);
}
I get the following error :
Severity Code Description Project File Line Suppression State Error CS1503 Argument 1: cannot convert from 'string' to 'ushort' arena v by FridgeBlaster C:\Users\Jonathan\Documents\Visual Studio 2015\Projects\arena v by FridgeBlaster\arena v by FridgeBlaster\vehicle.cs 71 Active
Either you want to convert the string to a short:
or
or you want to convert char to short by first converting string to array of chars: