Jump to content

Server-Side RemoteEvent not triggering


playunits

Recommended Posts

So, i was on my way to create a simple practice Script. Everything fine so far, my ClientSide Menu opens etc. The button activation gets fired and is from the correct element. The the Remote Event should trigger which does not seem to happen. Any Thoughts where i messed up?

 

So far i received no Error what so ever.

 

Server Side Main.cs (Snippet)
 

 [RemoteEvent("VehicleSpawn")]
  public void VehicleSpawn(Player player, bool locked, bool engine, string vehName)
  {
    player.SendChatMessage("Got called");
    uint vHash = NAPI.Util.GetHashKey(vehName);
    player.SendChatMessage(vHash.ToString());
    NAPI.Vehicle.CreateVehicle(vHash, player.Position.Around(5), 0.0f, 0, 0, locked: locked, engine: engine);
  }

 

Client Side Main Class

public class Main : Events.Script
    {
        public Main()
        {
            Events.Add("playRP.CMD.vehicle", VehicleNative);
        }

        public void VehicleNative(object[] args)
        {
            Chat.Show(false);
            RAGE.Ui.Cursor.Visible = true;

            MenuPool mPool = new MenuPool();

            UIMenu VehicleMenu = new UIMenu("Spawner","Spawn your desired Vehicle");

            mPool.Add(VehicleMenu);

            bool Locked = false;
            bool Engine = true;

            UIMenuCheckboxItem locked = new UIMenuCheckboxItem("Locked?", false);
            UIMenuCheckboxItem engine = new UIMenuCheckboxItem("Engine On?", true);

            VehicleMenu.AddItem(locked);
            VehicleMenu.AddItem(engine);

            var vehNames = new List<dynamic>
            {
                "Infernus",
                "Cheetah",
                "Dominator"
            };

            string selectedVeh = vehNames[0];

            UIMenuListItem VehicleName = new UIMenuListItem("Vehicle", vehNames, 0);

            VehicleMenu.AddItem(VehicleName);

            UIMenuItem CreateButon = new UIMenuItem("Create Vehicle!");

            VehicleMenu.AddItem(CreateButon);

            VehicleMenu.OnCheckboxChange += (sender, item, flag) =>
            {
                if(sender == VehicleMenu)
                {
                    if (item == locked)
                        Locked = flag;
                    else if (item == engine)
                        Engine = flag;
                }
            };

            VehicleMenu.OnListChange += (sender, item, index) =>
            {
                if(sender == VehicleMenu)
                {
                    if(item == VehicleName)
                    {
                        selectedVeh = item.IndexToItem(index).ToString();
                    }
                }
            };

            CreateButon.Activated += (sender, item) =>
            {
                if(sender == VehicleMenu)
                {
                    if(item == CreateButon)
                    {
                        Chat.Output("CALLED ACTIVATED");
                        Events.CallRemote("VehicleSpawn", locked, engine, selectedVeh);
                        Chat.Show(true);
                        VehicleMenu.Visible = false;
                        VehicleMenu.FreezeAllInput = false;
                        RAGE.Ui.Cursor.Visible = false;
                    }
                }
            };

            VehicleMenu.OnMenuClose += (sender) =>
            {
                if(sender == VehicleMenu)
                {
                    Chat.Show(true);
                    VehicleMenu.Visible = false;
                    VehicleMenu.FreezeAllInput = false;
                    RAGE.Ui.Cursor.Visible = false;
                }
            };

            VehicleMenu.Visible = true;
            VehicleMenu.FreezeAllInput = true;

            VehicleMenu.RefreshIndex();

            Events.Tick += (name) =>
            {
                mPool.ProcessMenus();
            };
        }
    }

 

Thanks in Advance for helping and hopefully pointing out the Obvious ^^

Link to comment
Share on other sites

  • 3 years later...
  • Xabi locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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