1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

KScript - Server Scripting for KAG Classic

Discussion in 'Community Dev Corner' started by master4523, Mar 26, 2013.

Mods: Downburst, Mazey
  1. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    KScript
    Hey everyone, let me introduce you to a project Ardivaba and I have been working on for the past few weeks.

    What is KScript?
    A tool used to create and execute scripts that can interact with the server.
    It allows you do make your own scripts for your server: kick/freeze/ban/swap a player, add custom chat commands, spawn zombies or any other entities at a certain position...

    How does it work?
    It connects to your server, via tcpr, and parses the rcon output which is then processed by a script manager.
    Here's a sample of code taken from a mod:
    PHP:
    ks.events.on('newPlayer', function(player) {
        
    ks.server.message('Hello, ' player.getName() + '!');
    });
    This sample will greet players when they joins the server.

    Where do I get it?
    https://github.com/master4523/kscript

    Available mods:
    - Killstreaks by master4523
    Shows first blood and killing sprees - Check Oban's Epic RTDM Server for a demo.

    - SnIcKeRs mods by SnIcKeRs
    A collection of mods, including kill/death ranking, spam kick, message of the day, time commands and much more!

    Servers featuring KScript:
    - Strathos' Dungeon & Zombies Server
    - jammer312s Magic CTF
    - Oban's Epic RTDM Server

    If you've made a mod, or if you're hosting a server with KScript, send it to me and I'll gladly add it here :)

    Help:
    We have an IRC channel if you need help: #kag.kscript @ QuakeNet
     
  2. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    1. should l create folder named 'mods'?
    if true
    then where should l make it?
     
  3. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    There's already a folder which is called /mods/.
    Put the downloaded mods inside that folder.
     
  4. crisslion

    crisslion Catapult Fodder

    Messages:
    4
    Hello, I have one question, what kind of data does | player.getData() | function returns? While looking at the source that confused me.
     
  5. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    where need l to run Kscript(server or my computer)?
     
  6. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    getData() returns an object which contains any custom variables. It is like a local storage for each player.
    PHP:
    player.data.myint 42;
    player.data.mystr 'abc';
    player.getData()
    => {  
    myint42mystr'abc' }
    It is also being shared between mods and extensions.

    It doesn't matter. KScript connects via tcpr so you can run it either locally or remotely.
     
    SnIcKeRs likes this.
  7. crisslion

    crisslion Catapult Fodder

    Messages:
    4
    oh, tnx, I thought it returns something like position or health from documentation.
     
  8. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    It don't launches.
    also l can't find dedicated_autoconfig.cfg. Maybe you mean '.gm'?

    UPDATED:
    Allowed 'node' to run,
    now it prints:
     
  9. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,912
    Let me tell you guys something small about this:
    -) You need tcprcon = 1, which is currently [ehh currently for lunix and mac? I mean will only be working on those and NEVER on windows, read the tcp rcon tread from FLAB for more info] only available on linux and mac (if you host your server on your home windows pc, google about virtual box with debian, or any other linux, I'd use debian)
    -) Mods. don't have any link to your server as in files, KScrupt can run is Auss for an European server, all what matters is IP PORT and RCON
    -) Read the tutorial at the website.
     
  10. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    maybe you need rewrite '/data/kscript_app.js' to './data/kscript_app.js'

    EDITED:
    Ubuntu users: you need to rewrite kscript.sh : you need to add '.' char at '/data' ('./data')
    Also you need to make kscript.sh and node files executable
    </br>--- merged: Mar 26, 2013 5:16 PM ---</br>
    Can somehow I make delay in script(like """ make something; wait; make something""")?
     
  11. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    By default it is "./node data/kscript_app.js", did you inadvertently add a '/' before 'data'?
    For delays, you could use javascript's setTimeout(callback, delay):
    Code:
    setTimeout(function() {
        log('Ding!');
    }, 1000);
    This script will show 'Ding!' after 1 second (1000ms)
     
  12. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    can l use it like 'setTimeout(1000);'?
     
  13. tobz789

    tobz789 Shark Slayer

    Messages:
    24
    ty alot!
     
  14. Zer0Striker

    Zer0Striker Shipwright

    Messages:
    139
    So there is no way you can use this program on windows?
     
  15. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    Of course you can. Mazey's post is actually misleading.
    You can use KScript on Windows, as long as your server is on Linux.
     
  16. Zer0Striker

    Zer0Striker Shipwright

    Messages:
    139
    -.- I mean host with it on the same computer if its windows lol, but thanks.
     
  17. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    How can player change name?
     
  18. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    Theorically they can't, but they can change their clantag (which emits the nameChange event)
    Also I forgot to mention but KScript is incompatible with migrants so if you're using it on a server with the default zombie gamemode you have to remove the migrants from the game.
     
  19. jammer312

    jammer312 Bison Rider Tester

    Messages:
    46
    Another question. class player.
    l need to read specific command from chat and freeze player. like <Fjammer312> it will freeze jammer312 and send message to chat "Player someplayer freezed jammer312"
    l tried to read player's name from chat and then player_to_freeze.freeze(10000)
    But it don't work. How else l can do it?
     
  20. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    Well it should work. Don't forget to use ks.server.getPlayerByName(name) in order to return a Player object.
     
Mods: Downburst, Mazey