Client command filter help. blocking weapon drop
Posted: Sat Aug 20, 2016 4:50 pm
I am new because I was using eventscripts.
I am trying to convert my script from eventscripts and A part of the script is blocking weapon drop.
Here is my previous eventscripts script which worked:
I made this, which is for source.python:
When a try to drop a weapon ingame I get this error:
Idk if this info helps but I tried to have print(args) and it would output 1:
ServerConsole:
I am trying to convert my script from eventscripts and A part of the script is blocking weapon drop.
Here is my previous eventscripts script which worked:
Syntax: Select all
import es
def preventweapondrop(userid, args):
if args[0] == 'drop' or args[0] == 'buy':
return False
return True
def load():
es.addons.registerClientCommandFilter(preventweapondrop)
I made this, which is for source.python:
Syntax: Select all
from commands.client import register_client_command_filter
from commands.client import unregister_client_command_filter
def enable_prevent_weapon_drop_mod():
register_client_command_filter(preventweapondrop)
print("[prevent_weapon_drop] enabled.")
def disable_prevent_weapon_drop_mod():
unregister_client_command_filter(preventweapondrop)
print("[prevent_weapon_drop] disabled.")
def preventweapondrop(userid, args):
if args[0] == 'drop' or args[0] == 'buy':
return False
return True
When a try to drop a weapon ingame I get this error:
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/plugins/mod/prevent_weapon_drop/prevent_weapon_drop.py', line 13, in preventweapondrop
if args[0] == 'drop' or args[0] == 'buy':
TypeError: 'int' object is not subscriptable
Idk if this info helps but I tried to have print(args) and it would output 1:
Syntax: Select all
def preventweapondrop(userid, args):
# if args[0] == 'drop' or args[0] == 'buy':
# return False
print(args)
return True
ServerConsole:
1
1
1
1