Quantcast

Jump to content

» «
Photo

[C#] NativeUI need help with Game.Player.Money

4 replies to this topic
M1XT3NZ
  • M1XT3NZ

    Player Hater

  • Members
  • Joined: 26 Jul 2017
  • Austria

#1

Posted 30 July 2017 - 10:17 PM

Hello guys im new to coding and i wanted to know how to use Game.Player.Money correctly in an NativeUI menu. Hope you can help me guys


ins1de
  • ins1de

    Vi Veri Veniversum Vivus Vici

  • Members
  • Joined: 23 Apr 2016
  • Antarctica

#2

Posted 01 August 2017 - 02:03 PM

What do you exactly want to achieve?


M1XT3NZ
  • M1XT3NZ

    Player Hater

  • Members
  • Joined: 26 Jul 2017
  • Austria

#3

Posted 11 August 2017 - 12:50 AM

i want to give myselfe in singleplayer a amount of money. so that i will get with game.player.money = 9999; but i dont really know how to do that with nativeui..


M1XT3NZ
  • M1XT3NZ

    Player Hater

  • Members
  • Joined: 26 Jul 2017
  • Austria

#4

Posted 11 August 2017 - 12:21 PM

because i try to make my own singleplayer mod menu


FIFSA
  • FIFSA

    Ass Kisser

  • Members
  • Joined: 14 May 2015
  • United-States

#5

Posted 4 weeks ago Edited by FIFSA, 4 weeks ago.

Here's a quick code to give the player 1000 in a menu.

Use it as a reference if you'd like.

 

Just in case you plan on trying to do this online, it will not work as the money online is server-side and not client-side.

using System;
using System.Drawing;
using System.Windows.Forms;
using GTA;
using GTA.Native;
using GTA.Math;
using NativeUI;

namespace Money
{
    public class Main : Script
    {
        MenuPool pool = new MenuPool();
        UIMenu moneyMenu = new UIMenu("Add Money", ""); // create the menu
        public Main()
        {
            Tick += onTick;
            KeyDown += onKeyDown;
            Interval = 1;

            moneyMenu.AddItem(new UIMenuItem("Add $1000")); // create the item

            moneyMenu.OnItemSelect += moneyMenu_itemSelectHandler; 

            pool.Add(moneyMenu); // add the menu to the menu pool
            moneyMenu.RefreshIndex();
        }

        private void moneyMenu_itemSelectHandler(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            switch(index)
            {
                case 0: // index # from moneyMenu.MenuItems list
                    Game.Player.Money += 1000; // give the player 1000
                    UI.Notify("+ $1000!");
                    return;
            }
        }

        private void onTick(object sender, EventArgs e)
        {
            pool.ProcessMenus(); // process the menu
        }

        private void onKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.M)
            {
                moneyMenu.Visible = !moneyMenu.Visible; // opens if not visible, closes if visible
            }
        }

    }
}






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users