Skip to content

Instantly share code, notes, and snippets.

@taifuhime
Created November 28, 2018 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taifuhime/90378eda3e904a428792ac774671d605 to your computer and use it in GitHub Desktop.
Save taifuhime/90378eda3e904a428792ac774671d605 to your computer and use it in GitHub Desktop.
giver of weapons
from players.entity import Player
from entities.entity import Entity
from weapons.entity import Weapon
from commands.typed import TypedClientCommand
from commands.typed import TypedSayCommand
from mathlib import NULL_VECTOR
from commands import CommandReturn
from memory import make_object
@TypedSayCommand('!awp')
@TypedClientCommand('sp_awp')
def give_awp(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
awp = make_object(Weapon, player.give_named_item('weapon_awp'))
player.set_active_weapon(awp)
return CommandReturn.BLOCK
@TypedSayCommand('!g3sg1')
@TypedClientCommand('sp_g3sg1')
def give_g3sg1(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
g3sg1 = make_object(Weapon, player.give_named_item('weapon_g3sg1'))
player.set_active_weapon(g3sg1)
return CommandReturn.BLOCK
@TypedSayCommand('!scout')
@TypedClientCommand('sp_scout')
def give_scout(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
scout = make_object(Weapon, player.give_named_item('weapon_scout'))
player.set_active_weapon(scout)
return CommandReturn.BLOCK
@TypedSayCommand('!sg550')
@TypedClientCommand('sp_sg550')
def give_sg550(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
sg550 = make_object(Weapon, player.give_named_item('weapon_sg550'))
player.set_active_weapon(sg550)
return CommandReturn.BLOCK
@TypedSayCommand('!ak47')
@TypedClientCommand('sp_ak47')
def give_ak47(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
ak47 = make_object(Weapon, player.give_named_item('weapon_ak47'))
player.set_active_weapon(ak47)
return CommandReturn.BLOCK
@TypedSayCommand('!aug')
@TypedClientCommand('sp_aug')
def give_aug(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
aug = make_object(Weapon, player.give_named_item('weapon_aug'))
player.set_active_weapon(aug)
return CommandReturn.BLOCK
@TypedSayCommand('!famas')
@TypedClientCommand('sp_famas')
def give_famas(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
famas = make_object(Weapon, player.give_named_item('weapon_famas'))
player.set_active_weapon(famas)
return CommandReturn.BLOCK
@TypedSayCommand('!galil')
@TypedClientCommand('sp_galil')
def give_galil(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
galil = make_object(Weapon, player.give_named_item('weapon_galil'))
player.set_active_weapon(galil)
return CommandReturn.BLOCK
@TypedSayCommand('!m4a1')
@TypedClientCommand('sp_m4a1')
def give_m4a1(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
m4a1 = make_object(Weapon, player.give_named_item('weapon_m4a1'))
player.set_active_weapon(m4a1)
return CommandReturn.BLOCK
@TypedSayCommand('!sg552')
@TypedClientCommand('sp_sg552')
def give_sg552(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
sg552 = make_object(Weapon, player.give_named_item('weapon_sg552'))
player.set_active_weapon(sg552)
return CommandReturn.BLOCK
@TypedSayCommand('!mac10')
@TypedClientCommand('sp_mac10')
def give_mac10(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
mac10 = make_object(Weapon, player.give_named_item('weapon_mac10'))
player.set_active_weapon(mac10)
return CommandReturn.BLOCK
@TypedSayCommand('!mp5navy')
@TypedClientCommand('sp_mp5navy')
def give_mp5navy(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
mp5navy = make_object(Weapon, player.give_named_item('weapon_mp5navy'))
player.set_active_weapon(mp5navy)
return CommandReturn.BLOCK
@TypedSayCommand('!p90')
@TypedClientCommand('sp_p90')
def give_p90(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
p90 = make_object(Weapon, player.give_named_item('weapon_p90'))
player.set_active_weapon(p90)
return CommandReturn.BLOCK
@TypedSayCommand('!tmp')
@TypedClientCommand('sp_tmp')
def give_tmp(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
tmp = make_object(Weapon, player.give_named_item('weapon_tmp'))
player.set_active_weapon(tmp)
return CommandReturn.BLOCK
@TypedSayCommand('!ump45')
@TypedClientCommand('sp_ump45')
def give_ump45(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
ump45 = make_object(Weapon, player.give_named_item('weapon_ump45'))
player.set_active_weapon(ump45)
return CommandReturn.BLOCK
@TypedSayCommand('!m3')
@TypedClientCommand('sp_m3')
def give_m3(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
m3 = make_object(Weapon, player.give_named_item('weapon_m3'))
player.set_active_weapon(m3)
return CommandReturn.BLOCK
@TypedSayCommand('!xm1014')
@TypedClientCommand('sp_xm1014')
def give_xm1014(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
xm1014 = make_object(Weapon, player.give_named_item('weapon_xm1014'))
player.set_active_weapon(xm1014)
return CommandReturn.BLOCK
@TypedSayCommand('!m249')
@TypedClientCommand('sp_m249')
def give_m249(command):
player = Player(command.index)
if player.primary:
current_weapon = player.primary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
m249 = make_object(Weapon, player.give_named_item('weapon_m249'))
player.set_active_weapon(m249)
return CommandReturn.BLOCK
@TypedSayCommand('!deagle')
@TypedClientCommand('sp_deagle')
def give_deagle(command):
player = Player(command.index)
if player.secondary:
current_weapon = player.secondary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
deagle = make_object(Weapon, player.give_named_item('weapon_deagle'))
player.set_active_weapon(deagle)
return CommandReturn.BLOCK
@TypedSayCommand('!elite')
@TypedClientCommand('sp_elite')
def give_elite(command):
player = Player(command.index)
if player.secondary:
current_weapon = player.secondary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
elite = make_object(Weapon, player.give_named_item('weapon_elite'))
player.set_active_weapon(elite)
return CommandReturn.BLOCK
@TypedSayCommand('!fiveseven')
@TypedClientCommand('sp_fiveseven')
def give_fiveseven(command):
player = Player(command.index)
if player.secondary:
current_weapon = player.secondary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
fiveseven = make_object(Weapon, player.give_named_item('weapon_fiveseven'))
player.set_active_weapon(fiveseven)
return CommandReturn.BLOCK
@TypedSayCommand('!glock')
@TypedClientCommand('sp_glock')
def give_glock(command):
player = Player(command.index)
if player.secondary:
current_weapon = player.secondary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
glock = make_object(Weapon, player.give_named_item('weapon_glock'))
player.set_active_weapon(glock)
return CommandReturn.BLOCK
@TypedSayCommand('!p228')
@TypedClientCommand('sp_p228')
def give_p228(command):
player = Player(command.index)
if player.secondary:
current_weapon = player.secondary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
p228 = make_object(Weapon, player.give_named_item('weapon_p228'))
player.set_active_weapon(p228)
return CommandReturn.BLOCK
@TypedSayCommand('!usp')
@TypedClientCommand('sp_usp')
def give_usp(command):
player = Player(command.index)
if player.secondary:
current_weapon = player.secondary
player.drop_weapon(current_weapon.pointer, NULL_VECTOR, NULL_VECTOR)
current_weapon.remove()
usp = make_object(Weapon, player.give_named_item('weapon_usp'))
player.set_active_weapon(usp)
return CommandReturn.BLOCK
@TypedSayCommand('!knife')
@TypedClientCommand('sp_knife')
def give_knife(command):
player = Player(command.index)
if player.get_weapon(classname='weapon_knife'):
return
knife = make_object(Weapon, player.give_named_item('weapon_knife'))
player.set_active_weapon(knife)
return CommandReturn.BLOCK
@TypedSayCommand('!hegrenade')
@TypedClientCommand('sp_hegrenade')
def give_hegrenade(command):
player = Player(command.index)
if player.get_projectile_ammo('hegrenade') not in (0, 1):
return
hegrenade = make_object(Weapon, player.give_named_item('weapon_hegrenade'))
player.set_active_weapon(hegrenade)
return CommandReturn.BLOCK
@TypedSayCommand('!flashbang')
@TypedClientCommand('sp_flashbang')
def give_flashbang(command):
player = Player(command.index)
if player.get_projectile_ammo('flashbang') not in (0, 1):
return
flashbang = make_object(Weapon, player.give_named_item('weapon_flashbang'))
player.set_active_weapon(flashbang)
return CommandReturn.BLOCK
@TypedSayCommand('!smokegrenade')
@TypedClientCommand('sp_smokegrenade')
def give_smokegrenade(command):
player = Player(command.index)
if player.get_projectile_ammo('smokegrenade') not in (0, 1):
return
smokegrenade = make_object(Weapon, player.give_named_item('weapon_smokegrenade'))
player.set_active_weapon(smokegrenade)
return CommandReturn.BLOCK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment