plugin conversion
Ok thanks it works fine
Now, I added a PagedMenu for listing maps :
How I can add a title (1)?
Is it possible to change the "10. Close" in "0. Close" (2)?
I would like to execute many actions like adding bots, changing maps, loading cfg files, ...
Before (with eventscript), I used this command (for changing map) : es.server.cmd("changelevel " + map.replace('.bsp',''))
How can I do with SP?
Thanks

Now, I added a PagedMenu for listing maps :
How I can add a title (1)?
Is it possible to change the "10. Close" in "0. Close" (2)?
I would like to execute many actions like adding bots, changing maps, loading cfg files, ...
Before (with eventscript), I used this command (for changing map) : es.server.cmd("changelevel " + map.replace('.bsp',''))
How can I do with SP?
Thanks
The PagedMenu class has a "title" attribute, which you can also set in the constructor. The close button was not intended to be labeled with a "10". I will fix this.
Edit: Fixed! https://github.com/Source-Python-Dev-Team/Source.Python/commit/73b4f0ec852822a4c8a8ecd330b163ded0e1189e
A new download is available (or you just apply the fix manually).
Syntax: Select all
from menus import PagedOption
from menus import PagedMenu
from events import Event
from engines.server import engine_server
def select_callback(menu, player_index, option):
engine_server.server_command('changelevel {};'.format(option.value))
maps_menu = PagedMenu(title='My menu', select_callback=select_callback)
# PagedOption(<display text>, <value>)
# In this case the display text and the value are the same. So, you could
# actually just use option.text in your select callback. However, it does
# make sense to use the value attribute. Maybe you want to change the display
# text some day.
maps_menu.append(PagedOption('de_dust2', 'de_dust2'))
maps_menu.append(PagedOption('cs_office', 'cs_office'))
Edit: Fixed! https://github.com/Source-Python-Dev-Team/Source.Python/commit/73b4f0ec852822a4c8a8ecd330b163ded0e1189e
A new download is available (or you just apply the fix manually).
Hello,
I added a title to the menu, I can change maps, add, kill and kick bots
Now, I would like to be able, thanks to the menu, to lock and unlock weapons and smoke with a cfg file.
For smokes only, this is my file (VerrouSmoke.cfg) :
sp load sprestrict //If sprestrict is not loaded
sprestrict @all weapon_smokegrenade
In GLOBAL VARIABLES I have this line : VerrouSmoke = PLUGIN_PATH.joinpath('VerrouSmoke.cfg')
And I lunch it with : engine_server.server_command(VerrouSmoke)
But it didn't work. Do you know why?
Thanks
[EDIT] When anyone say "!menu", the text appears in th chat. Is it possible to block it?
I added a title to the menu, I can change maps, add, kill and kick bots

Now, I would like to be able, thanks to the menu, to lock and unlock weapons and smoke with a cfg file.
For smokes only, this is my file (VerrouSmoke.cfg) :
sp load sprestrict //If sprestrict is not loaded
sprestrict @all weapon_smokegrenade
In GLOBAL VARIABLES I have this line : VerrouSmoke = PLUGIN_PATH.joinpath('VerrouSmoke.cfg')
And I lunch it with : engine_server.server_command(VerrouSmoke)
But it didn't work. Do you know why?
Thanks
[EDIT] When anyone say "!menu", the text appears in th chat. Is it possible to block it?
engine_server.server_command(<command>) only executes a server command and not a config file. But there is a server command to execute a config file, so you could just use this to execute it:AFAIK, this can only execute a config file within the cfg directory. And that's actually good, because that's where config files belong to.
To block the !menu command you have to register a say command.
Syntax: Select all
engine_server.server_command('exec my_config_file.cfg;')
To block the !menu command you have to register a say command.
Syntax: Select all
from commands.say import SayCommand
@SayCommand('!menu')
def open_menu(command, player_index, teamonly):
pass
Sorry, my fault. You also have to return CommandReturn.BLOCK to avoid the chat message.Syntax: Select all
from commands import CommandReturn
from commands.say import SayCommand
@SayCommand('!menu')
def open_menu(command, player_index, teamonly):
return CommandReturn.BLOCK
When I use this, it blocks the "command" and the menu doesn't appears. I just want to block "IVG : !menu" in the chat. Is it possible? It's not very important, just a finition for me

Ayuto wrote:Where did you save your config file? I see that your are using PLUGIN_PATH, which is the path to the plugins directory (../addons/source-python/plugins). This not correct. To execute a config file it must be saved in the cfg directory and I think the path must be relative and not absolute.
But I'm wondering what you are trying to do. If you want to create and execute config files I suggest you to take a look at the config package. Here are a few examples. http://wiki.sourcepython.com/pages/Examples:config
My config files are in my plugin "NewMenu.py" directory.
satoon101 wrote:The server cannot execute config files outside the ../cfg/ directory. Please move them into there. But again, what all is in them and is it necessary to have a cfg file or will just executing the commands directly suffice?
I have two lines in this file :
sp load sprestrict
@all weapon_smokegrenade
It works now. The plugin is loaded. But the second line is not understanded by SP : unknown command : @all
But in others files, I have 4 lines, or more...
Here there is the plugin I'm using for the weapon restriction and the differents files I used with an old plugin (which was working with eventscript). I would like to use the same.
ES has a command called mexec. What it does if the file is outside of the ../cfg/ directory, it copies it to the ../cfg/ directory as a temp file, executes it, and removes the temp file. Here at Source.Python, we believe everything has a proper place. For config files, that's the ../cfg/ directory. If these cfg files are truly necessary for your plugin, I suggest you create a new directory inside ../cfg/source-python/ with the name of your plugin to house these files.
Jerome69 wrote:satoon101 wrote:The server cannot execute config files outside the ../cfg/ directory. Please move them into there. But again, what all is in them and is it necessary to have a cfg file or will just executing the commands directly suffice?
I have two lines in this file :
sp load sprestrict
@all weapon_smokegrenade
It works now. The plugin is loaded. But the second line is not understanded by SP : unknown command : @all
But in others files, I have 4 lines, or more...
Here there is the plugin I'm using for the weapon restriction and the differents files I used with an old plugin (which was working with eventscript). I would like to use the same.
It seems to me that you are missing the command before @all.
The plugin he linked reads the restricted weapons from a restriction.txt.satoon101 wrote:It seems to me that you are missing the command before @all.
Jerome69 wrote:When I use this, it blocks the "command" and the menu doesn't appears. I just want to block "IVG : !menu" in the chat. Is it possible? It's not very important, just a finition for me![]()
Put your code in the SayCommand callback instead of the player_say event.
Syntax: Select all
@SayCommand('!menu')
def open_menu(command, index, teamonly):
player = PlayerEntity(index)
print('Steamid', player.steamid)
return CommandReturn.BLOCK
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 105 guests