Skip to content
Wenchao Wang edited this page Feb 17, 2016 · 13 revisions

Welcome to the WebScriptHook wiki!

Quick Start

  • Create a folder for you skin under "/apps" and create an "index.html"
  • Copy all the JS libraries or whatever framework you like under you skin folder

jQuery 1.11.3 and Bootstrap 3.3.6 are already available on the server, so you only have to do this

<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap-theme.min.css">
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/jquery-1.11.3.min.js"></script>
  • Implement an infinite loop, that GETs every few milliseconds from "/pull"
  • Parse the response as a JSON object

You need to check if the response is "NO_DATA", in case the plugin hasn't connected to the server yet

function update() {
  $.get("/pull", callback);
}
function callback(data) {
  if (data && data != "NO_DATA") {
    var j = JSON.parse(data);
    // TODO: update page elements
  }
  setTimeout(update, 40);
}
  • In terms of sending inputs to the game, you will need to POST to "/input"
function sendInput(cmd, arg, args, callback, errorCallback) {
  var stringified = JSON.stringify({ "Cmd": cmd, "Arg" : arg, "Args" : args });
  $.ajax({
    url: '/input',
    type: 'post',
    dataType: 'json',
    success: null,
    data: stringified,
    timeout: 2000,
    success: callback,
    error: errorCallback,
  });
}
Clone this wiki locally