lgrahl Posted May 11, 2015 Share Posted May 11, 2015 (edited) Script Hook V Py3kThis is an ASI plugin for Grand Theft Auto V that allows you to execute Python 3 scripts in game by using the Script Hook V from Alexander Blade.Features All native functions accessible Scripts run as lightweight asynchronous tasks High level requirement functions can be chained and waited for All the fancy Python packages out there can be used and... Dependencies will be installed automatically DownloadPrebuilt binaries can be found on the releases page.Installation Install the Script Hook V Install Python 3.5.0 for Windows x64 Copy the contents of the downloaded archive into your GTA V game folder Writing ScriptsTo get started on writing scripts, head over to this wiki page.ContributingAll contributions are warmly welcomed. Below are a few hints to the entry points of the code and a link to our to do list.Entry Points Py3kWrapperStart in wrapper.cpp is the entry point for the C++ part of the plugin _init in the gta module is the entry point for the Python part of the plugin TodoSee TODO.md.BuildingIf you want to build the ASI plugin yourself, you'll need: Visual Studio 2013 The Script Hook V SDK which has to be extracted into /sdk after downloading SWIG Version >= 3.0.5 which has to be extracted into /swig after downloading Python 3.5.0 for AMD64/EM64T/x64. Using the x86 version will not work! Open the project file and build the solution in Release configuration Edited November 8, 2015 by lgrahl LoneMerc, vithepunisher, Zeynohh and 1 other 4 Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/ Share on other sites More sharing options...
Zeynohh Posted May 11, 2015 Share Posted May 11, 2015 Sounds quite exciting ^^ Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067447567 Share on other sites More sharing options...
NoShotz Posted May 11, 2015 Share Posted May 11, 2015 hehe, just happens that i am learning python, lol Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067449547 Share on other sites More sharing options...
Scrumilation Posted May 12, 2015 Share Posted May 12, 2015 Good, i like lua but i love python. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067452854 Share on other sites More sharing options...
NeatSquid Posted May 13, 2015 Share Posted May 13, 2015 (edited) Hey, Great work. 2 questions though. 1. Where is the ASI plugin? I can't find it in my folder that I downloaded. 2. Would this work? EDIT: I know know how to compile the ASI, and I will try out my code Edited May 13, 2015 by NeatSquid Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067461102 Share on other sites More sharing options...
NeatSquid Posted May 13, 2015 Share Posted May 13, 2015 When I launch the game, I get a ScriptHookV error saying that it couldn't load the asi. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067461166 Share on other sites More sharing options...
lgrahl Posted May 14, 2015 Author Share Posted May 14, 2015 Hey, Great work. 2 questions though. 1. Where is the ASI plugin? I can't find it in my folder that I downloaded. 2. Would this work? EDIT: I know know how to compile the ASI, and I will try out my code We will provide the ASI plugin as soon as the keyboard coroutine has been written. When I launch the game, I get a ScriptHookV error saying that it couldn't load the asi. At the moment, the required files need to be assembled by hand. You need to copy everything from the /python folder and the compiled scripthookvpy3k.asi into your GTA V directory. There will be a log file in the GTA V directory called scripthookvpy3k.log when the script loader has been initialised. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067462936 Share on other sites More sharing options...
NeatSquid Posted May 14, 2015 Share Posted May 14, 2015 Hey, Great work. 2 questions though. 1. Where is the ASI plugin? I can't find it in my folder that I downloaded. 2. Would this work? EDIT: I know know how to compile the ASI, and I will try out my code We will provide the ASI plugin as soon as the keyboard coroutine has been written. When I launch the game, I get a ScriptHookV error saying that it couldn't load the asi. At the moment, the required files need to be assembled by hand. You need to copy everything from the /python folder and the compiled scripthookvpy3k.asi into your GTA V directory. There will be a log file in the GTA V directory called scripthookvpy3k.log when the script loader has been initialised. OK, thank you. Please @ me when you've released the final version, I've been waiting for this ever since the LUA plugin came out Nice work, carry it on Even if it's just for me Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067463403 Share on other sites More sharing options...
lgrahl Posted May 14, 2015 Author Share Posted May 14, 2015 I believe, the huge advantage we have with Python is that we can utilise all the fancy modules out there. Synchronising the current time and weather? Serving a website where other people can click on the map and spawn vehicles on top of your head? Yeah, possible. I'm sure you have even better and much more creative ideas! But we don't want all the hassle of installing dependencies on the command line from readme instructions that script writers provide, right? That's why we've implemented automatic dependency installation. Script writers just need to provide some metadata in their scripts and that's it. The dependencies will be downloaded and installed automatically (using pip and pypi). There are still some show stoppers we need to resolve until we're going to release the hook. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067465884 Share on other sites More sharing options...
NoShotz Posted May 14, 2015 Share Posted May 14, 2015 this is going to be awesome when it comes out Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067465895 Share on other sites More sharing options...
NeatSquid Posted May 14, 2015 Share Posted May 14, 2015 I think I'm using an older version of the mod, but I keep getting this error Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067466038 Share on other sites More sharing options...
lgrahl Posted May 15, 2015 Author Share Posted May 15, 2015 (edited) I think I'm using an older version of the mod, but I keep getting this error [...] We've done a lot of changes today. Now, there will be two separate logs. One for the wrapper (scripthookvpy3k.wrapper.log) and one for the Python module (scripthookvpy3k.log). Please, rebuild the plugin and paste the content of the logs here if it still doesn't work. Make sure that you delete all old Python scripts from the GTA V folder (Folders: __pycache__, gta, scripts, Files: gta_native.py). In the future, Python scripts will have their own sub folder so they don't create a mess in the GTA V folder. Edited May 15, 2015 by lgrahl Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067467609 Share on other sites More sharing options...
NeatSquid Posted May 15, 2015 Share Posted May 15, 2015 I think I'm using an older version of the mod, but I keep getting this error [...] We've done a lot of changes today. Now, there will be two separate logs. One for the wrapper (scripthookvpy3k.wrapper.log) and one for the Python module (scripthookvpy3k.log). Please, rebuild the plugin and paste the content of the logs here if it still doesn't work. Make sure that you delete all old Python scripts from the GTA V folder (Folders: __pycache__, gta, scripts, Files: gta_native.py). In the future, Python scripts will have their own sub folder so they don't create a mess in the GTA V folder.OK, I'll do that tonight and report back. Does the Python folder go into the directory of GTAV or into the scripts folder btw? Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067468202 Share on other sites More sharing options...
lgrahl Posted May 15, 2015 Author Share Posted May 15, 2015 I think I'm using an older version of the mod, but I keep getting this error [...] We've done a lot of changes today. Now, there will be two separate logs. One for the wrapper (scripthookvpy3k.wrapper.log) and one for the Python module (scripthookvpy3k.log). Please, rebuild the plugin and paste the content of the logs here if it still doesn't work. Make sure that you delete all old Python scripts from the GTA V folder (Folders: __pycache__, gta, scripts, Files: gta_native.py). In the future, Python scripts will have their own sub folder so they don't create a mess in the GTA V folder. OK, I'll do that tonight and report back. Does the Python folder go into the directory of GTAV or into the scripts folder btw? Currently, all content from the python folder goes into the directory of GTA V. Otherwise, you'll get an error in the log. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067469488 Share on other sites More sharing options...
CryptXor Posted May 15, 2015 Share Posted May 15, 2015 Oh snap. Now this is something that I am going to get into. Is there a TODO list? Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067469625 Share on other sites More sharing options...
NeatSquid Posted May 15, 2015 Share Posted May 15, 2015 Oh snap. Now this is something that I am going to get into. Is there a TODO list? Indeed. https://github.com/lgrahl/scripthookvpy3k/blob/master/TODO.md Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067470039 Share on other sites More sharing options...
NeatSquid Posted May 15, 2015 Share Posted May 15, 2015 (edited) Compiling the latest version I now have a copy of this at school so I can script at school when I'm bored Edited May 15, 2015 by NeatSquid Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067470752 Share on other sites More sharing options...
NeatSquid Posted May 15, 2015 Share Posted May 15, 2015 I still can't get it working. Maybe I'm scripting it wrong. The plugin works, but I can't script for my life import asyncioimport gta_nativeimport [email protected] main(): wanted_level = gta_native.player.get_player_wanted_level(player) if wanted_level > 2: gta_native.player.set_player_wanted_level(player, 0, True) Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067470857 Share on other sites More sharing options...
lgrahl Posted May 15, 2015 Author Share Posted May 15, 2015 I still can't get it working. Maybe I'm scripting it wrong. The plugin works, but I can't script for my life import asyncioimport gta_nativeimport [email protected] main(): wanted_level = gta_native.player.get_player_wanted_level(player) if wanted_level > 2: gta_native.player.set_player_wanted_level(player, 0, True) You, sir, just found a bug. Exceptions from scripts have not been logged until now. But when you rebuild the ASI plugin and run the game with the script you've posted, check out the exceptions in the scripthookvpy3k.log for troubleshooting. It will tell you that player is not defined. 2015-05-16 00:21:12 gta ERROR Script "neatsquid" returned with an exceptionTraceback (most recent call last): File "C:\Python34\Lib\asyncio\tasks.py", line 238, in _step result = next(coro) File "C:\Python34\Lib\asyncio\coroutines.py", line 141, in coro res = func(*args, **kw) File "D:\Games\GTA V\scripts\neatsquid.py", line 7, in main wanted_level = gta_native.player.get_player_wanted_level(player)NameError: name 'player' is not definedThe above exception was the direct cause of the following exception:Traceback (most recent call last): File "D:\Games\GTA V\gta\__init__.py", line 268, in _script_done raise ScriptExecutionError(name) from exc Also, as a side note: @asyncio.coroutine is a decorator for the main function and there should be no blank line between them. I highly recommend using PyCharm for coding which will tell you these kinds of things (and much more). Please, note that the ASI plugin currently cannot be reloaded at runtime. So, press F12 if you want to reload your script(s) without having to close GTA V. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067471466 Share on other sites More sharing options...
NeatSquid Posted May 16, 2015 Share Posted May 16, 2015 (edited) I still can't get it working. Maybe I'm scripting it wrong. The plugin works, but I can't script for my life import asyncioimport gta_nativeimport [email protected] main(): wanted_level = gta_native.player.get_player_wanted_level(player) if wanted_level > 2: gta_native.player.set_player_wanted_level(player, 0, True) You, sir, just found a bug. Exceptions from scripts have not been logged until now. But when you rebuild the ASI plugin and run the game with the script you've posted, check out the exceptions in the scripthookvpy3k.log for troubleshooting. It will tell you that player is not defined. 2015-05-16 00:21:12 gta ERROR Script "neatsquid" returned with an exceptionTraceback (most recent call last): File "C:\Python34\Lib\asyncio\tasks.py", line 238, in _step result = next(coro) File "C:\Python34\Lib\asyncio\coroutines.py", line 141, in coro res = func(*args, **kw) File "D:\Games\GTA V\scripts\neatsquid.py", line 7, in main wanted_level = gta_native.player.get_player_wanted_level(player)NameError: name 'player' is not definedThe above exception was the direct cause of the following exception:Traceback (most recent call last): File "D:\Games\GTA V\gta\__init__.py", line 268, in _script_done raise ScriptExecutionError(name) from excAlso, as a side note: @asyncio.coroutine is a decorator for the main function and there should be no blank line between them. I highly recommend using PyCharm for coding which will tell you these kinds of things (and much more). Please, note that the ASI plugin currently cannot be reloaded at runtime. So, press F12 if you want to reload your script(s) without having to close GTA V. Thank you terribly For some reason, F12 crashses the game for me, so I'll probably just remove the Rockstar intro for quicker access. Edited May 16, 2015 by NeatSquid Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067472713 Share on other sites More sharing options...
lgrahl Posted May 18, 2015 Author Share Posted May 18, 2015 (edited) It took a while to clean up the C++ part and to make sure that all potential errors are being catched and logged. There should be no crashes anymore. If you experience a crash, please post both log files (scripthookvpy3k.log, scripthookvpy3k.wrapper.log) here. There are still two big show stoppers (see issue #4 and #6). We really could use some help here to research whats going wrong. For now, the game executable will not stop after exiting and you'll need to kill the process in the task manager. The mentioned two issues need to be resolved and the keyboard co-routine still needs to be written until we are ready to release. Changes: All Python scripts now reside in a "python" sub folder You can use DEL to stop Python (F12 will restart Python) Logging has been massively improved Bug fixes... lots of 'em Also, there is a new script example that applies the current weather of Los Angeles to the game. Edited May 18, 2015 by lgrahl Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067481940 Share on other sites More sharing options...
NeatSquid Posted May 18, 2015 Share Posted May 18, 2015 Updated. Thanks bro Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067483266 Share on other sites More sharing options...
headscript Posted May 30, 2015 Share Posted May 30, 2015 will this be continued or is abandoned?(i wanna make my hands dirty) Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067530457 Share on other sites More sharing options...
Szabo Posted May 31, 2015 Share Posted May 31, 2015 will this be continued or is abandoned?(i wanna make my hands dirty) headscript you traitor! A python 3 plugin for scripthook would be awesome since python has the batteries included and the performance is just enough. Perhaps you guys could use pypy for even better performance though. I wish I had the time to mod the hell outta V. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067531035 Share on other sites More sharing options...
headscript Posted May 31, 2015 Share Posted May 31, 2015 will this be continued or is abandoned?(i wanna make my hands dirty) headscript you traitor! A python 3 plugin for scripthook would be awesome since python has the batteries included and the performance is just enough. Perhaps you guys could use pypy for even better performance though. I wish I had the time to mod the hell outta V. not being a traitor i just want to integrate it in mine^^(pacman) Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067531150 Share on other sites More sharing options...
lgrahl Posted May 31, 2015 Author Share Posted May 31, 2015 (edited) will this be continued or is abandoned?(i wanna make my hands dirty) Definitely not abandoned. After all, we are students and just tend to be (more) busy from time to time. If you want to make your hands dirty, feel free to join us and make a few pull requests. We have a to do list and some open issues. will this be continued or is abandoned?(i wanna make my hands dirty) headscript you traitor! A python 3 plugin for scripthook would be awesome since python has the batteries included and the performance is just enough. Perhaps you guys could use pypy for even better performance though. I wish I had the time to mod the hell outta V. Well, it already works fine and you can go ahead and do some scripting (after you've compiled the plugin). All native functions are available. We just need some higher level modules. I doubt that performance will be a problem. Still, you are correct that PyPy could probably be used as an alternative (as soon as it ships with Python 3.4 support). If you want to get started, just let me know and I'll post a sort-of-alpha version of the plugin. Edited May 31, 2015 by lgrahl Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067533269 Share on other sites More sharing options...
headscript Posted May 31, 2015 Share Posted May 31, 2015 will this be continued or is abandoned?(i wanna make my hands dirty) Definitely not abandoned. After all, we are students and just tend to be (more) busy from time to time. If you want to make your hands dirty, feel free to join us and make a few pull requests. We have a to do list and some open issues. i kinda wanted to rewrite it from scratch using boost python, a AST parser and Python 2.7 with Cython Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067533442 Share on other sites More sharing options...
Szabo Posted May 31, 2015 Share Posted May 31, 2015 will this be continued or is abandoned?(i wanna make my hands dirty) Definitely not abandoned. After all, we are students and just tend to be (more) busy from time to time. If you want to make your hands dirty, feel free to join us and make a few pull requests. We have a to do list and some open issues. will this be continued or is abandoned?(i wanna make my hands dirty) headscript you traitor! A python 3 plugin for scripthook would be awesome since python has the batteries included and the performance is just enough. Perhaps you guys could use pypy for even better performance though. I wish I had the time to mod the hell outta V. Well, it already works fine and you can go ahead and do some scripting (after you've compiled the plugin). All native functions are available. We just need some higher level modules. I doubt that performance will be a problem. Still, you are correct that PyPy could probably be used as an alternative (as soon as it ships with Python 3.4 support). If you want to get started, just let me know and I'll post a sort-of-alpha version of the plugin. At the moment I'm still struggling to find the time for the mod I'm programming in Lua atm, I'm hitting a thick wall of engine limitations though. The hardest part is workarounding them. will this be continued or is abandoned?(i wanna make my hands dirty) Definitely not abandoned. After all, we are students and just tend to be (more) busy from time to time. If you want to make your hands dirty, feel free to join us and make a few pull requests. We have a to do list and some open issues. i kinda wanted to rewrite it from scratch using boost python, a AST parser and Python 2.7 with Cython Good ole Cython... I still consider it the bestest language ever, you can use pretty much pure python most of the time and when you really need the extra performance you can just define some c types and BOOM! C-like performance . It lacks some good performance tools though and surely it lacks the popularity. It's the biggest aberration I've ever seen in terms of something not getting the popularity it deserves. People complain a lot that python doesn't compile the code nor obfuscates it somehow, but I've managed to compile an entire PyQt4 program with Cython and it worked outta the box. The performance of course was a little bit worse than Cpython because I didn't change a single line of code, but the level of 'obfuscation' is pretty good I'd say. Surely no one is going to be able to retrieve something that resembles the python source without sh*tloads of work. Personally I don't care about obfuscation, but according to google that's one of the most discussed topics. If you have an enterprise-level program and need some top secret stuff obfuscated, the only thing you can do to protect it (although not 100%) is running that on your own server. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067533486 Share on other sites More sharing options...
iFarbod Posted May 31, 2015 Share Posted May 31, 2015 Sounds awesome, I'll be using this for sure. Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067534005 Share on other sites More sharing options...
lgrahl Posted May 31, 2015 Author Share Posted May 31, 2015 i kinda wanted to rewrite it from scratch using boost python, a AST parser and Python 2.7 with Cython I respect your enthusiasm, but what would we gain from this approach? Link to comment https://gtaforums.com/topic/793533-vrel-script-hook-v-python-3k/#findComment-1067534497 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now