[C#] How can I spawn Cars by Name?
-
Hey Guys, im searching for a solution to spawn cars by name. Like you have a TextBox and there you type in the Vehicle name.
Maybe someone can give me a Code Example!
Greetings From Germany
-
Use
Game.GetUserInput
for the text box.If you want to spawn cars with a model name, just put the returned string from
Game.GetUserInput
intoWorld.CreateVehicle
If you want to spawn cars with their actual name:
Create aDictionary<Key, Value>
with the keys set as vehicle names and values set as model names.
Put the returned string fromGame.GetUserInput
inyourDictionaryVariable.TryGetValue(userInputReturnedStringHere, out variableForValue)
to get the model name. Use that model name inWorld.CreateVehicle
-
Thanks !