Hi New here
Posted: Mon Nov 06, 2017 8:46 pm
Hi . I am wondering if it is possible to make gunmenu on server side?
very cool site.
D
very cool site.
D
Syntax: Select all
# ==============================================================================
# >> IMPORTS
# ==============================================================================
from players.entity import Player
from players.dictionary import PlayerDictionary
from menus import PagedMenu
from menus import PagedOption
from commands.say import SayCommand
from events import Event
# ==============================================================================
# >> CONSTANTS/CONFIG
# ==============================================================================
# <display name>: <classname>
PRIMARY_WEAPONS = [
('Maverick M4A1 Carbine', 'weapon_m4a1'),
('AK47', 'weapon_ak47'),
('Schmidt Scout', 'weapon_scout'),
('Krieg 552', 'weapon_sg552'),
('IDF Defender', 'weapon_galil'),
('FAMAS', 'weapon_famas'),
('Bullpup', 'weapon_aug'),
('M249-SAW', 'weapon_m249'),
('KM UMP45', 'weapon_ump45'),
('MP5 Navy', 'weapon_mp5navy'),
('Leone 12 Gauge Super', 'weapon_m3'),
('Leone YG1265 Auto Shotgun', 'weapon_xm1014'),
('Schmidt Machine Pistol', 'weapon_tmp'),
('Ingram Mac-10', 'weapon_mac10'),
('ES C90', 'weapon_p90')
]
SECONDARY_WEAPONS = [
('USP Tactical', 'weapon_usp'),
('Glock', 'weapon_glock'),
('Desert Eagle', 'weapon_deagle'),
('P228', 'weapon_p228'),
('Dual 96G Elite Berettas', 'weapon_elite'),
('ES Five Seven', 'weapon_fiveseven'),
]
# Commands that open the weapon menu
WEAPON_COMMANDS = [
'!weapons',
'!guns',
]
# Health amount to give (0 to use default from game/other plugin)
HEALTH = 0
# Armor amount to give
ARMOR = 100
# Whether to give a helmet. If you want to disable armor, you must
# set this to "False" as well as setting armor to 0.
HELMET = True
# Whether to give flashbangs
FLASHBANGS = True
# Whether to give a smoke grenade
SMOKEGRENADE = False
# Whether to give an HE grenade
HEGRENADE = True
# Whether to give defusekits to CTs
DEFUSE_KITS = True
# ==============================================================================
# >> GLOBAL VARIABLES
# ==============================================================================
primary_menu = PagedMenu(
list(PagedOption(x, y) for x, y in PRIMARY_WEAPONS),
title='Choose a primary weapon'
)
secondary_menu = PagedMenu(
list(PagedOption(x, y) for x, y in SECONDARY_WEAPONS),
title='Choose a secondary weapon'
)
# ==============================================================================
# >> CLASSES
# ==============================================================================
class PlayerWeapons(object):
def __init__(self, index):
self.player = Player(index)
self.primary = None
self.secondary = None
player_weapons = PlayerDictionary(PlayerWeapons)
# ==============================================================================
# >> CALLBACKS
# ==============================================================================
@primary_menu.register_select_callback
def on_primary_menu_select(menu, index, option):
weapons = player_weapons[index]
player = weapons.player
for weapon in player.weapons(is_filters='primary'):
weapon.remove()
weapons.primary = option.value
player.give_named_item(option.value)
@secondary_menu.register_select_callback
def on_secondary_menu_select(menu, index, option):
weapons = player_weapons[index]
player = weapons.player
for weapon in player.weapons(is_filters='secondary'):
weapon.remove()
weapons.secondary = option.value
player.give_named_item(option.value)
# ==============================================================================
# >> COMMANDS
# ==============================================================================
@SayCommand(WEAPON_COMMANDS)
def on_weapons(command, index, team_only):
primary_menu.send(index)
secondary_menu.send(index)
# ==============================================================================
# >> EVENTS
# ==============================================================================
@Event('player_spawn')
def on_player_spawn(event):
weapons = player_weapons.from_userid(event['userid'])
player = weapons.player
if HEALTH != 0:
player.health += HEALTH
player.armor = ARMOR
if HELMET:
player.has_helmet = HELMET
if FLASHBANGS:
if player.get_projectile_ammo('flashbang') == 0:
player.give_named_item('weapon_flashbang')
player.set_projectile_ammo('flashbang', 2)
if SMOKEGRENADE and player.get_projectile_ammo('smokegrenade') == 0:
player.give_named_item('weapon_smokegrenade')
if HEGRENADE and player.get_projectile_ammo('hegrenade') == 0:
player.give_named_item('weapon_hegrenade')
if DEFUSE_KITS:
player.has_defuser = True
if weapons.primary is not None and player.primary is None:
player.give_named_item(weapons.primary)
if weapons.secondary is not None and player.secondary is None:
player.give_named_item(weapons.secondary)