Giter Site home page Giter Site logo

libertylocked / webscripthook Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 3.0 7.62 MB

WebScriptHook is a web plugin framework for GTAV, which allows interaction with a running instance of GTAV through a REST API.

Home Page: https://www.gta5-mods.com/tools/webscripthook-for-gtav

License: MIT License

C# 38.70% Go 7.35% Batchfile 0.92% HTML 27.82% JavaScript 21.89% CSS 3.31%
gtav script-hook game modding

webscripthook's Introduction

WebScriptHook plugin + server

Build status

A platform that allows interaction with a running instance of GTAV through a REST API. Extendable through extensions! Includes server and game-side plugin. Inspired by ETS2 Telemetry Server

Features

  • Second-screen experiences for GTAV through a web interface
  • Fetching real-time game statistics in JSON format with a GET request
  • Calling GTAV script native functions with POST requests
  • Web server included! Drop your HTML and CSS and JavaScript and you are good to go
  • Extension support allows developers to create extensions to handle more request types. Extensions are stateful and can be ticked with the game
  • You can easily port an existing ScriptHook V .NET script to a WebScriptHook extension
  • Includes a "Drive Cars With Your Phone" example extension (frontend and backend)

Installation

Requirements

WebScriptHook

  • Extract "WebScriptHook" folder to "GTAV/scripts"
  • The configuration file should be at GTAV/scripts/WebScriptHook/WebScriptHook.ini
  • The DLLs should be at GTAV/scripts/WebScriptHook/*.dll
  • The server exe should be at GTAV/scripts/WebScriptHook/webscripthook-server.exe
  • Run the game

WebScriptHook apps

Running a web app

  • Start the game
  • Run "webscripthook-server.exe"
  • You need to allow the program to communicate through firewall
  • The default port is 25555. Can be changed in config (restart game and the server to apply)
  • Open your browser and go to http://localhost:25555 You should see the home page
  • To access the page from devices on your LAN, replace "localhost" above with the address of your PC. Google "How to find my LAN IP" if you don't know how to do that
  • There is an Android client app for WebScriptHook

Installing a web app

  • Drop the folder of a WebScriptHook app under "/apps" folder
  • If done correctly, the index page of the app should be at /apps/<app name>/index.html
  • Refresh the webpage

WebScriptHook REST API

WebScriptHook provides a REST API that allows you to pull real-time data from the game, as well as calling native functions remotely!

  • Pulling some real-time data in JSON format
GET /pull
  • Calling a native function
POST /input
{
	"Cmd": "native",
	"Arg": "GET_ENTITY_HEALTH", <- Name or hash of the native function
	"Args": ["int", 2]  <- Return type (a string), native function arguments (an int/float/string/bool)
}

WebScriptHook extensions

Installing an extension

  • Put the extension dll files under "/extensions" folder
  • WebScriptHook searches for assemblies recursively, so create subfolders if you wish
  • Extensions will be automatically loaded when WebScriptHook starts

Creating an extension

  • You can write your own extensions to handle inputs sent through web
  • Subclass WebScriptHook.Extensions.Extension and override HandleCall method, which is invoked whenever your extension is called through web
  • Implement WebScriptHook.Extensions.ITickable if you want your extension to be ticked every frame
  • Your extension can also send stuff back to the caller, whenever HandleCall is called
  • It's possible to convert an existing ScriptHookVDotNet script to a WebScriptHook extension
  • See the wiki page for details

Calling an extension through REST API

  • POST to /input with cmd "extension"
  • Arg needs to be "assemblyname.namespace.classname". e.g. extension-examples.ExampleExtensions.MyExtension
  • Args will be used to call the extension

Other notes

  • Whether you start the game first or the server first does not matter
  • If things broke, check "GTAV/ScriptHookVDotNet-2016-01-19.log" (replace the date with your current date) for errors

Screenshots

Video

Video2 Video1

Have fun making your own apps! Pull requests are welcome

webscripthook's People

Contributors

libertylocked avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

webscripthook's Issues

Extension Manager exception handling

WebScriptHook should not crash entirely when one of its extensions throws an exception

This includes handling exceptions that might occur when

  • Loading extensions from assemblies through reflection
  • Ticking extensions
  • Extensions handling web calls

Extension support with reflection

  • Command extensions
    • Stateless
    • Handles custom commands (WebFunction delegates)
    • Can be called with POST
POST /extcmd
{
"Assembly": "ext.dll"
"Cmd": "cmd",
"Arg": "arg",
"Args": [ ]
}
  • Script extensions
    • Stateful - needs to be ticked
    • React to OnInput event, when it received an input from the server

Server-side extension data caching

Extensions should be able to push certain data to server and have this data cached at the server.
Whenever a client requests this data (via a GET or something), cached data will be returned.

This boosts performance by not having to route the request to the WSH plugin and to have the plugin process the request every time a request is made

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.