Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

2 years ago

Advertisement
July 16, 2019, 04:46:10 pm

Author Topic: Buy Menu  (Read 5236 times)

Philpax

  • Developer
  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Buy Menu
« on: December 16, 2013, 07:01:42 pm »
Grab the buy menu script here: https://github.com/Philpax/jc2mp-buymenu
Extract into a folder called "buymenu" and drop in scripts/

Eraknelo

  • Sr. Member
  • ****
  • Posts: 310
    • View Profile
Re: Buy Menu
« Reply #1 on: December 16, 2013, 08:49:14 pm »
Nice! I hope you don't mind Philpax, but for those who want everything to be free, open up server/buymenu.lua

Then, comment lines 103 through 109 and 118 through 127

You comment like so:
Code: [Select]
--[[ Commented Code Here ]]--
So, that is:
(103-109)
Code: [Select]
--[[if  self:IsInHotspot( player:GetPosition() ) and
 ........................
end]]--

(118-127)
Code: [Select]
--[[if player:GetMoney() < item:GetPrice() then
 ........................
end --]]
« Last Edit: December 16, 2013, 08:51:40 pm by Eraknelo »

DJWeownthis

  • Donator
  • Newbie
  • *****
  • Posts: 36
    • View Profile
Re: Buy Menu
« Reply #2 on: December 16, 2013, 09:47:17 pm »
Open up buymenu/shared/buymenu.lua Copy & Paste this in

Code: [Select]
class 'BuyMenu'
class 'BuyMenuEntry'

function BuyMenuEntry:__init( model_id, price, entry_type )
    self.model_id = model_id
    self.price = price
    self.entry_type = entry_type
end

function BuyMenuEntry:GetPrice()
     return 0
end

function BuyMenuEntry:GetModelId()
    return self.model_id
end

function BuyMenuEntry:GetListboxItem()
    return self.listbox_item
end

function BuyMenuEntry:SetListboxItem( item )
    self.listbox_item = item
end

class 'VehicleBuyMenuEntry' (BuyMenuEntry)

function VehicleBuyMenuEntry:__init( model_id, price )
    BuyMenuEntry.__init( self, model_id, price, 1 )
end

function VehicleBuyMenuEntry:GetName()
    return Vehicle.GetNameByModelId( self.model_id )
end

class 'WeaponBuyMenuEntry' (BuyMenuEntry)

function WeaponBuyMenuEntry:__init( model_id, price, slot, name )
    BuyMenuEntry.__init( self, model_id, price, 2 )
    self.slot = slot
    self.name = name
end

function WeaponBuyMenuEntry:GetSlot()
    return self.slot
end

function WeaponBuyMenuEntry:GetName()
    return self.name
end

class 'ModelBuyMenuEntry' (BuyMenuEntry)

function ModelBuyMenuEntry:__init( model_id, price, name )
    BuyMenuEntry.__init( self, model_id, price, 2 )
    self.name = name
end

function ModelBuyMenuEntry:GetName()
    return self.name
end

function BuyMenu:CreateItems()
    self.types = {
        ["Vehicle"] = 1,
        ["Weapon"] = 2,
        ["Model"] = 3
    }

    self.id_types = {}

    for k, v in pairs(self.types) do
        self.id_types[v] = k
    end
    self.items = {
        [self.types.Vehicle] = {
            { "Land", "Air", "Sea" },
            ["Land"] = {
                VehicleBuyMenuEntry( 2, 1000 ),
                VehicleBuyMenuEntry( 4, 750 ),
                VehicleBuyMenuEntry( 11, 250 ),
                VehicleBuyMenuEntry( 13, 600 ),
                VehicleBuyMenuEntry( 18, 5000 ),
                VehicleBuyMenuEntry( 21, 400 ),
                VehicleBuyMenuEntry( 22, 200 ),
                VehicleBuyMenuEntry( 35, 1500 ),
                VehicleBuyMenuEntry( 43, 400 ),
                VehicleBuyMenuEntry( 46, 800 ),
                VehicleBuyMenuEntry( 54, 1000 ),
                VehicleBuyMenuEntry( 56, 5000 ),
                VehicleBuyMenuEntry( 72, 800 ),
                VehicleBuyMenuEntry( 76, 2000 ),
                VehicleBuyMenuEntry( 77, 2500 ),
                VehicleBuyMenuEntry( 78, 1100 ),
                VehicleBuyMenuEntry( 79, 1300 ),
                VehicleBuyMenuEntry( 87, 700 ),
                VehicleBuyMenuEntry( 89, 450 ),
                VehicleBuyMenuEntry( 91, 1000 ),
                -- DLC
                --VehicleBuyMenuEntry( 20, 8000 ),
                --VehicleBuyMenuEntry( 58, 2000 ),
                --VehicleBuyMenuEntry( 75, 1000 ),
                --VehicleBuyMenuEntry( 82, 1000 )
            },

            ["Sea"] = {
                VehicleBuyMenuEntry( 5, 500 ),
                VehicleBuyMenuEntry( 16, 500 ),
                VehicleBuyMenuEntry( 25, 700 ),
                VehicleBuyMenuEntry( 27, 1100 ),
                VehicleBuyMenuEntry( 28, 900 ),
                VehicleBuyMenuEntry( 69, 1000 ),
                VehicleBuyMenuEntry( 80, 1000 ),
                VehicleBuyMenuEntry( 88, 1050 ),
                -- DLC
                --VehicleBuyMenuEntry( 53, 10000 )
            },

            ["Air"] = {
                VehicleBuyMenuEntry( 3, 3000 ),
                VehicleBuyMenuEntry( 30, 8000 ),
                VehicleBuyMenuEntry( 34, 10000 ),
                VehicleBuyMenuEntry( 64, 4000 ),
                VehicleBuyMenuEntry( 65, 4000 ),
                VehicleBuyMenuEntry( 81, 5000 ),
                VehicleBuyMenuEntry( 85, 10000 ),
                -- DLC
                --VehicleBuyMenuEntry( 24, 15000 )
            }
        },

        [self.types.Weapon] = {
            { "One-handed", "Two-handed" },
            ["One-handed"] = {
                WeaponBuyMenuEntry( Weapon.Handgun, 500, 1, "Pistol" ),
                WeaponBuyMenuEntry( Weapon.Revolver, 1000, 1, "Revolver" ),
                WeaponBuyMenuEntry( Weapon.SMG, 1200, 1, "SMG" ),
                WeaponBuyMenuEntry( Weapon.SawnOffShotgun, 1100, 1, "Sawn-off Shotgun" )
            },

            ["Two-handed"] = {
                WeaponBuyMenuEntry( Weapon.Assault, 2000, 2, "Assault Rifle" ),
                WeaponBuyMenuEntry( Weapon.Shotgun, 2000, 2, "Shotgun" ),
                WeaponBuyMenuEntry( Weapon.MachineGun, 4000, 2, "Machine Gun" ),
                WeaponBuyMenuEntry( Weapon.Sniper, 5000, 2, "Sniper Rifle" ),
                WeaponBuyMenuEntry( Weapon.RocketLauncher, 7500, 2, "Rocket Launcher" )
            }
        },

        [self.types.Model] = {
            { "Roaches", "Ular Boys", "Reapers", "Government", "Agency", "Misc" },

            ["Roaches"] = {
                ModelBuyMenuEntry( 2, 5000, "Razak Razman" ),
                ModelBuyMenuEntry( 5, 2500, "Elite" ),
                ModelBuyMenuEntry( 32, 1250, "Technician" ),
                ModelBuyMenuEntry( 85, 600, "Soldier 1" ),
                ModelBuyMenuEntry( 59, 600, "Soldier 2" )
            },

            ["Ular Boys"] = {
                ModelBuyMenuEntry( 38, 5000, "Sri Irawan" ),
                ModelBuyMenuEntry( 87, 2500, "Elite" ),
                ModelBuyMenuEntry( 22, 1250, "Technician" ),
                ModelBuyMenuEntry( 27, 600, "Soldier 1" ),
                ModelBuyMenuEntry( 103, 600, "Soldier 2" )
            },

            ["Reapers"] = {
                ModelBuyMenuEntry( 90, 5000, "Bolo Santosi" ),
                ModelBuyMenuEntry( 63, 2500, "Elite" ),
                ModelBuyMenuEntry( 8, 1250, "Technician" ),
                ModelBuyMenuEntry( 12, 600, "Soldier 1" ),
                ModelBuyMenuEntry( 58, 600, "Soldier 2" ),
            },

            ["Government"] = {
                ModelBuyMenuEntry( 74, 7500, "Baby Panay" ),
                ModelBuyMenuEntry( 67, 7500, "Burned Baby Panay" ),
                ModelBuyMenuEntry( 101, 5000, "Colonel" ),
                ModelBuyMenuEntry( 3, 2500, "Demo Expert" ),
                ModelBuyMenuEntry( 98, 2500, "Pilot" ),
                ModelBuyMenuEntry( 42, 2500, "Black Hand" ),
                ModelBuyMenuEntry( 44, 2500, "Ninja" ),
                ModelBuyMenuEntry( 23, 1250, "Scientist" ),
                ModelBuyMenuEntry( 52, 600, "Soldier 1" ),
                ModelBuyMenuEntry( 66, 600, "Soldier 2" )
            },

            ["Agency"] = {
                ModelBuyMenuEntry( 9, 1000, "Karl Blaine" ),
                ModelBuyMenuEntry( 65, 1000, "Jade Tan" ),
                ModelBuyMenuEntry( 25, 1000, "Maria Kane" ),
                ModelBuyMenuEntry( 30, 1000, "Marshall" ),
                ModelBuyMenuEntry( 34, 1000, "Tom Sheldon" ),
                ModelBuyMenuEntry( 100, 1000, "Black Market Dealer" ),
                ModelBuyMenuEntry( 83, 800, "White Tiger" ),
                ModelBuyMenuEntry( 51, 0, "Rico Rodriguez" )
            },

            ["Misc"] = {
                ModelBuyMenuEntry( 70, 5000, "General Masayo" ),
                ModelBuyMenuEntry( 11, 5000, "Zhang Sun" ),
                ModelBuyMenuEntry( 84, 5000, "Alexander Mirikov" ),
                ModelBuyMenuEntry( 19, 5000, "Chinese Businessman" ),
                ModelBuyMenuEntry( 36, 5000, "Politician" ),
                ModelBuyMenuEntry( 78, 4000, "Thug Boss" ),
                ModelBuyMenuEntry( 71, 2500, "Saul Sukarno" ),
                ModelBuyMenuEntry( 79, 2500, "Japanese Veteran" ),
                ModelBuyMenuEntry( 96, 2500, "Bodyguard" ),
                ModelBuyMenuEntry( 80, 2500, "Suited Guest 1" ),
                ModelBuyMenuEntry( 95, 2500, "Suited Guest 2" ),
                ModelBuyMenuEntry( 60, 1250, "Race Challenge Girl" ),
                ModelBuyMenuEntry( 15, 1250, "Male Stripper 1" ),
                ModelBuyMenuEntry( 17, 1250, "Male Stripper 2" ),
                ModelBuyMenuEntry( 86, 1250, "Female Stripper" ),
                ModelBuyMenuEntry( 16, 1250, "Panau Police" ),
                ModelBuyMenuEntry( 18, 1250, "Hacker" ),
                ModelBuyMenuEntry( 64, 1000, "Bom Bom Bohilano" ),
                ModelBuyMenuEntry( 40, 1000, "Factory Boss" ),
                ModelBuyMenuEntry( 1, 600, "Thug 1" ),
                ModelBuyMenuEntry( 39, 600, "Thug 2" ),
                ModelBuyMenuEntry( 61, 600, "Soldier" ),
                ModelBuyMenuEntry( 26, 600, "Boat Captain" ),
                ModelBuyMenuEntry( 21, 20, "Paparazzi" ),
            }
        }
    }
end

Have Fun!
« Last Edit: December 16, 2013, 10:24:54 pm by DJWeownthis »

Eraknelo

  • Sr. Member
  • ****
  • Posts: 310
    • View Profile
Re: Buy Menu
« Reply #3 on: December 16, 2013, 10:38:50 pm »
Open up buymenu/shared/buymenu.lua Copy & Paste this in

[...]

Have Fun!
What have you done to it?

Edit:
Oh, just GetPrice() to return 0?

DJWeownthis

  • Donator
  • Newbie
  • *****
  • Posts: 36
    • View Profile
Re: Buy Menu
« Reply #4 on: December 16, 2013, 11:05:33 pm »
Open up buymenu/shared/buymenu.lua Copy & Paste this in

[...]

Have Fun!
What have you done to it?

Edit:
Oh, just GetPrice() to return 0?

function BuyMenuEntry:GetPrice()
     return 0

DonDark

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Buy Menu
« Reply #5 on: December 19, 2013, 03:45:00 pm »
would there be a way to add into the script that weapons and grabling hook ect is upgraded to 6 stars ?