Jump to content

Array for Vehicle [C#]


adiq888

Recommended Posts

Hi everyone

I'd like to know how I can assign to a variable vehicles created by the NAPI.Vehicle.CreateVehicle function in c #

 

	public int[] Vehicle = new int[4];
	[ServerEvent(Event.ResourceStart)]
        public void OnResourceStart()
        {
            NAPI.Util.ConsoleOutput("Twoj projekt Rage zostal pomyslnie zaladowany!");
            Vehicle[0] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-418.4451, 1211.138, 325.4577), 235.3172f, 1, 1);
            Vehicle[1] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-419.3018, 1207.183, 325.4566),    235.3172f, 1, 1);
           Vehicle[2] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-420.7397, 1202.853, 325.4572),     235.3172f, 1, 1);
            Vehicle[3] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-421.3993, 1198.118, 325.4573),    235.3172f, 1, 1);
        }
	 
	

 

how to do it ? :/

 

Edited by adiq888
Link to comment
Share on other sites

	public Vehicle[] veh = new Vehicle[4];
	[ServerEvent(Event.ResourceStart)]
        public void OnResourceStart()
        {
            NAPI.Util.ConsoleOutput("Twoj projekt Rage zostal pomyslnie zaladowany!");
            veh[0] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-418.4451, 1211.138, 325.4577), 235.3172f, 1, 1);
            veh[1] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-419.3018, 1207.183, 325.4566),    235.3172f, 1, 1);
            veh[2] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-420.7397, 1202.853, 325.4572),     235.3172f, 1, 1);
            veh[3] = NAPI.Vehicle.CreateVehicle(-1346687836, new Vector3(-421.3993, 1198.118, 325.4573),    235.3172f, 1, 1);
        }
	 
	

 

Link to comment
Share on other sites

	[ServerEvent(Event.PlayerEnterVehicle)]
        void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seatID)
        {
            if (vehicle == veh[0])
            {
                NAPI.Chat.SendChatMessageToPlayer(player, "To jest pojazd kuriera!");
            }
        }
	

 

after executing this code the server will crash

Link to comment
Share on other sites

3 hours ago, adiq888 said:

 


	[ServerEvent(Event.PlayerEnterVehicle)]
        void OnPlayerEnterVehicle(Client player, Vehicle vehicle, sbyte seatID)
        {
            if (vehicle == veh[0])
            {
                NAPI.Chat.SendChatMessageToPlayer(player, "To jest pojazd kuriera!");
            }
        }
	

 

 

after executing this code the server will crash

And what's the exception?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...