Cancel weapon reload

Please post any questions about developing your plugin here. Please use the search function before posting!
ReQ220
Junior Member
Posts: 10
Joined: Sat Mar 28, 2020 7:25 pm

Cancel weapon reload

Postby ReQ220 » Mon May 11, 2020 5:17 am

Hi! I am trying to find a way how can I cancel the weapon reload.
For example below, I have there if a player has nova which has less than 8 bullets in his clip, I want him to can not reload.
If there any ideas how can I do that? I searched the whole SP wiki for any command like this, but I could not find it :(
Thank you in advance!

Code: Select all

@Event('weapon_reload')
def weapon_reload(event):
    userid = event['userid']
    player = Player.from_userid(userid)
    weapon = player.get_active_weapon()
    checkgun = (weapon.item_definition_index)
    nova = 35
    result = (str('CAN NOT RELOAD'))
   
    if checkgun == nova:
        value = weapon.clip
        If value < 7
            #here I need to cancel reload...
            print (result)
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Cancel weapon reload

Postby L'In20Cible » Mon May 11, 2020 5:47 am

Syntax: Select all

from listeners import OnPlayerRunCommand
from players.constants import PlayerButtons

@OnPlayerRunCommand
def on_player_run_command(player, user_cmd):
# Block the +reload key
user_cmd.buttons &= ~PlayerButtons.RELOAD

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 20 guests