ysc3839

  • VC:MP Beta Tester
  • Posts: 622
Python plugin
« on August 26th, 2017, 11:38 AM »Last edited on August 9th, 2018, 07:05 PM
I decided to write this because IRC bot written in Squirrel is buggy. And I don't like reinventing the wheel. So I choose Python since it has many useful libraries.

An IRC bot sample: https://gist.github.com/ysc3839/76418598bb6dd907c227bc7487fe269d
Unlike other plugins, this plugin exposes original functions to Python. Peoples can warp the functions as they like.

Project repository:
https://github.com/ysc3839/vcmp-python-plugin

Test code:
https://github.com/ysc3839/vcmp-python-test

1.0 released: https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0

Note: You may need to rename this plugin because the server can't take long filename.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,804
[WIP] Re: Python plugin
« Reply #1, on August 26th, 2017, 12:06 PM »
Heh, wanted to do this myself a few days ago when I looked at the state of that binding library. But then I realized I hate Python's syntax :D
.

Mahmoud Tornado

  • Full Member
  • Posts: 214
[WIP] Re: Python plugin
« Reply #2, on August 27th, 2017, 08:28 PM »
Quote from . on August 26th, 2017, 12:06 PM
Heh, wanted to do this myself a few days ago when I looked at the state of that binding library. But then I realized I hate Python's syntax :D
Nice Name

ysc3839

  • VC:MP Beta Tester
  • Posts: 622

ℛḝξ☂

  • Full Member
  • Posts: 107
Re: Python plugin
« Reply #4, on August 9th, 2018, 03:49 PM »
Good luck with this project!
I may be a slow walker but I am always walking.

ysc3839

  • VC:MP Beta Tester
  • Posts: 622
Re: Python plugin
« Reply #5, on August 9th, 2018, 07:13 PM »
Note: You may need to rename this plugin because the server can't take long filename.

31 characters length.
Code: [Select]
Plugin error >> dlopen() 'plugins/vcmp-python-plugin-cpy36-linux6.so' failed: plugins/vcmp-python-plugin-cpy36-linux6.so: cannot open shared object file: No such file or directory
Failed to load plugin: vcmp-python-plugin-cpy36-linux6
Re: Python plugin
« Reply #6, on August 14th, 2018, 05:19 PM »
1.0.2 released: download

This version compatible with 04rel004.
If you call new functions it will raise "NotImplementedError: server does not implement this function".
And new callbacks do not exist.

Changed output name to vcmp-python-plugin-cpyxx-(rel/dbg)(32/64).
Re: Python plugin
« Reply #7, on August 15th, 2018, 09:13 PM »Last edited on August 16th, 2018, 10:38 PM
Added automated builds.
Linux Windows
No 32 bit builds for Linux.
Re: Python plugin
« Reply #8, on August 16th, 2018, 10:41 PM »
Version 1.0.4:
  • Python error message will log to server_log.txt.
  • The plugin will read "pymodule" from both "server.cfg" and "server32/64.cfg".
Download: Linux Windows

DarkRaZoR^

  • Full Member
  • VC:MP Battlefield Head Developer/KF Leader
  • Posts: 226
Re: Python plugin
« Reply #11, on March 13th, 2019, 04:23 PM »
Quick question, @ysc3839 . Would it be possible for a Squirrel script and a Python script to communicate back to each other? Let's say I want to do an operation on Python by accessing one of the libraries from my Squirrel script. Would this be okay?

ysc3839

  • VC:MP Beta Tester
  • Posts: 622
Re: Python plugin
« Reply #12, on March 13th, 2019, 04:44 PM »
@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
  • Modify squirrel plugin to implement this function.
  • Make another plugin as squirrel extension to implement this function.
  • Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.

DarkRaZoR^

  • Full Member
  • VC:MP Battlefield Head Developer/KF Leader
  • Posts: 226
Re: Python plugin
« Reply #13, on March 13th, 2019, 07:30 PM »Last edited on March 13th, 2019, 07:33 PM
Quote from ysc3839 on March 13th, 2019, 04:44 PM
@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
  • Modify squirrel plugin to implement this function.
  • Make another plugin as squirrel extension to implement this function.
  • Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.
How would I send information from the Squirrel script to the Python script, with the usage of sockets? I have never messed with Unix sockets before. :o Is there a socket library for Python?

dracc

  • Jr. Member
  • Posts: 83
Re: Python plugin
« Reply #14, on March 13th, 2019, 08:24 PM »
Quote from DarkRaZoR^ on March 13th, 2019, 07:30 PM
Quote from ysc3839 on March 13th, 2019, 04:44 PM
@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
  • Modify squirrel plugin to implement this function.
  • Make another plugin as squirrel extension to implement this function.
  • Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.
How would I send information from the Squirrel script to the Python script, with the usage of sockets? I have never messed with Unix sockets before. :o Is there a socket library for Python?
Yes. The "socket" package. Further discussion of this should probably take place elsewhere as this subforum is not meant for programming help.