I have been working on a similar addon (though a lot more features to it) for quite some time. Last I tested, some parts didn't work properly, but I haven't worked on it in a few months now.
You won't probably need load or unload. You will want to use gg_levelup and player_spawn. Also, is this just for your server? If so, and knife is the last level, you will not need gg_leveldown (otherwise I would suggest using gg_leveldown for when a player levels down off of knife level).
You will need at least 3 files for your custom addon:
- __init__.py
Just needs to be an empty file
- <addon name>.py
The file that contains all of the code to run the addon
- <addon name>_config.py
The file that creates the server variable for the addon, which GG51 uses to know when to load/unload the addon
For the <addon name>_config.py, take a look at some of the included addons to know how to use that file. Pretty much copy/paste and replace the addon's name that you copied from with your addon's name.
Now, onto the actual file itself. Again, use gg_levelup and player_spawn to check the weapon of the player's level in those events. Use GG51's core to get the player's current level weapon:
from gungame51.core.players.shortcuts import Player
def player_spawn(event_var):
ggPlayer = Player(event_var['userid'])
player_weapon = ggPlayer.weapon
def gg_levelup(event_var):
ggPlayer = Player(event_var['leveler'])
player_weapon = ggPlayer.weapon
Then, just check to see if player_weapon equals
knife to know whether they should be give a smokegrenade.
Satoon