Sign in to follow this  
ezequil

[Comanda]/engine

Recommended Posts

    [Command("engine")]
        public void engine(Client player)
        {
            if(NAPI.Player.IsPlayerInAnyVehicle(player) == true)
            {
                Vehicle vehicle = NAPI.Player.GetPlayerVehicle(player);

                if(NAPI.Player.GetPlayerVehicleSeat(player) > -1)
                    return;

                if(NAPI.Vehicle.GetVehicleEngineStatus(vehicle) == false)
                {
                    NAPI.Vehicle.SetVehicleEngineStatus(vehicle, true);
                    NAPI.Chat.SendChatMessageToPlayer(player, "A fost pornit motorul vehicului !");
                }
                else
                {
                    NAPI.Vehicle.SetVehicleEngineStatus(vehicle, false);
                    NAPI.Chat.SendChatMessageToPlayer(player, "Motorul vehicului a fost oprit !");
                }
            }
        }

O comanda simpla.Am postat-o sa isi faca incepatorii o idee.

  • Like 1

Share this post


Link to post
Share on other sites

Mai trebuie modificate unele chestii la script, pentru ca gta 5 are deja un sistem de pornire/oprire a motorului, deci trebuie facut in asa fel incat sa il dezactivezi si pe ala.

Share this post


Link to post
Share on other sites
12 hours ago, robearded said:

Mai trebuie modificate unele chestii la script, pentru ca gta 5 are deja un sistem de pornire/oprire a motorului, deci trebuie facut in asa fel incat sa il dezactivezi si pe ala.

Daca crezi ca trebuie adaugat ceva in plus si vrei sa ajuti lasa un reply cu codul

Share this post


Link to post
Share on other sites
Posted (edited)

Eu cum am procedat:

// Server side
[ServerEvent(Event.PlayerEnterVehicle)]
public void OnPlayerEnterVehicle(Client client, Vehicle vehicle, sbyte seatID)
{
  if (seatID == -1)
  {
    bool engineStatus = vehicle.EngineStatus;
    client.TriggerEvent("SetVehicleEngine", engineStatus);
  }
}

              
// Client side
using System;
using System.Collections.Generic;
using System.Text;
using RAGE;
using RAGE.Elements;

namespace Main
{
    class Vehicles : Events.Script
    {
        public Vehicles()
        {
            Events.Add("SetVehicleEngine", SetVehicleEngine);
        }

        public void SetVehicleEngine(object[] args)
        {
            Vehicle veh = Player.LocalPlayer.Vehicle;

            if (veh != null)
            {
                veh.SetUndriveable(!Convert.ToBoolean(args[0]));
                veh.SetEngineOn(Convert.ToBoolean(args[0]), true, true);
            }
        }
    }
}

 

Poate va ajuta.

Edited by Tonytza
  • Mask 1

Share this post


Link to post
Share on other sites
13 hours ago, Tonytza said:

Eu cum am procedat:

// Server side
[ServerEvent(Event.PlayerEnterVehicle)]
public void OnPlayerEnterVehicle(Client client, Vehicle vehicle, sbyte seatID)
{
  if (seatID == -1)
  {
    bool engineStatus = vehicle.EngineStatus;
    client.TriggerEvent("SetVehicleEngine", engineStatus);
  }
}

              
// Client side
using System;
using System.Collections.Generic;
using System.Text;
using RAGE;
using RAGE.Elements;

namespace Main
{
    class Vehicles : Events.Script
    {
        public Vehicles()
        {
            Events.Add("SetVehicleEngine", SetVehicleEngine);
        }

        public void SetVehicleEngine(object[] args)
        {
            Vehicle veh = Player.LocalPlayer.Vehicle;

            if (veh != null)
            {
                veh.SetUndriveable(!Convert.ToBoolean(args[0]));
                veh.SetEngineOn(Convert.ToBoolean(args[0]), true, true);
            }
        }
    }
}

 

Poate va ajuta.

Chiar m-ai surprins !Bravo!

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.